def _createHeader( self, columnLayout, **kw ) : IECoreMaya.CompoundParameterUI._createHeader( self, columnLayout, **kw ) maya.cmds.rowLayout( numberOfColumns = 2, parent = columnLayout ) collapsable = True with IECore.IgnoredExceptions( KeyError ) : collapsable = self.parameter.userData()["UI"]["collapsable"].value lable = "Class" if collapsable else self.label() font = "smallPlainLabelFont" if collapsable else "tinyBoldLabelFont" maya.cmds.text( label = lable, font = font, align = "right", annotation = self.description() ) self.__menuParent = maya.cmds.iconTextStaticLabel( image = "arrowDown.xpm", font = "smallBoldLabelFont", label = self.__menuParentLabel(), style = "iconAndTextHorizontal", height = 23, ) # popup menu can be activated with either right or left buttons IECoreMaya.createMenu( self.__menuDefinition, self.__menuParent ) IECoreMaya.createMenu( self.__menuDefinition, self.__menuParent, button = 1 )
def _addPopupMenu( self, parentUI, **kw ) : existingMenus = maya.cmds.control( parentUI, query=True, popupMenuArray=True ) if existingMenus : for m in existingMenus : maya.cmds.deleteUI( m, menu=True ) IECoreMaya.createMenu( definition = IECore.curry( self.__popupMenuDefinition, **kw ), parent = parentUI, useInterToUI=False ) if "button1" in kw and kw["button1"] : IECoreMaya.createMenu( definition = IECore.curry( self.__popupMenuDefinition, **kw ), parent = parentUI, button = 1, useInterToUI=False )
def __init__( self, node, parameter, **kw ) : IECoreMaya.ParameterUI.__init__( self, node, parameter, maya.cmds.frameLayout( labelVisible = False, collapsable = False, ), **kw ) # passing borderVisible=False to the constructor does bugger all so we do it here instead. maya.cmds.frameLayout( self._topLevelUI(), edit=True, borderVisible=False ) collapsible = self.__parameterIsCollapsible() self.__kw = kw.copy() if collapsible : self.__kw["hierarchyDepth"] = self.__kw.get( "hierarchyDepth", -1 ) + 1 collapsed = self._retrieveCollapsedState( collapsible ) self.__collapsible = IECoreMaya.Collapsible( annotation = self.description(), label = self.label(), labelFont = IECoreMaya.CompoundParameterUI._labelFont( self.__kw["hierarchyDepth"] ), labelIndent = IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"] ), labelVisible = collapsible, collapsed = collapsed, expandCommand = self.__expand, collapseCommand = self.__collapse, ) self.__formLayout = maya.cmds.formLayout( parent=self.__collapsible.frameLayout() ) self.__buttonRow = maya.cmds.rowLayout( nc=3, adj=3, cw3=( 25, 25, 40 ), parent=self.__formLayout ) self.__addButton = maya.cmds.picture( image="ie_addIcon_grey.xpm", parent=self.__buttonRow, width=21 ) IECoreMaya.createMenu( IECore.curry( self.__classMenuDefinition, None ), self.__addButton, useInterToUI=False ) IECoreMaya.createMenu( IECore.curry( self.__classMenuDefinition, None ), self.__addButton, useInterToUI=False, button=1 ) self.__toolsButton = maya.cmds.picture( image="ie_actionIcon_grey.xpm", parent=self.__buttonRow, width=21 ) IECoreMaya.createMenu( IECore.curry( self.__toolsMenuDefinition, None ), self.__toolsButton, useInterToUI=False ) IECoreMaya.createMenu( IECore.curry( self.__toolsMenuDefinition, None ), self.__toolsButton, useInterToUI=False, button=1 ) self.__classInfo = [] self.__childUIs = {} # mapping from parameter name to ui name self.replace( node, parameter )
def _addPopupMenu(self, parentUI, **kw): existingMenus = maya.cmds.control(parentUI, query=True, popupMenuArray=True) if existingMenus: for m in existingMenus: maya.cmds.deleteUI(m, menu=True) IECoreMaya.createMenu(definition=IECore.curry( self.__popupMenuDefinition, **kw), parent=parentUI, useInterToUI=False) if "button1" in kw and kw["button1"]: IECoreMaya.createMenu(definition=IECore.curry( self.__popupMenuDefinition, **kw), parent=parentUI, button=1, useInterToUI=False)
def createCortexMenu(): if os.environ.get("IECOREMAYA_DISABLE_MENU", "0") == "1": return m = IECore.MenuDefinition() m.append("/Create Procedural", { "subMenu": proceduralCreationMenuDefinition, }) m.append("/Create Op", { "subMenu": opCreationMenuDefinition, }) global __cortexMenu __cortexMenu = IECoreMaya.createMenu(m, "MayaWindow", "Cortex")
def createCortexMenu() : if os.environ.get( "IECOREMAYA_DISABLE_MENU", "0" ) == "1" : return m = IECore.MenuDefinition() m.append( "/Create Procedural", { "subMenu" : proceduralCreationMenuDefinition, } ) m.append( "/Create Op", { "subMenu" : opCreationMenuDefinition, } ) global __cortexMenu __cortexMenu = IECoreMaya.createMenu( m, "MayaWindow", "Cortex" )
def pipeIdleStartup(): # force auto-load of these plugins at startup! plugs=[ 'slumMayaPlugin.py', 'ieCore.so', '3delight_for_maya%s' % os.environ['MAYA_VERSION_MAJOR'], ] if plugs: for each in plugs: print '='*80 print 'PIPE: auto-loading %s plugin...\n' % each try: m.loadPlugin( each ) except: pass print '='*80 # re-initialize cortex menu to filter out admin ops! try: import IECore, IECoreMaya except: IECore=None IECoreMaya=None if IECore: def __createOp( className ) : fnOH = IECoreMaya.FnOpHolder.create( os.path.basename( className ), className ) maya.cmds.select( fnOH.fullPathName() ) def filteredOpCreationMenuDefinition() : menu = IECore.MenuDefinition() loader = IECore.ClassLoader.defaultOpLoader() for className in loader.classNames() : if not filter( lambda x: x in className, ['admin/'] ): menu.append( "/" + className, { "command" : IECore.curry( __createOp, className ), } ) return menu menu = IECore.MenuDefinition() menu.append( "/Create Procedural", { "subMenu" : IECoreMaya.Menus.proceduralCreationMenuDefinition, } ) menu.append( "/Create Op", { "subMenu" : filteredOpCreationMenuDefinition, } ) #delete default cortex menu! for each in filter( lambda x: m.menu( x, q=1, l=1)=='Cortex', m.window( "MayaWindow", query=True, menuArray=True ) ): m.deleteUI( each, menu=True ) #create our custom one! global __cortexMenu __cortexMenu = IECoreMaya.createMenu( menu, "MayaWindow", "Cortex" ) # force unload of Alembic plugins!! m.unloadPlugin('AbcExport') m.unloadPlugin('AbcImport')
def loadAssetManager(): import IECore, IECoreMaya def __publishRender() : import maya.cmds as m #m.file() import IECore import Gaffer import GafferUI import os, pipe os.environ['PIPE_PUBLISH_FILTER'] = 'render/maya' appLoader = IECore.ClassLoader.defaultLoader( "GAFFER_APP_PATHS" ) appLoader.classNames() app=appLoader.load( 'opa' )() app.parameters()['arguments'] = IECore.StringVectorData(['-Asset.type','render/maya','1','IECORE_ASSET_OP_PATHS']) app.parameters()['op'] = 'publish' app.parameters()['gui'] = 1 app.run() def __publish(f='particle', t='nParticles') : import maya.cmds as m import IECore import Gaffer import PySide import os, pipe os.environ['PIPE_PUBLISH_FILTER'] = f appLoader = IECore.ClassLoader.defaultLoader( "GAFFER_APP_PATHS" ) appLoader.classNames() app=appLoader.load( 'opa' )() app.parameters()['arguments'] = IECore.StringVectorData(['-Asset.type','%s/%s' % (f,t),'1','IECORE_ASSET_OP_PATHS']) app.parameters()['op'] = 'publish' app.parameters()['gui'] = 1 app.run() def __gather() : global sam_window import IECore import Gaffer import GafferUI import assetBrowser import os, pipe scriptNode = Gaffer.ScriptNode() with GafferUI.Window( "Gaffer Browser" ) as sam_window : browser = GafferUI.BrowserEditor( scriptNode ) browser.pathChooser().getPath().setFromString( '/' ) sam_window.setVisible( True ) GafferUI.EventLoop.mainEventLoop().start() menu = IECore.MenuDefinition() menu.append("/Publish/Render", {"command" : __publishRender,"active" : True}) menu.append("/Publish/Particle/nParticle", {"command" : lambda: __publish('particle', 'nParticles'), "active" : True}) menu.append("/Publish/Model", {"command" : lambda: __publish('model', 'cortex'), "active" : True}) menu.append("/Publish/Rig/skeleton", {"command" : __gather, "active" : False}) menu.append("/Publish/Rig/light", {"command" : __gather, "active" : False}) menu.append("/Publish/Animation/camera", {"command" : __gather, "active" : False}) menu.append("/Publish/Animation/vertex", {"command" : __gather, "active" : False}) menu.append("/Publish/Animation/skeleton", {"command" : __gather, "active" : False}) menu.append("/Publish/Animation/particles", {"command" : __gather, "active" : False}) menu.append("/Publish/Texture", {"command" : __gather, "active" : False}) menu.append("/Gather", {"command" : __gather, "active" : True}) #create our custom one! global __cortexMenu __cortexMenu = IECoreMaya.createMenu( menu, "MayaWindow", "SAM" )
def __drawHeaderParameterControl( self, parameter, fnPH ) : ## \todo This would be so much easier if we could just use ParameterUI # instances for each of the controls. We can't because they all do their # own labelling and are layed out for an attribute editor. if we do the # todo in ParameterUI to remove the labels and stuff then we can do the # todo here. control = None parameterPlugPath = fnPH.parameterPlugPath( parameter ) annotation = IECore.StringUtil.wrap( "%s\n\n%s" % ( parameterPlugPath.split( "." )[1], parameter.description ), 48 ) if parameter.presetsOnly : control = maya.cmds.iconTextStaticLabel( image = "arrowDown.xpm", font = "smallBoldLabelFont", style = "iconAndTextHorizontal", height = 23, width = 80, annotation = annotation, ) IECoreMaya.createMenu( IECore.curry( self.__presetsMenu, parameter ), control ) IECoreMaya.createMenu( IECore.curry( self.__presetsMenu, parameter ), control, button=1 ) self.__presetParameters.append( parameter ) self.__presetUIs.append( control ) if self.__attributeChangedCallbackId is None : self.__attributeChangedCallbackId = IECoreMaya.CallbackId( maya.OpenMaya.MNodeMessage.addAttributeChangedCallback( self.__vectorParent().node(), self.__attributeChanged ) ) self.__updatePresetLabel( len( self.__presetUIs ) - 1 ) elif isinstance( parameter, IECore.BoolParameter ) : control = maya.cmds.checkBox( label="", annotation=annotation ) maya.cmds.connectControl( control, parameterPlugPath ) elif isinstance( parameter, IECore.FloatParameter ) : control = maya.cmds.floatField( annotation = annotation, minValue = parameter.minValue, maxValue = parameter.maxValue, width = 45, pre = 4 ) maya.cmds.connectControl( control, parameterPlugPath ) elif isinstance( parameter, IECore.IntParameter ) : kw = {} if parameter.hasMinValue() : kw["minValue"] = parameter.minValue if parameter.hasMaxValue() : kw["maxValue"] = parameter.maxValue control = maya.cmds.intField( annotation = annotation, width = 45, **kw ) maya.cmds.connectControl( control, parameterPlugPath ) elif isinstance( parameter, IECore.Color3fParameter ) : control = maya.cmds.attrColorSliderGrp( label = "", columnWidth = ( ( 1, 1 ), ( 2, 30 ), ( 3, 1 ) ), columnAttach = ( ( 1, "both", 0 ), ( 2, "both", 0 ), ( 3, "left", 0 ) ), attribute = parameterPlugPath, annotation = annotation, showButton = False ) elif isinstance( parameter, IECore.StringParameter ) : control = maya.cmds.textField( annotation = annotation, width = 150 ) maya.cmds.connectControl( control, parameterPlugPath ) elif isinstance( parameter, IECore.V2fParameter ) : control = maya.cmds.rowLayout( nc=2, cw2=( 45, 45 ) ) column1 = maya.cmds.floatField( annotation = annotation, width = 45, pre = 4, parent = control ) maya.cmds.connectControl( column1, parameterPlugPath + "X" ) column2 = maya.cmds.floatField( annotation = annotation, width = 45, pre = 4, parent = control ) maya.cmds.connectControl( column2, parameterPlugPath + "Y" ) else : IECore.msg( IECore.Msg.Level.Warning, "ClassVectorParameterUI", "Parameter \"%s\" has unsupported type for inclusion in header ( %s )." % ( parameter.name, parameter.typeName() ) ) return control
def __buildOptionalHeaderUI( self, formLayout, attachForm, attachControl, lastControl ) : defaultLabel = "" try : parentUIUserData = self.__vectorParent().parameter.userData()["UI"] defaultLabelStyle = parentUIUserData["defaultChildLabel"].value if 'classname' in defaultLabelStyle.lower() : defaultLabel = self.__class()[2] if defaultLabelStyle.startswith( 'abbreviated' ) : if "classNameFilter" in parentUIUserData : classNameFilter = parentUIUserData["classNameFilter"].value defaultLabel = defaultLabel.replace( classNameFilter.strip( '*' ), '' ) if defaultLabelStyle.endswith( 'ToUI' ) : defaultLabel = maya.mel.eval( 'interToUI( "%s" )' % defaultLabel ) defaultDescription = self.__class()[0].description except : defaultLabel = "" defaultDescription = "" labelPlugPath = self.__labelPlugPath() if labelPlugPath or defaultLabel : label = maya.cmds.getAttr( labelPlugPath ) if labelPlugPath else defaultLabel description = self.__parameter["label"].description if labelPlugPath else defaultDescription self.__label = maya.cmds.text( parent = formLayout, align = "left", label = label, font = IECoreMaya.CompoundParameterUI._labelFont( self.__kw["hierarchyDepth"] ), annotation = IECore.StringUtil.wrap( description, 48 ), width = 190 - IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"] ), recomputeSize = False, ) if labelPlugPath : lockedLabel = False with IECore.IgnoredExceptions( KeyError ) : lockedLabel = self.__parameter["label"].userData()["UI"]["locked"] if not lockedLabel : renameMenu = IECore.MenuDefinition( [ ( "Change label...", { "command" : self.__changeLabel } ), ] ) IECoreMaya.createMenu( renameMenu, self.__label ) IECoreMaya.createMenu( renameMenu, self.__label, button = 1 ) attachForm += [ ( self.__label, "top", 0 ), ( self.__label, "bottom", 0 ), ] attachControl += [ ( self.__label, "left", 4, lastControl ), ] lastControl = self.__label return self.__drawHeaderParameterControls( formLayout, attachForm, attachControl, lastControl, "classVectorParameterHeader" )
def __init__( self, parameter, **kw ) : IECoreMaya.UIElement.__init__( self, maya.cmds.columnLayout() ) if not isinstance( self.__vectorParent(), ClassVectorParameterUI ) : raise RuntimeError( "Parent must be a ClassVectorParameterUI" ) self.__kw = kw.copy() self.__kw["hierarchyDepth"] = self.__kw.get( "hierarchyDepth", -1 ) + 1 self.__parameter = parameter headerFormLayout = maya.cmds.formLayout() attachForm = [] attachControl = [] # triangle for expanding to view all parameters self.__parameterVisibilityIcon = maya.cmds.iconTextButton( style="iconOnly", height = 20, width = 20, image="arrowRight.xpm", command = self._createCallback( self.__toggleParameterVisibility ), annotation = "Show parameters", visible = self.__parameterIsCollapsible(), ) attachForm += [ ( self.__parameterVisibilityIcon, "left", IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"] ) ), ( self.__parameterVisibilityIcon, "top", 0 ), ( self.__parameterVisibilityIcon, "bottom", 0 ), ] lastControl = self.__buildOptionalPreHeaderUI( headerFormLayout, attachForm, attachControl, self.__parameterVisibilityIcon ) # layer icon layerIcon = maya.cmds.picture( width = 20, image = "%s.xpm" % self.__classIconName(), annotation = IECore.StringUtil.wrap( self.__class()[0].description + "\n\n" + "Click to reorder or remove.", 48, ) ) IECoreMaya.createMenu( self.__layerMenu, layerIcon, useInterToUI=False ) IECoreMaya.createMenu( self.__layerMenu, layerIcon, useInterToUI=False, button=1 ) attachControl += [ ( layerIcon, "left", 0, lastControl ), ] attachForm += [ ( layerIcon, "top", 0 ), ( layerIcon, "bottom", 0 ), ] # class specific fields self.__attributeChangedCallbackId = None self.__presetParameters = [] self.__presetUIs = [] self.__buildOptionalHeaderUI( headerFormLayout, attachForm, attachControl, layerIcon ) maya.cmds.formLayout( headerFormLayout, edit = True, attachForm = attachForm, attachControl = attachControl, ) # CompoundParameterUI to hold child parameters maya.cmds.setParent( self._topLevelUI() ) self.__compoundParameterUI = IECoreMaya.CompoundParameterUI( self.__vectorParent().node(), parameter, labelVisible = False, **kw ) self.setCollapsed( self.getCollapsed(), False )
def __drawHeaderParameterControl(self, parameter, fnPH): ## \todo This would be so much easier if we could just use ParameterUI # instances for each of the controls. We can't because they all do their # own labelling and are layed out for an attribute editor. if we do the # todo in ParameterUI to remove the labels and stuff then we can do the # todo here. control = None parameterPlugPath = fnPH.parameterPlugPath(parameter) annotation = IECore.StringUtil.wrap( "%s\n\n%s" % (parameterPlugPath.split(".")[1], parameter.description), 48) if parameter.presetsOnly: control = maya.cmds.iconTextStaticLabel( image="arrowDown.xpm", font="smallBoldLabelFont", style="iconAndTextHorizontal", height=23, width=80, annotation=annotation, ) IECoreMaya.createMenu(IECore.curry(self.__presetsMenu, parameter), control) IECoreMaya.createMenu(IECore.curry(self.__presetsMenu, parameter), control, button=1) self.__presetParameters.append(parameter) self.__presetUIs.append(control) if self.__attributeChangedCallbackId is None: self.__attributeChangedCallbackId = IECoreMaya.CallbackId( maya.OpenMaya.MNodeMessage.addAttributeChangedCallback( self.__vectorParent().node(), self.__attributeChanged)) self.__updatePresetLabel(len(self.__presetUIs) - 1) elif isinstance(parameter, IECore.BoolParameter): control = maya.cmds.checkBox(label="", annotation=annotation) maya.cmds.connectControl(control, parameterPlugPath) elif isinstance(parameter, IECore.FloatParameter): control = maya.cmds.floatField(annotation=annotation, minValue=parameter.minValue, maxValue=parameter.maxValue, width=45, pre=4) maya.cmds.connectControl(control, parameterPlugPath) elif isinstance(parameter, IECore.IntParameter): kw = {} if parameter.hasMinValue(): kw["minValue"] = parameter.minValue if parameter.hasMaxValue(): kw["maxValue"] = parameter.maxValue control = maya.cmds.intField(annotation=annotation, width=45, **kw) maya.cmds.connectControl(control, parameterPlugPath) elif isinstance(parameter, IECore.Color3fParameter): control = maya.cmds.attrColorSliderGrp( label="", columnWidth=((1, 1), (2, 30), (3, 1)), columnAttach=((1, "both", 0), (2, "both", 0), (3, "left", 0)), attribute=parameterPlugPath, annotation=annotation, showButton=False) elif isinstance(parameter, IECore.StringParameter): control = maya.cmds.textField(annotation=annotation, width=150) maya.cmds.connectControl(control, parameterPlugPath) elif isinstance(parameter, IECore.V2fParameter): control = maya.cmds.rowLayout(nc=2, cw2=(45, 45)) column1 = maya.cmds.floatField(annotation=annotation, width=45, pre=4, parent=control) maya.cmds.connectControl(column1, parameterPlugPath + "X") column2 = maya.cmds.floatField(annotation=annotation, width=45, pre=4, parent=control) maya.cmds.connectControl(column2, parameterPlugPath + "Y") else: IECore.msg( IECore.Msg.Level.Warning, "ClassVectorParameterUI", "Parameter \"%s\" has unsupported type for inclusion in header ( %s )." % (parameter.name, parameter.typeName())) return control
def __buildOptionalHeaderUI(self, formLayout, attachForm, attachControl, lastControl): defaultLabel = "" try: parentUIUserData = self.__vectorParent().parameter.userData()["UI"] defaultLabelStyle = parentUIUserData["defaultChildLabel"].value if 'classname' in defaultLabelStyle.lower(): defaultLabel = self.__class()[2] if defaultLabelStyle.startswith('abbreviated'): if "classNameFilter" in parentUIUserData: classNameFilter = parentUIUserData["classNameFilter"].value defaultLabel = defaultLabel.replace( classNameFilter.strip('*'), '') if defaultLabelStyle.endswith('ToUI'): defaultLabel = maya.mel.eval('interToUI( "%s" )' % defaultLabel) defaultDescription = self.__class()[0].description except: defaultLabel = "" defaultDescription = "" labelPlugPath = self.__labelPlugPath() if labelPlugPath or defaultLabel: label = maya.cmds.getAttr( labelPlugPath) if labelPlugPath else defaultLabel description = self.__parameter[ "label"].description if labelPlugPath else defaultDescription self.__label = maya.cmds.text( parent=formLayout, align="left", label=label, font=IECoreMaya.CompoundParameterUI._labelFont( self.__kw["hierarchyDepth"]), annotation=IECore.StringUtil.wrap(description, 48), width=190 - IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"]), recomputeSize=False, ) if labelPlugPath: lockedLabel = False with IECore.IgnoredExceptions(KeyError): lockedLabel = self.__parameter["label"].userData( )["UI"]["locked"] if not lockedLabel: renameMenu = IECore.MenuDefinition([ ("Change label...", { "command": self.__changeLabel }), ]) IECoreMaya.createMenu(renameMenu, self.__label) IECoreMaya.createMenu(renameMenu, self.__label, button=1) attachForm += [ (self.__label, "top", 0), (self.__label, "bottom", 0), ] attachControl += [ (self.__label, "left", 4, lastControl), ] lastControl = self.__label return self.__drawHeaderParameterControls( formLayout, attachForm, attachControl, lastControl, "classVectorParameterHeader")
def __init__(self, node, parameter, **kw): IECoreMaya.ParameterUI.__init__( self, node, parameter, maya.cmds.frameLayout( labelVisible=False, collapsable=False, ), **kw) # passing borderVisible=False to the constructor does bugger all so we do it here instead. maya.cmds.frameLayout(self._topLevelUI(), edit=True, borderVisible=False) collapsible = self.__parameterIsCollapsible() self.__kw = kw.copy() if collapsible: self.__kw["hierarchyDepth"] = self.__kw.get("hierarchyDepth", -1) + 1 collapsed = self._retrieveCollapsedState(collapsible) self.__collapsible = IECoreMaya.Collapsible( annotation=self.description(), label=self.label(), labelFont=IECoreMaya.CompoundParameterUI._labelFont( self.__kw["hierarchyDepth"]), labelIndent=IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"]), labelVisible=collapsible, collapsed=collapsed, expandCommand=self.__expand, collapseCommand=self.__collapse, ) self.__formLayout = maya.cmds.formLayout( parent=self.__collapsible.frameLayout()) self.__buttonRow = maya.cmds.rowLayout(nc=3, adj=3, cw3=(25, 25, 40), parent=self.__formLayout) self.__addButton = maya.cmds.picture(image="ie_addIcon_grey.xpm", parent=self.__buttonRow, width=21) IECoreMaya.createMenu(IECore.curry(self.__classMenuDefinition, None), self.__addButton, useInterToUI=False) IECoreMaya.createMenu(IECore.curry(self.__classMenuDefinition, None), self.__addButton, useInterToUI=False, button=1) self.__toolsButton = maya.cmds.picture(image="ie_actionIcon_grey.xpm", parent=self.__buttonRow, width=21) IECoreMaya.createMenu(IECore.curry(self.__toolsMenuDefinition, None), self.__toolsButton, useInterToUI=False) IECoreMaya.createMenu(IECore.curry(self.__toolsMenuDefinition, None), self.__toolsButton, useInterToUI=False, button=1) self.__classInfo = [] self.__childUIs = {} # mapping from parameter name to ui name self.replace(node, parameter)
def __init__(self, parameter, **kw): IECoreMaya.UIElement.__init__(self, maya.cmds.columnLayout()) if not isinstance(self.__vectorParent(), ClassVectorParameterUI): raise RuntimeError("Parent must be a ClassVectorParameterUI") self.__kw = kw.copy() self.__kw["hierarchyDepth"] = self.__kw.get("hierarchyDepth", -1) + 1 self.__parameter = parameter headerFormLayout = maya.cmds.formLayout() attachForm = [] attachControl = [] # triangle for expanding to view all parameters self.__parameterVisibilityIcon = maya.cmds.iconTextButton( style="iconOnly", height=20, width=20, image="arrowRight.xpm", command=self._createCallback(self.__toggleParameterVisibility), annotation="Show parameters", visible=self.__parameterIsCollapsible(), ) attachForm += [ (self.__parameterVisibilityIcon, "left", IECoreMaya.CompoundParameterUI._labelIndent( self.__kw["hierarchyDepth"])), (self.__parameterVisibilityIcon, "top", 0), (self.__parameterVisibilityIcon, "bottom", 0), ] lastControl = self.__buildOptionalPreHeaderUI( headerFormLayout, attachForm, attachControl, self.__parameterVisibilityIcon) # layer icon layerIcon = maya.cmds.picture( width=20, image="%s.xpm" % self.__classIconName(), annotation=IECore.StringUtil.wrap( self.__class()[0].description + "\n\n" + "Click to reorder or remove.", 48, )) IECoreMaya.createMenu(self.__layerMenu, layerIcon, useInterToUI=False) IECoreMaya.createMenu(self.__layerMenu, layerIcon, useInterToUI=False, button=1) attachControl += [ (layerIcon, "left", 0, lastControl), ] attachForm += [ (layerIcon, "top", 0), (layerIcon, "bottom", 0), ] # class specific fields self.__attributeChangedCallbackId = None self.__presetParameters = [] self.__presetUIs = [] self.__buildOptionalHeaderUI(headerFormLayout, attachForm, attachControl, layerIcon) maya.cmds.formLayout( headerFormLayout, edit=True, attachForm=attachForm, attachControl=attachControl, ) # CompoundParameterUI to hold child parameters maya.cmds.setParent(self._topLevelUI()) self.__compoundParameterUI = IECoreMaya.CompoundParameterUI( self.__vectorParent().node(), parameter, labelVisible=False, **kw) self.setCollapsed(self.getCollapsed(), False)