// =========================================================================== // 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 Tool Settings. Initialization involves // determining the initial Tool Settings preferences, creating the UI // and setting the initial visibility. // proc createToolSettings(string $parent) // // Description: // Create the Tool Settings for within the main window // // Arguments: // parent - The parent layout. Must be a form layout. // { string $requiredType = "formLayout"; if ($requiredType != `objectTypeUI $parent`) { string $errorDisplay = (uiRes("m_initToolSettings.kArgError")); string $error = `format -s $requiredType $errorDisplay`; error -showLineNumber true $error; return; } global string $gToolSettingsMainWindowLocation; global string $gToolSettingsMainWindowIcon; global string $gToolSettingsMainWindowName; global string $gToolSettingsMainWindowResetButton; global string $gToolSettingsMainWindowHelpButton; setParent $parent; // Setting the width of this separator is the key to keeping the // Tool Settings window from varying it's width. // // Any tool that makes the settings area wider should be // reformatted. // // *** Note that the hardcoded value of 398 makes the // Tool Settings the same width as the Attribute Editor. // //separator -style "none" -width 398; string $name = `text -label "" -align "left"`; string $reset = `button -label (uiRes("m_initToolSettings.kResetTool")) `; string $help = `button -label (uiRes("m_initToolSettings.kToolHelp")) `; string $toolArea = `tabLayout -scrollable true -childResizable true -tabsVisible false -innerMarginWidth 2 -innerMarginHeight 2 -borderStyle "none" `; columnLayout; formLayout -edit -attachForm $name "top" 1 -attachForm $name "left" 1 -attachControl $name "bottom" 5 $toolArea -attachNone $name "right" -attachForm $reset "top" 1 -attachPosition $reset "left" 0 56 -attachNone $reset "bottom" -attachPosition $reset "right" 3 80 -attachForm $help "top" 1 -attachPosition $help "left" 2 80 -attachNone $help "bottom" -attachForm $help "right" 0 -attachControl $toolArea "top" 2 $help -attachForm $toolArea "left" 0 -attachForm $toolArea "bottom" 0 -attachForm $toolArea "right" 0 $parent; $gToolSettingsMainWindowLocation = $toolArea; $gToolSettingsMainWindowIcon = ""; $gToolSettingsMainWindowName = $name; $gToolSettingsMainWindowResetButton = $reset; $gToolSettingsMainWindowHelpButton = $help; } global proc redirectToolSettings(string $destination) // // Description: // Redirect the location of the Tool Settings. // // This procedure will update the toolPropertyWindow // command so that it points to the correct controls // for displaying the Tool Settings. // // Arguments: // $destination - Either "Main Window" or "Separate Window". // { global string $gToolSettingsMainWindowLocation; global string $gToolSettingsMainWindowIcon; global string $gToolSettingsMainWindowName; global string $gToolSettingsMainWindowResetButton; global string $gToolSettingsMainWindowHelpButton; global string $gToolSettingsSeparateWindowLocation; global string $gToolSettingsSeparateWindowIcon; global string $gToolSettingsSeparateWindowName; global string $gToolSettingsSeparateWindowResetButton; global string $gToolSettingsSeparateWindowHelpButton; if ("Main Window" == $destination) { toolPropertyWindow -edit -location $gToolSettingsMainWindowLocation; toolPropertyWindow -edit -icon $gToolSettingsMainWindowIcon; toolPropertyWindow -edit -field $gToolSettingsMainWindowName; toolPropertyWindow -edit -resetButton $gToolSettingsMainWindowResetButton; toolPropertyWindow -edit -helpButton $gToolSettingsMainWindowHelpButton; toolPropertyWindow -edit -refresh; } else if ("Separate Window" == $destination) { toolPropertyWindow -edit -location $gToolSettingsSeparateWindowLocation; toolPropertyWindow -edit -icon $gToolSettingsSeparateWindowIcon; toolPropertyWindow -edit -field $gToolSettingsSeparateWindowName; toolPropertyWindow -edit -resetButton $gToolSettingsSeparateWindowResetButton; toolPropertyWindow -edit -helpButton $gToolSettingsSeparateWindowHelpButton; toolPropertyWindow -edit -refresh; } else if ("" == $destination) { toolPropertyWindow -edit -location ""; toolPropertyWindow -edit -icon ""; toolPropertyWindow -edit -field ""; toolPropertyWindow -edit -resetButton ""; toolPropertyWindow -edit -refresh; } else { error (uiRes("m_initToolSettings.kInvalidDestination")); } } global proc int toolSettingsVisibilityStateChange( int $newState, string $layout) // // Description: // This procedure is called whenever the visibility state is changed. // // Arguments: // newState - The new visible state. // // layout - The parent layout. // // Returns: // true - If the change of state is to be allowed. // // false - If the state change is rejected. // { int $result = true; if ($newState) { redirectToolSettings("Main Window"); } else { redirectToolSettings(""); } // Defer these commands because this proc is called when the visibility // state is about to change. This proc must return true to accept // the state change. After this proc returns then restore the // panel focus and update the pref menu. // evalDeferred("restoreLastPanelWithFocus(); updateEditorToggleCheckboxes(); updateMainWindowComponentState();"); return $result; } // Note that the following script block is not a procedure and will be // executed when this script file is sourced. // { global string $gToolSettingsForm; // Create the Tool Settings. // createToolSettings($gToolSettingsForm); // Set the initial state of Tool Settings. // string $toolSettingsWorkspaceControl = getUIComponentDockControl("Tool Settings", false); workspaceControl -e -initialWidth `optionVar -q workspacesWidePanelInitialWidth` -initialHeight `optionVar -q workspacesWidePanelInitialHeight` -widthProperty "preferred" -minimumWidth `optionVar -q workspacesWidePanelInitialWidth` $toolSettingsWorkspaceControl; setUIComponentStateCallback( "Tool Settings", "toolSettingsVisibilityStateChange"); // Set the initial visibility. // toolPropertyWindow -inMainWindow true; }