// =========================================================================== // 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. // =========================================================================== global proc setChannelBoxShowType(string $type) { global string $gChannelBoxName; optionVar -stringValue cbShowType $type; channelBox -e -update $gChannelBoxName; } global proc setChannelBoxAtTop(int $val) { global string $gChannelBoxName; string $cmd = ("channelBox -e -containerAtTop "+$val+" "+$gChannelBoxName); evalEcho $cmd; optionVar -intValue cbContainerAtTop $val; } global proc int channelBoxAttrCategories(string $filter) // // Custom filter to suppress the attribute menu items that do not // make sense for the channel box. // { string $nameString = `itemFilterAttr -q -byName $filter`; if (size($nameString) > 0) { return 1; } else if (`itemFilterAttr -q -hidden $filter`) { return 0; } else if (`itemFilterAttr -q -keyable $filter`) { return 0; } return 1; } global proc generateChannelShowMenu( string $parent ) // // Generates the Show menu on the channel box menubar. // { global string $gChannelBoxName; setParent -m $parent; string $showByType = "all"; if (`optionVar -exists cbShowType`) { $showByType = `optionVar -q cbShowType`; } if( 0 != `menu -q -ni $parent` ) { menuItem -e -radioButton ($showByType == "all") byAllItem; menuItem -e -radioButton ($showByType == "select") byObjectItem; } else { // // The menu doesn't exist yet - build it // menuItem -label (uiRes("m_generateChannelShowMenu.kAssets")) -subMenu true; radioMenuItemCollection; menuItem -label (uiRes("m_generateChannelShowMenu.kAll")) -c "setChannelBoxShowType(\"all\")" -radioButton ($showByType == "all") byAllItem; menuItem -label (uiRes("m_generateChannelShowMenu.kSelected")) -c "setChannelBoxShowType(\"select\")" -radioButton ($showByType == "select") byObjectItem; menuItem -divider true; menuItem -label (uiRes("m_generateChannelShowMenu.kShowAtTop")) -annotation (uiRes("m_generateChannelShowMenu.kShowAtTopAnnot")) -cb `channelBox -q -containerAtTop $gChannelBoxName` -c "setChannelBoxAtTop #1"; setParent -m ..; filterUICreateMenuSub($gChannelBoxName,$parent,0,1); filterUISetRelatedAttrFiltersProcedure($gChannelBoxName,"channelBoxAttrCategories"); // The filterUI sets up a new postMenuCommand for the menu, so // we need to add this command back to the script. // string $pmc = `menu -q -pmc $parent`; $pmc += ("; generateChannelShowMenu "+$parent); menu -e -pmc $pmc $parent; setParent -m ..; } }