[gimp] app: fix undo when moving a group-layer child outside the group
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix undo when moving a group-layer child outside the group
- Date: Sun, 22 Apr 2018 08:05:58 +0000 (UTC)
commit 577e17032abd3201b7eef6edac1a4f88c99f8728
Author: Ell <ell_se yahoo com>
Date: Sun Apr 22 03:18:37 2018 -0400
app: fix undo when moving a group-layer child outside the group
In gimp_image_reorder_item(), call gimp_item_start/end_move()
before/after reordering the item (and use an undo group, so that
the resulting undo actions are grouped together with the reordering
undo action,) so that if the item is a child of a group layer, and
reordering moves it out of the group in a way that causes the
group's mask to be resized, the mask will be properly restored when
undoing the operation.
app/core/core-enums.c | 2 ++
app/core/core-enums.h | 1 +
app/core/gimpimage.c | 26 +++++++++++++++++++++-----
3 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index 2433381..355b298 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -770,6 +770,7 @@ gimp_undo_type_get_type (void)
{ GIMP_UNDO_GROUP_IMAGE_CROP, "GIMP_UNDO_GROUP_IMAGE_CROP", "group-image-crop" },
{ GIMP_UNDO_GROUP_IMAGE_CONVERT, "GIMP_UNDO_GROUP_IMAGE_CONVERT", "group-image-convert" },
{ GIMP_UNDO_GROUP_IMAGE_ITEM_REMOVE, "GIMP_UNDO_GROUP_IMAGE_ITEM_REMOVE", "group-image-item-remove" },
+ { GIMP_UNDO_GROUP_IMAGE_ITEM_REORDER, "GIMP_UNDO_GROUP_IMAGE_ITEM_REORDER", "group-image-item-reorder" },
{ GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE, "GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE", "group-image-layers-merge" },
{ GIMP_UNDO_GROUP_IMAGE_VECTORS_MERGE, "GIMP_UNDO_GROUP_IMAGE_VECTORS_MERGE",
"group-image-vectors-merge" },
{ GIMP_UNDO_GROUP_IMAGE_QUICK_MASK, "GIMP_UNDO_GROUP_IMAGE_QUICK_MASK", "group-image-quick-mask" },
@@ -867,6 +868,7 @@ gimp_undo_type_get_type (void)
{ GIMP_UNDO_GROUP_IMAGE_CROP, NC_("undo-type", "Crop image"), NULL },
{ GIMP_UNDO_GROUP_IMAGE_CONVERT, NC_("undo-type", "Convert image"), NULL },
{ GIMP_UNDO_GROUP_IMAGE_ITEM_REMOVE, NC_("undo-type", "Remove item"), NULL },
+ { GIMP_UNDO_GROUP_IMAGE_ITEM_REORDER, NC_("undo-type", "Reorder item"), NULL },
{ GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE, NC_("undo-type", "Merge layers"), NULL },
{ GIMP_UNDO_GROUP_IMAGE_VECTORS_MERGE, NC_("undo-type", "Merge paths"), NULL },
{ GIMP_UNDO_GROUP_IMAGE_QUICK_MASK, NC_("undo-type", "Quick Mask"), NULL },
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index e0705d5..7cafdf3 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -361,6 +361,7 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_GROUP_IMAGE_CROP, /*< desc="Crop image" >*/
GIMP_UNDO_GROUP_IMAGE_CONVERT, /*< desc="Convert image" >*/
GIMP_UNDO_GROUP_IMAGE_ITEM_REMOVE, /*< desc="Remove item" >*/
+ GIMP_UNDO_GROUP_IMAGE_ITEM_REORDER, /*< desc="Reorder item" >*/
GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE, /*< desc="Merge layers" >*/
GIMP_UNDO_GROUP_IMAGE_VECTORS_MERGE,/*< desc="Merge paths" >*/
GIMP_UNDO_GROUP_IMAGE_QUICK_MASK, /*< desc="Quick Mask" >*/
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 7176369..8508419 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -4155,6 +4155,7 @@ gimp_image_reorder_item (GimpImage *image,
const gchar *undo_desc)
{
GimpItemTree *tree;
+ gboolean result;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
@@ -4164,14 +4165,29 @@ gimp_image_reorder_item (GimpImage *image,
g_return_val_if_fail (tree != NULL, FALSE);
- if (push_undo && ! undo_desc)
- undo_desc = GIMP_ITEM_GET_CLASS (item)->reorder_desc;
+ if (push_undo)
+ {
+ if (! undo_desc)
+ undo_desc = GIMP_ITEM_GET_CLASS (item)->reorder_desc;
+
+ gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_ITEM_REORDER,
+ undo_desc);
+ }
+
+ gimp_item_start_move (item, push_undo);
/* item and new_parent are type-checked in GimpItemTree
*/
- return gimp_item_tree_reorder_item (tree, item,
- new_parent, new_index,
- push_undo, undo_desc);
+ result = gimp_item_tree_reorder_item (tree, item,
+ new_parent, new_index,
+ push_undo, undo_desc);
+
+ gimp_item_end_move (item, push_undo);
+
+ if (push_undo)
+ gimp_image_undo_group_end (image);
+
+ return result;
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]