// =========================================================================== // 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. // =========================================================================== // // Description: // An option window for ToggleVisibilityAndKeepSelection. // // // Procedure Name: // setOptionVars // // Description: // Initialize the option values. // // Input Arguments: // Whether to set the options to default values. // // Return Value: // None. // proc setOptionVars(int $forceFactorySettings) { if ($forceFactorySettings || !`optionVar -exists toggleVisibilityAndKeepSelectionBehaviour`) { optionVar -intValue toggleVisibilityAndKeepSelectionBehaviour 1; } } // // Procedure Name: // toggleVisibilityAndKeepSelectionSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc toggleVisibilityAndKeepSelectionSetup(string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); setParent $parent; int $op = `optionVar -query toggleVisibilityAndKeepSelectionBehaviour`; radioButtonGrp -edit -sl $op toggleVisibilityAndKeepSelectionBehaviour; } // // Procedure Name: // toggleVisibilityAndKeepSelectionCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc toggleVisibilityAndKeepSelectionCallback(string $parent, int $doIt) { setParent $parent; optionVar -intValue toggleVisibilityAndKeepSelectionBehaviour `radioButtonGrp -query -sl toggleVisibilityAndKeepSelectionBehaviour`; if ($doIt) { toggleVisibilityAndKeepSelection `optionVar -query toggleVisibilityAndKeepSelectionBehaviour`; addToRecentCommandQueue "toggleVisibilityAndKeepSelection" "Toggle Visibility and Keep Selection"; } } // // Procedure Name: // toggleVisibilityAndKeepSelectionOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // Return Value: // None. // global proc toggleVisibilityAndKeepSelectionOptions() { // Name of the command for this option box. // string $commandName = "toggleVisibilityAndKeepSelection"; // Build the option box actions. // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // STEP 1: Get the option box. // ============================ // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; // STEP 2: Pass the command name to the option box. // ================================================= // // Any default option box behaviour based on the command name is set // up with this call. For example, updating the 'Help' menu item with // the name of the command. // setOptionBoxCommandName($commandName); // STEP 3: Activate the default UI template. // ========================================== // // Activate the default UI template so that the layout of this // option box is consistent with the layout of the rest of the // application. // setUITemplate -pushTemplate DefaultTemplate; // STEP 4: Create option box contents. // =================================== // // This, of course, will vary from option box to option box. // Turn on the wait cursor. // waitCursor -state 1; tabLayout -tabsVisible 0 -scrollable 1 -innerMarginWidth 4; string $parent = `columnLayout -adjustableColumn 1 -rowSpacing 4`; // Grid size. // frameLayout -label (uiRes("m_toggleVisibilityAndKeepSelectionOptions.kOptions")) -collapsable false -collapse false; columnLayout; radioButtonGrp -vr -label (uiRes("m_toggleVisibilityAndKeepSelectionOptions.kMultipleObjects")) -numberOfRadioButtons 2 -label1 (uiRes("m_toggleVisibilityAndKeepSelectionOptions.kDependent")) -label2 (uiRes("m_toggleVisibilityAndKeepSelectionOptions.kIndependent")) toggleVisibilityAndKeepSelectionBehaviour; setParent ..; setParent ..; // Turn off the wait cursor. // waitCursor -state 0; // Step 5: Deactivate the default UI template. // =========================================== // setUITemplate -popTemplate; // Step 6: Customize the buttons. // ============================== // // Provide more descriptive labels for the buttons. This is not // necessary, but in some cases, for example, a button labelled // 'Create' may be more meaningful to the user than one labelled // 'Apply'. // // Disable those buttons that are not applicable to the option box. // // Attach actions to those buttons that are applicable to the option // box. Note that the 'Close' button has a default action attached // to it that will hide the window. If a a custom action is // attached to the 'Close' button then be sure to call the 'hide the // option box' procedure within the custom action so that the option // box is hidden properly. // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Close' button. string $closeBtn = getOptionBoxCloseBtn(); button -edit -command ( $callback + " " + $parent + " " + 0 + "; hideOptionBox" ) $closeBtn; // 'Reset' menu item string $resetBtn = getOptionBoxResetBtn(); button -edit -command ( $setup + " " + $parent + " " + 1 ) $resetBtn; // 'Save' menu item string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ( $callback + " " + $parent + " " + 0 ) $saveBtn; // Step 7: Set the option box title. // ================================= // string $optionBoxTitle = (uiRes("m_toggleVisibilityAndKeepSelectionOptions.kToggleVisibilityOptions")); setOptionBoxTitle($optionBoxTitle); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "toggleVisibilityAndKeepSelection" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); }