Skip to content

Commit

Permalink
CatalogueUI : Fix undo for image reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Mar 19, 2024
1 parent 9baf443 commit ea88e4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Fixes
-----

- PlugAlgo : Updated `canSetValueFromData()`, `setValueFromData()` and `getValueAsData()` with support for missing types.
- Catalogue : Fixed bugs caused by reordering images using `GraphComponent::reorderChildren()`.
- Catalogue :
- Fixed undo for image reordering via drag & drop.
- Fixed bugs caused by reordering images using `GraphComponent::reorderChildren()`.

API
---
Expand Down
9 changes: 8 additions & 1 deletion python/GafferImageUI/CatalogueUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,8 @@ def __init__( self, plug, **kw ) :
GafferUI.Label( "Description" )
self.__descriptionWidget = GafferUI.MultiLineStringPlugValueWidget( plug = None )

self.__mergeGroupId = 0

Gaffer.Metadata.plugValueChangedSignal( plug.node() ).connect( Gaffer.WeakMethod( self.__plugMetadataValueChanged ), scoped = False )

self.contextMenuSignal().connect( Gaffer.WeakMethod( self.__contextMenu ), scoped = False )
Expand Down Expand Up @@ -1044,6 +1046,7 @@ def __pathListingDragEnter( self, widget, event ) :
if isinstance( event.data, IECore.StringVectorData ) :
# Allow reordering of images
self.__moveToPath = None
self.__mergeGroupId += 1
return True

if self.__dropImage( event.data ) is None :
Expand Down Expand Up @@ -1108,7 +1111,11 @@ def __pathListingDragMove( self, listing, event ) :
images.insert( newIndex, image )
previous = image

_ImagesPath._reorderImages( [image for image in images if image ] )
with Gaffer.UndoScope(
self.getPlug().ancestor( Gaffer.ScriptNode ),
mergeGroup = "ImageListing{}{}".format( id( self, ), self.__mergeGroupId )
) :
_ImagesPath._reorderImages( [image for image in images if image ] )

self.__pathListing.getPath().pathChangedSignal()( self.__pathListing.getPath() )

Expand Down

0 comments on commit ea88e4e

Please sign in to comment.