Skip to content

Commit

Permalink
ColorChooser : Add spacer between triplets
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Oct 7, 2024
1 parent d5faf39 commit 54e3f99
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion python/GafferUI/ColorChooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ def __init__( self, color=imath.Color3f( 1 ), **kw ) :
# an empty `QFrame` within the `GafferUI.Frame` is not working, so we
# reserve space for each channel with an empty `GafferUI.Image` of the right size.
self.__channelIconPlaceholders = { k : GafferUI.Image( "colorFieldEmptyIcon.png" ) for k in "rgbahsvtmi" }
self.__spacers = {}
self.__componentValueChangedConnections = []

self.__componentToolTip = "Click to use this component in the color field."
Expand All @@ -611,7 +612,8 @@ def __init__( self, color=imath.Color3f( 1 ), **kw ) :

# sliders and numeric widgets
c, staticComponent = self.__colorField.getColor()
for row, component in enumerate( "rgbahsvtmi" ) :
for component in "rgbahsvtmi" :
row = { "r" : 0, "g" : 1, "b" : 2, "a" : 4, "h" : 6, "s" : 7, "v" : 8, "t" : 10, "m" : 11, "i" : 12 }[component]
self.__channelFrames[component] = GafferUI.Frame(
self.__channelIconPlaceholders[component],
borderWidth = 0,
Expand Down Expand Up @@ -694,6 +696,11 @@ def __init__( self, color=imath.Color3f( 1 ), **kw ) :
slider.valueChangedSignal().connect( Gaffer.WeakMethod( self.__componentValueChanged ) )
)

spacerHeight = 2
self.__spacers["a"] = GafferUI.Spacer( imath.V2i( 0, spacerHeight ), parenting = { "index" : ( 0, 3 ) } )
self.__spacers["hsv"] = GafferUI.Spacer( imath.V2i( 0, spacerHeight ), parenting = { "index" : ( 0, 5 ) } )
self.__spacers["tmi"] = GafferUI.Spacer( imath.V2i( 0, spacerHeight ), parenting = { "index" : ( 0, 9 ) } )

# Options Button
GafferUI.MenuButton(
image = "gear.png",
Expand Down Expand Up @@ -1166,6 +1173,13 @@ def __setComponentVisible( self, component, visible ) :
self.__numericWidgets[component].setVisible( visible )
self.__sliders[component].setVisible( visible )

if component == "a" :
self.__spacers["a"].setVisible( visible and any( self.__channelLabels[c].getVisible() for c in "rgb" ) )
elif component in "hsv" :
self.__spacers["hsv"].setVisible( visible and any( self.__channelLabels[c].getVisible() for c in "rgba" ) )
elif component in "tmi" :
self.__spacers["tmi"].setVisible( visible and any( self.__channelLabels[c].getVisible() for c in "rgbahsv" ) )

def __setVisibleComponentsInternal( self, components ) :

componentsSet = set( components )
Expand Down

0 comments on commit 54e3f99

Please sign in to comment.