From b25b038edbb40d12dfcd42a143a8f24d26e055c5 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 25 Mar 2024 18:09:36 -0400 Subject: [PATCH] LabelPlugValueWidget : `showValueChangedIndicator` --- Changes.md | 5 +++++ python/GafferUI/LabelPlugValueWidget.py | 11 +++++++++++ python/GafferUI/_StyleSheet.py | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Changes.md b/Changes.md index b39c770dedf..b36cfac22c3 100644 --- a/Changes.md +++ b/Changes.md @@ -8,6 +8,11 @@ Features - USD Kind : When selecting, the first ancestor location with a `usd:kind` attribute matching the chosen list of USD Kind will ultimately be selected. USD's Kind Registry includes `Assembly`, `Component`, `Group`, `Model` and `SubComponent` by default and can be extended via USD startup scripts. - Shader Assignment : When selecting, the first ancestor location with a renderable and direct (not inherited) shader attribute will ultimately be selected. This can be used to select either surface or displacement shaders. +Improvements +------------ + +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. + Fixes ----- 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;