diff --git a/Changes.md b/Changes.md index ea3162de00a..e348fb5e4ac 100644 --- a/Changes.md +++ b/Changes.md @@ -20,6 +20,8 @@ Breaking Changes - RenderUI : Removed deprecated `rendererPresetNames()` function. - Menu : Removed support for `enter` and `leave` properties on menu items. - SceneEditor : Removed `numInputs` argument to `Settings` constructor. +- UserPlugs : Removed - use `PlugCreationWidget` instead. +- CompoundDataPlugValueWidget : Removed. LayoutPlugValueWidget and PlugCreationWidget replace all previous functionality. 1.6.x.x (relative to 1.6.7.0) ======= diff --git a/python/GafferSceneUI/AttributesUI.py b/python/GafferSceneUI/AttributesUI.py index 195e1b4af1a..f3c1a7749f4 100644 --- a/python/GafferSceneUI/AttributesUI.py +++ b/python/GafferSceneUI/AttributesUI.py @@ -100,7 +100,7 @@ def __attributePresets( plug ) : interface, or using the CompoundDataPlug API via python. """, - "compoundDataPlugValueWidget:editable" : False, + "layout:customWidget:addButton:visibilityActivator" : False, }, diff --git a/python/GafferSceneUI/CameraUI.py b/python/GafferSceneUI/CameraUI.py index deae2dc9c1a..6fddd621e94 100644 --- a/python/GafferSceneUI/CameraUI.py +++ b/python/GafferSceneUI/CameraUI.py @@ -349,7 +349,7 @@ corresponding global render options. """, "layout:section" : "Render Overrides", - "compoundDataPlugValueWidget:editable" : False, + "layout:customWidget:addButton:visibilityActivator" : False, }, @@ -383,7 +383,7 @@ """, "layout:section" : "Visualisation", - "compoundDataPlugValueWidget:editable" : False, + "layout:customWidget:addButton:visibilityActivator" : False, }, diff --git a/python/GafferSceneUI/CustomAttributesUI.py b/python/GafferSceneUI/CustomAttributesUI.py index 8529d6cecd2..feb7fbe1949 100644 --- a/python/GafferSceneUI/CustomAttributesUI.py +++ b/python/GafferSceneUI/CustomAttributesUI.py @@ -63,7 +63,7 @@ "attributes" : { "plugCreationWidget:excludedTypes" : "Gaffer.ObjectPlug", - "compoundDataPlugValueWidget:editable" : True, + "layout:customWidget:addButton:visibilityActivator" : True, "ui:scene:acceptsAttributes" : True, }, diff --git a/python/GafferSceneUI/CustomOptionsUI.py b/python/GafferSceneUI/CustomOptionsUI.py index 6d6d6e29886..ce81229c308 100644 --- a/python/GafferSceneUI/CustomOptionsUI.py +++ b/python/GafferSceneUI/CustomOptionsUI.py @@ -69,7 +69,7 @@ """, "plugCreationWidget:excludedTypes" : "Gaffer.ObjectPlug", - "compoundDataPlugValueWidget:editable" : True, + "layout:customWidget:addButton:visibilityActivator" : True, "ui:scene:acceptsOptions" : True, }, diff --git a/python/GafferSceneUI/LightUI.py b/python/GafferSceneUI/LightUI.py index a67042b898b..0168b4ee1d2 100644 --- a/python/GafferSceneUI/LightUI.py +++ b/python/GafferSceneUI/LightUI.py @@ -200,7 +200,7 @@ def __parameterMetadata( plug, key ) : """, "layout:section" : "Visualisation", - "compoundDataPlugValueWidget:editable" : False, + "layout:customWidget:addButton:visibilityActivator" : False, "layout:activator:lookThroughApertureVisibility" : lambda parentPlug : __lightTypeMatches( parentPlug.node(), ["distant"] ), "layout:activator:lookThroughClippingPlanesVisibility" : lambda parentPlug : __lightTypeMatches( parentPlug.node(), ["distant", "spot"] ), diff --git a/python/GafferSceneUI/OptionsUI.py b/python/GafferSceneUI/OptionsUI.py index d8a3bea0155..649d8b819ff 100644 --- a/python/GafferSceneUI/OptionsUI.py +++ b/python/GafferSceneUI/OptionsUI.py @@ -98,7 +98,7 @@ def __optionPresets( plug ) : python. """, - "compoundDataPlugValueWidget:editable" : False, + "layout:customWidget:addButton:visibilityActivator" : False, }, diff --git a/python/GafferSceneUI/OutputsUI.py b/python/GafferSceneUI/OutputsUI.py index 31716e00d70..dff5c0c257f 100644 --- a/python/GafferSceneUI/OutputsUI.py +++ b/python/GafferSceneUI/OutputsUI.py @@ -261,7 +261,7 @@ def __collapseButtonClicked( self, button ) : GafferUI.PlugWidget( self.getPlug()["fileName"] ) GafferUI.PlugWidget( self.getPlug()["type"] ) GafferUI.PlugWidget( self.getPlug()["data"] ) - GafferUI.CompoundDataPlugValueWidget( self.getPlug()["parameters"] ) + GafferUI.PlugValueWidget.create( self.getPlug()["parameters"] ) GafferUI.Divider( GafferUI.Divider.Orientation.Horizontal ) self.__detailsColumn.setVisible( visible ) diff --git a/python/GafferUITest/CompoundDataPlugValueWidgetTest.py b/python/GafferUI/CompoundDataPlugUI.py similarity index 66% rename from python/GafferUITest/CompoundDataPlugValueWidgetTest.py rename to python/GafferUI/CompoundDataPlugUI.py index fcc1f159c8b..7604ded557e 100644 --- a/python/GafferUITest/CompoundDataPlugValueWidgetTest.py +++ b/python/GafferUI/CompoundDataPlugUI.py @@ -1,6 +1,7 @@ ########################################################################## # -# Copyright (c) 2015, Image Engine Design Inc. All rights reserved. +# Copyright (c) 2012, John Haddon. All rights reserved. +# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -34,32 +35,12 @@ # ########################################################################## -import unittest - import Gaffer -import GafferUI -import GafferUITest - -class CompoundDataPlugValueWidgetTest( GafferUITest.TestCase ) : - - def testSetPlug( self ) : - - n = Gaffer.Node() - n["user"]["p1"] = Gaffer.CompoundDataPlug() - n["user"]["p2"] = Gaffer.CompoundDataPlug() - - m1 = Gaffer.NameValuePlug( "test", 10 ) - n["user"]["p1"].addChild( m1 ) - m2 = Gaffer.NameValuePlug( "test", 10 ) - n["user"]["p2"].addChild( m2 ) - - w = GafferUI.CompoundDataPlugValueWidget( n["user"]["p1"] ) - w1 = w.childPlugValueWidget( m1 ) - self.assertTrue( w1.getPlug().isSame( m1 ) ) - - w.setPlug( n["user"]["p2"] ) - w2 = w.childPlugValueWidget( m2 ) - self.assertTrue( w2.getPlug().isSame( m2 ) ) -if __name__ == "__main__": - unittest.main() +Gaffer.Metadata.registerValue( Gaffer.CompoundDataPlug, "*", "deletable", lambda plug : plug.getFlags( Gaffer.Plug.Flags.Dynamic ) ) +Gaffer.Metadata.registerValue( Gaffer.CompoundDataPlug, "plugValueWidget:type", "GafferUI.LayoutPlugValueWidget" ) +# Of all CompoundDataPlug clients to date, the majority want a PlugCreationWidget. So we register one by +# default and turn it off again in clients that don't want it. +Gaffer.Metadata.registerValue( Gaffer.CompoundDataPlug, "layout:customWidget:addButton:widgetType", "GafferUI.PlugCreationWidget" ) +Gaffer.Metadata.registerValue( Gaffer.CompoundDataPlug, "layout:customWidget:addButton:index", -1 ), # Last +Gaffer.Metadata.registerValue( Gaffer.CompoundDataPlug, "plugCreationWidget:useGeometricInterpretation", True ) diff --git a/python/GafferUI/CompoundDataPlugValueWidget.py b/python/GafferUI/CompoundDataPlugValueWidget.py deleted file mode 100644 index cac558453ed..00000000000 --- a/python/GafferUI/CompoundDataPlugValueWidget.py +++ /dev/null @@ -1,98 +0,0 @@ -########################################################################## -# -# Copyright (c) 2012, John Haddon. All rights reserved. -# Copyright (c) 2013, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with -# the distribution. -# -# * Neither the name of John Haddon nor the names of -# any other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import Gaffer -import GafferUI - -## Supported plug metadata : -# -# "compoundDataPlugValueWidget:editable" -# -## \deprecated Use LayoutPlugValueWidget and PlugCreationWidget -# directly instead. -class CompoundDataPlugValueWidget( GafferUI.PlugValueWidget ) : - - def __init__( self, plug, **kw ) : - - self.__column = GafferUI.ListContainer( spacing = 6 ) - - GafferUI.PlugValueWidget.__init__( self, self.__column, plug, **kw ) - - with self.__column : - - self.__layout = GafferUI.PlugLayout( plug ) - self.__plugCreationWidget = GafferUI.PlugCreationWidget( plug ) - - def hasLabel( self ) : - - return True - - def setPlug( self, plug ) : - - GafferUI.PlugValueWidget.setPlug( self, plug ) - - self.__layout = GafferUI.PlugLayout( plug ) - self.__plugCreationWidget = GafferUI.PlugCreationWidget( plug ) - self.__column[:] = [ self.__layout, self.__plugCreationWidget ] - - def childPlugValueWidget( self, childPlug ) : - - return self.__layout.plugValueWidget( childPlug ) - - def _updateFromMetadata( self ) : - - editable = Gaffer.Metadata.value( self.getPlug(), "compoundDataPlugValueWidget:editable" ) - editable = editable if editable is not None else True - self.__plugCreationWidget.setVisible( editable ) - - def _updateFromEditable( self ) : - - # Not using `_editable()` as it considers the whole plug to be non-editable if - # any child has an input connection, but that shouldn't prevent us adding a new - # child. - self.__plugCreationWidget.setEnabled( - self.getPlug().getInput() is None and not Gaffer.MetadataAlgo.readOnly( self.getPlug() ) - ) - -GafferUI.PlugValueWidget.registerType( Gaffer.CompoundDataPlug, CompoundDataPlugValueWidget ) - -########################################################################## -# Plug metadata -########################################################################## - -Gaffer.Metadata.registerValue( Gaffer.CompoundDataPlug, "*", "deletable", lambda plug : plug.getFlags( Gaffer.Plug.Flags.Dynamic ) ) -Gaffer.Metadata.registerValue( Gaffer.CompoundDataPlug, "plugCreationWidget:useGeometricInterpretation", True ) diff --git a/python/GafferUI/UserPlugs.py b/python/GafferUI/UserPlugs.py deleted file mode 100644 index 18e4d4bfd41..00000000000 --- a/python/GafferUI/UserPlugs.py +++ /dev/null @@ -1,155 +0,0 @@ -########################################################################## -# -# Copyright (c) 2015, Image Engine Design Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above -# copyright notice, this list of conditions and the following -# disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with -# the distribution. -# -# * Neither the name of John Haddon nor the names of -# any other contributors to this software may be used to endorse or -# promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -########################################################################## - -import functools -import warnings - -import imath - -import IECore - -import Gaffer -import GafferUI - -## \deprecated. Remove in version 1.7. -def appendPlugCreationMenuDefinitions( plugParent, menuDefinition, prefix = "" ) : - - warnings.warn( "GafferUI.UserPlugs is deprecated, use PlugCreationWidget instead.", DeprecationWarning, 2 ) - - active = not Gaffer.MetadataAlgo.readOnly( plugParent ) - - menuDefinition.append( prefix + "/Bool", { "command" : functools.partial( __addPlug, plugParent, Gaffer.BoolPlug ), "active" : active } ) - menuDefinition.append( prefix + "/Float", { "command" : functools.partial( __addPlug, plugParent, Gaffer.FloatPlug ), "active" : active } ) - menuDefinition.append( prefix + "/Int", { "command" : functools.partial( __addPlug, plugParent, Gaffer.IntPlug ), "active" : active } ) - menuDefinition.append( prefix + "/NumericDivider", { "divider" : True } ) - - menuDefinition.append( prefix + "/String", { "command" : functools.partial( __addPlug, plugParent, Gaffer.StringPlug ), "active" : active } ) - menuDefinition.append( prefix + "/StringDivider", { "divider" : True } ) - - menuDefinition.append( prefix + "/V2i", { "command" : functools.partial( __addPlug, plugParent, Gaffer.V2iPlug ), "active" : active } ) - menuDefinition.append( prefix + "/V3i", { "command" : functools.partial( __addPlug, plugParent, Gaffer.V3iPlug ), "active" : active } ) - menuDefinition.append( prefix + "/V2f", { "command" : functools.partial( __addPlug, plugParent, Gaffer.V2fPlug ), "active" : active } ) - menuDefinition.append( prefix + "/V3f", { "command" : functools.partial( __addPlug, plugParent, Gaffer.V3fPlug ), "active" : active } ) - menuDefinition.append( prefix + "/VectorDivider", { "divider" : True } ) - - menuDefinition.append( prefix + "/Color3f", { "command" : functools.partial( __addPlug, plugParent, Gaffer.Color3fPlug ), "active" : active } ) - menuDefinition.append( prefix + "/Color4f", { "command" : functools.partial( __addPlug, plugParent, Gaffer.Color4fPlug ), "active" : active } ) - menuDefinition.append( prefix + "/ColorDivider", { "divider" : True } ) - - # Arrays - - for label, plugType in [ - ( "Float", Gaffer.FloatVectorDataPlug ), - ( "Int", Gaffer.IntVectorDataPlug ), - ( "NumericDivider", None ), - ( "String", Gaffer.StringVectorDataPlug ), - ] : - if plugType is not None : - menuDefinition.append( - prefix + "/Array/" + label, - { - "command" : functools.partial( - __addPlug, plugParent, - plugCreator = functools.partial( plugType, defaultValue = plugType.ValueType() ) - ), - "active" : active - } - ) - else : - menuDefinition.append( prefix + "/Array/" + label, { "divider" : True } ) - -## \deprecated. Remove in version 1.7. -def plugCreationWidget( plugParent ) : - - warnings.warn( "GafferUI.UserPlugs is deprecated, use PlugCreationWidget instead.", DeprecationWarning, 2 ) - return __PlugCreationWidget( plugParent ) - -def __addPlug( plugParent, plugCreator, **kw ) : - - with Gaffer.UndoScope( plugParent.ancestor( Gaffer.ScriptNode ) ) : - plug = plugCreator( flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) - Gaffer.Metadata.registerValue( plug, "nodule:type", "" ) - plugParent.addChild( plug ) - -## \todo Maybe it would make more sense to expose this directly? -class __PlugCreationWidget( GafferUI.Widget ) : - - def __init__( self, plugParent, **kw ) : - - row = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal ) - GafferUI.Widget.__init__( self, row, **kw ) - - with row : - GafferUI.Spacer( imath.V2i( GafferUI.PlugWidget.labelWidth(), 1 ) ) - self.__button = GafferUI.MenuButton( - image="plus.png", - hasFrame=False, - menu=GafferUI.Menu( Gaffer.WeakMethod( self.__menuDefinition ) ), - toolTip = "Click to add plugs" - ) - GafferUI.Spacer( imath.V2i( 1 ), imath.V2i( 999999, 1 ), parenting = { "expand" : True } ) - - self.__plugParent = plugParent - - Gaffer.Metadata.nodeValueChangedSignal().connect( - Gaffer.WeakMethod( self.__nodeMetadataChanged ) - ) - if isinstance( plugParent, Gaffer.Plug ) : - Gaffer.Metadata.plugValueChangedSignal( plugParent.node() ).connect( - Gaffer.WeakMethod( self.__plugMetadataChanged ) - ) - - self.__updateReadOnly() - - def __menuDefinition( self ) : - - result = IECore.MenuDefinition() - appendPlugCreationMenuDefinitions( self.__plugParent, result ) - return result - - def __updateReadOnly( self ) : - - self.__button.setEnabled( not Gaffer.MetadataAlgo.readOnly( self.__plugParent ) ) - - def __nodeMetadataChanged( self, nodeTypeId, key, node ) : - - if Gaffer.MetadataAlgo.readOnlyAffectedByChange( self.__plugParent, nodeTypeId, key, node ) : - self.__updateReadOnly() - - def __plugMetadataChanged( self, plug, key, reason ) : - - if Gaffer.MetadataAlgo.readOnlyAffectedByChange( self.__plugParent, plug, key ) : - self.__updateReadOnly() diff --git a/python/GafferUI/__init__.py b/python/GafferUI/__init__.py index a1c612df7e2..2dba2e188fc 100644 --- a/python/GafferUI/__init__.py +++ b/python/GafferUI/__init__.py @@ -221,7 +221,6 @@ def __shiboken() : from . import FileMenu from . import LayoutMenu from . import EditMenu -from . import UserPlugs from .Frame import Frame from .CompoundNumericPlugValueWidget import CompoundNumericPlugValueWidget from .BoxPlugValueWidget import BoxPlugValueWidget @@ -242,7 +241,7 @@ def __shiboken() : from .GraphComponentBrowserMode import GraphComponentBrowserMode from .ToolPlugValueWidget import ToolPlugValueWidget from .LabelPlugValueWidget import LabelPlugValueWidget -from .CompoundDataPlugValueWidget import CompoundDataPlugValueWidget +from . import CompoundDataPlugUI from .LayoutPlugValueWidget import LayoutPlugValueWidget from . import ScriptNodeUI from .RefreshPlugValueWidget import RefreshPlugValueWidget diff --git a/python/GafferUITest/__init__.py b/python/GafferUITest/__init__.py index f8996613514..5f35e483357 100644 --- a/python/GafferUITest/__init__.py +++ b/python/GafferUITest/__init__.py @@ -101,7 +101,6 @@ from .LazyMethodTest import LazyMethodTest from .BackgroundMethodTest import BackgroundMethodTest from .ReferenceUITest import ReferenceUITest -from .CompoundDataPlugValueWidgetTest import CompoundDataPlugValueWidgetTest from .GraphGadgetTest import GraphGadgetTest from .MenuBarTest import MenuBarTest from .GadgetWidgetTest import GadgetWidgetTest