// =========================================================================== // 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. // =========================================================================== // // Procedure Name: // AErampTemplate // // Description Name; // Creates the attribute editor controls for the ramp Node // // Input Value: // nodeName // // Output Value: // None // // // Procedure Name: // AEmakeRampInteractiveNew // global string $gEditColorWidgetName = ""; global proc AEmakeRampInteractiveNew (string $colorEntry1, string $colorEntry2, string $colorEntry3, string $colorEntry4, string $colorEntry5) { // Crack an attribute name open to get the name of the node // string $rampName[]; tokenize($colorEntry1, ".", $rampName); setUITemplate -pst attributeEditorTemplate; rowLayout -nc 3 -cw3 5 320 20 -adjustableColumn 2 -cat 1 "left" 5 -cat 3 "both" 8 -cl3 "center" "center" "center"; text -label ""; // create the controls string $portName = `rampColorPort -n $rampName[0] -vl false rampColorPort`; string $editButton = $rampName[1] + "RampEdit"; $editButton = `button -l ">" -width 25 -h 75 -c ("editRampNode "+$rampName[0]) $editButton`; setParent ..; string $scc = `attrColorSliderGrp -label (uiRes("m_AErampTemplate.kSelectedColor")) scc`; string $spc = `attrFieldSliderGrp -label (uiRes("m_AErampTemplate.kSelectedPosition")) spc`; // tell the port about the controls rampColorPort -e -sc $scc $portName; rampColorPort -e -sp $spc $portName; setUITemplate -ppt; } global proc editRampNodeSetVertical( string $rampWidget, string $win, int $vertical ) { int $v = `rampColorPort -q -vl $rampWidget`; if( $v != $vertical ){ rampColorPort -e -vl $vertical $rampWidget; int $h = `window -q -height $win`; int $w = `window -q -width $win`; if( ($h > $w) != $vertical ){ window -e -height $w -width $h $win; // swap width+height } else { if( $vertical ){ $w -= 10; } else { $h -= 10; } window -e -height $h -width $w $win; // force refresh } } optionVar -iv "editRampIsVertical" $vertical; } global proc editRampNode (string $nodeAttr) { global string $gEditColorWidgetName; string $winName; $winName = "rampNodeAttributeEditor"; int $isVertical = false; if( !`optionVar -exists "editRampIsVertical"` ){ optionVar -iv "editRampIsVertical" $isVertical; } else { $isVertical = `optionVar -q "editRampIsVertical"`; } if( `window -ex $winName` ){ $rampWidge = $gEditColorWidgetName; rampColorPort -e -n $nodeAttr $rampWidge; window -e -title $nodeAttr $winName; } else { if($isVertical) $winName= `window -ret -widthHeight 250 640 -title $nodeAttr $winName`; else $winName= `window -ret -widthHeight 640 250 -title $nodeAttr $winName`; string $form = `formLayout`; string $portName = `rampColorPort -n $nodeAttr -vl $isVertical`; $gEditColorWidgetName = $portName; string $verticalButton = `checkBox -label (uiRes("m_AErampTemplate.kVertical")) -w 70 -v $isVertical -onc ("editRampNodeSetVertical "+$portName + " " + $winName +" true") -ofc ("editRampNodeSetVertical "+$portName + " " + $winName +" false")`; string $scc = `attrColorSliderGrp -label (uiRes("m_AErampTemplate.kSelectedColor")) -cw4 100 56 100 25 -cal 1 "right"`; string $spc = `attrFieldSliderGrp -label (uiRes("m_AErampTemplate.kSelectedPosition")) -cw 1 110 -cw 2 56 -cw 3 1 -cw 4 24 spc`; string $sic = `attrEnumOptionMenuGrp -label (uiRes("m_AErampTemplate.kInterpolation")) -cw2 85 95 -cal 1 "right" sic`; rampColorPort -e -sc $scc $portName; rampColorPort -e -sp $spc $portName; rampColorPort -e -si $sic $portName; formLayout -edit -attachForm $sic "bottom" 1 -attachForm $sic "left" 5 -attachForm $scc "bottom" 1 -attachControl $scc "left" 3 $sic -attachForm $spc "bottom" 1 -attachControl $spc "left" 10 $scc -attachForm $portName "left" 0 -attachForm $portName "right" 0 -attachForm $portName "top" 0 -attachControl $portName "bottom" 2 $spc $form; formLayout -edit -attachControl $verticalButton "left" 15 $spc -attachForm $verticalButton "bottom" 1 $form; setParent ..; } showWindow $winName; string $callbackProc = ("editRampNodeAttributeDeleted(\"" + $winName + "\")"); string $attr = $nodeAttr + ".colorEntryList"; scriptJob -parent $winName -attributeDeleted $attr $callbackProc; } global proc editRampNodeAttributeDeleted(string $winName) { if( `window -ex $winName` ) { string $cmd = "deleteUI \"" + $winName + "\""; evalDeferred($cmd); } } // // Procedure Name: // AEmakeRampInteractiveReplace // global proc AEmakeRampInteractiveReplace (string $colorEntry1, string $colorEntry2, string $colorEntry3, string $colorEntry4, string $colorEntry5) { // Crack an attribute name open to get the name of the node // string $rampName[]; tokenize($colorEntry1, ".", $rampName); string $editButton = $rampName[1] + "RampEdit"; if( `button -exists $editButton` ){ button -edit -c ("editRampNode "+$rampName[0]) $editButton; } global string $gEditColorWidgetName; string $winName = "rampNodeAttributeEditor"; if( `window -ex $winName` ){ rampColorPort -e -n $rampName[0] $gEditColorWidgetName; window -e -title $rampName[0] $winName; } rampColorPort -edit -node $rampName[0] rampColorPort; } global proc AErampTemplate ( string $nodeName ) { AEswatchDisplay $nodeName; editorTemplate -beginScrollLayout; editorTemplate -beginLayout (uiRes("m_AErampTemplate.kRampAttributes")) -collapse 0; editorTemplate -addControl "type"; editorTemplate -addControl "interpolation"; editorTemplate -callCustom "AEmakeRampInteractiveNew" "AEmakeRampInteractiveReplace" "colorEntry1" "colorEntry2" "colorEntry3" "colorEntry4" "colorEntry5"; editorTemplate -addControl "uWave"; editorTemplate -addControl "vWave"; editorTemplate -addControl "noise"; editorTemplate -addControl "noiseFreq"; editorTemplate -addControl "fast"; editorTemplate -endLayout; editorTemplate -beginLayout (uiRes("m_AErampTemplate.kHSVColorNoise")); editorTemplate -addControl "hueNoise"; editorTemplate -addControl "satNoise"; editorTemplate -addControl "valNoise"; editorTemplate -addControl "hueNoiseFreq"; editorTemplate -addControl "satNoiseFreq"; editorTemplate -addControl "valNoiseFreq"; editorTemplate -endLayout; // include/call base class/node attributes AEtexture2dCommon $nodeName; // suppressed attributes editorTemplate -suppress "colorEntryList"; editorTemplate -addExtraControls; editorTemplate -endScrollLayout; }