Ejemplo n.º 1
0
	def __init__( self, plug, **kw ) :

		column = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing = 4 )

		GafferUI.PlugValueWidget.__init__( self, column, plug, **kw )

		with column :
			with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) :
				GafferUI.Spacer( IECore.V2i( 0 ), parenting = { "expand" : True } )
				GafferUI.LabelPlugValueWidget( plug["basis"], horizontalAlignment=GafferUI.Label.HorizontalAlignment.Right )
				GafferUI.SplineBasisPlugValueWidget( plug )

			self.__splineWidget = GafferUI.SplineWidget()
			self.__splineWidget.setDrawMode( self.__splineWidget.DrawMode.Ramp )
			self.__splineWidget._qtWidget().setMinimumHeight( 50 )

			self.__slider = GafferUI.Slider()
			self.__slider.setSizeEditable( True )
			self.__slider.setMinimumSize( 2 )
			self.__positionsChangedConnection = self.__slider.positionChangedSignal().connect( Gaffer.WeakMethod( self.__positionsChanged ) )
			self.__indexRemovedConnection = self.__slider.indexRemovedSignal().connect( Gaffer.WeakMethod( self.__indexRemoved ) )
			self.__selectedIndexChangedConnection = self.__slider.selectedIndexChangedSignal().connect( Gaffer.WeakMethod( self.__selectedIndexChanged ) )

			self.__lastPositionChangedReason = None
			self.__positionsMergeGroupId = 0

			with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) :

				self.__positionLabel = GafferUI.LabelPlugValueWidget( plug.pointXPlug( 0 ) )
				self.__positionField = GafferUI.NumericPlugValueWidget( plug.pointXPlug( 0 ) )

				self.__valueLabel = GafferUI.LabelPlugValueWidget( plug.pointYPlug( 0 ) )
				self.__valueField = GafferUI.ColorPlugValueWidget( plug.pointYPlug( 0 ) )

		self.setPlug( plug )
Ejemplo n.º 2
0
	def __init__( self, plug, **kw ) :

		column = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing = 4 )

		GafferUI.PlugValueWidget.__init__( self, column, plug, **kw )

		with column :
			with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) :
				GafferUI.Label( "Display Mode" )
				drawModeWidget = GafferUI.MultiSelectionMenu( allowMultipleSelection = False, allowEmptySelection = False )
				drawModeWidget.append( "Ramp" )
				drawModeWidget.append( "Curves" )
				drawModeWidget.setSelection( "Ramp" )
				self.__drawModeChangedConnection = drawModeWidget.selectionChangedSignal().connect( Gaffer.WeakMethod( self.__drawModeChanged ) )

				GafferUI.Spacer( imath.V2i( 0 ), parenting = { "expand" : True } )

				# TODO: Since we don't have a good way to register metadata on child plugs, we just write the
				# metadata on this child plug right before constructing a widget for it.  There should probably
				# be some way to do this genericly during initialization
				Gaffer.Metadata.registerValue( plug['interpolation'],
					"plugValueWidget:type", "GafferUI.PresetsPlugValueWidget", persistent=False )  
				for name, value in sorted( Gaffer.SplineDefinitionInterpolation.names.items() ):
					Gaffer.Metadata.registerValue( plug['interpolation'], "preset:" + name, value, persistent=False )

				GafferUI.PlugWidget( GafferUI.PlugValueWidget.create( plug["interpolation"] ) )

			self.__splineWidget = GafferUI.SplineWidget()
			if isinstance( plug, ( Gaffer.SplinefColor3fPlug, Gaffer.SplinefColor4fPlug ) ) :
				self.__splineWidget.setDrawMode( self.__splineWidget.DrawMode.Ramp )
			else:
				self.__splineWidget.setDrawMode( self.__splineWidget.DrawMode.Splines )
			self.__splineWidget._qtWidget().setMinimumHeight( 50 )

			self.__slider = GafferUI.Slider()
			self.__slider.setSizeEditable( True )
			self.__slider.setMinimumSize( 2 )
			self.__positionsChangedConnection = self.__slider.positionChangedSignal().connect( Gaffer.WeakMethod( self.__positionsChanged ) )
			self.__indexRemovedConnection = self.__slider.indexRemovedSignal().connect( Gaffer.WeakMethod( self.__indexRemoved ) )
			self.__selectedIndexChangedConnection = self.__slider.selectedIndexChangedSignal().connect( Gaffer.WeakMethod( self.__selectedIndexChanged ) )

			self.__lastPositionChangedReason = None
			self.__positionsMergeGroupId = 0

			with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) :

				self.__positionLabel = GafferUI.LabelPlugValueWidget( plug.pointXPlug( 0 ) )
				self.__positionField = GafferUI.NumericPlugValueWidget( plug.pointXPlug( 0 ) )

				self.__valueLabel = GafferUI.LabelPlugValueWidget( plug.pointYPlug( 0 ) )
				if isinstance( plug.pointYPlug( 0 ), Gaffer.FloatPlug ):
					self.__valueField = GafferUI.NumericPlugValueWidget( plug.pointYPlug( 0 ) )
				else:
					self.__valueField = GafferUI.ColorPlugValueWidget( plug.pointYPlug( 0 ) )

		self.setPlug( plug )
Ejemplo n.º 3
0
    def __init__(self, plug, **kw):

        self.__column = GafferUI.ListContainer(spacing=8)
        GafferUI.PlugValueWidget.__init__(self, self.__column, plug, **kw)

        with self.__column:

            with GafferUI.ListContainer(
                    GafferUI.ListContainer.Orientation.Horizontal, spacing=4):

                label = GafferUI.LabelPlugValueWidget(
                    plug,
                    horizontalAlignment=GafferUI.Label.HorizontalAlignment.
                    Right,
                    verticalAlignment=GafferUI.Label.VerticalAlignment.Top,
                )
                label.label()._qtWidget().setFixedWidth(
                    GafferUI.PlugWidget.labelWidth())

                self.__menuButton = GafferUI.MenuButton()
                self.__menuButton.setMenu(
                    GafferUI.Menu(Gaffer.WeakMethod(self.__menuDefinition)))

                GafferUI.Spacer(IECore.V2i(1),
                                IECore.V2i(100000, 1),
                                parenting={"expand": True})

            GafferUI.Divider()

        self._updateFromPlug()
Ejemplo n.º 4
0
    def __init__(self, plug, **kw):

        self.__column = GafferUI.ListContainer()
        GafferUI.PlugValueWidget.__init__(self, self.__column, plug, **kw)

        row = GafferUI.ListContainer(
            GafferUI.ListContainer.Orientation.Horizontal, spacing=4)

        label = GafferUI.LabelPlugValueWidget(
            plug,
            horizontalAlignment=GafferUI.Label.HorizontalAlignment.Right,
            verticalAlignment=GafferUI.Label.VerticalAlignment.Top,
        )
        label.label()._qtWidget().setMinimumWidth(
            GafferUI.PlugWidget.labelWidth())
        row.append(label)

        self.__menuButton = GafferUI.MenuButton()
        self.__menuButton.setMenu(
            GafferUI.Menu(Gaffer.WeakMethod(self.__menuDefinition)))
        row.append(self.__menuButton)
        row.append(GafferUI.Spacer(IECore.V2i(1), IECore.V2i(100000, 1)),
                   expand=True)

        self.__column.append(row)

        self._updateFromPlug()
Ejemplo n.º 5
0
    def __init__(self, childPlug, label=None):

        self.__row = GafferUI.ListContainer(
            GafferUI.ListContainer.Orientation.Horizontal, spacing=4)

        GafferUI.PlugValueWidget.__init__(self, self.__row, childPlug)

        if label is not None or not childPlug.getFlags(
                Gaffer.Plug.Flags.Dynamic):
            nameWidget = GafferUI.LabelPlugValueWidget(
                childPlug,
                horizontalAlignment=GafferUI.Label.HorizontalAlignment.Right,
                verticalAlignment=GafferUI.Label.VerticalAlignment.Top,
            )
            if label is not None:
                nameWidget.label().setText(label)
            nameWidget.label()._qtWidget().setFixedWidth(
                GafferUI.PlugWidget.labelWidth())
        else:
            nameWidget = GafferUI.StringPlugValueWidget(childPlug["name"])
            nameWidget.textWidget()._qtWidget().setFixedWidth(
                GafferUI.PlugWidget.labelWidth())

        self.__row.append(nameWidget)

        if "enabled" in childPlug:
            self.__row.append(
                GafferUI.PlugValueWidget.create(childPlug["enabled"]))

        self.__row.append(GafferUI.PlugValueWidget.create(childPlug["value"]),
                          expand=True)

        self._updateFromPlug()
Ejemplo n.º 6
0
    def __init__(self, childPlug):

        self.__row = GafferUI.ListContainer(
            GafferUI.ListContainer.Orientation.Horizontal, spacing=4)

        GafferUI.PlugValueWidget.__init__(self, self.__row, childPlug)

        ## \todo We should support no plugs here. Move the UI configuration into setPlugs
        assert (len(self.getPlugs()) > 0)

        # We use a non-editable label for the name for non-dynamic plugs, or any that request it

        anyStatic = any([
            not p.getFlags(Gaffer.Plug.Flags.Dynamic) for p in self.getPlugs()
        ])
        anyIgnoreName = any([
            Gaffer.Metadata.value(
                p, "nameValuePlugPlugValueWidget:ignoreNamePlug")
            for p in self.getPlugs()
        ])

        if anyStatic or anyIgnoreName:
            nameWidget = GafferUI.LabelPlugValueWidget(
                self.getPlugs(),
                horizontalAlignment=GafferUI.Label.HorizontalAlignment.Right,
                verticalAlignment=GafferUI.Label.VerticalAlignment.Center,
            )
            nameWidget.label()._qtWidget().setFixedWidth(
                GafferUI.PlugWidget.labelWidth())
            # cheat to get the height of the label to match the height of a line edit
            # so the label and plug widgets align nicely. ideally we'd get the stylesheet
            # sorted for the QLabel so that that happened naturally, but QLabel sizing appears
            # somewhat unpredictable (and is sensitive to HTML in the text as well), making this
            # a tricky task.
            nameWidget.label()._qtWidget().setFixedHeight(20)
        else:
            nameWidget = GafferUI.StringPlugValueWidget(
                {plug["name"]
                 for plug in self.getPlugs()})
            nameWidget.textWidget()._qtWidget().setFixedWidth(
                GafferUI.PlugWidget.labelWidth())

        self.__row.append(
            nameWidget, verticalAlignment=GafferUI.Label.VerticalAlignment.Top)

        if all(["enabled" in plug for plug in self.getPlugs()]):
            self.__row.append(
                GafferUI.BoolPlugValueWidget(
                    {plug["enabled"]
                     for plug in self.getPlugs()},
                    displayMode=GafferUI.BoolWidget.DisplayMode.Switch),
                verticalAlignment=GafferUI.Label.VerticalAlignment.Top,
            )

        self.__row.append(GafferUI.PlugValueWidget.create(
            {plug["value"]
             for plug in self.getPlugs()}),
                          expand=True)

        self._updateFromPlugs()
Ejemplo n.º 7
0
    def __init__(self, plugOrWidget, label=None, description=None, **kw):

        GafferUI.Widget.__init__(self, QtWidgets.QWidget(), **kw)

        layout = QtWidgets.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(4)
        layout.setSizeConstraint(QtWidgets.QLayout.SetMinAndMaxSize)
        self._qtWidget().setLayout(layout)

        if isinstance(plugOrWidget, Gaffer.Plug):
            self.__valueWidget = GafferUI.PlugValueWidget.create(plugOrWidget)
            plug = plugOrWidget
        else:
            assert (isinstance(plugOrWidget, GafferUI.PlugValueWidget)
                    or hasattr(plugOrWidget, "plugValueWidget"))
            self.__valueWidget = plugOrWidget
            plug = self.plugValueWidget().getPlug()

        self.__label = GafferUI.LabelPlugValueWidget(
            plug,
            horizontalAlignment=GafferUI.Label.HorizontalAlignment.Right,
            verticalAlignment=GafferUI.Label.VerticalAlignment.Top,
        )

        ## \todo Decide how we allow this sort of tweak using the public
        # interface. Perhaps we should have a SizeableContainer or something?
        self.__label.label()._qtWidget().setFixedWidth(self.labelWidth())

        if label is not None:
            warnings.warn(
                "The PlugWidget label parameter is deprecated. Use Metadata instead.",
                DeprecationWarning, 2)
            self.__label.label().setText(label)

        if description is not None:
            warnings.warn(
                "The PlugWidget description parameter is deprecated. Use Metadata instead.",
                DeprecationWarning, 2)
            self.__label.label().setToolTip(description)

        layout.addWidget(self.__label._qtWidget())
        layout.addWidget(self.__valueWidget._qtWidget())

        # The plugValueWidget() may have smarter drop behaviour than the labelPlugValueWidget(),
        # because it has specialised PlugValueWidget._convertValue(). It's also more meaningful to the
        # user if we highlight the plugValueWidget() on dragEnter rather than the label. So we
        # forward the dragEnter/dragLeave/drop signals from the labelPlugValueWidget() to the plugValueWidget().
        self.__dragEnterConnection = self.__label.dragEnterSignal().connect(
            0, Gaffer.WeakMethod(self.__labelDragEnter))
        self.__dragLeaveConnection = self.__label.dragLeaveSignal().connect(
            0, Gaffer.WeakMethod(self.__labelDragLeave))
        self.__dropConnection = self.__label.dropSignal().connect(
            0, Gaffer.WeakMethod(self.__labelDrop))
Ejemplo n.º 8
0
    def __init__(self, childPlug, label=None):

        self.__row = GafferUI.ListContainer(
            GafferUI.ListContainer.Orientation.Horizontal, spacing=4)

        GafferUI.PlugValueWidget.__init__(self, self.__row, childPlug)

        if label is not None or not childPlug.getFlags(
                Gaffer.Plug.Flags.Dynamic):
            nameWidget = GafferUI.LabelPlugValueWidget(
                childPlug,
                horizontalAlignment=GafferUI.Label.HorizontalAlignment.Right,
                verticalAlignment=GafferUI.Label.VerticalAlignment.Center,
            )
            if label is not None:
                nameWidget.label().setText(label)
            nameWidget.label()._qtWidget().setFixedWidth(
                GafferUI.PlugWidget.labelWidth())
            # cheat to get the height of the label to match the height of a line edit
            # so the label and plug widgets align nicely. ideally we'd get the stylesheet
            # sorted for the QLabel so that that happened naturally, but QLabel sizing appears
            # somewhat unpredictable (and is sensitive to HTML in the text as well), making this
            # a tricky task.
            nameWidget.label()._qtWidget().setFixedHeight(20)
        else:
            nameWidget = GafferUI.StringPlugValueWidget(childPlug["name"])
            nameWidget.textWidget()._qtWidget().setFixedWidth(
                GafferUI.PlugWidget.labelWidth())

        self.__row.append(
            nameWidget, verticalAlignment=GafferUI.Label.VerticalAlignment.Top)

        if "enabled" in childPlug:
            self.__row.append(
                GafferUI.BoolPlugValueWidget(
                    childPlug["enabled"],
                    displayMode=GafferUI.BoolWidget.DisplayMode.Switch),
                verticalAlignment=GafferUI.Label.VerticalAlignment.Top,
            )

        self.__row.append(GafferUI.PlugValueWidget.create(childPlug["value"]),
                          expand=True)

        self._updateFromPlug()
Ejemplo n.º 9
0
    def __init__(self, plug, **kw):

        column = GafferUI.ListContainer(
            GafferUI.ListContainer.Orientation.Vertical, spacing=4)

        GafferUI.PlugValueWidget.__init__(self, column, plug, **kw)

        with column:
            with GafferUI.ListContainer(
                    GafferUI.ListContainer.Orientation.Horizontal, spacing=4):
                GafferUI.Label("Display Mode")
                drawModeWidget = GafferUI.MultiSelectionMenu(
                    allowMultipleSelection=False, allowEmptySelection=False)
                drawModeWidget.append("Ramp")
                drawModeWidget.append("Curves")
                drawModeWidget.setSelection("Ramp")
                drawModeWidget.selectionChangedSignal().connect(
                    Gaffer.WeakMethod(self.__drawModeChanged), scoped=False)

                GafferUI.Spacer(imath.V2i(0), parenting={"expand": True})
                GafferUI.PlugWidget(
                    GafferUI.PlugValueWidget.create(plug["interpolation"]))

            self.__splineWidget = GafferUI.SplineWidget()
            if isinstance(
                    plug,
                (Gaffer.SplinefColor3fPlug, Gaffer.SplinefColor4fPlug)):
                self.__splineWidget.setDrawMode(
                    self.__splineWidget.DrawMode.Ramp)
            else:
                self.__splineWidget.setDrawMode(
                    self.__splineWidget.DrawMode.Splines)
            self.__splineWidget._qtWidget().setMinimumHeight(50)

            self.__slider = GafferUI.Slider()
            self.__slider.setMinimumSize(2)
            self.__positionsChangedConnection = self.__slider.positionChangedSignal(
            ).connect(Gaffer.WeakMethod(self.__positionsChanged), scoped=False)
            self.__slider.indexRemovedSignal().connect(Gaffer.WeakMethod(
                self.__indexRemoved),
                                                       scoped=False)
            self.__slider.selectedIndexChangedSignal().connect(
                Gaffer.WeakMethod(self.__selectedIndexChanged), scoped=False)

            self.__lastPositionChangedReason = None
            self.__positionsMergeGroupId = 0

            with GafferUI.ListContainer(
                    GafferUI.ListContainer.Orientation.Horizontal, spacing=4):

                self.__positionLabel = GafferUI.LabelPlugValueWidget(
                    plug.pointXPlug(0))
                self.__positionField = GafferUI.NumericPlugValueWidget(
                    plug.pointXPlug(0))

                self.__valueLabel = GafferUI.LabelPlugValueWidget(
                    plug.pointYPlug(0))
                if isinstance(plug.pointYPlug(0), Gaffer.FloatPlug):
                    self.__valueField = GafferUI.NumericPlugValueWidget(
                        plug.pointYPlug(0))
                else:
                    self.__valueField = GafferUI.ColorPlugValueWidget(
                        plug.pointYPlug(0))

        self.setPlug(plug)