PDA

View Full Version : A template for greying out items in a checkbox?


cgbeige
01-04-2013, 03:22 PM
I am wondering if anyone has experience or shareable code for a set of checkboxes that are related and sub-items fade/grey out and aren't clickable if another is unchecked. I want to do this:

checkbox: Render a dirt pass shader?
sub-checkbox: Composite with existing shader? (dependent on above)

What little work I've done to get inter-dependent checkboxes to switch states has been a messy so I'm looking to avoid the inevitable hair pulling.

Neilman
01-04-2013, 07:07 PM
I don't know if this is messier than what you already have, but this is how I might go about it right off the bat. If you don't like the global variables you could always query the checkbox values from within each function.


createOptionWindow();


global proc dirtPassToggle() {

global int $dirtPass;
global int $composite;
$dirtPass = !$dirtPass;

checkBox -edit
-enable ($dirtPass)
"compositeCheck";

if (!$dirtPass) {
checkBox -edit -value 0 "compositeCheck";
$composite = 0;
}

}

global proc compositeToggle() {

global int $composite;
$composite = !$composite;

}



global proc createOptionWindow() {

global int $dirtPass;
global int $composite;

$optionWindow = `window -title "Options" -sizeable 0`;

rowColumnLayout -numberOfColumns 1
-columnOffset 1 both 10
-rowOffset 1 both 10
-rowOffset 2 bottom 10;

checkBox -label "Render a dirt pass shader?"
-value $dirtPass
-changeCommand "dirtPassToggle()"
"dirtPassCheck";

checkBox -label "Composite with existing shader?"
-value $composite
-enable ($dirtPass)
-changeCommand "compositeToggle()"
"compositeCheck";

setParent ..;

showWindow;

}

cgbeige
01-04-2013, 08:52 PM
that's perfect. thanks so much :beer:

CGTalk Moderation
01-04-2013, 08:52 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.