From 61bd942c43d12ad2f1647e5eada717a63778619b Mon Sep 17 00:00:00 2001 From: John Haddon Date: Mon, 5 Aug 2024 14:26:43 +0100 Subject: [PATCH] CatalogueUI : Use SplitContainer to allow resizing of listing/properties The description field was growing a little large for some folks' taste. I did try limiting the description field to a fixed number of lines, but I'm concerned that some other folks might be using large descriptions (lots of different notes on settings perhaps?), so I think providing explicit control is probably better. --- Changes.md | 1 + python/GafferImageUI/CatalogueUI.py | 116 +++++++++++++++------------- 2 files changed, 64 insertions(+), 53 deletions(-) diff --git a/Changes.md b/Changes.md index 45108729e2..0f13834d5d 100644 --- a/Changes.md +++ b/Changes.md @@ -13,6 +13,7 @@ Improvements - Green : Render - Blue : Proxy - Red : Guide +- Catalogue : Added a handle for controlling the relative sizes of the listing and image property widgets. Fixes ----- diff --git a/python/GafferImageUI/CatalogueUI.py b/python/GafferImageUI/CatalogueUI.py index 7b0620bca9..7f31307dec 100644 --- a/python/GafferImageUI/CatalogueUI.py +++ b/python/GafferImageUI/CatalogueUI.py @@ -721,73 +721,79 @@ class ImageListing( GafferUI.PlugValueWidget ) : def __init__( self, plug, **kw ) : - self.__column = GafferUI.ListContainer( spacing = 4 ) + splitContainer = GafferUI.SplitContainer() - GafferUI.PlugValueWidget.__init__( self, self.__column, plug, **kw ) + GafferUI.PlugValueWidget.__init__( self, splitContainer, plug, **kw ) - with self.__column : + with splitContainer : - self.__pathListing = GafferUI.PathListingWidget( - _ImagesPath( self.__images(), [] ), - columns = self.__listingColumns(), - selectionMode = GafferUI.PathListingWidget.SelectionMode.Rows, - sortable = False, - horizontalScrollMode = GafferUI.ScrollMode.Automatic - ) - self.__pathListing.setDragPointer( "" ) - self.__pathListing.setHeaderVisible( True ) - self.__pathListing.selectionChangedSignal().connect( - Gaffer.WeakMethod( self.__pathListingSelectionChanged ), scoped = False - ) - self.__pathListing.dragEnterSignal().connect( - Gaffer.WeakMethod( self.__pathListingDragEnter ), scoped = False - ) - self.__pathListing.dragLeaveSignal().connect( - Gaffer.WeakMethod( self.__pathListingDragLeave ), scoped = False - ) - self.__pathListing.dragMoveSignal().connect( - Gaffer.WeakMethod( self.__pathListingDragMove ), scoped = False - ) - self.__pathListing.dropSignal().connect( - Gaffer.WeakMethod( self.__pathListingDrop ), scoped = False - ) - self.keyPressSignal().connect( Gaffer.WeakMethod( self.__keyPress ), scoped = False ) + with GafferUI.ListContainer( spacing = 4 ) : + + self.__pathListing = GafferUI.PathListingWidget( + _ImagesPath( self.__images(), [] ), + columns = self.__listingColumns(), + selectionMode = GafferUI.PathListingWidget.SelectionMode.Rows, + sortable = False, + horizontalScrollMode = GafferUI.ScrollMode.Automatic + ) + self.__pathListing.setDragPointer( "" ) + self.__pathListing.setHeaderVisible( True ) + self.__pathListing.selectionChangedSignal().connect( + Gaffer.WeakMethod( self.__pathListingSelectionChanged ), scoped = False + ) + self.__pathListing.dragEnterSignal().connect( + Gaffer.WeakMethod( self.__pathListingDragEnter ), scoped = False + ) + self.__pathListing.dragLeaveSignal().connect( + Gaffer.WeakMethod( self.__pathListingDragLeave ), scoped = False + ) + self.__pathListing.dragMoveSignal().connect( + Gaffer.WeakMethod( self.__pathListingDragMove ), scoped = False + ) + self.__pathListing.dropSignal().connect( + Gaffer.WeakMethod( self.__pathListingDrop ), scoped = False + ) + self.keyPressSignal().connect( Gaffer.WeakMethod( self.__keyPress ), scoped = False ) + + with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) as self.__buttonRow : + + addButton = GafferUI.Button( image = "pathChooser.png", hasFrame = False, toolTip = "Load image" ) + addButton.clickedSignal().connect( Gaffer.WeakMethod( self.__addClicked ), scoped = False ) - with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) as self.__buttonRow : + self.__duplicateButton = GafferUI.Button( image = "duplicate.png", hasFrame = False, toolTip = "Duplicate selected image, hold alt to view copy. [Ctrl-D]" ) + self.__duplicateButton.setEnabled( False ) + self.__duplicateButton.clickedSignal().connect( Gaffer.WeakMethod( self.__duplicateClicked ), scoped = False ) - addButton = GafferUI.Button( image = "pathChooser.png", hasFrame = False, toolTip = "Load image" ) - addButton.clickedSignal().connect( Gaffer.WeakMethod( self.__addClicked ), scoped = False ) + self.__exportButton = GafferUI.Button( image = "export.png", hasFrame = False, toolTip = "Export selected image" ) + self.__exportButton.setEnabled( False ) + self.__exportButton.clickedSignal().connect( Gaffer.WeakMethod( self.__exportClicked ), scoped = False ) - self.__duplicateButton = GafferUI.Button( image = "duplicate.png", hasFrame = False, toolTip = "Duplicate selected image, hold alt to view copy. [Ctrl-D]" ) - self.__duplicateButton.setEnabled( False ) - self.__duplicateButton.clickedSignal().connect( Gaffer.WeakMethod( self.__duplicateClicked ), scoped = False ) + self.__extractButton = GafferUI.Button( image = "extract.png", hasFrame = False, toolTip = "Create CatalogueSelect node for selected image" ) + self.__extractButton.setEnabled( False ) + self.__extractButton.clickedSignal().connect( Gaffer.WeakMethod( self.__extractClicked ), scoped = False ) - self.__exportButton = GafferUI.Button( image = "export.png", hasFrame = False, toolTip = "Export selected image" ) - self.__exportButton.setEnabled( False ) - self.__exportButton.clickedSignal().connect( Gaffer.WeakMethod( self.__exportClicked ), scoped = False ) + GafferUI.Spacer( imath.V2i( 0 ), parenting = { "expand" : True } ) - self.__extractButton = GafferUI.Button( image = "extract.png", hasFrame = False, toolTip = "Create CatalogueSelect node for selected image" ) - self.__extractButton.setEnabled( False ) - self.__extractButton.clickedSignal().connect( Gaffer.WeakMethod( self.__extractClicked ), scoped = False ) + self.__removeButton = GafferUI.Button( image = "delete.png", hasFrame = False, toolTip = "Remove selected image [Delete]" ) + self.__removeButton.setEnabled( False ) + self.__removeButton.clickedSignal().connect( Gaffer.WeakMethod( self.__removeClicked ), scoped = False ) - GafferUI.Spacer( imath.V2i( 0 ), parenting = { "expand" : True } ) + GafferUI.Spacer( size = imath.V2i( 2 ) ) - self.__removeButton = GafferUI.Button( image = "delete.png", hasFrame = False, toolTip = "Remove selected image [Delete]" ) - self.__removeButton.setEnabled( False ) - self.__removeButton.clickedSignal().connect( Gaffer.WeakMethod( self.__removeClicked ), scoped = False ) + with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing = 4 ) : - GafferUI.Divider() + GafferUI.Spacer( size = imath.V2i( 2 ) ) - with GafferUI.Collapsible( label = "Image Properties", collapsed = False ) : + GafferUI.Label( "

Image Properties

" ) - with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Vertical, spacing = 4 ) : + GafferUI.Spacer( size = imath.V2i( 2 ) ) - with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) : - GafferUI.Label( "Name" ) - self.__nameWidget = GafferUI.NameWidget( graphComponent = None ) + with GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing = 4 ) : + GafferUI.Label( "Name" ) + self.__nameWidget = GafferUI.NameWidget( graphComponent = None ) - GafferUI.Label( "Description" ) - self.__descriptionWidget = GafferUI.MultiLineStringPlugValueWidget( plug = None ) + GafferUI.Label( "Description" ) + self.__descriptionWidget = GafferUI.MultiLineStringPlugValueWidget( plug = None ) self.__mergeGroupId = 0 @@ -826,7 +832,11 @@ def _updateFromValues( self, values, exception ) : def _updateFromEditable( self ) : - self.__column.setEnabled( self._editable() ) + self.__pathListing.setEnabled( self._editable() ) + self.__buttonRow.setEnabled( self._editable() ) + # No need to manage editability of `self.__nameWidget` and + # `self.__descriptionWidget` because they deal with that + # internally. def __plugMetadataValueChanged( self, plug, key, reason ) :