def testSelectedKeysContainsSignature(self): k = Gaffer.Animation.Key() g = GafferUI.AnimationGadget() s = g.selectedKeys() self.assertIsNotNone(s) self.assertFalse(s.contains(k))
def __init__(self, scriptNode, **kw): mainRow = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, borderWidth=5, spacing=5) GafferUI.NodeSetEditor.__init__(self, mainRow, scriptNode, **kw) # Set up widget for curve names on the left self.__curveList = GafferUI.PathListingWidget( Gaffer.DictPath( {}, "/"), # placeholder, updated in `_updateFromSet()`. columns=(GafferUI.PathListingWidget.defaultNameColumn, ), displayMode=GafferUI.PathListingWidget.DisplayMode.Tree, allowMultipleSelection=True) self.__curveList._qtWidget().setMinimumSize(160, 0) self.__curveList._qtWidget().setSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Ignored) self.__curveList.expansionChangedSignal().connect(Gaffer.WeakMethod( self.__updateGadgetSets), scoped=False) self.__selectionChangedConnection = self.__curveList.selectionChangedSignal( ).connect(Gaffer.WeakMethod(self.__updateGadgetSets), scoped=False) # Set up the widget responsible for actual curve drawing self.__animationGadget = GafferUI.AnimationGadget() # Set up signals needed to update selection state in PathListingWidget editable = self.__animationGadget.editablePlugs() self.__editablePlugsConnections = [ editable.memberAddedSignal().connect(Gaffer.WeakMethod( self.__editablePlugAdded), scoped=False), editable.memberRemovedSignal().connect(Gaffer.WeakMethod( self.__editablePlugRemoved), scoped=False) ] self.__gadgetWidget = GafferUI.GadgetWidget( bufferOptions={ GafferUI.GLWidget.BufferOptions.Depth, GafferUI.GLWidget.BufferOptions.Double }) self.__gadgetWidget.getViewportGadget().setPrimaryChild( self.__animationGadget) self.__gadgetWidget.getViewportGadget().setVariableAspectZoom(True) # Set up the widget responsible for curve editing self.__curveEditor = _CurveEditor(self.__animationGadget) # Assemble UI self.__splitMain = GafferUI.SplitContainer( orientation=GafferUI.SplitContainer.Orientation.Horizontal) self.__splitSide = GafferUI.SplitContainer( orientation=GafferUI.SplitContainer.Orientation.Vertical) mainRow.addChild(self.__splitMain) self.__splitSide.append(self.__curveList) self.__splitSide.append(self.__curveEditor) self.__splitMain.append(self.__splitSide) self.__splitMain.append(self.__gadgetWidget) # Initial allocation of screen space: # If there's enough space for the list to get 160 pixels give the rest to the AnimationGadget. # If that's not the case, divide the space 50/50 # \todo: do we want to preserve that ratio when maximizing the window as being done currently? self.__splitMain.setSizes((1, 1)) currentSizes = self.__splitMain.getSizes() if currentSizes[0] > 160: total = sum(currentSizes) betterSize = [float(x) / total for x in [160, total - 160]] self.__splitMain.setSizes(betterSize) # set initial state self._updateFromSet() self._updateFromContext(["frame"]) self.__curveList._qtWidget().adjustSize() # \todo: is this a reasonable initial framing? bound = imath.Box3f(imath.V3f(-1, -1, 0), imath.V3f(10, 10, 0)) self.__gadgetWidget.getViewportGadget().frame(bound) # connect context menu for animation gadget self.__gadgetWidget.contextMenuSignal().connect(Gaffer.WeakMethod( self.__animationGadgetContextMenu), scoped=False)