diff --git a/python/GafferUI/ColorChooser.py b/python/GafferUI/ColorChooser.py index 34bc0bf869..0d641cbc82 100644 --- a/python/GafferUI/ColorChooser.py +++ b/python/GafferUI/ColorChooser.py @@ -235,19 +235,20 @@ def __componentValueChanged( self, componentWidget, reason ) : if componentWidget.component in ( "r", "g", "b", "a" ) : newColor = self.__color.__class__( self.__color ) - + a = { "r" : 0, "g" : 1, "b" : 2, "a" : 3 }[componentWidget.component] newColor[a] = componentValue + + self.__setColorInternal( newColor, reason ) else : newColor = self.__colorHSV.__class__( self.__colorHSV ) a = { "h" : 0, "s" : 1, "v" : 2 }[componentWidget.component] newColor[a] = componentValue - newColor = newColor.hsv2rgb() - self.__setColorInternal( newColor, reason ) + self.__setColorInternal( newColor, reason, True ) - def __setColorInternal( self, color, reason ) : + def __setColorInternal( self, color, reason, hsv = False ) : dragBeginOrEnd = reason in ( GafferUI.Slider.ValueChangedReason.DragBegin, @@ -255,14 +256,18 @@ def __setColorInternal( self, color, reason ) : GafferUI.NumericWidget.ValueChangedReason.DragBegin, GafferUI.NumericWidget.ValueChangedReason.DragEnd, ) - if color != self.__color or dragBeginOrEnd : + + previousColor = self.__colorHSV if hsv else self.__color + + if color != previousColor or dragBeginOrEnd : # we never optimise away drag begin or end, because it's important # that they emit in pairs. - self.__color = color - self.__colorSwatch.setColor( color ) + colorRGB = color.hsv2rgb() if hsv else color + self.__color = colorRGB + self.__colorSwatch.setColor( colorRGB ) self.__colorChangedSignal( self, reason ) - hsv = self.__color.rgb2hsv() + hsv = color if hsv else color.rgb2hsv() hsv[0] = hsv[0] if hsv[1] > 1e-7 and hsv[2] > 1e-7 else self.__colorHSV[0] hsv[1] = hsv[1] if hsv[2] > 1e-7 else self.__colorHSV[1]