コード例 #1
0
    def __buildPlugWidgets(self):

        # mapping from plug name to PlugValueWidget for use in plugValueWidget().
        ## \todo Using names makes us vulnerable to plug name changes - do better. We
        # currently have the same problem in CompoundPlugValueWidget, where the problem is
        # worse because the names are much more likely to change.
        self.__plugValueWidgets = {}

        for plug in self.node().children(Gaffer.Plug.staticTypeId()):

            if plug.getName().startswith("__"):
                continue

            sectionName = GafferUI.Metadata.plugValue(
                plug, "nodeUI:section") or self.__defaultSectionName
            if self.__displayMode == self.DisplayMode.Simplified and sectionName != self.__defaultSectionName:
                continue

            widget = GafferUI.PlugValueWidget.create(plug)
            if widget is None:
                continue

            self.__plugValueWidgets[plug.getName()] = widget

            if isinstance(widget,
                          GafferUI.PlugValueWidget) and not widget.hasLabel():
                widget = GafferUI.PlugWidget(widget)

            sectionColumn = self.__sectionColumn(sectionName)
            sectionColumn.append(widget)

            if GafferUI.Metadata.plugValue(plug, "divider"):
                sectionColumn.append(GafferUI.Divider())
コード例 #2
0
    def __init__(self, plug):

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

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

        with column:

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

                self.__plugValueWidgets = []
                self.__plugValueWidgets.append(
                    GafferUI.StringPlugValueWidget(plug["name"]))
                self.__plugValueWidgets.append(
                    GafferUI.BoolPlugValueWidget(
                        plug["enabled"],
                        displayMode=GafferUI.BoolWidget.DisplayMode.Switch))
                self.__plugValueWidgets.append(
                    GafferUI.PlugValueWidget.create(plug["value"]))

                self.__plugValueWidgets[0].textWidget()._qtWidget(
                ).setFixedWidth(self.__labelWidth)

            self.__dragDivider = GafferUI.Divider()

        self._updateFromPlug()
コード例 #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()
コード例 #4
0
	def __init__( self, childPlug ) :

		column = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing=4 )
		GafferUI.PlugValueWidget.__init__( self, column, childPlug )

		with column :

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

				collapseButton = GafferUI.Button( image = "collapsibleArrowRight.png", hasFrame=False )
				collapseButton.__clickedConnection = collapseButton.clickedSignal().connect( Gaffer.WeakMethod( self.__collapseButtonClicked ) )

				GafferUI.PlugValueWidget.create( childPlug["active"] )
				self.__label = GafferUI.Label( self.__namePlug().getValue() )

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

				self.__deleteButton = GafferUI.Button( image = "delete.png", hasFrame=False )
				self.__deleteButton.__clickedConnection = self.__deleteButton.clickedSignal().connect( Gaffer.WeakMethod( self.__deleteButtonClicked ) )
				self.__deleteButton.setVisible( False )

			with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing= 4 ) as self.__detailsColumn :

				GafferUI.PlugWidget( self.__namePlug() )
				GafferUI.PlugWidget( self.__fileNamePlug() )
				GafferUI.PlugWidget( childPlug["type"] )
				GafferUI.PlugWidget( childPlug["data"] )
				GafferUI.CompoundDataPlugValueWidget( childPlug["parameters"] )

				GafferUI.Divider( GafferUI.Divider.Orientation.Horizontal )

			self.__detailsColumn.setVisible( False )

			self.__enterConnection = header.enterSignal().connect( Gaffer.WeakMethod( self.__enter ) )
			self.__leaveConnection = header.leaveSignal().connect( Gaffer.WeakMethod( self.__leave ) )
コード例 #5
0
	def __update( self ) :

		# get the plugs we want to represent
		plugs = self.__parent.children( Gaffer.Plug )
		plugs = [ plug for plug in plugs if not plug.getName().startswith( "__" ) ]

		# reorder them based on metadata
		plugs = self.layoutOrder( plugs )

		# ditch widgets we don't need any more
		plugsSet = set( plugs )
		self.__plugsToWidgets = dict(
			( plug, widget ) for plug, widget in self.__plugsToWidgets.items() if plug in plugsSet
		)

		# make (or reuse existing) uis for each plug
		orderedWidgets = []
		for plug in plugs :
			if plug not in self.__plugsToWidgets :
				widget = self.__createPlugWidget( plug )
				self.__plugsToWidgets[plug] = widget
			else :
				widget = self.__plugsToWidgets[plug]

			if widget is not None :
				orderedWidgets.append( widget )
				if Gaffer.Metadata.plugValue( plug, "divider" ) :
					orderedWidgets.append( GafferUI.Divider(
						GafferUI.Divider.Orientation.Horizontal if self.__mainContainer.orientation() == GafferUI.ListContainer.Orientation.Vertical else GafferUI.Divider.Orientation.Vertical
					) )

		# and update the column to display them in the right order
		self.__mainContainer[:] = orderedWidgets
コード例 #6
0
	def __updateLayout( self ) :

		# get the items to lay out - these are a combination
		# of plugs and strings representing custom widgets.
		items = self.layoutOrder( self.__parent, includeCustomWidgets = True, layoutName = self.__layoutName, rootSection = self.__rootSectionName )

		# ditch widgets we don't need any more

		itemsSet = set( items )
		self.__widgets = { k : v for k, v in self.__widgets.items() if k in itemsSet }

		# ditch widgets whose metadata type has changed - we must recreate these.
		self.__widgets = {
			k : v for k, v in self.__widgets.items()
			if isinstance( k, str ) or v is not None and Gaffer.Metadata.value( k, "plugValueWidget:type" ) == v.__plugValueWidgetType
		}


		# make (or reuse existing) widgets for each item, and sort them into
		# sections.
		rootSectionDepth = self.__rootSectionName.count( "." ) + 1 if self.__rootSectionName else 0
		self.__rootSection.clear()
		for item in items :

			if item not in self.__widgets :
				if isinstance( item, Gaffer.Plug ) :
					widget = self.__createPlugWidget( item )
				else :
					widget = self.__createCustomWidget( item )
				self.__widgets[item] = widget
			else :
				widget = self.__widgets[item]

			if widget is None :
				continue

			section = self.__rootSection
			for sectionName in self.__sectionPath( item )[rootSectionDepth:] :
				section = section.subsection( sectionName )

			if len( section.widgets ) and self.__itemMetadataValue( item, "accessory" ) :
				if isinstance( section.widgets[-1], _AccessoryRow ) :
					section.widgets[-1].append( widget )
				else :
					row = _AccessoryRow()
					row.append( section.widgets[-1] )
					row.append( widget )
					section.widgets[-1] = row
			else :
				section.widgets.append( widget )

			if self.__itemMetadataValue( item, "divider" ) :
				section.widgets.append( GafferUI.Divider(
					GafferUI.Divider.Orientation.Horizontal if self.__layout.orientation() == GafferUI.ListContainer.Orientation.Vertical else GafferUI.Divider.Orientation.Vertical
				) )
コード例 #7
0
	def __init__( self, attribute, **kwargs ) :

		GafferUI.ListContainer.__init__( self, spacing = 8, **kwargs )
		self.__attribute = attribute
		self.__widgets = {}

		with self :

			self.__label = GafferUI.Label( self.__attributeLabel( attribute ) )

			GafferUI.Divider()

			for parameter in _registeredShaderParameters( self.__attribute ) :
				self.__widgets[ parameter ] = _ParameterWidget( parameter )
コード例 #8
0
    def __updateChildPlugUIs(self):

        # ditch child uis we don't need any more
        childPlugs = self.node().children(Gaffer.Plug.staticTypeId())
        childNames = set(self.node().keys())
        for childName in self.__childPlugUIs.keys():
            if childName not in childNames:
                del self.__childPlugUIs[childName]

        # make (or reuse existing) uis for each child plug
        orderedChildUIs = []
        for plug in childPlugs:

            if plug.getName().startswith("__"):
                continue

            if plug.getName() not in self.__childPlugUIs:

                widget = GafferUI.PlugValueWidget.create(plug)
                if widget is not None:

                    if (isinstance(widget, GafferUI.PlugValueWidget)
                            and not widget.hasLabel() and
                            Gaffer.Metadata.plugValue(plug, "label") != ""):
                        widget = GafferUI.PlugWidget(widget)
                        # undo the annoying fixed size the PlugWidget has applied
                        # to the label.
                        ## \todo Shift all the label size fixing out of PlugWidget and
                        # into CompoundPlugValueWidget so we don't have to do this at all.
                        QWIDGETSIZE_MAX = 16777215  # qt #define not exposed by PyQt or PySide
                        widget.labelPlugValueWidget().label()._qtWidget(
                        ).setFixedWidth(QWIDGETSIZE_MAX)

                self.__childPlugUIs[plug.getName()] = widget

            else:

                widget = self.__childPlugUIs[plug.getName()]

            if widget is not None:
                orderedChildUIs.append(widget)
                if Gaffer.Metadata.plugValue(plug, "divider"):
                    orderedChildUIs.append(
                        GafferUI.Divider(
                            GafferUI.Divider.Orientation.Vertical))

        del self.__row[:]  # must clear first, to bypass ListContainer's "helpful" remembering of expand statuses
        self.__row[:] = orderedChildUIs
        self.__row.insert(0, GafferUI.Spacer(IECore.V2i(1, 1)), expand=True)
コード例 #9
0
    def __updateChildPlugUIs(self):

        # ditch child uis we don't need any more
        childNames = set(self.getPlug().keys())
        for childName in self.__childPlugUIs.keys():
            if childName not in childNames:
                del self.__childPlugUIs[childName]

        # make (or reuse existing) uis for each child plug
        orderedChildUIs = []
        for childPlug in self._childPlugs():
            if childPlug.getName().startswith("__"):
                continue
            if childPlug.getName() not in self.__childPlugUIs:
                widget = self._childPlugWidget(childPlug)
                assert (isinstance(widget,
                                   (GafferUI.PlugValueWidget, type(None)))
                        or hasattr(widget, "plugValueWidget"))
                self.__childPlugUIs[childPlug.getName()] = widget
                if widget is not None:
                    if isinstance(widget, GafferUI.PlugValueWidget):
                        widget.setReadOnly(self.getReadOnly())
                    elif isinstance(widget, GafferUI.PlugWidget):
                        widget.labelPlugValueWidget().setReadOnly(
                            self.getReadOnly())
                        widget.plugValueWidget().setReadOnly(
                            self.getReadOnly())
                    else:
                        widget.plugValueWidget().setReadOnly(
                            self.getReadOnly())
            else:
                widget = self.__childPlugUIs[childPlug.getName()]
            if widget is not None:
                orderedChildUIs.append(widget)
                if Gaffer.Metadata.plugValue(childPlug, "divider"):
                    orderedChildUIs.append(GafferUI.Divider())

        # add header and footer
        headerWidget = self._headerWidget()
        if headerWidget is not None:
            orderedChildUIs.insert(0, headerWidget)
        footerWidget = self._footerWidget()
        if footerWidget is not None:
            orderedChildUIs.append(footerWidget)

        # and update the column to display them
        self.__column[:] = orderedChildUIs
コード例 #10
0
ファイル: OutputsUI.py プロジェクト: themissingcow/gaffer
    def __collapseButtonClicked(self, button):

        visible = not self.__detailsColumn.getVisible()

        if visible and not len(self.__detailsColumn):
            # Build details section the first time it is shown,
            # to avoid excessive overhead in the initial UI build.
            with self.__detailsColumn:
                GafferUI.PlugWidget(self.__namePlug())
                GafferUI.PlugWidget(self.__fileNamePlug())
                GafferUI.PlugWidget(self.getPlug()["type"])
                GafferUI.PlugWidget(self.getPlug()["data"])
                GafferUI.CompoundDataPlugValueWidget(
                    self.getPlug()["parameters"])
                GafferUI.Divider(GafferUI.Divider.Orientation.Horizontal)

        self.__detailsColumn.setVisible(visible)
        button.setImage("collapsibleArrowDown.png"
                        if visible else "collapsibleArrowRight.png")
コード例 #11
0
ファイル: NameSwitchUI.py プロジェクト: whitemoonstone/gaffer
    def __init__(self, plug):

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

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

        with column:

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

                self.__dragHandle = _DragHandle()
                with GafferUI.ListContainer(
                        GafferUI.ListContainer.Orientation.Horizontal,
                        spacing=4) as self.__defaultLabel:
                    # Spacers on default row occupy the space taken by PlugValueWidgets on
                    # non-default rows. This keeps the ConnectionPlugValueWidgets in alignment.
                    GafferUI.Spacer(imath.V2i(11, 1))
                    label = GafferUI.Label(
                        "Default",
                        horizontalAlignment=GafferUI.HorizontalAlignment.Left)
                    label._qtWidget().setFixedWidth(self.__labelWidth)
                    GafferUI.Spacer(imath.V2i(25, 1))

                self.__plugValueWidgets = []
                self.__plugValueWidgets.append(
                    GafferUI.StringPlugValueWidget(plug["name"]))
                self.__plugValueWidgets.append(
                    GafferUI.BoolPlugValueWidget(
                        plug["enabled"],
                        displayMode=GafferUI.BoolWidget.DisplayMode.Switch))
                self.__plugValueWidgets.append(
                    GafferUI.PlugValueWidget.create(plug["value"]))

                self.__plugValueWidgets[0].textWidget()._qtWidget(
                ).setFixedWidth(self.__labelWidth)

            self.__dragDivider = GafferUI.Divider()

        self.__updateWidgetVisibility()
        self._updateFromPlug()
コード例 #12
0
    def __init__(self, tool, **kw):

        GafferUI.Frame.__init__(self, borderWidth=4, **kw)

        self.__tool = tool

        with self:
            with GafferUI.ListContainer(orientation=GafferUI.ListContainer.
                                        Orientation.Horizontal) as self.__row:

                self.__infoIcon = GafferUI.Image("infoSmall.png")
                self.__errorIcon = GafferUI.Image("errorSmall.png")
                self.__warningIcon = GafferUI.Image("warningSmall.png")
                GafferUI.Spacer(size=imath.V2i(4), maximumSize=imath.V2i(4))
                self.__label = GafferUI.Label("")

                GafferUI.Spacer(size=imath.V2i(8), maximumSize=imath.V2i(8))
                GafferUI.Divider(
                    orientation=GafferUI.Divider.Orientation.Vertical)
                GafferUI.Spacer(size=imath.V2i(8), maximumSize=imath.V2i(8))

                with GafferUI.ListContainer(
                        orientation=GafferUI.ListContainer.Orientation.
                        Horizontal) as self.__controls:

                    self.__enabledLabel = GafferUI.Label("Enabled")
                    self.__enabled = GafferUI.BoolPlugValueWidget(None)
                    self.__enabled.boolWidget().setDisplayMode(
                        GafferUI.BoolWidget.DisplayMode.Switch)

                    button = GafferUI.Button("Reset")
                    button._qtWidget().setFixedWidth(50)
                    button.clickedSignal().connect(Gaffer.WeakMethod(
                        self.__buttonClicked),
                                                   scoped=False)

        self.__tool.statusChangedSignal().connect(Gaffer.WeakMethod(
            self.__update, fallbackResult=None),
                                                  scoped=False)

        self.__update()
コード例 #13
0
ファイル: CatalogueUI.py プロジェクト: shdwdln/gaffer
    def __init__(self, plug, **kw):

        self.__column = GafferUI.ListContainer(spacing=4)

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

        with self.__column:

            self.__pathListing = GafferUI.PathListingWidget(
                _ImagesPath(self.__images(), []),
                columns=(GafferUI.PathListingWidget.defaultNameColumn, ),
            )
            self.__pathListing.setSortable(False)
            self.__pathListing.setHeaderVisible(False)
            self.__pathListingSelectionChangedConnection = self.__pathListing.selectionChangedSignal(
            ).connect(Gaffer.WeakMethod(self.__pathListingSelectionChanged))
            self.__pathListingDragEnterConnection = self.__pathListing.dragEnterSignal(
            ).connect(Gaffer.WeakMethod(self.__pathListingDragEnter))
            self.__pathListingDragLeaveConnection = self.__pathListing.dragLeaveSignal(
            ).connect(Gaffer.WeakMethod(self.__pathListingDragLeave))
            self.__pathListingDropConnection = self.__pathListing.dropSignal(
            ).connect(Gaffer.WeakMethod(self.__pathListingDrop))

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

                addButton = GafferUI.Button(image="pathChooser.png",
                                            hasFrame=False,
                                            toolTip="Load image")
                self.__addClickedConnection = addButton.clickedSignal(
                ).connect(Gaffer.WeakMethod(self.__addClicked))

                self.__duplicateButton = GafferUI.Button(
                    image="duplicate.png",
                    hasFrame=False,
                    toolTip="Duplicate selected image")
                self.__duplicateButton.setEnabled(False)
                self.__duplicateButtonClickedConnection = self.__duplicateButton.clickedSignal(
                ).connect(Gaffer.WeakMethod(self.__duplicateClicked))

                self.__exportButton = GafferUI.Button(
                    image="export.png",
                    hasFrame=False,
                    toolTip="Export selected image")
                self.__exportButton.setEnabled(False)
                self.__exportButtonClickedConnection = self.__exportButton.clickedSignal(
                ).connect(Gaffer.WeakMethod(self.__exportClicked))

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

                self.__removeButton = GafferUI.Button(
                    image="delete.png",
                    hasFrame=False,
                    toolTip="Remove selected image")
                self.__removeButton.setEnabled(False)
                self.__removeClickedConnection = self.__removeButton.clickedSignal(
                ).connect(Gaffer.WeakMethod(self.__removeClicked))

            GafferUI.Divider()

            with GafferUI.Collapsible(label="Image Properties",
                                      collapsed=False):

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

                    with GafferUI.ListContainer(
                            GafferUI.ListContainer.Orientation.Horizontal,
                            spacing=4):
                        GafferUI.Label("Name")
                        self.__nameWidget = GafferUI.NameWidget(
                            graphComponent=None)

                    GafferUI.Label("Description")
                    self.__descriptionWidget = GafferUI.MultiLineStringPlugValueWidget(
                        plug=None)

        self._updateFromPlug()
コード例 #14
0
    def __init__(self):

        import IECore
        import functools

        GafferUI.GridContainer.__init__(self, spacing=4, borderWidth=4)

        # tool tips
        frameToolTip = "# Frame\n\nThe frame of the currently selected keys."
        valueToolTip = "# Value\n\nThe value of the currently selected keys."
        interpolationToolTip = "# Interpolation\n\nThe interpolation of the currently selected keys."
        tieModeToolTip = "# Tie Mode\n\nThe tie mode of the currently selected keys."
        slopeToolTip = "# Slope\n\nThe slope of the %stangents of the currently selected keys."
        scaleToolTip = "# Scale\n\nThe scale of the %stangents of the currently selected keys."

        # create labels
        frameLabel = GafferUI.Label(text="Frame", toolTip=frameToolTip)
        valueLabel = GafferUI.Label(text="Value", toolTip=valueToolTip)
        interpolationLabel = GafferUI.Label(text="Interpolation",
                                            toolTip=interpolationToolTip)
        tieModeLabel = GafferUI.Label(text="Tie Mode", toolTip=tieModeToolTip)
        slopeLabel = GafferUI.Label(text="Slope", toolTip=(slopeToolTip % ""))
        scaleLabel = GafferUI.Label(text="Scale", toolTip=(scaleToolTip % ""))

        # create editors
        # NOTE: initial value type (e.g. int or float) determines validated value type of widget
        self.__frameEditor = GafferUI.NumericWidget(value=int(0),
                                                    toolTip=frameToolTip)
        self.__valueEditor = GafferUI.NumericWidget(value=float(0),
                                                    toolTip=valueToolTip)
        self.__interpolationEditor = GafferUI.MenuButton(
            toolTip=interpolationToolTip)
        self.__tieModeEditor = GafferUI.MenuButton(toolTip=tieModeToolTip)
        self.__slopeEditor = (GafferUI.NumericWidget(value=float(0),
                                                     toolTip=(slopeToolTip %
                                                              "in ")),
                              GafferUI.NumericWidget(value=float(0),
                                                     toolTip=(slopeToolTip %
                                                              "out ")))
        self.__scaleEditor = (GafferUI.NumericWidget(value=float(0),
                                                     toolTip=(scaleToolTip %
                                                              "in ")),
                              GafferUI.NumericWidget(value=float(0),
                                                     toolTip=(scaleToolTip %
                                                              "out ")))

        # build interpolation menu
        im = IECore.MenuDefinition()
        for mode in sorted(Gaffer.Animation.Interpolation.values.values()):
            im.append(
                "%s" % (mode.name), {
                    "command":
                    functools.partial(
                        Gaffer.WeakMethod(self.__setInterpolation), mode=mode),
                    "checkBox":
                    functools.partial(Gaffer.WeakMethod(
                        self.__checkBoxStateForKeyInterpolation),
                                      mode=mode)
                })
        self.__interpolationEditor.setMenu(GafferUI.Menu(im))

        # build tie mode menu
        tm = IECore.MenuDefinition()
        for mode in sorted(Gaffer.Animation.TieMode.values.values()):
            tm.append(
                "%s" % (mode.name), {
                    "command":
                    functools.partial(Gaffer.WeakMethod(self.__setTieMode),
                                      mode=mode),
                    "checkBox":
                    functools.partial(Gaffer.WeakMethod(
                        self.__checkBoxStateForTieMode),
                                      mode=mode)
                })
        self.__tieModeEditor.setMenu(GafferUI.Menu(tm))

        # setup editor connections
        self.__frameConnection = self.__frameEditor.valueChangedSignal(
        ).connect(Gaffer.WeakMethod(self.__setFrame), scoped=False)
        self.__valueConnection = self.__valueEditor.valueChangedSignal(
        ).connect(Gaffer.WeakMethod(self.__setValue), scoped=False)
        self.__slopeConnection = (
            self.__slopeEditor[
                Gaffer.Animation.Direction.In].valueChangedSignal().connect(
                    functools.partial(Gaffer.WeakMethod(self.__setSlope),
                                      Gaffer.Animation.Direction.In),
                    scoped=False),
            self.__slopeEditor[
                Gaffer.Animation.Direction.Out].valueChangedSignal().connect(
                    functools.partial(Gaffer.WeakMethod(self.__setSlope),
                                      Gaffer.Animation.Direction.Out),
                    scoped=False))
        self.__scaleConnection = (
            self.__scaleEditor[
                Gaffer.Animation.Direction.In].valueChangedSignal().connect(
                    functools.partial(Gaffer.WeakMethod(self.__setScale),
                                      Gaffer.Animation.Direction.In),
                    scoped=False),
            self.__scaleEditor[
                Gaffer.Animation.Direction.Out].valueChangedSignal().connect(
                    functools.partial(Gaffer.WeakMethod(self.__setScale),
                                      Gaffer.Animation.Direction.Out),
                    scoped=False))

        # layout widgets
        alignment = (GafferUI.HorizontalAlignment.Right,
                     GafferUI.VerticalAlignment.Center)
        self.addChild(frameLabel, index=(0, 0), alignment=alignment)
        self[1:3, 0] = self.__frameEditor
        self.addChild(valueLabel, index=(0, 1), alignment=alignment)
        self[1:3, 1] = self.__valueEditor
        self.addChild(interpolationLabel, index=(0, 2), alignment=alignment)
        self[1:3, 2] = self.__interpolationEditor
        self.addChild(tieModeLabel, index=(0, 3), alignment=alignment)
        self[1:3, 3] = self.__tieModeEditor
        self[0:3, 4] = GafferUI.Divider()
        self.addChild(slopeLabel, index=(0, 5), alignment=alignment)
        self[1, 5] = self.__slopeEditor[Gaffer.Animation.Direction.In]
        self[2, 5] = self.__slopeEditor[Gaffer.Animation.Direction.Out]
        self.addChild(scaleLabel, index=(0, 6), alignment=alignment)
        self[1, 6] = self.__scaleEditor[Gaffer.Animation.Direction.In]
        self[2, 6] = self.__scaleEditor[Gaffer.Animation.Direction.Out]

        # curve connections
        self.__connections = {}

        # numeric widget undo queue state
        self.__lastChangedReasonValue = None
        self.__lastChangedReasonFrame = None
        self.__lastChangedReasonSlope = [None, None]
        self.__lastChangedReasonScale = [None, None]
        self.__mergeGroupIdValue = 0
        self.__mergeGroupIdFrame = 0
        self.__mergeGroupIdSlope = [0, 0]
        self.__mergeGroupIdScale = [0, 0]

        # scale of selected keys at start of merge group
        self.__selectedKeysMergeGroupScale = [{}, {}]
コード例 #15
0
    def __init__(self,
                 color=imath.Color3f(1),
                 useDisplayTransform=True,
                 components="rgb-HSL-a",
                 showSwatch=True,
                 **kw):

        self.__column = GafferUI.ListContainer(
            GafferUI.ListContainer.Orientation.Vertical, spacing=4)

        GafferUI.Widget.__init__(self, self.__column, **kw)

        self.__color = color
        self.__defaultColor = color

        self.__sliders = {}
        self.__numericWidgets = {}
        self.__componentValueChangedConnections = []

        with self.__column:

            # sliders and numeric widgets
            for component in components:

                if component == "-":
                    GafferUI.Divider()
                    continue

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

                    label = GafferUI.Label(component.upper(),
                                           horizontalAlignment=GafferUI.Label.
                                           HorizontalAlignment.Center)
                    label._qtWidget().setFixedWidth(20)
                    numericWidget = GafferUI.NumericWidget(0.0)
                    numericWidget.setFixedCharacterWidth(6)
                    numericWidget.component = component
                    self.__numericWidgets[component] = numericWidget

                    slider = _ComponentSlider(
                        color,
                        component,
                        useDisplayTransform=useDisplayTransform)
                    self.__sliders[component] = slider

                    self.__componentValueChangedConnections.append(
                        numericWidget.valueChangedSignal().connect(
                            Gaffer.WeakMethod(self.__componentValueChanged),
                            scoped=False))

                    self.__componentValueChangedConnections.append(
                        slider.valueChangedSignal().connect(Gaffer.WeakMethod(
                            self.__componentValueChanged),
                                                            scoped=False))

            if showSwatch:

                # initial and current colour swatches
                with GafferUI.ListContainer(
                        GafferUI.ListContainer.Orientation.Horizontal,
                        parenting={"expand": True}):

                    self.__initialColorSwatch = GafferUI.ColorSwatch(
                        color,
                        useDisplayTransform=useDisplayTransform,
                        parenting={"expand": True})
                    self.__initialColorSwatch.buttonPressSignal().connect(
                        Gaffer.WeakMethod(self.__initialColorPress),
                        scoped=False)

                    GafferUI.Spacer(imath.V2i(4, 40))

                    self.__colorSwatch = GafferUI.ColorSwatch(
                        color,
                        useDisplayTransform=useDisplayTransform,
                        parenting={"expand": True})

            else:

                self.__initialColorSwatch = None
                self.__colorSwatch = None

        self.__colorChangedSignal = Gaffer.Signal2()

        self.__updateUIFromColor()
コード例 #16
0
    def __init__(self, plug, **kw):

        self.__column = GafferUI.ListContainer(spacing=4)

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

        with self.__column:

            columns = self.__listingColumns()

            self.__pathListing = GafferUI.PathListingWidget(
                _ImagesPath(self.__images(), []),
                columns=columns,
                allowMultipleSelection=True,
                sortable=False,
                horizontalScrollMode=GafferUI.ScrollMode.Automatic)
            self.__pathListing.setDragPointer("")
            self.__pathListing.setHeaderVisible(True)
            self.__pathListing.selectionChangedSignal().connect(
                Gaffer.WeakMethod(self.__pathListingSelectionChanged),
                scoped=False)
            self.__pathListing.dragEnterSignal().connect(Gaffer.WeakMethod(
                self.__pathListingDragEnter),
                                                         scoped=False)
            self.__pathListing.dragLeaveSignal().connect(Gaffer.WeakMethod(
                self.__pathListingDragLeave),
                                                         scoped=False)
            self.__pathListing.dragMoveSignal().connect(Gaffer.WeakMethod(
                self.__pathListingDragMove),
                                                        scoped=False)
            self.__pathListing.dropSignal().connect(Gaffer.WeakMethod(
                self.__pathListingDrop),
                                                    scoped=False)
            self.keyPressSignal().connect(Gaffer.WeakMethod(self.__keyPress),
                                          scoped=False)

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

                addButton = GafferUI.Button(image="pathChooser.png",
                                            hasFrame=False,
                                            toolTip="Load image")
                addButton.clickedSignal().connect(Gaffer.WeakMethod(
                    self.__addClicked),
                                                  scoped=False)

                self.__duplicateButton = GafferUI.Button(
                    image="duplicate.png",
                    hasFrame=False,
                    toolTip=
                    "Duplicate selected image, hold <kbd>alt</kbd> to view copy. [<kbd>Ctrl-D</kbd>]"
                )
                self.__duplicateButton.setEnabled(False)
                self.__duplicateButton.clickedSignal().connect(
                    Gaffer.WeakMethod(self.__duplicateClicked), scoped=False)

                self.__exportButton = GafferUI.Button(
                    image="export.png",
                    hasFrame=False,
                    toolTip="Export selected image")
                self.__exportButton.setEnabled(False)
                self.__exportButton.clickedSignal().connect(Gaffer.WeakMethod(
                    self.__exportClicked),
                                                            scoped=False)

                self.__extractButton = GafferUI.Button(
                    image="extract.png",
                    hasFrame=False,
                    toolTip="Create CatalogueSelect node for selected image")
                self.__extractButton.setEnabled(False)
                self.__extractButton.clickedSignal().connect(Gaffer.WeakMethod(
                    self.__extractClicked),
                                                             scoped=False)

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

                self.__removeButton = GafferUI.Button(
                    image="delete.png",
                    hasFrame=False,
                    toolTip="Remove selected image [<kbd>Delete</kbd>]")
                self.__removeButton.setEnabled(False)
                self.__removeButton.clickedSignal().connect(Gaffer.WeakMethod(
                    self.__removeClicked),
                                                            scoped=False)

            GafferUI.Divider()

            with GafferUI.Collapsible(label="Image Properties",
                                      collapsed=False):

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

                    with GafferUI.ListContainer(
                            GafferUI.ListContainer.Orientation.Horizontal,
                            spacing=4):
                        GafferUI.Label("Name")
                        self.__nameWidget = GafferUI.NameWidget(
                            graphComponent=None)

                    GafferUI.Label("Description")
                    self.__descriptionWidget = GafferUI.MultiLineStringPlugValueWidget(
                        plug=None)

        Gaffer.Metadata.plugValueChangedSignal(plug.node()).connect(
            Gaffer.WeakMethod(self.__plugMetadataValueChanged), scoped=False)

        self.contextMenuSignal().connect(Gaffer.WeakMethod(self.__contextMenu),
                                         scoped=False)

        self._updateFromPlug()