From 15fcc7b0eb4439ccb7d1f3023f95c71b130e1d88 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 4 Oct 2024 14:08:25 -0400 Subject: [PATCH] fixup! ColorChooser : Custom layout for color field row --- python/GafferUI/ColorChooser.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/python/GafferUI/ColorChooser.py b/python/GafferUI/ColorChooser.py index 85bbac990e7..4ca8e58a132 100644 --- a/python/GafferUI/ColorChooser.py +++ b/python/GafferUI/ColorChooser.py @@ -462,6 +462,7 @@ def __init__( self ) : # and the options button. self.setSpacing( 0 ) self.__buttonSpacing = 4 + self.__minColorFieldSize = 66 # Height of 3 sliders self.__items = [] @@ -489,7 +490,12 @@ def minimumSize( self ) : assert( len( self.__items ) == 3 ) - return self.__size( self.__items[1].minimumSize(), self.__items[2].minimumSize() ) + size1 = self.__items[1].minimumSize() + size2 = self.__items[2].minimumSize() + return QtCore.QSize( + self.__minColorFieldSize + size1.width() + size2.width() + self.__buttonSpacing, + max( self.__minColorFieldSize, max( size1.height(), size2.height() ) ) + ) def maximumSize( self ) : @@ -499,7 +505,12 @@ def sizeHint( self ) : assert( len( self.__items ) == 3 ) - return self.__size( self.__items[1].sizeHint(), self.__items[2].sizeHint() ) + size1 = self.__items[1].sizeHint() + size2 = self.__items[2].sizeHint() + return QtCore.QSize( + size1.height() + size1.width() + size2.width() + self.__buttonSpacing, + max( self.__minColorFieldSize, max( size1.height(), size2.height() ) ) + ) def setGeometry( self, rect ) : @@ -510,8 +521,8 @@ def setGeometry( self, rect ) : leftSize = 0 if not self.__items[0].isEmpty() : - self.__items[0].setGeometry( QtCore.QRect( rect.left(), rect.top(), size1.height(), size1.height() ) ) - leftSize = size1.height() + leftSize = max( self.__minColorFieldSize, min( size1.height(), rect.width() / 2 ) ) + self.__items[0].setGeometry( QtCore.QRect( rect.left(), rect.top(), leftSize, leftSize ) ) self.__items[1].setGeometry( QtCore.QRect( @@ -525,12 +536,6 @@ def setGeometry( self, rect ) : QtCore.QRect( rect.right() - size2.width(), rect.top(), size2.width(), size2.height() ) ) - def __size( self, size1, size2 ) : - - return QtCore.QSize( - size1.height() + size1.width() + size2.width() + self.__buttonSpacing, - max( size1.height(), size2.height() ) - ) class _ColorFieldRowContainer( GafferUI.ContainerWidget ) :