diff --git a/Changes.md b/Changes.md index 4eb27163214..3517fd3658d 100644 --- a/Changes.md +++ b/Changes.md @@ -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 --- diff --git a/python/GafferImageUI/CatalogueUI.py b/python/GafferImageUI/CatalogueUI.py index 5a6cf559b56..744d3d7e5d3 100644 --- a/python/GafferImageUI/CatalogueUI.py +++ b/python/GafferImageUI/CatalogueUI.py @@ -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 ) @@ -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 : @@ -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() )