From 0fb5721993cb45703499d909542d1e911bbedba2 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 18 Mar 2024 15:58:38 -0400 Subject: [PATCH 1/7] StyleSheet : Reserve space for `valueChanged` icon --- Changes.md | 1 + python/GafferUI/_StyleSheet.py | 9 +++------ resources/graphics.svg | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Changes.md b/Changes.md index cd6ca1894ec..26624c7da2e 100644 --- a/Changes.md +++ b/Changes.md @@ -29,6 +29,7 @@ Fixes - Display : Fixed shutdown crashes caused by Python slots connected to `driverCreatedSignal()` and `imageReceivedSignal()` [^1]. - LightPositionTool : Fixed crash when changing the tool mode with nothing selected [^1]. - ViewportGadget : Fixed selection issues with Intel GPUs (#901, #2788). +- TransformTool : Fixed alignment of green "value changed" icon for `orientation` plugs. API --- diff --git a/python/GafferUI/_StyleSheet.py b/python/GafferUI/_StyleSheet.py index 23bf1e5ea63..98ae65344a2 100644 --- a/python/GafferUI/_StyleSheet.py +++ b/python/GafferUI/_StyleSheet.py @@ -241,19 +241,16 @@ def styleColor( key ) : QLabel#gafferPlugLabel { /* - QLabel's text layout seems to lurch from one approach - to another in the presence of non-zero padding. So we - need some padding here so that we get a layout that - matches the `gafferValueChanged="true"` styling below. + Ensure that there is enough space reserved for the `valueChanged` + icon whether it is visible or not. */ - padding-left: 1px; + padding-left: 10px; } QLabel#gafferPlugLabel[gafferValueChanged="true"] { background-image: url(:/valueChanged.png); background-repeat: no-repeat; background-position: left; - padding-left: 16px; } QLabel#gafferDefaultRowLabel { diff --git a/resources/graphics.svg b/resources/graphics.svg index 26a72465dd5..d28532bb367 100644 --- a/resources/graphics.svg +++ b/resources/graphics.svg @@ -3309,6 +3309,14 @@ style="display:inline;opacity:0.1;fill:none;fill-opacity:1;stroke:none;stroke-width:0.597614;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:1.10173;stroke-opacity:1;paint-order:markers stroke fill" inkscape:label="activeRenderPassFadedHighlightedIcon" /> + - Date: Mon, 25 Mar 2024 18:09:36 -0400 Subject: [PATCH 2/7] LabelPlugValueWidget : `showValueChangedIndicator` --- Changes.md | 1 + python/GafferUI/LabelPlugValueWidget.py | 11 +++++++++++ python/GafferUI/_StyleSheet.py | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Changes.md b/Changes.md index 26624c7da2e..ec4232f6407 100644 --- a/Changes.md +++ b/Changes.md @@ -39,6 +39,7 @@ API - ProcessorWidget provides a base class for custom widgets, and a factory mechanism for registering them against processors. - SimpleProcessorWidget provides a base class for widgets with a simple summary label and optional action links. - TractorDispatcher : The `preSpoolSignal()` now provides an additional `taskData` argument to slots, which maps from Tractor tasks to information about the Gaffer tasks they will execute. +- LabelPlugValueWidget : Added optional `showValueChangedIndicator` metadata entry. If a plug has this entry set to `False`, the icon next to the label that indicates the value has changed will not be shown. Defaults to `True` if the value is not set. Breaking Changes ---------------- diff --git a/python/GafferUI/LabelPlugValueWidget.py b/python/GafferUI/LabelPlugValueWidget.py index d3eab7fa4f6..c9fb39dfe45 100644 --- a/python/GafferUI/LabelPlugValueWidget.py +++ b/python/GafferUI/LabelPlugValueWidget.py @@ -45,6 +45,8 @@ # Supported plug metadata : # # - "renameable" +# - "showValueChangedIndicator" : If `False`, the indicator that the +# plug value has changed will not be shown. Defaults to `True` if not set. class LabelPlugValueWidget( GafferUI.PlugValueWidget ) : ## \todo Remove alignment arguments. Vertically the only alignment that looks good is `Center`, and @@ -72,6 +74,15 @@ def __init__( self, plug, horizontalAlignment=GafferUI.Label.HorizontalAlignment self.__label._qtWidget().setFixedHeight( 20 ) layout.addWidget( self.__label._qtWidget() ) + showIndicator = False + if all( p.direction() == Gaffer.Plug.Direction.In for p in self.getPlugs() ) : + showIndicator = Gaffer.Metadata.value( self.getPlug(), "showValueChangedIndicator" ) + showIndicator = showIndicator if showIndicator is not None else True + self.__label._qtWidget().setProperty( + "gafferShowValueChangedIndicator", + GafferUI._Variant.toVariant( showIndicator ) + ) + self.__editableLabel = None # we'll make this lazily as needed # Connecting at front so we're called before the slots diff --git a/python/GafferUI/_StyleSheet.py b/python/GafferUI/_StyleSheet.py index 98ae65344a2..5bd7f6ad27c 100644 --- a/python/GafferUI/_StyleSheet.py +++ b/python/GafferUI/_StyleSheet.py @@ -239,7 +239,7 @@ def styleColor( key ) : color: #b0d8fb; } - QLabel#gafferPlugLabel { + QLabel#gafferPlugLabel[gafferShowValueChangedIndicator="true"] { /* Ensure that there is enough space reserved for the `valueChanged` icon whether it is visible or not. @@ -247,7 +247,7 @@ def styleColor( key ) : padding-left: 10px; } - QLabel#gafferPlugLabel[gafferValueChanged="true"] { + QLabel#gafferPlugLabel[gafferShowValueChangedIndicator="true"][gafferValueChanged="true"] { background-image: url(:/valueChanged.png); background-repeat: no-repeat; background-position: left; From 6e9766eca87486cfad268ac1329d568f884331ec Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 2 Apr 2024 17:45:23 -0400 Subject: [PATCH 3/7] RampPlugValueWidget : hide value changed indicator --- python/GafferUI/RampPlugValueWidget.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/GafferUI/RampPlugValueWidget.py b/python/GafferUI/RampPlugValueWidget.py index 45f6b33be3f..095087c6bec 100644 --- a/python/GafferUI/RampPlugValueWidget.py +++ b/python/GafferUI/RampPlugValueWidget.py @@ -83,6 +83,7 @@ def __init__( self, plug, **kw ) : spacing = 4 ) : + Gaffer.Metadata.registerValue( plug.pointXPlug( 0 ), "showValueChangedIndicator", False ) self.__positionLabel = GafferUI.LabelPlugValueWidget( plug.pointXPlug( 0 ), parenting = { "verticalAlignment" : GafferUI.VerticalAlignment.Top } @@ -92,6 +93,7 @@ def __init__( self, plug, **kw ) : parenting = { "verticalAlignment" : GafferUI.VerticalAlignment.Top } ) + Gaffer.Metadata.registerValue( plug.pointYPlug( 0 ), "showValueChangedIndicator", False ) self.__valueLabel = GafferUI.LabelPlugValueWidget( plug.pointYPlug( 0 ), parenting = { "verticalAlignment" : GafferUI.VerticalAlignment.Top } From 7719c2e552c359f801849d18c630f90d34443d09 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 3 Apr 2024 12:29:32 +0100 Subject: [PATCH 4/7] fixup! LabelPlugValueWidget : `showValueChangedIndicator` Fix broken support for multiple plugs - we can't call `getPlug()` because it throws if there is more than one. --- python/GafferUI/LabelPlugValueWidget.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/GafferUI/LabelPlugValueWidget.py b/python/GafferUI/LabelPlugValueWidget.py index c9fb39dfe45..59454711924 100644 --- a/python/GafferUI/LabelPlugValueWidget.py +++ b/python/GafferUI/LabelPlugValueWidget.py @@ -74,13 +74,15 @@ def __init__( self, plug, horizontalAlignment=GafferUI.Label.HorizontalAlignment self.__label._qtWidget().setFixedHeight( 20 ) layout.addWidget( self.__label._qtWidget() ) - showIndicator = False - if all( p.direction() == Gaffer.Plug.Direction.In for p in self.getPlugs() ) : - showIndicator = Gaffer.Metadata.value( self.getPlug(), "showValueChangedIndicator" ) - showIndicator = showIndicator if showIndicator is not None else True self.__label._qtWidget().setProperty( "gafferShowValueChangedIndicator", - GafferUI._Variant.toVariant( showIndicator ) + all( + ( + p.direction() == Gaffer.Plug.Direction.In and + Gaffer.Metadata.value( p, "showValueChangedIndicator" ) != False + ) + for p in self.getPlugs() + ) ) self.__editableLabel = None # we'll make this lazily as needed From 755ea10e9866bcce76738add14123fa607930a42 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 3 Apr 2024 12:35:45 +0100 Subject: [PATCH 5/7] fixup! RampPlugValueWidget : hide value changed indicator We were making serialisable per-instance metadata when a static registration could do the same job. --- python/GafferUI/RampPlugValueWidget.py | 2 -- python/GafferUI/SplinePlugValueWidget.py | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/GafferUI/RampPlugValueWidget.py b/python/GafferUI/RampPlugValueWidget.py index 095087c6bec..45f6b33be3f 100644 --- a/python/GafferUI/RampPlugValueWidget.py +++ b/python/GafferUI/RampPlugValueWidget.py @@ -83,7 +83,6 @@ def __init__( self, plug, **kw ) : spacing = 4 ) : - Gaffer.Metadata.registerValue( plug.pointXPlug( 0 ), "showValueChangedIndicator", False ) self.__positionLabel = GafferUI.LabelPlugValueWidget( plug.pointXPlug( 0 ), parenting = { "verticalAlignment" : GafferUI.VerticalAlignment.Top } @@ -93,7 +92,6 @@ def __init__( self, plug, **kw ) : parenting = { "verticalAlignment" : GafferUI.VerticalAlignment.Top } ) - Gaffer.Metadata.registerValue( plug.pointYPlug( 0 ), "showValueChangedIndicator", False ) self.__valueLabel = GafferUI.LabelPlugValueWidget( plug.pointYPlug( 0 ), parenting = { "verticalAlignment" : GafferUI.VerticalAlignment.Top } diff --git a/python/GafferUI/SplinePlugValueWidget.py b/python/GafferUI/SplinePlugValueWidget.py index 187b05df86a..602fd9712a6 100644 --- a/python/GafferUI/SplinePlugValueWidget.py +++ b/python/GafferUI/SplinePlugValueWidget.py @@ -98,6 +98,8 @@ def __buttonPress( self, button, event ) : Gaffer.Metadata.registerValue( plugType, "interpolation", "plugValueWidget:type", "GafferUI.PresetsPlugValueWidget" ) for name, value in sorted( Gaffer.SplineDefinitionInterpolation.names.items() ): Gaffer.Metadata.registerValue( plugType, "interpolation", "preset:" + name, value ) + Gaffer.Metadata.registerValue( plugType, "p[0-9]*.x", "showValueChangedIndicator", False ) + Gaffer.Metadata.registerValue( plugType, "p[0-9]*.y", "showValueChangedIndicator", False ) ## \todo See comments for `ColorSwatchPlugValueWidget._ColorPlugValueDialogue`. # I think the best approach is probably to move the `acquire()` mechanism to the From bcb073a04bce18aa28a35762ab517015cbcb02f7 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 3 Apr 2024 12:43:20 +0100 Subject: [PATCH 6/7] LabelPlugValueWidget : Add prefix for widget-specific metadata --- Changes.md | 2 +- python/GafferUI/LabelPlugValueWidget.py | 4 ++-- python/GafferUI/SplinePlugValueWidget.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Changes.md b/Changes.md index ec4232f6407..d73422ab2a3 100644 --- a/Changes.md +++ b/Changes.md @@ -39,7 +39,7 @@ API - ProcessorWidget provides a base class for custom widgets, and a factory mechanism for registering them against processors. - SimpleProcessorWidget provides a base class for widgets with a simple summary label and optional action links. - TractorDispatcher : The `preSpoolSignal()` now provides an additional `taskData` argument to slots, which maps from Tractor tasks to information about the Gaffer tasks they will execute. -- LabelPlugValueWidget : Added optional `showValueChangedIndicator` metadata entry. If a plug has this entry set to `False`, the icon next to the label that indicates the value has changed will not be shown. Defaults to `True` if the value is not set. +- LabelPlugValueWidget : Added optional `labelPlugValueWidget:showValueChangedIndicator` metadata entry. If a plug has this entry set to `False`, the icon next to the label that indicates the value has changed will not be shown. Defaults to `True` if the value is not set. Breaking Changes ---------------- diff --git a/python/GafferUI/LabelPlugValueWidget.py b/python/GafferUI/LabelPlugValueWidget.py index 59454711924..f412ba43d62 100644 --- a/python/GafferUI/LabelPlugValueWidget.py +++ b/python/GafferUI/LabelPlugValueWidget.py @@ -45,7 +45,7 @@ # Supported plug metadata : # # - "renameable" -# - "showValueChangedIndicator" : If `False`, the indicator that the +# - "labelPlugValueWidget:showValueChangedIndicator" : If `False`, the indicator that the # plug value has changed will not be shown. Defaults to `True` if not set. class LabelPlugValueWidget( GafferUI.PlugValueWidget ) : @@ -79,7 +79,7 @@ def __init__( self, plug, horizontalAlignment=GafferUI.Label.HorizontalAlignment all( ( p.direction() == Gaffer.Plug.Direction.In and - Gaffer.Metadata.value( p, "showValueChangedIndicator" ) != False + Gaffer.Metadata.value( p, "labelPlugValueWidget:showValueChangedIndicator" ) != False ) for p in self.getPlugs() ) diff --git a/python/GafferUI/SplinePlugValueWidget.py b/python/GafferUI/SplinePlugValueWidget.py index 602fd9712a6..25300fd57cd 100644 --- a/python/GafferUI/SplinePlugValueWidget.py +++ b/python/GafferUI/SplinePlugValueWidget.py @@ -98,8 +98,8 @@ def __buttonPress( self, button, event ) : Gaffer.Metadata.registerValue( plugType, "interpolation", "plugValueWidget:type", "GafferUI.PresetsPlugValueWidget" ) for name, value in sorted( Gaffer.SplineDefinitionInterpolation.names.items() ): Gaffer.Metadata.registerValue( plugType, "interpolation", "preset:" + name, value ) - Gaffer.Metadata.registerValue( plugType, "p[0-9]*.x", "showValueChangedIndicator", False ) - Gaffer.Metadata.registerValue( plugType, "p[0-9]*.y", "showValueChangedIndicator", False ) + Gaffer.Metadata.registerValue( plugType, "p[0-9]*.x", "labelPlugValueWidget:showValueChangedIndicator", False ) + Gaffer.Metadata.registerValue( plugType, "p[0-9]*.y", "labelPlugValueWidget:showValueChangedIndicator", False ) ## \todo See comments for `ColorSwatchPlugValueWidget._ColorPlugValueDialogue`. # I think the best approach is probably to move the `acquire()` mechanism to the From ad9a78bb1b221db11eeec728bfcbbaf8d9e6ef48 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 3 Apr 2024 12:53:47 +0100 Subject: [PATCH 7/7] LabelPlugValueWidget : Remove value changed indicator metadata And instead just use a NameLabel in RampPlugValueWidget. --- Changes.md | 1 - python/GafferUI/LabelPlugValueWidget.py | 7 +------ python/GafferUI/RampPlugValueWidget.py | 17 ++++++++--------- python/GafferUI/SplinePlugValueWidget.py | 2 -- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Changes.md b/Changes.md index d73422ab2a3..26624c7da2e 100644 --- a/Changes.md +++ b/Changes.md @@ -39,7 +39,6 @@ API - ProcessorWidget provides a base class for custom widgets, and a factory mechanism for registering them against processors. - SimpleProcessorWidget provides a base class for widgets with a simple summary label and optional action links. - TractorDispatcher : The `preSpoolSignal()` now provides an additional `taskData` argument to slots, which maps from Tractor tasks to information about the Gaffer tasks they will execute. -- LabelPlugValueWidget : Added optional `labelPlugValueWidget:showValueChangedIndicator` metadata entry. If a plug has this entry set to `False`, the icon next to the label that indicates the value has changed will not be shown. Defaults to `True` if the value is not set. Breaking Changes ---------------- diff --git a/python/GafferUI/LabelPlugValueWidget.py b/python/GafferUI/LabelPlugValueWidget.py index f412ba43d62..a21a15526fe 100644 --- a/python/GafferUI/LabelPlugValueWidget.py +++ b/python/GafferUI/LabelPlugValueWidget.py @@ -45,8 +45,6 @@ # Supported plug metadata : # # - "renameable" -# - "labelPlugValueWidget:showValueChangedIndicator" : If `False`, the indicator that the -# plug value has changed will not be shown. Defaults to `True` if not set. class LabelPlugValueWidget( GafferUI.PlugValueWidget ) : ## \todo Remove alignment arguments. Vertically the only alignment that looks good is `Center`, and @@ -77,10 +75,7 @@ def __init__( self, plug, horizontalAlignment=GafferUI.Label.HorizontalAlignment self.__label._qtWidget().setProperty( "gafferShowValueChangedIndicator", all( - ( - p.direction() == Gaffer.Plug.Direction.In and - Gaffer.Metadata.value( p, "labelPlugValueWidget:showValueChangedIndicator" ) != False - ) + p.direction() == Gaffer.Plug.Direction.In for p in self.getPlugs() ) ) diff --git a/python/GafferUI/RampPlugValueWidget.py b/python/GafferUI/RampPlugValueWidget.py index 45f6b33be3f..2b8e396f9a5 100644 --- a/python/GafferUI/RampPlugValueWidget.py +++ b/python/GafferUI/RampPlugValueWidget.py @@ -83,8 +83,9 @@ def __init__( self, plug, **kw ) : spacing = 4 ) : - self.__positionLabel = GafferUI.LabelPlugValueWidget( + self.__positionLabel = GafferUI.NameLabel( plug.pointXPlug( 0 ), + formatter = lambda _ : "Position", parenting = { "verticalAlignment" : GafferUI.VerticalAlignment.Top } ) self.__positionField = GafferUI.NumericPlugValueWidget( @@ -92,8 +93,9 @@ def __init__( self, plug, **kw ) : parenting = { "verticalAlignment" : GafferUI.VerticalAlignment.Top } ) - self.__valueLabel = GafferUI.LabelPlugValueWidget( + self.__valueLabel = GafferUI.NameLabel( plug.pointYPlug( 0 ), + formatter = lambda _ : "Value", parenting = { "verticalAlignment" : GafferUI.VerticalAlignment.Top } ) if isinstance( plug.pointYPlug( 0 ), Gaffer.FloatPlug ): @@ -211,20 +213,17 @@ def __selectedIndexChanged( self, slider ) : index = slider.getSelectedIndex() if self.getPlug() is not None and index is not None : pointPlug = self.getPlug().pointPlug( index ) - self.__positionLabel.setPlug( pointPlug["x"] ) + self.__positionLabel.setGraphComponent( pointPlug["x"] ) self.__positionField.setPlug( pointPlug["x"] ) - self.__valueLabel.setPlug( pointPlug["y"] ) + self.__valueLabel.setGraphComponent( pointPlug["y"] ) self.__valueField.setPlug( pointPlug["y"] ) else : - self.__positionLabel.setPlug( None ) + self.__positionLabel.setGraphComponent( None ) self.__positionField.setPlug( None ) - self.__valueLabel.setPlug( None ) + self.__valueLabel.setGraphComponent( None ) self.__valueField.setPlug( None ) - self.__positionLabel.label().setText( "Position" ) - self.__valueLabel.label().setText( "Value" ) - # we don't register this automatically for any plugs, as it takes up a lot of room # in the node editor. this means the SplinePlugValueWidget will be used instead, and # that will launch a dialogue containing a RampPlugValueWidget when appropriate. for diff --git a/python/GafferUI/SplinePlugValueWidget.py b/python/GafferUI/SplinePlugValueWidget.py index 25300fd57cd..187b05df86a 100644 --- a/python/GafferUI/SplinePlugValueWidget.py +++ b/python/GafferUI/SplinePlugValueWidget.py @@ -98,8 +98,6 @@ def __buttonPress( self, button, event ) : Gaffer.Metadata.registerValue( plugType, "interpolation", "plugValueWidget:type", "GafferUI.PresetsPlugValueWidget" ) for name, value in sorted( Gaffer.SplineDefinitionInterpolation.names.items() ): Gaffer.Metadata.registerValue( plugType, "interpolation", "preset:" + name, value ) - Gaffer.Metadata.registerValue( plugType, "p[0-9]*.x", "labelPlugValueWidget:showValueChangedIndicator", False ) - Gaffer.Metadata.registerValue( plugType, "p[0-9]*.y", "labelPlugValueWidget:showValueChangedIndicator", False ) ## \todo See comments for `ColorSwatchPlugValueWidget._ColorPlugValueDialogue`. # I think the best approach is probably to move the `acquire()` mechanism to the