Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColorChooser : Hollow circle indicator #6097

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Improvements

- Light Editor : Added `is_sphere` column for Cycles lights.
- Windows : Gaffer now uses the TBB memory allocator for significantly better performance.
- ColorChooser : Changed the color field widget to a color wheel when hue is one of the varying components. [^1]
- ColorChooser :
- Changed the color field widget to a color wheel when hue is one of the varying components. [^1]
- Changed the indicator for the color field and color sliders to an unfilled circle so the chosen color is visible in the center.

API
---
Expand Down
66 changes: 57 additions & 9 deletions python/GafferUI/ColorChooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ def _rgbToTMI( c ) :
"i" : __Range( 0, 1, -sys.float_info.max, sys.float_info.max ),
}

def _drawIndicator( painter, position ) :

painter.setBrush( QtCore.Qt.transparent )

pen = QtGui.QPen( QtGui.QColor( 0, 0, 0, 255 ) )
pen.setWidth( 1 )
painter.setPen( pen )

painter.drawEllipse( position, 4.5, 4.5 )

pen.setColor( QtGui.QColor( 255, 255, 255, 255 ) )
painter.setPen( pen )
painter.drawEllipse( position, 3.5, 3.5 )

# A custom slider for drawing the backgrounds.
class _ComponentSlider( GafferUI.Slider ) :

Expand Down Expand Up @@ -158,6 +172,40 @@ def _drawBackground( self, painter ) :
brush = QtGui.QBrush( grad )
painter.fillRect( 0, 0, size.x, size.y, brush )

def _drawValue( self, painter, value, position, state ) :

size = self.size()

if position >= 0 and position <= size.x :
_drawIndicator( painter, QtCore.QPoint( position, size.y / 2 ) )
return

pen = QtGui.QPen( QtGui.QColor( 0, 0, 0, 255 ) )
pen.setWidth( 1 )
painter.setPen( pen )
painter.setBrush( QtGui.QColor( 255, 255, 255, 255 ) )

if position < 0 :
painter.drawPolygon(
QtGui.QPolygonF(
[
QtCore.QPointF( 8, 4 ),
QtCore.QPointF( 8, size.y - 4 ),
QtCore.QPointF( 2, size.y / 2 ),
]
)
)
elif position > size.x :
painter.drawPolygon(
QtGui.QPolygonF(
[
QtCore.QPointF( size.x - 8, 4 ),
QtCore.QPointF( size.x - 8, size.y - 4 ),
QtCore.QPointF( size.x - 2, size.y / 2 ),
]
)
)

def _displayTransformChanged( self ) :

GafferUI.Slider._displayTransformChanged( self )
Expand Down Expand Up @@ -429,27 +477,27 @@ def __drawValue( self, painter ) :

position = self.__colorToPosition( self.__color )

pen = QtGui.QPen( QtGui.QColor( 0, 0, 0, 255 ) )
pen.setWidth( 1 )
painter.setPen( pen )

color = QtGui.QColor( 119, 156, 255, 255 )

painter.setBrush( QtGui.QBrush( color ) )

size = self.size()

# Use a dot when both axes are a valid value.
positionClamped = self.__clampPosition( position )
delta = position - positionClamped

if abs( delta.x ) < 1e-3 and abs( delta.y ) < 1e-3 :
painter.drawEllipse( QtCore.QPoint( position.x, position.y ), 4.5, 4.5 )
_drawIndicator( painter, QtCore.QPoint( position.x, position.y ) )
return

triangleWidth = 5.0
triangleSpacing = 2.0

pen = QtGui.QPen( QtGui.QColor( 0, 0, 0, 255 ) )
pen.setWidth( 1 )
painter.setPen( pen )

color = QtGui.QColor( 255, 255, 255, 255 )

painter.setBrush( QtGui.QBrush( color ) )

offset = imath.V2f( 0 )

if self.__useWheel() :
Expand Down
Loading