def uiFunc_toggleContext(self): _str_func = 'animDrawTool.uiFunc_toggleContext' if self._animDrawTool: self._animDrawTool.quit() uiFunc_exit_draw_context(self) else: uiFunc_load_selected(self) if not self._mTransformTargets: log.error("No object selected. Can't start draw context") return self._animDrawTool = animDraw.AnimDraw( plane=self._optionDict['plane'], mode=self._optionDict['mode'], planeObject=self._optionDict['planeObject'], aimFwd=self._optionDict['aimFwd'], aimUp=self._optionDict['aimUp'], postBlendFrames=self._optionDict['postBlendFrames'], loopTime=self._optionDict['loopTime'], debug=self._optionDict['debug'], recordMode=self._optionDict['recordMode'], onStart=cgmGEN.Callback(uiFunc_recordingStarted, self), onComplete=cgmGEN.Callback(uiFunc_recordingCompleted, self), onReposition=cgmGEN.Callback(uiFunc_recordingCompleted, self), onExit=cgmGEN.Callback(uiFunc_exit_draw_context, self)) self._animDrawTool.activate() self.animDrawBtn(e=True, label='Stop Recording Context', bgc=[.35, 1, .35]) self._infoLayout(edit=True, vis=True)
def buildRow_getVector(self, parent): #>>>Match mode ------------------------------------------------------------------------------------- _row = mUI.MelHSingleStretchLayout(parent, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=5) mUI.MelLabel(_row, l='Vector:') _row.setStretchWidget(mUI.MelSeparator(_row)) for i, item in enumerate(SHARED._l_axis_by_string): mc.button(parent=_row, ut='cgmUITemplate', label=item, c=cgmGEN.Callback(uiFunc_getVectorOfSelected, self, item), ann='Get selected objects {0} vector'.format(item)) mUI.MelSpacer(_row, w=2) mc.button(parent=_row, ut='cgmUITemplate', label='Between Sel', c=cgmGEN.Callback(uiFunc_getVectorOfSelected, self, 'between'), ann='Get the vector between the first and last selected') mUI.MelSpacer(_row, w=2) _row.layout()
def buildRow_worldUp(self, parent): #>>>Vector ------------------------------------------------------------------------------------- _row = mUI.MelHSingleStretchLayout(parent, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=5) mUI.MelLabel(_row, l='World:') _row.setStretchWidget(mUI.MelSeparator(_row)) _base_str = 'uiFF_worldUp' for i, a in enumerate(list('xyz')): #mUI.MelLabel(_row ,l=a) _field = mUI.MelFloatField(_row, ut='cgmUISubTemplate', w=60) self.__dict__['{0}{1}'.format(_base_str, a.capitalize())] = _field if i == 1: _field.setValue(1.0) mc.button(parent=_row, ut='cgmUITemplate', l='X', c=cgmGEN.Callback(uiFunc_setWorldUp, self, 1.0, 0, 0), ann="Set to X") mc.button(parent=_row, ut='cgmUITemplate', l='Y', c=cgmGEN.Callback(uiFunc_setWorldUp, self, 0, 1.0, 0), ann="Set to Y") mc.button(parent=_row, ut='cgmUITemplate', l='Z', c=cgmGEN.Callback(uiFunc_setWorldUp, self, 0, 0, 1.0), ann="Set to Z") mUI.MelSpacer(_row, w=5) _row.layout()
def buildRow_tweak(self,parent): #>>>Vector ------------------------------------------------------------------------------------- _row = mUI.MelHSingleStretchLayout(parent,ut='cgmUISubTemplate',padding = 5) mUI.MelSpacer(_row ,w=5) mUI.MelLabel(_row ,l='Tweak Values:') _row.setStretchWidget(mUI.MelSeparator(_row )) _base_str = 'uiff_transformTweak' #self._d_transformAttrFields[label] = {} #self._d_transformRows[label] = _row for a in list('xyz'): mUI.MelLabel(_row ,l=a) _field = mUI.MelFloatField(_row , ut='cgmUISubTemplate', w= 60 ) self.__dict__['{0}{1}'.format(_base_str,a.capitalize())] = _field mc.button(parent=_row , ut = 'cgmUITemplate', l = '+', c = cgmGEN.Callback(uiFunc_valuesTweak,self,'+'), ann = "Adds value relatively to current") mc.button(parent=_row , ut = 'cgmUITemplate', l = '-', c = cgmGEN.Callback(uiFunc_valuesTweak,self,'-'), ann = "Subracts value relatively to current") mc.button(parent=_row , ut = 'cgmUITemplate', l = 'Zero', c = cgmGEN.Callback(uiFunc_valuesTweak,self,'zero'), ann = "Zero out the fields. Uncheck all tweak check boxes") mUI.MelSpacer(_row ,w=5) _row.layout()
def add_connection_row(self, parent, connection, label, connectionInfo): # Add Connection # _row = mUI.MelHSingleStretchLayout(parent,ut='cgmUISubTemplate',padding = 5) mUI.MelSpacer(_row,w=_padding) mUI.MelLabel(_row,l='Target:') conLabel = mUI.MelLabel(_row,ut='cgmUIInstructionsTemplate',l=label,en=False) _row.setStretchWidget( conLabel ) mUI.MelLabel(_row,l='Min:') ff_min = mUI.MelFloatField(_row, ut='cgmUISubTemplate', w= 50, precision = 2, v=connectionInfo['min']) mUI.MelLabel(_row,l='Max:') ff_max = mUI.MelFloatField(_row, ut='cgmUISubTemplate', w= 50, precision = 2, v=connectionInfo['max']) mUI.MelLabel(_row,l='Damp:') ff_damp = mUI.MelFloatField(_row, ut='cgmUISubTemplate', w= 50, precision = 2, v=connectionInfo['damp']) ff_min(edit=True, cc=cgmGEN.Callback(uiFunc_change_connection,self,connection, label, ff_min, ff_max, ff_damp)) ff_max(edit=True, cc=cgmGEN.Callback(uiFunc_change_connection,self,connection, label, ff_min, ff_max, ff_damp)) ff_damp(edit=True, cc=cgmGEN.Callback(uiFunc_change_connection,self,connection, label, ff_min, ff_max, ff_damp)) cgmUI.add_Button(_row,'X', cgmGEN.Callback(uiFunc_remove_connection,self,_row, connection, label), "Remove connection.") mUI.MelSpacer(_row,w=_padding) _row.layout()
def buildMenu_first(self): self.uiMenu_FirstMenu.clear() #>>> Reset Options mUI.MelMenuItemDiv(self.uiMenu_FirstMenu) mUI.MelMenuItem(self.uiMenu_FirstMenu, l="Save Mappings", c=cgmGEN.Callback(uiFunc_save, self)) mUI.MelMenuItem(self.uiMenu_FirstMenu, l="Load Mappings", c=cgmGEN.Callback(uiFunc_load, self)) recent = mUI.MelMenuItem(self.uiMenu_FirstMenu, l="Recent", subMenu=True) for mapping in self.recentMappings: mUI.MelMenuItem(recent, l=mapping, c=cgmGEN.Callback(uiFunc_load, self, mapping)) mUI.MelMenuItem(self.uiMenu_FirstMenu, l="Reload", c=lambda *a: mc.evalDeferred(self.reload, lp=True)) mUI.MelMenuItem(self.uiMenu_FirstMenu, l="Reset", c=lambda *a: mc.evalDeferred(self.reload, lp=True))
def uiFunc_build_controller_connection_column(self, parent, connection): mc.setParent(parent) cgmUI.add_LineSubBreak() # Connection Column # connectionColumn = mUI.MelColumnLayout(parent,useTemplate = 'cgmUISubTemplate') for label in self.connectionDict[connection]: add_connection_row(self, connectionColumn, connection, label, self.connectionDict[connection][label]) # # End Connection Column _row = mUI.MelHLayout(parent,ut='cgmUISubTemplate',padding = _padding) btn = cgmUI.add_Button(_row,'Add Connection', cgmGEN.Callback(add_connection,self, connectionColumn, connection), #lambda *a: attrToolsLib.doAddAttributesToSelected(self), 'Add Connection Button',h=25) btn = cgmUI.add_Button(_row,'Clear All', cgmGEN.Callback(uiFunc_clear_connections,self, connectionColumn, connection), #lambda *a: attrToolsLib.doAddAttributesToSelected(self), 'Clear Connections Button',h=25) _row.layout() mc.setParent(parent) cgmUI.add_LineSubBreak()
def uiMenu(parent): _str_func = 'uiMenu' _uiRoot = mc.menuItem(parent=parent, l='LightLoom Lite', subMenu=True, tearOff=True) _keys = d_profiles.keys() _keys.sort() _uiToPersp = mc.menuItem( parent=_uiRoot, subMenu=True, l='toPersp', ) _uiToSelected = mc.menuItem( parent=_uiRoot, subMenu=True, l='toSelected', ) _uiToNone = mc.menuItem( parent=_uiRoot, subMenu=True, l='toWorld', ) for k in _keys: mc.menuItem(parent=_uiToPersp, l=k, ann="Setup {0} Orient to persp cam".format(k), c=cgmGEN.Callback(factory, **{ 'profile': k, 'constrainTo': 'persp' })) mc.menuItem(parent=_uiToSelected, l=k, ann="Setup {0} Orient to selected".format(k), c=cgmGEN.Callback( factory, **{ 'profile': k, 'constrainTo': 'selected' })) mc.menuItem(parent=_uiToNone, l=k, ann="Setup {0} to world".format(k), c=cgmGEN.Callback(factory, **{ 'profile': k, 'constrainTo': None })) mUI.MelMenuItemDiv(_uiRoot) mc.menuItem(parent=_uiRoot, l='Clean cgmLights', ann="Remove cgmLights from scene", c=cgmGEN.Callback(clean_lights))
def build_menus(self): self.uiMenu_FirstMenu = mUI.MelMenu(l='Setup', pmc=cgmGEN.Callback( self.buildMenu_first)) self.uiMenu_tools = mUI.MelMenu(l='Tools', pmc=cgmGEN.Callback( self.buildMenu_tools)) self.uiMenu_help = mUI.MelMenu(l='Help', pmc=cgmGEN.Callback( self.buildMenu_help))
def buildRow_matchMode(self,parent): try:self.var_matchModeMove except:self.var_matchModeMove = cgmMeta.cgmOptionVar('cgmVar_matchModeMove', defaultValue = 1) try:self.var_matchModeRotate except:self.var_matchModeRotate = cgmMeta.cgmOptionVar('cgmVar_matchModeRotate', defaultValue = 1) try:self.var_matchMode except:self.var_matchMode = cgmMeta.cgmOptionVar('cgmVar_matchMode', defaultValue = 2) #>>>Match mode ------------------------------------------------------------------------------------- _row = mUI.MelHSingleStretchLayout(parent,ut='cgmUISubTemplate',padding = 5) mUI.MelSpacer(_row,w=5) mUI.MelLabel(_row,l='Match Mode:') _row.setStretchWidget( mUI.MelSeparator(_row) ) uiRC = mUI.MelRadioCollection() _on = self.var_matchMode.value for i,item in enumerate(['point','orient','point/orient']): if i == _on: _rb = True else:_rb = False uiRC.createButton(_row,label=item,sl=_rb, onCommand = cgmGEN.Callback(LOCINATOR.uiFunc_change_matchMode,self,i)) mUI.MelSpacer(_row,w=2) _row.layout()
def buildRow_aimMode(self,parent): try:self.var_aimMode except:self.var_aimMode = cgmMeta.cgmOptionVar('cgmVar_aimMode', defaultValue = 'world') #>>>Match mode ------------------------------------------------------------------------------------- _row = mUI.MelHSingleStretchLayout(parent,ut='cgmUISubTemplate',padding = 5) mUI.MelSpacer(_row,w=5) mUI.MelLabel(_row,l='Aim Mode:') _row.setStretchWidget( mUI.MelSeparator(_row) ) uiRC = mUI.MelRadioCollection() _on = self.var_aimMode.value for i,item in enumerate(['local','world','matrix']): if item == _on: _rb = True else:_rb = False uiRC.createButton(_row,label=item,sl=_rb, onCommand = cgmGEN.Callback(self.var_aimMode.setValue,item)) mUI.MelSpacer(_row,w=2) _row.layout()
def build_menus(self): self.uiMenu_FirstMenu = mUI.MelMenu(l='Setup', pmc=cgmGEN.Callback( self.buildMenu_first)) #self.uiMenu_Buffers = mUI.MelMenu( l='Buffers', pmc = lambda *a:UICHUNKS.uiOptionMenu_buffers(self,False)) self.uiMenu_Help = mUI.MelMenu(l='Help', pmc=lambda *a: self.buildMenu_help())
def uiFunc_create_selection_list(parent, items): itemList = cgmUI.cgmScrollList(parent, numberOfRows=4, height=75) itemList.setItems(items) itemList(edit=True, selectCommand=cgmGEN.Callback(uiFunc_select_list_item, itemList)) return itemList
def uiFunc_make_display_line(parent, label="", text="", button=False, buttonLabel = ">>", buttonCommand=None, buttonInfo="", presetOptions=False, presetObj=None): _row = mUI.MelHSingleStretchLayout(parent,ut='cgmUISubTemplate',padding = _padding) mUI.MelSpacer(_row,w=_padding) mUI.MelLabel(_row, l=label) uiTF = mUI.MelLabel(_row,ut='cgmUIInstructionsTemplate',l=text, en=True) if button: cgmUI.add_Button(_row,buttonLabel, buttonCommand, buttonInfo) _row.setStretchWidget(uiTF) if presetOptions: presetMenu = mUI.MelOptionMenu(_row,useTemplate = 'cgmUITemplate') presetMenu.append("Load Preset") for a in mc.nodePreset( list=presetObj ): presetMenu.append(a) presetMenu.append("---") presetMenu.append("Save Preset") presetMenu(edit=True, value = "Load Preset", cc = cgmGEN.Callback(uiFunc_process_preset_change, presetObj, presetMenu) ) mUI.MelSpacer(_row,w=_padding) _row.layout() return uiTF
def start_controller(self): self.animDrawBtn(edit=True, en=False) self.animDrawBtn(edit=True, label="Stop Controller", bgc=[.35, 1, .35]) mc.refresh() self.controllerPuppet = controllerPuppet.ControllerPuppet( self.mappingList, onEnded=cgmGEN.Callback(stop_controller, self)) self.controllerPuppet.start()
def buildRow_space(self,parent,optionVarPrefix = 'source', options = __l_spaceModes): _plug = 'var_{0}TransSpaceMode'.format(optionVarPrefix) self.__dict__[_plug] = cgmMeta.cgmOptionVar('cgmVar_{0}TransSpaceMode'.format(optionVarPrefix), defaultValue = options[0]) mPlug = self.__dict__[_plug] #>>>Row ==================================================================================== uiRC = mUI.MelRadioCollection() _row1 = mUI.MelHSingleStretchLayout(parent,ut='cgmUISubTemplate',padding = 5) mUI.MelSpacer(_row1,w=5) mUI.MelLabel(_row1,l='{0} Space Mode'.format(optionVarPrefix.capitalize())) _row1.setStretchWidget( mUI.MelSeparator(_row1) ) uiRC = mUI.MelRadioCollection() _on = mPlug.value for i,item in enumerate(options): if item == _on: _rb = True else:_rb = False uiRC.createButton(_row1,label=item,sl=_rb, onCommand = cgmGEN.Callback(mPlug.setValue,item)) mUI.MelSpacer(_row1,w=2) _row1.layout()
def buildRow_lockSource(self,parent): _plug = 'var_transformLockSource' self.__dict__[_plug] = cgmMeta.cgmOptionVar('cgmVar_transformLockSource', defaultValue = 1) mPlug = self.__dict__[_plug] #>>>Row ==================================================================================== uiRC = mUI.MelRadioCollection() _row1 = mUI.MelHSingleStretchLayout(parent,ut='cgmUISubTemplate',padding = 5) mUI.MelSpacer(_row1,w=5) mUI.MelLabel(_row1,l='Lock Source: ') _row1.setStretchWidget( mUI.MelSeparator(_row1) ) uiRC = mUI.MelRadioCollection() _on = mPlug.value for i,item in enumerate(['off','on']): if i == _on: _rb = True else:_rb = False uiRC.createButton(_row1,label=item,sl=_rb, ann = "When locked, the source object will not be affected by value changes via the ui", onCommand = cgmGEN.Callback(mPlug.setValue,i)) mUI.MelSpacer(_row1,w=2) _row1.layout()
def buildSection_objDefaults(self,parent,frame=True): try:self.var_objDefaultAimAxis except:self.var_objDefaultAimAxis = cgmMeta.cgmOptionVar('cgmVar_objDefaultAimAxis', defaultValue = 2) try:self.var_objDefaultUpAxis except:self.var_objDefaultUpAxis = cgmMeta.cgmOptionVar('cgmVar_objDefaultUpAxis', defaultValue = 1) try:self.var_objDefaultOutAxis except:self.var_objDefaultOutAxis = cgmMeta.cgmOptionVar('cgmVar_objDefaultOutAxis', defaultValue = 3) if frame: _frame = mUI.MelFrameLayout(parent,label = 'Obj Defaults',vis=True, collapse=self.var_objectDefaultsFrameCollapse.value, collapsable=True, enable=True, useTemplate = 'cgmUIHeaderTemplate', expandCommand = lambda:self.var_objectDefaultsFrameCollapse.setValue(0), collapseCommand = lambda:self.var_objectDefaultsFrameCollapse.setValue(1) ) _inside = mUI.MelColumnLayout(_frame,useTemplate = 'cgmUISubTemplate') else: _inside = parent #>>>Aim defaults mode ------------------------------------------------------------------------------------- _d = {'aim':self.var_objDefaultAimAxis, 'up':self.var_objDefaultUpAxis, 'out':self.var_objDefaultOutAxis} for k in _d.keys(): _var = _d[k] _row = mUI.MelHSingleStretchLayout(_inside,ut='cgmUISubTemplate',padding = 5) mUI.MelSpacer(_row,w=5) mUI.MelLabel(_row,l='Obj {0}:'.format(k)) _row.setStretchWidget( mUI.MelSeparator(_row) ) uiRC = mUI.MelRadioCollection() _on = _var.value for i,item in enumerate(SHARED._l_axis_by_string): if i == _on: _rb = True else:_rb = False uiRC.createButton(_row,label=item,sl=_rb, onCommand = cgmGEN.Callback(_var.setValue,i)) mUI.MelSpacer(_row,w=2) _row.layout() #>>>Buttons ------------------------------------------------------------------------------------- _row_defaults = mUI.MelHLayout(_inside,ut='cgmUISubTemplate',padding = 5, ) cgmUI.add_Button(_row_defaults,'Tag selected for aim', lambda *a:MMCONTEXT.func_process(SNAP.verify_aimAttrs, mc.ls(sl=True),'each','Verify aim attributes',True,**{}),) _row_defaults.layout()
def uiBuilderMenu(self,parent = None): _short = self.p_nameShort mc.menuItem(en=False, label = "Master") mc.menuItem(ann = '[{0}] Recreate the base shape and push values to baseSize attr'.format(_short), c = cgmGEN.Callback(resize_masterShape,self,**{'resize':1}), label = "Resize")
def buildMenu_utils(self, mMenu): mUI.MelMenuItemDiv(mMenu, label='Maya Settings..') for a in 'inTangent', 'outTangent', 'both': if a == 'inTangent': fnc = MAYASET.defaultInTangent_set _current = MAYASET.defaultInTangent_get() elif a == 'outTangent': fnc = MAYASET.defaultOutTangent_set _current = MAYASET.defaultOutTangent_get() else: fnc = MAYASET.defaultTangents_set _current = MAYASET.defaultOutTangent_get() _sub = mUI.MelMenuItem(mMenu, l=a, subMenu=True) for t in PU._tangents: if t == _current: _l = "{0}(current)".format(t) else: _l = t mUI.MelMenuItem(_sub, l=_l, c=cgmGEN.Callback(fnc, t)) mUI.MelMenuItemDiv(mMenu, label='Global Settings..') mUI.MelMenuItem(mMenu, l="World Match", c=lambda *a: fncMayaSett_do(self, True, False)) mUI.MelMenuItem(mMenu, l="Anim Match", c=lambda *a: fncMayaSett_do(self, False, True)) mUI.MelMenuItem(mMenu, l="All Match", c=lambda *a: fncMayaSett_do(self, True, True)) #mUI.MelMenuItemDiv( mMenu,) mUI.MelMenuItem(mMenu, l="Query", c=lambda *a: fncMayaSett_query(self)) mUI.MelMenuItemDiv(mMenu) #DropBox... _fileTrash = mUI.MelMenuItem(mMenu, l='File Trash', subMenu=True) mUI.MelMenuItem(_fileTrash, label='Query', ut='cgmUITemplate', c=lambda *a: find_tmpFiles(self.directory), ann='Query trash files') mUI.MelMenuItem(_fileTrash, label='Clean', ut='cgmUITemplate', c=lambda *a: find_tmpFiles(self.directory, cleanFiles=1), ann='Clean trash files')
def uiBuilderMenu(self, parent=None): uiMenu = mc.menuItem(parent=parent, l='Master:', subMenu=True) _short = self.p_nameShort mc.menuItem( uiMenu, ann='[{0}] Recreate the base shape and push values to baseSize attr'. format(_short), c=cgmGEN.Callback(resize_masterShape, self), label="Resize")
def buildRow_vector(self, parent, label='translate', tweak=True): #>>>Vector ------------------------------------------------------------------------------------- _row = mUI.MelHSingleStretchLayout(parent, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=5) mUI.MelLabel(_row, l=label + ':') _row.setStretchWidget(mUI.MelSeparator(_row)) _base_str = 'uiff_{0}'.format(label) self._d_transformAttrFields[label] = {} self._d_transformRows[label] = _row self._d_transformCBs[label] = mUI.MelCheckBox( _row, en=tweak, ann='Tweak the {0} value with relative buttons above'.format(label)) for a in list('xyz'): mUI.MelLabel(_row, l=a) _field = mUI.MelFloatField(_row, ut='cgmUISubTemplate', w=60) self.__dict__['{0}{1}'.format(_base_str, a.capitalize())] = _field self._d_transformAttrFields[label][a.capitalize()] = _field mc.button( parent=_row, ut='cgmUITemplate', l='>', c=cgmGEN.Callback(uiFunc_valuesSend, self, label, a.capitalize()), #c = lambda *a:uiFunc_valuesSend(self,label,a), #c = lambda *a:TOOLBOX.uiFunc_vectorMeasureToField(self), ann="Send to targets") mc.button( parent=_row, ut='cgmUITemplate', l='>>>', c=cgmGEN.Callback(uiFunc_valuesSend, self, label, None), #c = lambda *a:TOOLBOX.uiFunc_vectorMeasureToField(self), ann="Measures vector between selected objects/components") mUI.MelSpacer(_row, w=5) _row.layout()
def buildScrollForm(self, parent, hasHeader = False, buttonArgs = [], headerText = 'Header', allowMultiSelection=True, buttonCommand=None, doubleClickCommand=None, selectCommand=None): main_form = mUI.MelFormLayout(parent,ut='cgmUITemplate') header = None if(hasHeader): header = cgmUI.add_Header(headerText, overrideUpper = True) scroll_list = mUI.MelObjectScrollList( main_form, ut='cgmUITemplate', allowMultiSelection=allowMultiSelection, doubleClickCommand=cgmGEN.Callback(doubleClickCommand,self), selectCommand=cgmGEN.Callback(selectCommand,self) ) buttonLayout = None buttons = [] hasButton = len(buttonArgs) > 0 if(hasButton): #buttonLayout = mUI.MelColumnLayout(main_form,useTemplate = 'cgmUISubTemplate') buttonLayout = mUI.MelHLayout(main_form,ut='cgmUISubTemplate',padding = 1,bgc=_subLineBGC) for btn in buttonArgs: button = cgmUI.add_Button(buttonLayout,btn['label'], cgmGEN.Callback(btn['command'],self), btn['annotation'], bgc=_buttonBGC) buttons.append(button) buttonLayout.layout() af = [(scroll_list,"left",0), (scroll_list,"right",0)] ac = [] attachNone = [] if(hasHeader): af += [ (header,"top",0), (header,"left",0), (header,"right",0) ] ac += [(scroll_list,"top",0,header)] attachNone += [(header,"bottom")] else: af += [ (scroll_list,"top",0) ] if(hasButton): af += [ (buttonLayout,"bottom",0), (buttonLayout,"left",0), (buttonLayout,"right",0)] ac += [(scroll_list,"bottom",0,buttonLayout)] attachNone += [(buttonLayout,"top")] else: af += [ (scroll_list,"bottom",0) ] main_form(edit=True, af = af, ac = ac, attachNone = attachNone) return [main_form, scroll_list, header, buttons]
def uiUpdate_commits(self): self.uiScroll_commits.clear() #_d_ui_annotations = {} _sidePadding = 25 _parent = self.uiScroll_commits _branch = self.var_branchMode.value _dat = cgmUpdate.get_dat(_branch, _commit_limit, True) uiRC = mUI.MelRadioCollection() self.uiRC_commits = uiRC self.dat_commits = _dat for i, d in enumerate(_dat): _hash = d['hash'] _msg = d['msg'] _date = d['date'] _url = d['url'] _ann = '\n {0} commit {1} | {2} | {3} \n {4} \n {5}'.format( _branch, i, _hash, _date, _msg, _url) _report = '{0} | {1}'.format(_hash, _msg[:50]) _label = "{0} - {1} | {3}...".format(i, _date, _hash[:8], _msg[:40]) #log.debug(_report) #cgmUI.mUI.MelLabel(_parent, l = _msg, # annotation = d['msg']) #mc.separator(parent = _parent, height = 5, #ut='cgmUISubTemplate' # ) cgmUI.mUI.MelSpacer(_parent, h=5) uiRC.createButton( _parent, label=_label, annotation=_ann, onCommand=cgmGEN.Callback(log.info, _ann), #ut='cgmUIHeader', #onCommand = lambda*a:(log.info("{0} | {1} | {2}".format(uiRC.getSelectedIndex(), _branch, self.dat_commits[uiRC.getSelectedIndex()]['hash']))) #sl=_rb, #onCommand = cgmGEN.Callback(_var.setValue,i) ) mc.setParent(_parent) cgmUI.add_LineSubBreak()
def uiFunc_build_post_process_column(self, parentColumn): mc.setParent(parentColumn) cgmUI.add_LineSubBreak() # Post Process Action # _row = mUI.MelHSingleStretchLayout(parentColumn, ut='cgmUISubTemplate', padding=5) self._post_row_aimDirection = _row mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Action:') _row.setStretchWidget(mUI.MelSeparator(_row)) actions = ['Dragger', 'Spring', 'Trajectory Aim', 'Keys to Motion Curve'] self.post_actionMenu = mUI.MelOptionMenu(_row, useTemplate='cgmUITemplate', changeCommand=cgmGEN.Callback( uiFunc_setPostAction, self)) for dir in actions: self.post_actionMenu.append(dir) self.post_actionMenu.setValue(actions[0]) mUI.MelSpacer(_row, w=_padding) _row.layout() # # End Post Process Action # Post Process Options Frame # self._postProcessOptionsColumn = mUI.MelColumnLayout( parentColumn, useTemplate='cgmUISubTemplate') # # Post Process Options Frame uiFunc_setPostAction(self)
def uiPopup_createRayCast(self): if self.uiPopUpMenu_raycastCreate: self.uiPopUpMenu_raycastCreate.clear() self.uiPopUpMenu_raycastCreate.delete() self.uiPopUpMenu_raycastCreate = None self.uiPopUpMenu_raycastCreate = mUI.MelPopupMenu( self.uiField_rayCastCreate, button=1) _popUp = self.uiPopUpMenu_raycastCreate mUI.MelMenuItem(_popUp, label="Set Create Type", en=False) mUI.MelMenuItemDiv(_popUp) for m in [ 'locator', 'joint', 'jointChain', 'curve', 'duplicate', 'vectorLine', 'data' ]: mUI.MelMenuItem(_popUp, label=m, ann="Create {0} by rayCasting".format(m), c=cgmGEN.Callback(self.cb_setRayCastCreate, m))
def buildColumn_main(self,parent, asScroll = False): """ Trying to put all this in here so it's insertable in other uis """ if asScroll: _inside = mUI.MelScrollLayout(parent,useTemplate = 'cgmUISubTemplate') else: _inside = mUI.MelColumnLayout(parent,useTemplate = 'cgmUISubTemplate') #>>>Objects Load Row --------------------------------------------------------------------------------------- _row_objLoad = mUI.MelHSingleStretchLayout(_inside,ut='cgmUITemplate',padding = 5) mUI.MelSpacer(_row_objLoad,w=10) mUI.MelLabel(_row_objLoad, l='Source:') uiTF_objLoad = mUI.MelLabel(_row_objLoad,ut='cgmUITemplate',l='', en=True) self.uiTF_objLoad = uiTF_objLoad cgmUI.add_Button(_row_objLoad,'<<', cgmGEN.Callback(uiFunc_load_selected,self), "Load first selected object.") _row_objLoad.setStretchWidget(uiTF_objLoad) mUI.MelSpacer(_row_objLoad,w=10) """ _row_objLoad.layout() #>>>Report --------------------------------------------------------------------------------------- _row_report = mUI.MelHLayout(_inside ,ut='cgmUIInstructionsTemplate',h=20) self.uiField_report = mUI.MelLabel(_row_report, bgc = SHARED._d_gui_state_colors.get('help'), label = '...', h=20) _row_report.layout() """ _row_objLoad.layout() uiFunc_load_selected(self) return _inside
def build_menus(self): self.uiMenu_FirstMenu = mUI.MelMenu(l='Setup', pmc=cgmGEN.Callback( self.buildMenu_first))
def uiFunc_update_details(self): if not self._mDynFK: return self.detailsFrame.clear() dat = self._mDynFK.get_dat() self.detailsFrame(edit=True, collapse=False) _details = mUI.MelColumnLayout(self.detailsFrame, useTemplate='cgmUIHeaderTemplate') cgmUI.add_LineSubBreak() # Base Name uiFunc_make_display_line(_details, label='Base Name:', text=self._mDynFK.baseName, button=False) # Direction Info _row = mUI.MelHSingleStretchLayout(_details, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l="Direction:") _row.setStretchWidget(mUI.MelSeparator(_row)) mUI.MelLabel(_row, l="Fwd:") uiTF = mUI.MelLabel(_row, ut='cgmUISubTemplate', l=self._mDynFK.fwd, en=True) mUI.MelLabel(_row, l="Up:") uiTF = mUI.MelLabel(_row, ut='cgmUISubTemplate', l=self._mDynFK.up, en=True) mUI.MelSpacer(_row, w=10) _row.layout() # Nucleus uiFunc_make_display_line(_details, label='Nucleus:', text=self._mDynFK.mNucleus[0], button=True, buttonLabel=">>", buttonCommand=cgmGEN.Callback( uiFunc_select_item, self._mDynFK.mNucleus[0]), buttonInfo="Select nucleus transform.", presetOptions=True, presetObj=self._mDynFK.mNucleus[0]) uiFunc_make_display_line(_details, label='Hair System:', text=dat['mHairSysShape'].p_nameBase, button=True, buttonLabel=">>", buttonCommand=cgmGEN.Callback( uiFunc_select_item, dat['mHairSysShape'].p_nameBase), buttonInfo="Select hair system transform.", presetOptions=True, presetObj=dat['mHairSysShape'].p_nameBase) _row = mUI.MelHSingleStretchLayout(_details, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Enabled:') _row.setStretchWidget(mUI.MelSeparator(_row)) self.nucleusEnabledCB = mUI.MelCheckBox(_row, en=True, v=True, label='', ann='Enable Nucleus') self.nucleusEnabledCB(edit=True, changeCommand=cgmGEN.Callback( uiFunc_set_nucleus_enabled, self)) mUI.MelSpacer(_row, w=_padding) _row.layout() # Start Times _row = mUI.MelHSingleStretchLayout(_details, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Start Time:') _row.setStretchWidget(mUI.MelSeparator(_row)) self.startTimeIF = mUI.MelIntField(_row, v=dat['mNucleus'].startFrame) self.startTimeIF(edit=True, changeCommand=cgmGEN.Callback(uiFunc_set_start_time, self, mode='refresh')) cgmUI.add_Button( _row, '<<', cgmGEN.Callback(uiFunc_set_start_time, self, mode='beginning'), "Set Start To Beginning of Slider.") mUI.MelSpacer(_row, w=_padding) _row.layout() # TimeInput Row ---------------------------------------------------------------------------------- _row = mUI.MelHSingleStretchLayout(_details, ut='cgmUISubTemplate') mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Bake Time:') _row.setStretchWidget(mUI.MelSeparator(_row)) mUI.MelLabel(_row, l='Start:') self.uiFieldInt_start = mUI.MelIntField(_row, 'cgmLocWinStartFrameField', width=40) mUI.MelLabel(_row, l='End:') self.uiFieldInt_end = mUI.MelIntField(_row, 'cgmLocWinEndFrameField', width=40) cgmUI.add_Button(_row, '<<', cgmGEN.Callback(uiFunc_updateTimeRange, self, 'min'), "Set Start To Beginning of Slider.") cgmUI.add_Button(_row, '[ ]', cgmGEN.Callback(uiFunc_updateTimeRange, self, 'slider'), "Set Time to Slider.") cgmUI.add_Button(_row, '>>', cgmGEN.Callback(uiFunc_updateTimeRange, self, 'max'), "Set End To End of Slider.") uiFunc_updateTimeRange(self, mode='slider') mUI.MelSpacer(_row, w=_padding) _row.layout() mc.setParent(_details) cgmUI.add_LineSubBreak() allChains = [] for idx in dat['chains']: allChains += dat['chains'][idx]['mObjJointChain'] allTargets = [] for idx in dat['chains']: allTargets += dat['chains'][idx]['mTargets'] _row = mUI.MelHLayout(_details, ut='cgmUISubTemplate', padding=_padding * 2) cgmUI.add_Button( _row, 'Bake All Joints', cgmGEN.Callback(uiFunc_bake, self, 'chain', allChains), #lambda *a: attrToolsLib.doAddAttributesToSelected(self), 'Bake All Joints') cgmUI.add_Button(_row, 'Bake All Targets', cgmGEN.Callback(uiFunc_bake, self, 'target', allTargets), 'Bake All Targets') _row.layout() _row = mUI.MelHLayout(_details, ut='cgmUISubTemplate', padding=_padding * 2) cgmUI.add_Button( _row, 'Connect All Targets', cgmGEN.Callback(uiFunc_connect_targets, self), #lambda *a: attrToolsLib.doAddAttributesToSelected(self), 'Connect All Targets') cgmUI.add_Button(_row, 'Disconnect All Targets', cgmGEN.Callback(uiFunc_disconnect_targets, self), 'Disconnect All Targets') _row.layout() # Chains for i, chain in enumerate(self._mDynFK.msgList_get('chain')): _row = mUI.MelHSingleStretchLayout(_details, ut='cgmUISubTemplate', padding=_padding) mUI.MelSpacer(_row, w=_padding) _subChainColumn = mUI.MelColumnLayout( _row, useTemplate='cgmUIHeaderTemplate') chainFrame = mUI.MelFrameLayout(_subChainColumn, label=chain.p_nameBase, collapsable=True, collapse=True, useTemplate='cgmUIHeaderTemplate') _chainColumn = mUI.MelColumnLayout(chainFrame, useTemplate='cgmUIHeaderTemplate') _row.setStretchWidget(_subChainColumn) #mUI.MelSpacer(_row,w=_padding) _row.layout() mc.setParent(_chainColumn) cgmUI.add_LineSubBreak() uiFunc_make_display_line( _chainColumn, label='Follicle:', text=cgmMeta.asMeta(chain.mFollicle[0]).p_nameBase, button=True, buttonLabel=">>", buttonCommand=cgmGEN.Callback(uiFunc_select_item, chain.mFollicle[0]), buttonInfo="Select follicle transform.", presetOptions=True, presetObj=chain.mFollicle[0]) mc.setParent(_chainColumn) cgmUI.add_LineSubBreak() uiFunc_make_display_line(_chainColumn, label='Group:', text=chain.p_nameShort, button=True, buttonLabel=">>", buttonCommand=cgmGEN.Callback( uiFunc_select_item, chain.p_nameBase), buttonInfo="Select group transform.") mc.setParent(_chainColumn) cgmUI.add_LineSubBreak() _row = mUI.MelHSingleStretchLayout(_chainColumn, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Orient Up:') _row.setStretchWidget(mUI.MelSeparator(_row)) chainDirections = [] for dir in ['x+', 'x-', 'y+', 'y-', 'z+', 'z-']: if chain.fwd[0] != dir[0]: chainDirections.append(dir) chainDirections.append('None') upMenu = mUI.MelOptionMenu(_row, useTemplate='cgmUITemplate') for dir in chainDirections: upMenu.append(dir) upMenu.setValue(chain.up) upMenu(edit=True, changeCommand=cgmGEN.Callback(uiFunc_set_chain_up, self, i, upMenu)) mUI.MelSpacer(_row, w=_padding) _row.layout() _row = mUI.MelHLayout(_chainColumn, ut='cgmUISubTemplate', padding=_padding * 2) cgmUI.add_Button( _row, 'Bake Joints', cgmGEN.Callback(uiFunc_bake, self, 'chain', chain.msgList_get('mObjJointChain')), #lambda *a: attrToolsLib.doAddAttributesToSelected(self), 'Bake All Joints') cgmUI.add_Button( _row, 'Bake Targets', cgmGEN.Callback(uiFunc_bake, self, 'target', chain.msgList_get('mTargets')), 'Bake All Targets') _row.layout() _row = mUI.MelHLayout(_chainColumn, ut='cgmUISubTemplate', padding=_padding * 2) cgmUI.add_Button( _row, 'Connect Targets', cgmGEN.Callback(uiFunc_connect_targets, self, i), #lambda *a: attrToolsLib.doAddAttributesToSelected(self), 'Connect All Targets') cgmUI.add_Button(_row, 'Disconnect Targets', cgmGEN.Callback(uiFunc_disconnect_targets, self, i), 'Disconnect All Targets') _row.layout() _row = mUI.MelHLayout(_chainColumn, ut='cgmUISubTemplate', padding=_padding * 2) cgmUI.add_Button( _row, 'Delete Chain', cgmGEN.Callback(uiFunc_delete_chain, self, i), #lambda *a: attrToolsLib.doAddAttributesToSelected(self), 'Bake All Joints') _row.layout() frameDat = [['Targets', 'mTargets'], ['Locators', 'mLocs'], ['Joint Chain', 'mObjJointChain'], ['Aims', 'mAims'], ['Parents', 'mParents']] for dat in frameDat: frame = mUI.MelFrameLayout(_chainColumn, label=dat[0], collapsable=True, collapse=True, useTemplate='cgmUIHeaderTemplate') column = mUI.MelColumnLayout(frame, useTemplate='cgmUITemplate', height=75) row = mUI.MelHSingleStretchLayout(column, ut='cgmUIHeaderTemplate', padding=_padding) mUI.MelSpacer(row, w=_padding) itemList = uiFunc_create_selection_list( row, [x.p_nameShort for x in chain.msgList_get(dat[1])]) mUI.MelSpacer(row, w=_padding) row.setStretchWidget(itemList) row.layout() # End Chains mc.setParent(_details) cgmUI.add_LineSubBreak()
def buildColumn_main(self, parent, asScroll=False): """ Trying to put all this in here so it's insertable in other uis """ if asScroll: _inside = mUI.MelScrollLayout(parent, useTemplate='cgmUIHeaderTemplate') else: _inside = mUI.MelColumnLayout(parent, useTemplate='cgmUIHeaderTemplate') #>>>Objects Load Row --------------------------------------------------------------------------------------- mUI.MelSeparator(_inside, ut='cgmUISubTemplate', h=3) _row = mUI.MelHSingleStretchLayout(_inside, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Dynamic Chain System:') uiTF_objLoad = mUI.MelLabel(_row, ut='cgmUIInstructionsTemplate', l='', en=True) self.uiTF_objLoad = uiTF_objLoad cgmUI.add_Button(_row, '<<', cgmGEN.Callback(uiFunc_load_selected, self), "Load first selected object.") _row.setStretchWidget(uiTF_objLoad) mUI.MelSpacer(_row, w=_padding) _row.layout() mc.setParent(_inside) cgmUI.add_LineSubBreak() self.detailsFrame = mUI.MelFrameLayout(_inside, label="Details", collapsable=True, collapse=True, useTemplate='cgmUIHeaderTemplate') uiFunc_update_details(self) # Create Frame self.createFrame = mUI.MelFrameLayout(_inside, label="Create", collapsable=True, collapse=False, useTemplate='cgmUIHeaderTemplate') _create = mUI.MelColumnLayout(self.createFrame, useTemplate='cgmUIHeaderTemplate') cgmUI.add_LineSubBreak() _row = mUI.MelHSingleStretchLayout(_create, ut='cgmUISubTemplate', padding=_padding) mUI.MelSpacer(_row, w=_padding) _subRow = mUI.MelColumnLayout(_row, useTemplate='cgmUIHeaderTemplate') self.itemList = cgmUI.cgmScrollList(_subRow, numberOfRows=8, height=100) self.itemList(edit=True, allowMultiSelection=True) mUI.MelSpacer(_row, w=_padding) _row.setStretchWidget(_subRow) _row.layout() mUI.MelSeparator(_create, ut='cgmUISubTemplate', h=5) _row = mUI.MelHSingleStretchLayout(_create, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) addBtn = cgmUI.add_Button( _row, 'Add Selected', cgmGEN.Callback(uiFunc_list_function, self.itemList, 'add selected'), "Load selected objects.") cgmUI.add_Button( _row, 'Remove Selected', cgmGEN.Callback(uiFunc_list_function, self.itemList, 'remove selected'), "Remove selected objects.") cgmUI.add_Button( _row, 'Clear', cgmGEN.Callback(uiFunc_list_function, self.itemList, 'clear'), "Clear all objects.") _row.setStretchWidget(addBtn) mUI.MelSpacer(_row, w=_padding) _row.layout() cgmUI.add_LineSubBreak() _row = mUI.MelHSingleStretchLayout(_create, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) _row.setStretchWidget( cgmUI.add_Button(_row, 'Make Dynamic Chain', cgmGEN.Callback(uiFunc_make_dynamic_chain, self), "Make Dynamic Chain.")) mUI.MelSpacer(_row, w=_padding) _row.layout() cgmUI.add_LineSubBreak() self.optionsFrame = mUI.MelFrameLayout(_create, label="Options", collapsable=True, collapse=True, useTemplate='cgmUIHeaderTemplate') _options = mUI.MelColumnLayout(self.optionsFrame, useTemplate='cgmUISubTemplate') mUI.MelSeparator(_options, ut='cgmUISubTemplate', h=5) _row = mUI.MelHSingleStretchLayout(_options, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Base Name: ') self.options_baseName = mUI.MelTextField(_row, ann='Name', text='DynamicChain') _row.setStretchWidget(self.options_baseName) mUI.MelSpacer(_row, w=_padding) _row.layout() _row = mUI.MelHSingleStretchLayout(_options, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Name: ') self.options_name = mUI.MelTextField(_row, ann='Name', text='') _row.setStretchWidget(self.options_name) mUI.MelSpacer(_row, w=_padding) _row.layout() mUI.MelSeparator(_options, ut='cgmUISubTemplate', h=5) _row = mUI.MelHSingleStretchLayout(_options, ut='cgmUISubTemplate', padding=5) mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Direction:') _row.setStretchWidget(mUI.MelSeparator(_row)) directions = ['x+', 'x-', 'y+', 'y-', 'z+', 'z-'] mUI.MelLabel(_row, l='Fwd:') self.fwdMenu = mUI.MelOptionMenu(_row, useTemplate='cgmUITemplate') for dir in directions: self.fwdMenu.append(dir) self.fwdMenu.setValue('z+') mUI.MelSpacer(_row, w=_padding) mUI.MelLabel(_row, l='Up:') self.upMenu = mUI.MelOptionMenu(_row, useTemplate='cgmUITemplate') for dir in directions: self.upMenu.append(dir) self.upMenu.setValue('y+') mUI.MelSpacer(_row, w=_padding) _row.layout() """ _row.layout() #>>>Report --------------------------------------------------------------------------------------- _row_report = mUI.MelHLayout(_inside ,ut='cgmUIInstructionsTemplate',h=20) self.uiField_report = mUI.MelLabel(_row_report, bgc = SHARED._d_gui_state_colors.get('help'), label = '...', h=20) _row_report.layout() """ return _inside