def __init__(self, plug, **kw): frame = GafferUI.Frame(borderWidth=4) GafferUI.PlugValueWidget.__init__(self, frame, plug, **kw) # Style selector specificity rules seem to preclude us styling this # based on gafferClass. frame._qtWidget().setObjectName("gafferColorInspector") with frame: with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4): GafferUI.Spacer(imath.V2i(0, 10)) self.__positionLabel = GafferUI.Label() self.__positionLabel._qtWidget().setFixedWidth(90) self.__swatch = GafferUI.ColorSwatch() self.__swatch._qtWidget().setFixedWidth(12) self.__swatch._qtWidget().setFixedHeight(12) self.__busyWidget = GafferUI.BusyWidget(size=12) self.__rgbLabel = GafferUI.Label() GafferUI.Spacer(imath.V2i(20, 10), imath.V2i(20, 10)) self.__hsvLabel = GafferUI.Label() GafferUI.Spacer(imath.V2i(0, 10)) self.__pixel = imath.V2f(0) viewportGadget = plug.parent().viewportGadget() viewportGadget.mouseMoveSignal().connect(Gaffer.WeakMethod( self.__mouseMove), scoped=False) imageGadget = viewportGadget.getPrimaryChild() imageGadget.buttonPressSignal().connect(Gaffer.WeakMethod( self.__buttonPress), scoped=False) imageGadget.dragBeginSignal().connect(Gaffer.WeakMethod( self.__dragBegin), scoped=False) imageGadget.dragEndSignal().connect(Gaffer.WeakMethod(self.__dragEnd), scoped=False) self.__updateLabels(imath.V2i(0), imath.Color4f(0, 0, 0, 1))
def __init__(self, title, **kw): GafferUI.Dialogue.__init__(self, title, **kw) # Build UI. We have widgets for two states - busy and error - and manage # widget visibility to switch between those states. with GafferUI.ListContainer(spacing=4) as column: GafferUI.Spacer(imath.V2i(250, 20)) self.__busyWidget = GafferUI.BusyWidget( parenting={ "horizontalAlignment": GafferUI.ListContainer.HorizontalAlignment.Center }) self.__errorImage = GafferUI.Image( "failure.png", parenting={ "horizontalAlignment": GafferUI.HorizontalAlignment.Center, "expand": True, }) self.__label = GafferUI.Label( parenting={ "horizontalAlignment": GafferUI.ListContainer.HorizontalAlignment.Center }) GafferUI.Spacer(imath.V2i(250, 20)) self.__messageWidget = GafferUI.MessageWidget(toolbars=True) self._setWidget(column) self.__continueButton = self._addButton("Continue") self.__cancelButton = self._addButton("Cancel") # Make it impossible to accidentally cancel by hitting `Enter`. self.__cancelButton._qtWidget().setFocusPolicy(QtCore.Qt.NoFocus) self.__cancelButton.clickedSignal().connect(Gaffer.WeakMethod( self.__cancelClicked), scoped=False) self.keyPressSignal().connect(Gaffer.WeakMethod(self.__keyPress), scoped=False) self.__backgroundTask = None self.__messageHandler = IECore.CapturingMessageHandler()
def __init__( self, displayWidget, path ) : self.__tabbedContainer = GafferUI.TabbedContainer() GafferUI.PathPreviewWidget.__init__( self, self.__tabbedContainer, path ) self.__tabbedContainer.setTabsVisible( False ) self.__tabbedContainer.append( GafferUI.BusyWidget( size = 25 ) ) # for when we're loading self.__tabbedContainer.append( displayWidget ) # for when we loaded ok self.__tabbedContainer.append( GafferUI.Spacer( size = imath.V2i( 10 ) ) ) # for when we didn't load ok # a timer we use to display the busy status if loading takes too long self.__busyTimer = QtCore.QTimer() self.__busyTimer.setSingleShot( True ) self.__busyTimer.timeout.connect( functools.partial( DeferredPathPreview.__displayBusy, weakref.ref( self ) ) )
def __init__( self, sceneView, **kw ) : row = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) GafferUI.Widget.__init__( self, row, **kw ) with row : self.__button = GafferUI.Button( hasFrame = False ) self.__busyWidget = GafferUI.BusyWidget( size = 20 ) self.__sceneGadget = sceneView.viewportGadget().getPrimaryChild() self.__button.clickedSignal().connect( Gaffer.WeakMethod( self.__buttonClick ), scoped = False ) self.__sceneGadget.stateChangedSignal().connect( Gaffer.WeakMethod( self.__stateChanged ), scoped = False ) self.__update()
def __initiateDispatch(self, button): self.__progressIconFrame.setChild(GafferUI.BusyWidget()) self.__progressLabel.setText("<h3>Dispatching...</h3>") self.__backButton.setVisible(False) self.__backButton.setEnabled(False) self.__primaryButton.setVisible(False) self.__primaryButton.setEnabled(False) self.__messageWidget.clear() self.__messageCollapsible.setCollapsed(True) self._getWidget().setChild(self.__progressUI) threading.Thread(target=self.__dispatch).start()
def __init__(self, plug, **kw): frame = GafferUI.Frame(borderWidth=4) frame._qtWidget().setObjectName("gafferDarker") GafferUI.PlugValueWidget.__init__(self, frame, plug, **kw) with frame: with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4): self.__positionLabel = GafferUI.Label() self.__positionLabel._qtWidget().setFixedWidth(90) self.__swatch = GafferUI.ColorSwatch() self.__swatch._qtWidget().setFixedWidth(12) self.__swatch._qtWidget().setFixedHeight(12) self.__busyWidget = GafferUI.BusyWidget(size=12) self.__rgbLabel = GafferUI.Label() GafferUI.Spacer(imath.V2i(20, 10), imath.V2i(20, 10)) self.__hsvLabel = GafferUI.Label() self.__pixel = imath.V2f(0) viewportGadget = plug.parent().viewportGadget() self.__mouseMoveConnection = viewportGadget.mouseMoveSignal().connect( Gaffer.WeakMethod(self.__mouseMove)) imageGadget = viewportGadget.getPrimaryChild() self.__buttonPressSignal = imageGadget.buttonPressSignal().connect( Gaffer.WeakMethod(self.__buttonPress)) self.__dragBeginSignal = imageGadget.dragBeginSignal().connect( Gaffer.WeakMethod(self.__dragBegin)) self.__dragEndSignal = imageGadget.dragEndSignal().connect( Gaffer.WeakMethod(self.__dragEnd)) self.__updateLabels(imath.V2i(0), imath.Color4f(0, 0, 0, 1))
def __init__(self, plug, contextName, label, toolTipPrefix, **kw): toolTip = toolTipPrefix + " " + inspect.cleandoc(""" Varying the context requires extra evaluations of the `prototypes` scene, and can dramatically increase the cost of the Instancer. Note that variations are measured across all locations in the scene where the instancer is filtered. """) l = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4, toolTip=toolTip) GafferUI.PlugValueWidget.__init__(self, l, plug, **kw) if isinstance(contextName, Gaffer.StringPlug): self.contextName = None self.contextNamePlug = contextName self.contextNamePlug.node().plugDirtiedSignal().connect( Gaffer.WeakMethod(self.__namePlugDirtied), scoped=False) else: self.contextName = contextName self.contextNamePlug = None with l: GafferUI.Spacer(imath.V2i(0), preferredSize=imath.V2i(0)) if label: GafferUI.Label("<h4>%s</h4>" % label, toolTip=toolTip) with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=2, borderWidth=3) as h: h._qtWidget().setObjectName("gafferVariationCount") self.__busyWidget = GafferUI.BusyWidget(size=14) self.__countLabel = GafferUI.Label( horizontalAlignment=GafferUI.HorizontalAlignment.Right, toolTip=toolTip) self.__countLabel._qtWidget().setMinimumWidth(90) self.__updateLabel(-1) self._updateFromPlug()
def __init__(self, uvView, **kw): row = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4) GafferUI.Widget.__init__(self, row, **kw) with row: self.__busyWidget = GafferUI.BusyWidget(size=20) self.__button = GafferUI.Button(hasFrame=False) self.__uvView = uvView self.__buttonClickedConnection = self.__button.clickedSignal().connect( Gaffer.WeakMethod(self.__buttonClick)) self.__stateChangedConnection = self.__uvView.stateChangedSignal( ).connect(Gaffer.WeakMethod(self.__stateChanged)) self.__update()
def __init__( self, sceneView ) : self.__frame = GafferUI.Frame( borderWidth = 4 ) GafferUI.Widget.__init__( self, self.__frame ) self.__attachToView( sceneView ) with self.__frame : with GafferUI.ListContainer( spacing = 8 ) : with GafferUI.ListContainer( orientation = GafferUI.ListContainer.Orientation.Horizontal, spacing = 8 ) : GafferUI.Spacer( imath.V2i( 12 ), imath.V2i( 12 ) ) # hideButton GafferUI.Spacer( imath.V2i( 20 ), imath.V2i( 20 ) ) # BusyWidget GafferUI.Spacer( imath.V2i( 1 ) ) GafferUI.Label( "<h4 style=\"color: rgba( 255, 255, 255, 120 );\">Inspector</h4>" ) GafferUI.Spacer( imath.V2i( 1 ) ) self.__busyWidget = GafferUI.BusyWidget( size = 20, busy = False ) hideButton = GafferUI.Button( image="deleteSmall.png", hasFrame=False ) hideButton.clickedSignal().connect( Gaffer.WeakMethod( self.__closeButtonClicked ), scoped = False ) with GafferUI.ScrolledContainer( horizontalMode = GafferUI.ScrollMode.Never ) : with GafferUI.ListContainer( spacing = 20 ) : self.__groups = { a : _ParameterGroup(a) for a in _registeredShaderAttributes() } # The on/off state of the Inspector is managed by setVisible, which also disables lazy updates when # we're turned off. We desire to hide ourselves when we have nothing to show, but still need background # updates so we can re-appear as needed. We achieve this by managing the visibility of our frame, # independently of the widget. self.__frame.setVisible( False ) self.keyPressSignal().connect( Gaffer.WeakMethod( self.__keyPress ), scoped = False) Gaffer.Metadata.nodeValueChangedSignal().connect( Gaffer.WeakMethod( self.__nodeMetadataChanged ), scoped = False ) Gaffer.Metadata.plugValueChangedSignal().connect( Gaffer.WeakMethod( self.__plugMetadataChanged ), scoped = False )
def __init__(self, plug, **kw): l = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=4) GafferUI.PlugValueWidget.__init__(self, l, plug, **kw) mode = plug["mode"].getValue() with l: self.__indexLabel = GafferUI.Label() labelFont = QtGui.QFont(self.__indexLabel._qtWidget().font()) labelFont.setBold(True) labelFont.setPixelSize(10) labelFontMetrics = QtGui.QFontMetrics(labelFont) self.__indexLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("99")) self.__modeImage = GafferUI.Image("sourceCursor.png") self.__positionLabel = GafferUI.Label() self.__positionLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("9999 9999 -> 9999 9999")) self.__swatch = GafferUI.ColorSwatch() self.__swatch._qtWidget().setFixedWidth(12) self.__swatch._qtWidget().setFixedHeight(12) self.__busyWidget = GafferUI.BusyWidget(size=12) self.__rgbLabel = GafferUI.Label() self.__rgbLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("RGBA : 99999 99999 99999 99999")) self.__hsvLabel = GafferUI.Label() self.__hsvLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("HSV : 99999 99999 99999")) self.__exposureLabel = GafferUI.Label() self.__exposureLabel._qtWidget().setMinimumWidth( labelFontMetrics.width("EV : 19.9")) l.addChild(GafferUI.Spacer(size=imath.V2i(0))) if mode == GafferImageUI.ImageView.ColorInspectorPlug.Mode.Cursor: m = IECore.MenuDefinition() m.append( "/Pixel Inspector", { "command": functools.partial( Gaffer.WeakMethod(self.__addClick), GafferImageUI. ImageView.ColorInspectorPlug.Mode.Pixel) }) m.append( "/Area Inspector", { "command": functools.partial( Gaffer.WeakMethod(self.__addClick), GafferImageUI. ImageView.ColorInspectorPlug.Mode.Area) }) button = GafferUI.MenuButton("", "plus.png", hasFrame=False, menu=GafferUI.Menu( m, title="Add Color Inspector")) else: button = GafferUI.Button("", "delete.png", hasFrame=False) button.clickedSignal().connect(Gaffer.WeakMethod( self.__deleteClick), scoped=False) self.__pixel = imath.V2i(0) self.__createInspectorStartPosition = None if plug.getName() == "ColorInspectorPlug": viewportGadget = plug.node().viewportGadget() imageGadget = viewportGadget.getPrimaryChild() imageGadget.mouseMoveSignal().connect(Gaffer.WeakMethod( self.__mouseMove), scoped=False) imageGadget.buttonPressSignal().connect(Gaffer.WeakMethod( self.__buttonPress), scoped=False) imageGadget.buttonReleaseSignal().connect(Gaffer.WeakMethod( self.__buttonRelease), scoped=False) imageGadget.dragBeginSignal().connect(Gaffer.WeakMethod( self.__dragBegin), scoped=False) imageGadget.dragEnterSignal().connect(Gaffer.WeakMethod( self.__dragEnter), scoped=False) imageGadget.dragMoveSignal().connect(Gaffer.WeakMethod( self.__dragMove), scoped=False) imageGadget.dragEndSignal().connect(Gaffer.WeakMethod( self.__dragEnd), scoped=False) self.__swatch.buttonPressSignal().connect(Gaffer.WeakMethod( self.__buttonPress), scoped=False) self.__swatch.dragBeginSignal().connect(Gaffer.WeakMethod( self.__dragBegin), scoped=False) self.__swatch.dragEndSignal().connect(Gaffer.WeakMethod( self.__dragEnd), scoped=False) plug.node()["colorInspector"]["evaluator"]["pixelColor"].getInput( ).node().plugDirtiedSignal().connect(Gaffer.WeakMethod( self.__updateFromImageNode), scoped=False) plug.node().plugDirtiedSignal().connect(Gaffer.WeakMethod( self._plugDirtied), scoped=False) plug.node()["in"].getInput().node().scriptNode().context( ).changedSignal().connect(Gaffer.WeakMethod(self.__updateFromContext), scoped=False) Gaffer.Metadata.plugValueChangedSignal(self.getPlug().node()).connect( Gaffer.WeakMethod(self.__plugMetadataChanged), scoped=False) self.__updateLabels(imath.V2i(0), imath.Color4f(0, 0, 0, 1)) # Set initial state of mode icon self._plugDirtied(plug["mode"])
def __init__(self, scriptNode, **kw): column = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, borderWidth=8, spacing=8) self.__tabbedContainer = GafferUI.TabbedContainer() nodeAndLocationContainer = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, borderWidth=8, spacing=8) nodeAndLocationContainer.append(GafferUI.Label("Node")) self.__nodeLabel = GafferUI.NameLabel(None) self.__nodeLabel.setFormatter(_nodeLabelFormatter) self.__nodeFrame = GafferUI.Frame( borderWidth=4, borderStyle=GafferUI.Frame.BorderStyle.None_, child=self.__nodeLabel) self.__nodeFrame._qtWidget().setObjectName("gafferNodeFrame") self.__nodeFrame._qtWidget().setProperty("gafferDiff", "Other") nodeAndLocationContainer.append(self.__nodeFrame) nodeAndLocationContainer.append(GafferUI.Label("Location")) self.__locationLabel = GafferUI.Label("Select a location to inspect") self.__locationFrame = GafferUI.Frame( borderWidth=4, borderStyle=GafferUI.Frame.BorderStyle.None_, child=self.__locationLabel) self.__locationFrame._qtWidget().setObjectName("gafferLocationFrame") self.__locationFrame._qtWidget().setProperty("gafferDiff", "Other") nodeAndLocationContainer.append(self.__locationFrame) self.__busyWidget = GafferUI.BusyWidget(size=20) nodeAndLocationContainer.append(self.__busyWidget) column.append(nodeAndLocationContainer) column.append(self.__tabbedContainer) self.__dataWidgets = {} self.__tabbedChildWidgets = {} def listContainer(child): l = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, borderWidth=8, spacing=8) l.append(child) return l vectorDataWidgetOptions = { "editable": False, "header": True, "horizontalScrollMode": GafferUI.ScrollMode.Automatic, "verticalScrollMode": GafferUI.ScrollMode.Automatic } self.__dataWidgets[IECoreScene.PrimitiveVariable.Interpolation. Constant] = GafferUI.VectorDataWidget( **vectorDataWidgetOptions) self.__dataWidgets[IECoreScene.PrimitiveVariable.Interpolation. Uniform] = GafferUI.VectorDataWidget( **vectorDataWidgetOptions) self.__dataWidgets[IECoreScene.PrimitiveVariable.Interpolation. Vertex] = GafferUI.VectorDataWidget( **vectorDataWidgetOptions) self.__dataWidgets[IECoreScene.PrimitiveVariable.Interpolation. Varying] = GafferUI.VectorDataWidget( **vectorDataWidgetOptions) self.__dataWidgets[IECoreScene.PrimitiveVariable.Interpolation. FaceVarying] = GafferUI.VectorDataWidget( **vectorDataWidgetOptions) self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation. Constant] = listContainer(self.__dataWidgets[ IECoreScene.PrimitiveVariable.Interpolation.Constant]) self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation. Uniform] = listContainer(self.__dataWidgets[ IECoreScene.PrimitiveVariable.Interpolation.Uniform]) self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation. Vertex] = listContainer(self.__dataWidgets[ IECoreScene.PrimitiveVariable.Interpolation.Vertex]) self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation. Varying] = listContainer(self.__dataWidgets[ IECoreScene.PrimitiveVariable.Interpolation.Varying]) self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation. FaceVarying] = listContainer(self.__dataWidgets[ IECoreScene.PrimitiveVariable.Interpolation.FaceVarying]) self.__tabbedContainer.append( self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation.Constant], "Constant") self.__tabbedContainer.append( self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation.Uniform], "Uniform") self.__tabbedContainer.append( self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation.Vertex], "Vertex") self.__tabbedContainer.append( self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation.Varying], "Varying") self.__tabbedContainer.append( self.__tabbedChildWidgets[ IECoreScene.PrimitiveVariable.Interpolation.FaceVarying], "FaceVarying") GafferUI.NodeSetEditor.__init__(self, column, scriptNode, **kw) self._updateFromSet()
def __initiateExecution(self, *unused): self.__progressIconFrame.setChild(GafferUI.BusyWidget()) self.__progressLabel.setText("<h3>Processing...</h3>") self.__backButton.setEnabled(False) self.__forwardButton.setEnabled(False) self.__messageWidget.textWidget().setText("") self.__messageCollapsible.setCollapsed(True) self.__state = self.__State.Execution if self.__executeInBackground: self.__frame.setChild(self.__progressUI) threading.Thread(target=self.__execute).start() else: # we don't display progress when we're not threaded, # because we have no way of updating it. self.__execute()