// =========================================================================== // 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. // =========================================================================== // // // Original Creation Date: 08 Nov 2000 // separated out from initChanelsLayers 21 Nov 2008 // // Description: // This script initializes the Channel Box. // Initialization involves determining the initial preferences, // creating the UI and setting the initial visibility. // global proc setChannelsWidth(int $size) // // Description: // Set the Channel Box to a particular width. // // Arguments: // $size - Width of the area. // { // Return on trivial case. // if (0 >= $size) { error (uiRes("m_initChannels.kArgumentMustBeGreater")); return; } global string $gChannelsForm; global int $gChannelsWidth; global string $gMainPane; // Maximum and minimum widths of area. // int $kMaxWidth = 398; int $kMinWidth = 134; // If the argument is outside the allowable range then print a // warning and clamp the size to within the allowable range. // if ($kMinWidth > $size || $kMaxWidth < $size) { string $warningMsg = (uiRes("m_initChannels.kWidthMustBeGreater")); $warningMsg = `format -s $kMinWidth -s $kMaxWidth $warningMsg`; warning -showLineNumber true $warningMsg; if ($kMinWidth > $size) $size = $kMinWidth; else if ($kMaxWidth < $size) $size = $kMaxWidth; } $gChannelsWidth = $size; setParent $gChannelsForm; // Unmanage the main pane layout area of the window. Required for // Motif, harmless on NT. // layout -edit -manage false $gMainPane; // Save the new width as a preference value. // optionVar -intValue channelsWidth $gChannelsWidth; // Manage the main window pane layout. // layout -edit -manage true $gMainPane; // Unmanaging the main window pane layout has the effect of // losing panel focus. Restore it. // restoreLastPanelWithFocus(); } global proc createChannels(string $parent) // // Description: // Create the Channel Box 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 $gChannelBoxForm; global string $gChannelButtonForm; // Default width of Channel Box / Layer Editor. // global int $gChannelsWidth = 230; // Bail if parent layout is not correct type. // string $requiredType = "formLayout"; if ($requiredType != `objectTypeUI $parent`) { string $errorMsg = (uiRes("m_initChannels.kArgumentError")); error (`format -s $requiredType $errorMsg`); return; } // Set up the preference value to store the width if it doesn't // exist. Query the value if it does. // if (!`optionVar -exists channelsWidth`) { optionVar -intValue channelsWidth $gChannelsWidth; } else { $gChannelsWidth = `optionVar -query channelsWidth`; } $gChannelButtonForm = "ChannelButtonForm"; formLayout -parent $parent $gChannelButtonForm; symbolButton -i "channelBoxNoManips.png" -annotation (uiRes("m_initChannels.kSwitchBetweenManipulatorsAnnot")) cbManipsButton; symbolButton -i "channelBoxSlow.png" -annotation (uiRes("m_initChannels.kSwitchBetweenSliderSetting")) cbSpeedButton; symbolCheckBox -annotation (uiRes("m_initChannels.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; // Create the Channel Box. // $gChannelBoxForm = "ChannelBoxForm"; formLayout -parent $parent $gChannelBoxForm; eval ("source initChannelBox"); formLayout -edit -attachForm $gChannelButtonForm "top" 0 -attachForm $gChannelButtonForm "left" 0 -attachNone $gChannelButtonForm "bottom" -attachForm $gChannelButtonForm "right" 0 -attachControl $gChannelBoxForm "top" 0 $gChannelButtonForm -attachForm $gChannelBoxForm "left" 0 -attachForm $gChannelBoxForm "bottom" 0 -attachForm $gChannelBoxForm "right" 0 $parent; } global proc showChannels(int $visible) // // Description: // Show the Channel Box // // This method manages the visibility of the // Channel Box // { global string $gChannelsForm; // name of editor in main window global string $gChannelBoxForm; global string $gChannelButtonForm; // Set the correct parent. // setParent $gChannelsForm; if(`formLayout -exists $gChannelButtonForm` && `formLayout -exists $gChannelBoxForm`) { formLayout -e -parent $gChannelsForm $gChannelButtonForm; formLayout -e -parent $gChannelsForm $gChannelBoxForm; formLayout -edit -attachForm $gChannelButtonForm "top" 0 -attachForm $gChannelButtonForm "left" 0 -attachNone $gChannelButtonForm "bottom" -attachForm $gChannelButtonForm "right" 0 -attachControl $gChannelBoxForm "top" 0 $gChannelButtonForm -attachForm $gChannelBoxForm "left" 0 -attachForm $gChannelBoxForm "bottom" 0 -attachForm $gChannelBoxForm "right" 0 $gChannelsForm; } // Make sure the state of the Channel Box buttons is // in sync with the actual state of the component. initChannelBoxButtons; setChannelsVisible($visible); } global proc setChannelsVisible(int $visible) // // Description: // Set the visibility of the Channel Box. // // Arguments: // $visible - Visibility for the Channel Box. // { int $currentlyVisible = isUIComponentVisible("Channel Box"); if ($visible && !$currentlyVisible || !$visible && $currentlyVisible) { toggleUIComponentVisibility "Channel Box"; } } global proc raiseChannels() // // Description: // Raise the Channel Box 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", false); workspaceControl -edit -restore $component; } global proc int isChannelsRaised() // // Description: // Returns whether or not the Channel Box is visible and // either floating or at the top of its dock widget area. // { string $component = getUIComponentDockControl("Channel Box", false); return `workspaceControl -q -raise $component`; } // // Description: // This code is executed when this script file is sourced. // // Create the Channel Box area. // { global string $gChannelsForm; if(`optionVar -query channelsLayersSeparate`) { // Create the Channel Editor. // createChannels($gChannelsForm); } // Set the initial width. // string $component = getUIComponentDockControl("Channel Box", false); $gChannelsWidth = `optionVar -q workspacesNarrowPanelInitialWidth`; workspaceControl -edit -initialWidth $gChannelsWidth -minimumWidth $gChannelsWidth -widthProperty "preferred" $component; // Set the initial visibility. // setChannelsVisible(`optionVar -query channelsVisible`); }