// =========================================================================== // 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: // This script provides a color picker that allows users to set // indexed colors on a particular plug // // global proc colorIndexPickerOkPressed(string $plugToSet,string $window, string $control, int $plugValueOffset ) { int $newColor = `colorIndexSliderGrp -q -value $control`-$plugValueOffset; setAttr $plugToSet $newColor; deleteUI -window $window; global string $gPlayBackSlider; timeControl -edit -forceRefresh $gPlayBackSlider; } global proc colorIndexPickerCancelPressed(string $window) { deleteUI -window $window; } global proc colorIndexPicker( string $plugToSet, int $firstColorIndex, int $lastColorIndex, int $plugValueOffset, string $title, string $postCmd ) { global string $gColorPickerWindow; if( $title == "" ) { $title = (uiRes("m_colorIndexPicker.kColorIndexPickerTitle")); } $gColorPickerWindow = `window -title $title -width 450 -height 90`; string $layout = `formLayout`; int $currColorIndex = `getAttr $plugToSet`+$plugValueOffset; string $control = `colorIndexSliderGrp -label (uiRes("m_colorIndexPicker.kColorIndexPickerSelectColor")) -min $firstColorIndex -max $lastColorIndex -value $currColorIndex` ; string $okButton = `button -label (uiRes("m_colorIndexPicker.kColorIndexPickerOk")) -command ("colorIndexPickerOkPressed"+" "+$plugToSet+" "+$gColorPickerWindow+" "+$control+" "+ $plugValueOffset+";"+$postCmd ) -w 60 -h 20`; string $cancelButton = `button -label (uiRes("m_colorIndexPicker.kColorIndexPickerCancel")) -command ("colorIndexPickerCancelPressed" + " " + $gColorPickerWindow) -w 60 -h 20`; formLayout -e -attachForm $control "top" 2 -attachForm $control "left" 2 -attachNone $control "bottom" -attachNone $control "right" -attachNone $okButton "top" -attachNone $okButton "left" -attachForm $okButton "bottom" 2 -attachForm $okButton "right" 122 -attachNone $cancelButton "top" -attachNone $cancelButton "left" -attachForm $cancelButton "bottom" 2 -attachForm $cancelButton "right" 40 $layout; showWindow $gColorPickerWindow; }