def setupUi(self, parent): layout = QtWidgets.QVBoxLayout(self) propertiesHeader = createHeaderLabel(parent, "Rig Properties") layout.addWidget(propertiesHeader) rigNameLabel = QtWidgets.QLabel(parent) rigNameLabel.setText("Rig Name") self.rigNameText = QtWidgets.QLineEdit(parent) self.rigNameText.setText(self.blueprintModel.getRigName()) self.rigNameText.textChanged.connect(self.rigNameTextChanged) formLayout1 = QtWidgets.QFormLayout(parent) formLayout1.setWidget(0, QtWidgets.QFormLayout.LabelRole, rigNameLabel) formLayout1.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.rigNameText) layout.addLayout(formLayout1) fileNameLabel = QtWidgets.QLabel(parent) fileNameLabel.setText("File Name") self.fileNameText = QtWidgets.QLineEdit(parent) self.fileNameText.setText(self.getSceneRelativeFilePath(self.blueprintModel.getBlueprintFilepath())) self.fileNameText.setReadOnly(True) formLayout2 = QtWidgets.QFormLayout(parent) formLayout2.setWidget(0, QtWidgets.QFormLayout.LabelRole, fileNameLabel) formLayout2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.fileNameText) layout.addLayout(formLayout2) spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout.addItem(spacer) self.refreshState()
def setupUi(self, parent): layout = QtWidgets.QVBoxLayout(parent) layout.setMargin(4) self.frame = QtWidgets.QFrame(parent) self.frame.setObjectName("panelFrame") layout.addWidget(self.frame) hlayout = QtWidgets.QHBoxLayout(self.frame) labelLayout = QtWidgets.QVBoxLayout(parent) hlayout.addLayout(labelLayout) font = QtGui.QFont() font.setPointSize(10) font.setWeight(75) font.setBold(True) self.rigNameLabel = QtWidgets.QLabel(parent) self.rigNameLabel.setFont(font) self.rigNameLabel.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.rigNameLabel.setText( self.getRigNameText(self.blueprintModel.getRigName())) labelLayout.addWidget(self.rigNameLabel) font = QtGui.QFont() font.setItalic(True) self.rigOrBlueprintLabel = QtWidgets.QLabel(parent) self.rigOrBlueprintLabel.setFont(font) labelLayout.addWidget(self.rigOrBlueprintLabel) self.checkBtn = QtWidgets.QPushButton(parent) self.checkBtn.setText("Validate") self.checkBtn.setMaximumWidth(80) self.checkBtn.clicked.connect(self.runValidation) hlayout.addWidget(self.checkBtn) self.buildBtn = QtWidgets.QPushButton(parent) self.buildBtn.setText("Build") self.buildBtn.setMaximumWidth(80) self.buildBtn.clicked.connect(self.runBuild) hlayout.addWidget(self.buildBtn) self.openBPBtn = QtWidgets.QPushButton(parent) self.openBPBtn.setText("Open Blueprint") self.openBPBtn.clicked.connect(self.openBlueprintAndReload) hlayout.addWidget(self.openBPBtn) self.cleanState()
def setupUi(self, parent): layout = QtWidgets.QVBoxLayout(self) formLayout1 = QtWidgets.QFormLayout(self) rigNameLabel = QtWidgets.QLabel(self) rigNameLabel.setText("Rig Name") self.rigNameText = QtWidgets.QLineEdit(self) self.rigNameText.setText(self.blueprintModel.getRigName()) self.rigNameText.textChanged.connect(self.rigNameTextChanged) formLayout1.setWidget(0, QtWidgets.QFormLayout.LabelRole, rigNameLabel) formLayout1.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.rigNameText) layout.addLayout(formLayout1) initBtn = QtWidgets.QPushButton(self) initBtn.setText("Initialize Blueprint") initBtn.clicked.connect(self.initBlueprint) layout.addWidget(initBtn) debugPrintBtn = QtWidgets.QPushButton(self) debugPrintBtn.setText("Debug Print YAML") debugPrintBtn.clicked.connect(self.debugPrintSerialized) layout.addWidget(debugPrintBtn) spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout.addItem(spacer) self.refreshState()
def setupDefaultFormUi(self, parent): """ Optional UI setup that builds a standardized layout. Includes a form layout and a label with the attributes name. Should be called at the start of setupUi if desired. """ self.formLayout = QtWidgets.QFormLayout(parent) # margin that will give us some visible area of # the frame that can change color based on valid state self.formLayout.setMargin(2) self.formLayout.setFieldGrowthPolicy( QtWidgets.QFormLayout.ExpandingFieldsGrow) self.formLayout.setLabelAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTop | QtCore.Qt.AlignTrailing) self.formLayout.setHorizontalSpacing(10) # attribute name self.labelLayout = QtWidgets.QHBoxLayout(parent) self.label = QtWidgets.QLabel(parent) self.label.setMinimumSize( QtCore.QSize(self.LABEL_WIDTH, self.LABEL_HEIGHT)) self.label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignTop) # add some space above the label so it lines up self.label.setMargin(2) self.label.setText(pulse.names.toTitle(self.attr['name'])) self.labelLayout.addWidget(self.label) self.formLayout.setLayout(0, QtWidgets.QFormLayout.LabelRole, self.labelLayout)
def setupVariantsUi(self, parent, layout): # variant header variantHeader = QtWidgets.QFrame(parent) variantHeader.setStyleSheet( ".QFrame{ background-color: rgb(255, 255, 255, 15); border-radius: 2px }" ) layout.addWidget(variantHeader) variantHeaderLayout = QtWidgets.QHBoxLayout(variantHeader) variantHeaderLayout.setContentsMargins(10, 4, 4, 4) variantHeaderLayout.setSpacing(4) self.variantsLabel = QtWidgets.QLabel(variantHeader) self.variantsLabel.setText("Variants: ") variantHeaderLayout.addWidget(self.variantsLabel) spacer = QtWidgets.QSpacerItem(20, 4, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) layout.addItem(spacer) # add variant button addVariantBtn = QtWidgets.QPushButton(variantHeader) addVariantBtn.setText('+') addVariantBtn.setFixedSize(QtCore.QSize(20, 20)) addVariantBtn.clicked.connect(self.addVariant) variantHeaderLayout.addWidget(addVariantBtn) # variant list layout self.variantListLayout = QtWidgets.QVBoxLayout(parent) self.variantListLayout.setContentsMargins(0, 0, 0, 0) self.variantListLayout.setSpacing(4) layout.addLayout(self.variantListLayout)
def setupUi(self, parent): """ Build a collapsible panel ui that can be used by all design panels. All panel widgets should be attached to `self.panelWidget` """ self.mainLayout = QtWidgets.QVBoxLayout(parent) self.mainLayout.setMargin(0) self.mainLayout.setSpacing(2) # header frame self.headerFrame = CollapsibleFrame(parent) headerColor = 'rgba({0}, {1}, {2}, 40)'.format(*self.getPanelColor()) self.headerFrame.setStyleSheet(".CollapsibleFrame{{ background-color: {color}; border-radius: 2px; }}".format(color=headerColor)) self.headerFrame.collapsedChanged.connect(self.onCollapsedChanged) # header layout self.headerLayout = QtWidgets.QHBoxLayout(self.headerFrame) self.headerLayout.setContentsMargins(10, 2, 2, 2) # display name label font = QtGui.QFont() font.setWeight(75) font.setBold(True) self.displayNameLabel = QtWidgets.QLabel(self.headerFrame) self.displayNameLabel.setMinimumHeight(18) self.displayNameLabel.setFont(font) self.displayNameLabel.setText(self.getPanelDisplayName()) self.headerLayout.addWidget(self.displayNameLabel) self.mainLayout.addWidget(self.headerFrame) self.panelWidget = QtWidgets.QWidget(parent) self.mainLayout.addWidget(self.panelWidget)
def createLabel(self, parent, text): label = QtWidgets.QLabel(parent) label.setText(text) label.setMinimumHeight(20) label.setContentsMargins(10, 2, 2, 2) label.setStyleSheet( 'background-color: rgba(0, 0, 0, 40); border-radius: 2px') return label
def createHeaderLabel(parent, text): font = QtGui.QFont() font.setWeight(75) font.setBold(True) label = QtWidgets.QLabel(parent) label.setText(text) label.setMinimumHeight(20) label.setContentsMargins(10, 2, 2, 2) label.setFont(font) label.setStyleSheet( 'background-color: rgba(0, 0, 0, 40); border-radius: 2px') return label
def setupVariantsUi(self, parent): viewutils.clearLayout(self.variantLayout) self.variantsLabel.setText("Variants: {0}".format( len(self.buildItem.variantValues))) for i, variant in enumerate(self.buildItem.variantValues): if i > 0: # divider line dividerLine = QtWidgets.QFrame(parent) dividerLine.setStyleSheet( ".QFrame{ background-color: rgb(0, 0, 0, 15); border-radius: 2px }" ) dividerLine.setMinimumHeight(2) self.variantLayout.addWidget(dividerLine) variantHLayout = QtWidgets.QHBoxLayout(parent) # remove variant button removeVariantBtn = QtWidgets.QPushButton(parent) removeVariantBtn.setText('x') removeVariantBtn.setFixedSize(QtCore.QSize(20, 20)) removeVariantBtn.clicked.connect( partial(self.removeVariantAtIndex, i)) variantHLayout.addWidget(removeVariantBtn) # create attr form for all variant attributes variantVLayout = QtWidgets.QVBoxLayout(parent) variantVLayout.setSpacing(0) variantHLayout.addLayout(variantVLayout) if self.buildItem.variantAttributes: for attr in self.buildItem.actionClass.config['attrs']: if attr['name'] not in self.buildItem.variantAttributes: continue attrValue = variant[attr['name']] # context = variant attrForm = ActionAttrForm.createForm(attr, attrValue, parent=parent) attrForm.valueChanged.connect( partial(self.attrValueChanged, variant, attrForm)) variantVLayout.addWidget(attrForm) else: noAttrsLabel = QtWidgets.QLabel(parent) noAttrsLabel.setText("No variant attributes") noAttrsLabel.setMinimumHeight(24) noAttrsLabel.setContentsMargins(10, 0, 0, 0) noAttrsLabel.setEnabled(False) variantVLayout.addWidget(noAttrsLabel) self.variantLayout.addLayout(variantHLayout)
def setupContentUi(self, parent): """ Build the content ui for this BatchBuildAction. Creates ui to manage the array of variant attributes. """ # constants main layout self.constantsLayout = QtWidgets.QVBoxLayout(parent) self.constantsLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addLayout(self.constantsLayout) spacer = QtWidgets.QSpacerItem(20, 4, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.mainLayout.addItem(spacer) # variant header variantHeader = QtWidgets.QFrame(parent) variantHeader.setStyleSheet( ".QFrame{ background-color: rgb(255, 255, 255, 15); border-radius: 2px }" ) self.mainLayout.addWidget(variantHeader) variantHeaderLayout = QtWidgets.QHBoxLayout(variantHeader) variantHeaderLayout.setContentsMargins(10, 4, 4, 4) variantHeaderLayout.setSpacing(4) self.variantsLabel = QtWidgets.QLabel(variantHeader) self.variantsLabel.setText("Variants: {0}".format( len(self.buildItem.variantValues))) variantHeaderLayout.addWidget(self.variantsLabel) spacer = QtWidgets.QSpacerItem(20, 4, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.mainLayout.addItem(spacer) # add variant button addVariantBtn = QtWidgets.QPushButton(variantHeader) addVariantBtn.setText('+') addVariantBtn.setFixedSize(QtCore.QSize(20, 20)) addVariantBtn.clicked.connect(self.addVariant) variantHeaderLayout.addWidget(addVariantBtn) # variant list main layout self.variantLayout = QtWidgets.QVBoxLayout(parent) self.variantLayout.setContentsMargins(0, 0, 0, 0) self.variantLayout.setSpacing(4) self.mainLayout.addLayout(self.variantLayout) self.setupConstantsUi(parent) self.setupVariantsUi(parent)
def setupHeaderUi(self, parent): step = self.step() layout = QtWidgets.QHBoxLayout(parent) layout.setContentsMargins(10, 4, 4, 4) # display name label font = QtGui.QFont() font.setWeight(75) font.setBold(True) self.displayNameLabel = QtWidgets.QLabel(parent) self.displayNameLabel.setMinimumHeight(18) self.displayNameLabel.setFont(font) self.displayNameLabel.setText(step.getDisplayName()) layout.addWidget(self.displayNameLabel)
def setupUi(self, parent): layout = QtWidgets.QHBoxLayout(parent) self.rigNameLabel = QtWidgets.QLabel(parent) self.rigNameLabel.setText(self.blueprint.rigName) layout.addWidget(self.rigNameLabel) checkBtn = QtWidgets.QPushButton(parent) checkBtn.setText("Check") checkBtn.setMaximumWidth(80) checkBtn.clicked.connect(self.runCheck) layout.addWidget(checkBtn) buildBtn = QtWidgets.QPushButton(parent) buildBtn.setText("Build") buildBtn.setMaximumWidth(80) buildBtn.clicked.connect(self.runBuild) layout.addWidget(buildBtn)
def setupUi(self, parent): layout = QtWidgets.QVBoxLayout(parent) # clear color btn clearBtn = QtWidgets.QPushButton(parent) clearBtn.setText("Remove Color") clearBtn.clicked.connect( cmd(pulse.editorutils.disableColorOverrideForSelected)) layout.addWidget(clearBtn) bodyLayout = self.setupBodyUi(parent) layout.addLayout(bodyLayout) # help text self.helpText = QtWidgets.QLabel() self.helpText.setFont(style.UIFonts.getHelpTextFont()) layout.addWidget(self.helpText) layout.setStretch(2, 1)
def setupUi(self, parent): """ Build the UI for the main body of the window """ layout = QtWidgets.QVBoxLayout(parent) # preview text self.namePreviewBtn = QtWidgets.QPushButton(parent) font = QtGui.QFont() font.setPointSize(10) font.setWeight(75) font.setBold(True) self.namePreviewBtn.setFont(font) self.namePreviewBtn.setStatusTip("The current constructed name. " "Click to apply to the selected node") # self.namePreviewBtn.setAlignment(QtCore.Qt.AlignCenter) self.namePreviewBtn.setContentsMargins(10, 10, 10, 10) # self.namePreviewBtn.setStyleSheet( # 'background-color: rgba(0, 0, 0, 40); border-radius: 2px') self.namePreviewBtn.clicked.connect(self.onPreviewBtnClicked) layout.addWidget(self.namePreviewBtn) # prefixes / suffixes self.prefixSuffixLayout = QtWidgets.QHBoxLayout() prefixLayout = self.setupPrefixesUi(parent) self.prefixSuffixLayout.addLayout(prefixLayout) suffixLayout = self.setupSuffixesUi(parent) self.prefixSuffixLayout.addLayout(suffixLayout) layout.addLayout(self.prefixSuffixLayout) # keywords keywordsLayout = self.setupKeywordsUi(parent) layout.addLayout(keywordsLayout) # help text self.helpText = QtWidgets.QLabel() self.helpText.setFont(style.UIFonts.getHelpTextFont()) layout.addWidget(self.helpText) layout.setStretch(2, 1)
def setupKeywordCategoryUi(self, parent, name, keywords): """ Build a keyword category layout and button grid. Returns the layout. Args: name: A string name of the category keywords: A list of string names of the keywords in the category """ layout = QtWidgets.QVBoxLayout(parent) catLabel = self.createLabel(parent, pulse.names.toTitle(name)) catLabel.setStyleSheet( 'background-color: rgba(255, 255, 255, 5); border-radius: 2px') layout.addWidget(catLabel) catBtnGrid = QtWidgets.QGridLayout() # create button for all keywords x = 0 y = 0 for name in keywords: btn = QtWidgets.QPushButton() btn.setObjectName('keywordBtn_' + name) btn.setText(name) catBtnGrid.addWidget(btn, y, x, 1, 1) self.keywordBtns[name] = btn btn.installEventFilter(self) btn.clicked.connect(partial(self.onKeywordClicked, name)) x += 1 if x > 3: x = 0 y += 1 if y == 0: while x <= 3: spacer = QtWidgets.QLabel() catBtnGrid.addWidget(spacer, y, x, 1, 1) x += 1 layout.addLayout(catBtnGrid) return layout
def setupUi(self, parent): """ Create the UI that is common to all BuildItem editors, including a basic header and layout. """ # main layout containing header and body layout = QtWidgets.QVBoxLayout(parent) layout.setSpacing(4) layout.setMargin(0) # header frame self.headerFrame = QtWidgets.QFrame(parent) headerColor = 'rgba({0}, {1}, {2}, 40)'.format(*self.getItemColor()) self.headerFrame.setStyleSheet( ".QFrame{{ background-color: {color}; border-radius: 2px; }}". format(color=headerColor)) layout.addWidget(self.headerFrame) # header layout self.headerLayout = QtWidgets.QHBoxLayout(self.headerFrame) self.headerLayout.setContentsMargins(10, 4, 4, 4) # display name label font = QtGui.QFont() font.setWeight(75) font.setBold(True) self.displayNameLabel = QtWidgets.QLabel(self.headerFrame) self.displayNameLabel.setMinimumHeight(18) self.displayNameLabel.setFont(font) self.displayNameLabel.setText(self.getItemDisplayName()) self.headerLayout.addWidget(self.displayNameLabel) # body layout bodyFrame = QtWidgets.QFrame(parent) bodyFrame.setObjectName("bodyFrame") bodyColor = 'rgba(255, 255, 255, 5)'.format(*self.getItemColor()) bodyFrame.setStyleSheet( ".QFrame#bodyFrame{{ background-color: {color}; }}".format( color=bodyColor)) layout.addWidget(bodyFrame) self.mainLayout = QtWidgets.QVBoxLayout(bodyFrame) self.mainLayout.setMargin(6) self.mainLayout.setSpacing(0)
def setupUi(self, parent): layout = QtWidgets.QHBoxLayout(parent) self.rigNameLabel = QtWidgets.QLabel(parent) self.rigNameLabel.setText(self.blueprintModel.getRigName()) layout.addWidget(self.rigNameLabel) self.saveBtn = QtWidgets.QPushButton(parent) self.saveBtn.setText("Save") self.saveBtn.setMaximumWidth(80) self.saveBtn.clicked.connect(self.saveBlueprintAndFile) layout.addWidget(self.saveBtn) self.loadBtn = QtWidgets.QPushButton(parent) self.loadBtn.setText("Load") self.loadBtn.setMaximumWidth(80) self.loadBtn.clicked.connect(self.blueprintModel.loadFromFile) layout.addWidget(self.loadBtn) self.checkBtn = QtWidgets.QPushButton(parent) self.checkBtn.setText("Check") self.checkBtn.setMaximumWidth(80) self.checkBtn.clicked.connect(self.runCheck) layout.addWidget(self.checkBtn) self.buildBtn = QtWidgets.QPushButton(parent) self.buildBtn.setText("Build") self.buildBtn.setMaximumWidth(80) self.buildBtn.clicked.connect(self.runBuild) layout.addWidget(self.buildBtn) self.openBPBtn = QtWidgets.QPushButton(parent) self.openBPBtn.setText("Open Blueprint") self.openBPBtn.clicked.connect(self.openBlueprintAndReload) layout.addWidget(self.openBPBtn) self.cleanState()
def setupContenUi(self, parent): layout = QtWidgets.QVBoxLayout(parent) layout.setMargin(0) # settings # -------- self.keepChildPosCheck = QtWidgets.QCheckBox(parent) self.keepChildPosCheck.setText("Preserve Children") self.keepChildPosCheck.setStatusTip( "Preseve the positions of child nodes when rotating " "or orienting a transform or joint") self.keepChildPosCheck.setChecked(self.orientPreserveChildren) self.keepChildPosCheck.stateChanged.connect( self.setOrientPreserveChildren) self.keepShapeCheck = QtWidgets.QCheckBox(parent) self.keepShapeCheck.setText("Preserve Shapes") self.keepShapeCheck.setStatusTip( "Preseve the orientation of shapes when rotating nodes") self.keepShapeCheck.setChecked(self.orientPreserveShapes) self.keepShapeCheck.stateChanged.connect(self.setOrientPreserveShapes) self.syncJointAxesCheck = QtWidgets.QCheckBox(parent) self.syncJointAxesCheck.setText('Keep Axes Synced') self.syncJointAxesCheck.setStatusTip( "When enabled, joint translate and scale axes are automatically " "updated when the jointOrient and rotateAxis values are changed.") self.syncJointAxesCheck.setChecked(self.syncJointAxes) self.syncJointAxesCheck.stateChanged.connect(self.setSyncJointAxes) self.includeChildrenCheck = QtWidgets.QCheckBox(parent) self.includeChildrenCheck.setText("Include All Children") self.includeChildrenCheck.setStatusTip( "Update all child joints when using orient to joint or world") self.includeChildrenCheck.setChecked(self.orientIncludeChildren) self.includeChildrenCheck.stateChanged.connect( self.setOrientIncludeChildren) # joint orient axes hlayout = QtWidgets.QHBoxLayout(parent) hlayout.setSpacing(4) axisOrderLabel = QtWidgets.QLabel(parent) axisOrderLabel.setText("Orient Axes") self.axisOrderCombo = QtWidgets.QComboBox(parent) for option in self.AXIS_ORDER_OPTIONS: optionStr = '{0} forward, {1} up'.format(option[0], option[1]) self.axisOrderCombo.addItem(optionStr) self.axisOrderCombo.setCurrentIndex(self.orientAxisOrder) self.axisOrderCombo.setStatusTip( "The local axes to use for forward / up / secondary") self.axisOrderCombo.currentIndexChanged.connect( self.setOrientAxisOrder) self.upAxisCombo = QtWidgets.QComboBox(parent) for option in self.UP_AXIS_OPTIONS: optionStr = '{0} world up'.format(option) self.upAxisCombo.addItem(optionStr) self.upAxisCombo.setCurrentIndex(self.orientUpAxis) self.upAxisCombo.setStatusTip( "The world axis that up vector of the joint should point towards") self.upAxisCombo.currentIndexChanged.connect(self.setOrientUpAxis) hlayout.addWidget(axisOrderLabel) hlayout.addWidget(self.axisOrderCombo) hlayout.addWidget(self.upAxisCombo) hlayout.addItem(viewutils.createHSpacer()) layout.addWidget(self.keepChildPosCheck) layout.addWidget(self.keepShapeCheck) layout.addWidget(self.syncJointAxesCheck) layout.addWidget(self.includeChildrenCheck) layout.addLayout(hlayout) # button grid # ----------- gridLayout = QtWidgets.QGridLayout(parent) gridLayout.setMargin(0) gridLayout.setSpacing(2) toggleCBBtn = QPushButton(parent) toggleCBBtn.setText('Toggle Channel Box Attrs') toggleCBBtn.setStatusTip( "Toggle the display of rotateAxis, localPivot, and other " "attributes in the channel box") toggleCBBtn.clicked.connect( cmd(editorutils.toggleDetailedChannelBoxForSelected)) toggleLRABtn = QPushButton(parent) toggleLRABtn.setText('Toggle LRAs') toggleLRABtn.setStatusTip( "Toggle the display of local rotation axes") toggleLRABtn.clicked.connect( cmd(self.toggleLocalRotationAxesForSelected)) syncAxesBtn = QtWidgets.QPushButton(parent) syncAxesBtn.setText("Sync Axes") syncAxesBtn.setStatusTip( "Match the translate and scale axes of a " "joint to its orientation") syncAxesBtn.clicked.connect(self.matchJointRotationToOrientForSelected) orientToJointBtn = QtWidgets.QPushButton(parent) orientToJointBtn.setText("Orient to Joint") orientToJointBtn.clicked.connect(self.orientToJointForSelected) orientToWorldBtn = QtWidgets.QPushButton(parent) orientToWorldBtn.setText("Orient to World") orientToWorldBtn.clicked.connect(self.orientToWorldForSelected) interactiveOrientBtn = QtWidgets.QPushButton(parent) interactiveOrientBtn.setText("Interactive Orient") interactiveOrientBtn.setEnabled(False) gridItems = [ [orientToJointBtn, orientToWorldBtn], [interactiveOrientBtn, syncAxesBtn], [toggleCBBtn, toggleLRABtn], ] viewutils.addItemsToGrid(gridLayout, gridItems) layout.addLayout(gridLayout) # rotate orient buttons # --------------------- rotateForm = self.createRotateAxisForm(parent) layout.addWidget(rotateForm)
def setupConstantsUi(self, parent): viewutils.clearLayout(self.constantsLayout) # create attr form all constant attributes for attr in self.buildItem.actionClass.config['attrs']: isConstant = (attr['name'] in self.buildItem.constantValues) # make an HBox with a button to toggle variant state attrHLayout = QtWidgets.QHBoxLayout(parent) attrHLayout.setSpacing(10) attrHLayout.setMargin(0) self.constantsLayout.addLayout(attrHLayout) if isConstant: # constant value, make an attr form attrValue = self.buildItem.constantValues[attr['name']] context = self.buildItem.constantValues attrForm = ActionAttrForm.createForm(attr, attrValue, parent=parent) attrForm.valueChanged.connect( partial(self.attrValueChanged, context, attrForm)) attrHLayout.addWidget(attrForm) else: # variant value, check for batch editor, or just display a label attrLabel = QtWidgets.QLabel(parent) # extra 2 to account for the left-side frame padding that occurs in the ActionAttrForm attrLabel.setFixedSize( QtCore.QSize(ActionAttrForm.LABEL_WIDTH + 2, ActionAttrForm.LABEL_HEIGHT)) attrLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignTop) attrLabel.setMargin(2) attrLabel.setText(pulse.names.toTitle(attr['name'])) attrLabel.setEnabled(False) attrHLayout.addWidget(attrLabel) if BatchAttrForm.doesFormExist(attr): batchEditor = BatchAttrForm.createForm(self.buildItem, attr, parent=parent) batchEditor.valuesChanged.connect( self.batchEditorValuesChanged) attrHLayout.addWidget(batchEditor) else: spacer = QtWidgets.QSpacerItem( 24, 24, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) attrHLayout.addItem(spacer) # not a constant value, add a line with button to make it constant # button to toggle variant toggleVariantBtn = QtWidgets.QPushButton(parent) toggleVariantBtn.setText("v") toggleVariantBtn.setFixedSize(QtCore.QSize(20, 20)) toggleVariantBtn.setCheckable(True) toggleVariantBtn.setChecked(not isConstant) attrHLayout.addWidget(toggleVariantBtn) attrHLayout.setAlignment(toggleVariantBtn, QtCore.Qt.AlignTop) toggleVariantBtn.clicked.connect( partial(self.setIsVariantAttr, attr['name'], isConstant))