// =========================================================================== // 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: Nov 16, 2006 // // Description: // This script is use to display and update the options. // // Input Arguments: // None. // // Return Value: // None. // source "colorSetEditCmd.mel"; proc setOptionVars(int $forceFactorySettings) { if( $forceFactorySettings || !`optionVar -exists createEmptyColorSetClamped`) optionVar -intValue createEmptyColorSetClamped 0; if( $forceFactorySettings || !`optionVar -exists createEmptyColorSetRepresentation`) optionVar -intValue createEmptyColorSetRepresentation 4; if ($forceFactorySettings || !`optionVar -exists perInstanceColorSet`) optionVar -intValue perInstanceColorSet 0; } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // proc string assembleCmd() { string $cmd = "colorSetEditCmdNew new none "; int $clamped = `optionVar -query createEmptyColorSetClamped`; int $rep = `optionVar -query createEmptyColorSetRepresentation`; string $representation = "RGBA"; if ($rep == 1) { $representation = "A"; } else if ($rep == 3) { $representation = "RGB"; } $cmd += $clamped + " " + $representation; int $perInstance = `optionVar -query perInstanceColorSet`; $cmd += (" "+$perInstance); return $cmd; } // // Procedure Name: // createEmptyColorSetCallback // // 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 createEmptyColorSetCallback(string $parent) { setParent $parent; int $clamped = `checkBoxGrp -q -value1 createEmptyColorSetClamped`; optionVar -iv createEmptyColorSetClamped $clamped; int $type; if (`radioButtonGrp -q -sl createEmptyColorSetRepresentation1`) { $type = 1; } else if (`radioButtonGrp -q -sl createEmptyColorSetRepresentation3`) { $type = 3; } else if (`radioButtonGrp -q -sl createEmptyColorSetRepresentation4`) { $type = 4; } optionVar -iv createEmptyColorSetRepresentation $type; int $perInstanceRadio = `radioButtonGrp -q -sl perInstanceColorRadio`; int $perInstance = ($perInstanceRadio-1); optionVar -intValue perInstanceColorSet $perInstance; $cmd = `assembleCmd`; eval($cmd); } // // Procedure Name: // createEmptyColorSetSetup // // 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 createEmptyColorSetSetup(string $parent, int $forceFactorySettings) { setOptionVars($forceFactorySettings); setParent $parent; int $clamped = `optionVar -query createEmptyColorSetClamped`; checkBoxGrp -e -value1 $clamped createEmptyColorSetClamped; radioButtonGrp -e -sl 0 createEmptyColorSetRepresentation1; radioButtonGrp -e -sl 0 createEmptyColorSetRepresentation3; radioButtonGrp -e -sl 0 createEmptyColorSetRepresentation4; int $rep = `optionVar -query createEmptyColorSetRepresentation`; if ($rep == 1) { radioButtonGrp -e -sl 1 createEmptyColorSetRepresentation1; } else if ($rep == 3) { radioButtonGrp -e -sl 1 createEmptyColorSetRepresentation3; } else if ($rep == 4) { radioButtonGrp -e -sl 1 createEmptyColorSetRepresentation4; } int $perInstVal = `optionVar -query perInstanceColorSet`; radioButtonGrp -edit -select ($perInstVal+1) perInstanceColorRadio; } // Procedure Name: // createEmptyColorSetOptions // // Description: // Construct the option box UI. Involves accessing the standard option // box and customizing the UI accordingly. // // Input Arguments: // None. // // Return Value: // None. // proc createEmptyColorSetOptions() { // Name of the command for this option box. // string $commandName = "createEmptyColorSet"; // 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; string $parent = `columnLayout -adjustableColumn 1`; frameLayout -l " " -collapse 0; columnLayout; // Create the widgets for this option box // checkBoxGrp -label1 (uiRes("m_createEmptyColorSet.kClamped")) -label (uiRes("m_createEmptyColorSet.kColorRange")) createEmptyColorSetClamped; radioButtonGrp -label (uiRes("m_createEmptyColorSet.kCompType")) -nrb 1 -l1 (uiRes("m_createEmptyColorSet.kCreateEmptyColorSetA")) createEmptyColorSetRepresentation1; radioButtonGrp -label "" -nrb 1 -scl createEmptyColorSetRepresentation1 -l1 (uiRes("m_createEmptyColorSet.kRGB")) createEmptyColorSetRepresentation3; radioButtonGrp -label "" -nrb 1 -scl createEmptyColorSetRepresentation1 -l1 (uiRes("m_createEmptyColorSet.kRGBA")) createEmptyColorSetRepresentation4; radioButtonGrp -numberOfRadioButtons 3 -vr -label (uiRes("m_createEmptyColorSet.kColorSetSharing")) -label1 (uiRes("m_createEmptyColorSet.kShared")) -label2 (uiRes("m_createEmptyColorSet.kPerInstanceShared")) -label3 (uiRes("m_createEmptyColorSet.kPerInstanceUnshared")) perInstanceColorRadio; 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) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Step 7: Set the option box title. // ================================= // setOptionBoxTitle((uiRes("m_createEmptyColorSet.kOptions"))); // Step 8: Customize the 'Help' menu item text. // ============================================ // setOptionBoxHelpTag( "createEmptyColorSet" ); // Step 9: Set the current values of the option box. // ================================================= // eval (($setup + " " + $parent + " " + 0)); // Step 10: Show the option box. // ============================= // showOptionBox(); } // // Procedure Name: // createEmptyColorSet // // Description: // Perform the create color set command using the corresponding // option values. This procedure will also show the option box // window if necessary as well as construct the command string // that will invoke the unfold command with the current // option box values. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string createEmptyColorSet(int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // evalEcho($cmd); break; // Show the option box. // case 1: createEmptyColorSetOptions; break; // Return the command string. // case 2: // Retrieve the option settings. // setOptionVars (false); // Get the command. // $cmd = `assembleCmd`; break; } return $cmd; }