From 08e984166687f97bb04890e5d7ae1624410fa2d2 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Mon, 30 Sep 2024 15:24:56 -0400 Subject: [PATCH 1/2] ColorPlugValueWidget : Lazy `ColorShooser` create --- Changes.md | 1 + python/GafferUI/ColorPlugValueWidget.py | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Changes.md b/Changes.md index d39c768429a..f0395291984 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ Improvements ------------ - NumericWidget : Added the ability to use Ctrl + scroll wheel to adjust values in the same manner as Up and Down (#6009). +- ColorPlugValueWidget : Improved performance when creating the widget with the color chooser hidden. Fixes ----- diff --git a/python/GafferUI/ColorPlugValueWidget.py b/python/GafferUI/ColorPlugValueWidget.py index 78260002df8..97503137f08 100644 --- a/python/GafferUI/ColorPlugValueWidget.py +++ b/python/GafferUI/ColorPlugValueWidget.py @@ -64,7 +64,7 @@ def __init__( self, plugs, **kw ) : self.__chooserButton = GafferUI.Button( image = "colorPlugValueWidgetSlidersOff.png", hasFrame = False ) self.__chooserButton.clickedSignal().connect( Gaffer.WeakMethod( self.__chooserButtonClicked ), scoped = False ) - self.__colorChooser = GafferUI.ColorChooserPlugValueWidget( plugs ) + self.__colorChooser = None self.setColorChooserVisible( sole( Gaffer.Metadata.value( plug, "colorPlugValueWidget:colorChooserVisible" ) for plug in self.getPlugs() ) @@ -78,10 +78,15 @@ def setColorChooserVisible( self, visible ) : self.__colorChooserVisible = visible - self.__colorChooser.setVisible( - self.__colorChooserVisible and - not any( p.direction() == Gaffer.Plug.Direction.Out for p in self.getPlugs() ) - ) + if visible and self.__colorChooser is None : + self.__colorChooser = GafferUI.ColorChooserPlugValueWidget( self.getPlugs() ) + self.__column.append( self.__colorChooser ) + + if self.__colorChooser is not None : + self.__colorChooser.setVisible( + self.__colorChooserVisible and + not any( p.direction() == Gaffer.Plug.Direction.Out for p in self.getPlugs() ) + ) self.__chooserButton.setImage( "colorPlugValueWidgetSliders{}.png".format( "On" if visible else "Off" ) @@ -89,14 +94,15 @@ def setColorChooserVisible( self, visible ) : def getColorChooserVisible( self ) : - return self.__colorChooser.getVisible() + return self.__colorChooser.getVisible() if self.__colorChooser is not None else False def setPlugs( self, plugs ) : GafferUI.PlugValueWidget.setPlugs( self, plugs ) self.__compoundNumericWidget.setPlugs( plugs ) - self.__colorChooser.setPlugs( plugs ) + if self.__colorChooser is not None : + self.__colorChooser.setPlugs( plugs ) self.__swatch.setPlugs( plugs ) # Update widget visibility if the plug directions changed From dfde6078cdf26f79d9280dbdaf9cbf71cefbd27f Mon Sep 17 00:00:00 2001 From: John Haddon Date: Tue, 1 Oct 2024 09:55:39 +0100 Subject: [PATCH 2/2] Changes.md : Tweak wording Trying to make it more meaningful to the average user. --- Changes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changes.md b/Changes.md index f0395291984..6f6e84604ba 100644 --- a/Changes.md +++ b/Changes.md @@ -5,7 +5,7 @@ Improvements ------------ - NumericWidget : Added the ability to use Ctrl + scroll wheel to adjust values in the same manner as Up and Down (#6009). -- ColorPlugValueWidget : Improved performance when creating the widget with the color chooser hidden. +- NodeEditor : Improved performance when showing a node with many colour plugs. Showing the Arnold `standard_surface` shader is now almost 2x faster. Fixes -----