Skip to content

Commit

Permalink
ColorChooser : Improve plug alignment
Browse files Browse the repository at this point in the history
This was broken slightly in GafferHQ#5902 when we introduced channel name
labels. The text width varies somewhat, causing the numeric widget and
sliders to be imperfectly aligned.
  • Loading branch information
ericmehl committed Jul 16, 2024
1 parent a14d565 commit 38bb0e9
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions python/GafferUI/ColorChooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,22 @@ def __init__( self, color=imath.Color3f( 1 ), **kw ) :

with self.__column :

# sliders and numeric widgets
for component in "rgbahsvtmi" :
with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) :
with GafferUI.GridContainer( spacing = 4 ) :

with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 8 ) :
GafferUI.Label( component.capitalize() )
numericWidget = GafferUI.NumericWidget( 0.0 )
# sliders and numeric widgets
for row, component in enumerate( "rgb_a_hsv_tmi" ) :
if component == "_" :
GafferUI.Spacer( imath.V2i( 0, 4 ), imath.V2i( 0, 4 ), parenting = { "index" : ( 0, row ) } )
continue

GafferUI.Label( component.capitalize(), parenting = { "index" : ( 0, row ), "alignment" : ( GafferUI.HorizontalAlignment.Center, GafferUI.VerticalAlignment.Center ) } )
numericWidget = GafferUI.NumericWidget( 0.0, parenting = { "index" : ( 1, row ) } )

numericWidget.setFixedCharacterWidth( 6 )
numericWidget.component = component
self.__numericWidgets[component] = numericWidget

slider = _ComponentSlider( color, component )
slider = _ComponentSlider( color, component, parenting = { "index" : ( 2, row ) } )
self.__sliders[component] = slider

self.__componentValueChangedConnections.append(
Expand All @@ -184,8 +187,6 @@ def __init__( self, color=imath.Color3f( 1 ), **kw ) :
self.__componentValueChangedConnections.append(
slider.valueChangedSignal().connect( Gaffer.WeakMethod( self.__componentValueChanged ), scoped = False )
)
if component in "bavi" :
GafferUI.Spacer( imath.V2i( 0, 4 ), imath.V2i( 0, 4 ) )

# initial and current colour swatches
with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) as self.__swatchRow :
Expand Down

0 comments on commit 38bb0e9

Please sign in to comment.