def setup(self): translators = self.getTranslators() if translators: if len(translators) > 1: self.beginLayout('hide', collapse=False) # if there is more than one translator, we group each in its own layout # create the menu for selecting the translator self.addCustom("aiTranslator", aeCallback(lambda attr: self.createMenu(attr.split('.')[0])), aeCallback(lambda attr: self.updateMenu(attr.split('.')[0]))) for translator, template in self.getTranslatorTemplates(): # we always create a layout, even if it's empty self.beginLayout(translator, collapse=False) self.addChildTemplate('message', template) self.endLayout() self.endLayout() # timing on AE's is difficult: the frameLayouts are not created at this point even though # the `editorTemplate -beginLayout` calls have been made. this is a little hack # to ensure we get a callback after the AE ui elements have been built: normal controls can get # an update callback, but we don't have any normal controls around, so we'll have to make one and # hide it self.addCustom('message', aeCallback(self.updateChildrenCallback), aeCallback(self.updateChildrenCallback)) else: translator, template = self.getTranslatorTemplates()[0] self.addChildTemplate('message', template)
def setup(self): translators = self.getTranslators() if translators: if len(translators) > 1: self.beginLayout('hide', collapse=False) # if there is more than one translator, we group each in its own layout # create the menu for selecting the translator self.addCustom( "aiTranslator", aeCallback( lambda attr: self.createMenu(attr.split('.')[0])), aeCallback( lambda attr: self.updateMenu(attr.split('.')[0]))) for translator, template in self.getTranslatorTemplates(): # we always create a layout, even if it's empty self.beginLayout(translator, collapse=False) self.addChildTemplate('message', template) self.endLayout() self.endLayout() # timing on AE's is difficult: the frameLayouts are not created at this point even though # the `editorTemplate -beginLayout` calls have been made. this is a little hack # to ensure we get a callback after the AE ui elements have been built: normal controls can get # an update callback, but we don't have any normal controls around, so we'll have to make one and # hide it self.addCustom('message', aeCallback(self.updateChildrenCallback), aeCallback(self.updateChildrenCallback)) else: translator, template = self.getTranslatorTemplates()[0] self.addChildTemplate('message', template)
def addCustom(self, attr, newFunc, replaceFunc): # TODO: support multiple attributes passed if hasattr(newFunc, '__call__'): newFunc = aeCallback(newFunc) if hasattr(replaceFunc, '__call__'): replaceFunc = aeCallback(replaceFunc) args = (newFunc, replaceFunc, attr) pm.cmds.editorTemplate(callCustom=1, *args)
def addChildTemplate(self, attr, template): template._setToChildMode() template._record = True template.setup() for attr in template._attributes: try: pm.cmds.editorTemplate(suppress=attr) except RuntimeError: pass pm.cmds.editorTemplate(aeCallback(template._doSetup), aeCallback(template._doUpdate), attr, callCustom=True)
def addControl(self, attr, label=None, changeCommand=None, annotation=None, preventOverride=False, dynamic=False, enumeratedItem=None): if not label: label = prettify(attr) if label.startswith('Ai '): label = label[3:] args = [attr] kwargs = {} # kwargs['preventOverride'] = preventOverride if dynamic: kwargs['addDynamicControl'] = True else: kwargs['addControl'] = True if changeCommand: if hasattr(changeCommand, '__call__'): changeCommand = aeCallback(changeCommand) args.append(changeCommand) if label: kwargs['label'] = label if annotation: kwargs['annotation'] = annotation pm.cmds.editorTemplate(*args, **kwargs)
def aiSwatchDisplay(nodeName): cmds.editorTemplate(aeCallback(aiSwatchDisplayNew), aeCallback(aiSwatchDisplayReplace), "message", callCustom=True)
def aiSwatchDisplay(nodeName) : cmds.editorTemplate(aeCallback(aiSwatchDisplayNew), aeCallback(aiSwatchDisplayReplace), "message", callCustom=True)