// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: 08 Nov 2000 // // Description: // This script initializes the Channel Box and Layer Editor. // Initialization involves determining the initial preferences, // creating the UI and setting the initial visibility. // // This global fixes any potential problems with double updates. // The showChannelsLayers() procedure may change the visibility // of the LE in the main window. That results in an additional update // of the LE. We need this flag to ignore the second update // in channelsLayersVisibilityStateChange(). global int $gIgnoreLEUpdate = false; global proc setChannelsLayersVisible(int $visible) // Description: // Set the visibility of the Channel Box / Layer Editor. // // Arguments: // $visible - Visibility for the Channel Box / Layer Editor. // { int $currentlyVisible = isUIComponentVisible("Channel Box / Layer Editor"); if ($visible && !$currentlyVisible || !$visible && $currentlyVisible) { toggleUIComponentVisibility "Channel Box / Layer Editor"; } } global proc raiseChannelsLayers() // // Description: // Raise the Channel Box / Layer Editor to the top of its // dock widget area if it is visible and not floating (if // floating, will set it to have focus) // { string $component = getUIComponentDockControl("Channel Box / Layer Editor", false); workspaceControl -edit -restore $component; } global proc int isChannelsLayersRaised() // // Description: // Returns whether or not the Channel Box / Layer Editor // is visible and either floating or at the top of its // dock widget area. // { string $component = getUIComponentDockControl("Channel Box / Layer Editor", false); return `workspaceControl -q -raise $component`; } global proc showChannelsLayers(int $visible) // // Description: // Show the Channel Box, Layer Editor or both. // // This method manages the visibility of the // Channel Box / Layer Editor. // // Arguments: // $component - Values are: "Channel Box", "Layer Editor", // or "Channel Box / Layer Editor". You may // also specify an empty string in an attempt // to show the previous component configuration. // $fromMenu - Values are: true to indicate that this command has // been accessed from the menu (will open a separate // window); false otherwise. // { global string $gChannelsLayersForm; // name of editor in main window global string $gChannelBoxForm; global string $gChannelButtonForm; global string $gLayerEditorForm; global string $gChannelsLayersPane; global int $gIgnoreLEUpdate; // used to avoid updating twice // Set the correct parent. // setParent $gChannelsLayersForm; if(!`paneLayout -exists $gChannelsLayersPane`) { $gChannelsLayersPane = `paneLayout -separatorThickness 4 -separatorMovedCommand ("channelsLayersPaneSizeChanged " + $gChannelsLayersPane) ChannelsLayersPaneLayout`; setParent ..; } if(`formLayout -exists $gChannelBoxForm`) { formLayout -e -parent $gChannelsLayersPane $gChannelBoxForm; } if(`formLayout -exists $gLayerEditorForm`) { formLayout -e -parent $gChannelsLayersPane $gLayerEditorForm; } if(`formLayout -exists $gChannelButtonForm`) { formLayout -e -parent $gChannelsLayersForm $gChannelButtonForm; formLayout -edit -attachForm $gChannelButtonForm "top" 0 -attachForm $gChannelButtonForm "left" 0 -attachNone $gChannelButtonForm "bottom" -attachForm $gChannelButtonForm "right" 0 -attachControl $gChannelsLayersPane "top" 0 $gChannelButtonForm -attachForm $gChannelsLayersPane "left" 0 -attachForm $gChannelsLayersPane "bottom" 0 -attachForm $gChannelsLayersPane "right" 0 $gChannelsLayersForm; } // // Show Channel Box and Layer Editor. Set pane layout to // display Channel Box first and Layer Editor second. // Also set configuration to be split horizontally. // paneLayout -edit -configuration "horizontal2" -setPane $gChannelBoxForm 1 -paneSize 1 100 `optionVar -query channelsLayersPaneSize` $gChannelsLayersPane; updateChannelsLayers(); $gIgnoreLEUpdate = true; setChannelsLayersVisible( $visible ); $gIgnoreLEUpdate = false; } global proc createChannelsLayers(string $parent) // // Description: // Create the Channel Box / Layer Editor component area. // // The actual content for this UI isn't created here just // the parent structure and layout to contain them. // // Arguments: // $parent - Parent layout. Must be a form layout. // { global string $gLayerEditorForm; global string $gChannelBoxForm; global string $gChannelButtonForm; global string $gChannelsLayersPane; // Default width of Channel Box / Layer Editor. // global int $gChannelsLayersWidth = 230; $gChannelsLayersWidth = `optionVar -q workspacesNarrowPanelInitialWidth`; // Bail if parent layout is not correct type. // string $requiredType = "formLayout"; if ($requiredType != `objectTypeUI $parent`) { string $errorMsg = (uiRes("m_initChannelsLayers.kArgumentError")); error (`format -s $requiredType $errorMsg`); return; } int $channelsLayersPaneSize = 70; if (`optionVar -exists channelsLayersPaneSize`) { $channelsLayersPaneSize = `optionVar -query channelsLayersPaneSize`; } else { optionVar -intValue channelsLayersPaneSize $channelsLayersPaneSize; } $gChannelButtonForm = "ChannelButtonForm"; formLayout -parent $parent $gChannelButtonForm; // Create the channel box buttons that were at the bottom of // the channel box prior to version 4.0 // symbolButton -i "channelBoxNoManips.png" -annotation (uiRes("m_initChannelsLayers.kSwitchBetweenManipulatorsAnnot")) cbManipsButton; symbolButton -i "channelBoxSlow.png" -annotation (uiRes("m_initChannelsLayers.kSwitchBetweenSliderSetting")) cbSpeedButton; symbolCheckBox -annotation (uiRes("m_initChannelsLayers.kSwitchBetweenLinearSliderSetting")) -cc "channelBoxSettings hyperbolic #1" -onImage "channelBoxHyperbolicOn.png" -offImage "channelBoxHyperbolicOff.png" cbHyperbolicButton; int $topSpacing = 0; int $botSpacing = 1; formLayout -edit -attachForm cbManipsButton "top" $topSpacing -attachNone cbManipsButton "left" -attachForm cbManipsButton "bottom" $botSpacing -attachControl cbManipsButton "right" 2 cbSpeedButton -attachForm cbSpeedButton "top" $topSpacing -attachNone cbSpeedButton "left" -attachForm cbSpeedButton "bottom" $botSpacing -attachControl cbSpeedButton "right" 2 cbHyperbolicButton -attachForm cbHyperbolicButton "top" $topSpacing -attachNone cbHyperbolicButton "left" -attachForm cbHyperbolicButton "bottom" $botSpacing -attachForm cbHyperbolicButton "right" 2 $gChannelButtonForm; // This pane layout contains the Channel Box and the // Layer Editor. // // Other parts of the UI are depending on the order of // creation here, specifically create the Channel Box first // and the Layer Editor second. // $gChannelsLayersPane = `paneLayout -parent $parent -separatorThickness 4 ChannelsLayersPaneLayout`; // Create the Channel Box. // $gChannelBoxForm = "ChannelBoxForm"; formLayout -parent $gChannelsLayersPane $gChannelBoxForm; eval ("source initChannelBox"); // Create the Layer Editor. // $gLayerEditorForm = "LayerEditorForm"; formLayout -parent $gChannelsLayersPane $gLayerEditorForm; eval ("source layerEditor"); formLayout -edit -attachForm $gChannelButtonForm "top" 0 -attachForm $gChannelButtonForm "left" 0 -attachNone $gChannelButtonForm "bottom" -attachForm $gChannelButtonForm "right" 0 -attachControl $gChannelsLayersPane "top" 0 $gChannelButtonForm -attachForm $gChannelsLayersPane "left" 0 -attachForm $gChannelsLayersPane "bottom" 0 -attachForm $gChannelsLayersPane "right" 0 $parent; // Set up the initial state of the Channel Box / Layer Editor area. // paneLayout -edit -configuration "horizontal2" -setPane $gChannelBoxForm 1 -paneSize 1 100 $channelsLayersPaneSize $gChannelsLayersPane; // Add a callback for when the user changes the pane size. // paneLayout -edit -separatorMovedCommand ("channelsLayersPaneSizeChanged " + $gChannelsLayersPane) $gChannelsLayersPane; } global proc updateChannelsLayers() // // Description: // Update the Channel Box / Layer Editor area. // // Call this method to make sure the state of the Channel Box and // Layer Editor buttons are in sync with the actual state of these // components. This is only needed for the main (docked) window, // NOT for the separate Layer Editor window. // { initChannelBoxButtons; } global proc channelsLayersPaneSizeChanged(string $parent) // // Description: // This procedure is called whenever the user changes the size of the // panes in the Channel Box / Layer Editor area. // // Store the size so that it can be restored between Maya sessions. // { int $paneSize[]; $paneSize = `paneLayout -query -paneSize $parent`; optionVar -intValue channelsLayersPaneSize $paneSize[1]; } global proc channelsLayersPrefChange(int $separate) // // Description: // This procedure is called whenever the user toggles the // preference of whether the Channel Box and Layer Editor // are to be displayed as one dock widget or two. // // Switches between Channel Box/Layer Editor as one or two // dock widgets. The dock widget area, visibility and float // states of the previous widget(s) are adopted in the new // one(s) (when switching from two to one, the Channel Box's // settings are taken. // { string $clDockWidget = getUIComponentDockControl("Channel Box / Layer Editor", false); string $channelsDockWidget = getUIComponentDockControl("Channel Box", false); string $layersDockWidget = getUIComponentDockControl("Layer Editor", false); if(size($clDockWidget) && size($channelsDockWidget) && size($layersDockWidget)) { if($separate) { optionVar -intValue channelsLayersSeparate true; int $clVisible = `isUIComponentVisible("Channel Box / Layer Editor")`; showChannels($clVisible); showLayers($clVisible); } else { optionVar -intValue channelsLayersSeparate false; // This is the one exception to the rule where we will also // take the Layer Editor's visibility setting into account int $channelsVisible = `isUIComponentVisible("Channel Box")` || `isUIComponentVisible("Layer Editor")`; showChannelsLayers($channelsVisible); } // Update which editor toggle checkboxes to show on the status line // toggleChannelsLayersButtons(); // Update the select states of the editor toggle checkboxes // updateEditorToggleCheckboxes(); } } // // Description: // This code is executed when this script file is sourced. // // Create the Channel Box / Layer Editor area. // { global string $gChannelsLayersForm; if(!`optionVar -query channelsLayersSeparate`) { // Create the Channel Box / Layer Editor. // createChannelsLayers($gChannelsLayersForm); } // Set the initial width. // string $component = getUIComponentDockControl("Channel Box / Layer Editor", false); workspaceControl -edit -initialWidth $gChannelsLayersWidth -minimumWidth $gChannelsLayersWidth -widthProperty "preferred" $component; // Set the initial visibility. // setChannelsLayersVisible(`optionVar -query channelsLayersVisible`); }