Skip to content

Commit

Permalink
LabelPlugValueWidget : showValueChangedIndicator
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Apr 2, 2024
1 parent 9167a3a commit b25b038
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----

Expand Down
11 changes: 11 additions & 0 deletions python/GafferUI/LabelPlugValueWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions python/GafferUI/_StyleSheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ 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.
*/
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;
Expand Down

0 comments on commit b25b038

Please sign in to comment.