How do I toggle between 'Hide UI Elements' and 'Show UI Elements?'
The general MEL command for this is:
However, this is not a toggle. Nor does it have a query mechanism to
determine in what state it is currently in, or for what state it was last
called. And, passing 'true' doesn't mean "make them visible" but rather
"return them to their state before they were explicitly hidden."
You have a few options:
Pick one of the UI elements and use its visibility to determine if you
are toggling the works on or off. For example, if you want to base it on
the Time Slider:
setAllMainWindowComponentsVisible( !isTimeSliderVisible() );
Or the Shelf:
setAllMainWindowComponentsVisible( !isShelfVisible() );
Use your own optionVar to store the last toggled state, and use its
complement as the visibility:
int $globalUIVisibilityFlag = true;
if ( `optionVar -exists globalUIVisibilityFlag` )
$globalUIVisibilityFlag = `optionVar -q globalUIVisibilityFlag`;
$globalUIVisibilityFlag = !$globalUIVisibilityFlag;
optionVar -intValue globalUIVisibilityFlag $globalUIVisibilityFlag;
However, this could prove an inconvenience. As alluded to above, the
setAll...() function doesn't specifically turn the UI elements on and off.
It turns them off and restores them to their last visible state. If
everything is already invisible when your own script asks everything to be
invisible, the setAll...() script will remember everything as invisible and
you'll have to manually toggle everything back on again.
Write your own hard-toggle script that specifically hides all UI elements
but also specifically unhides the UI elements that you want on.