[gimp] app: fix layer-group mask cropping during move operation undo
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: fix layer-group mask cropping during move operation undo
- Date: Sun, 25 Mar 2018 15:48:29 +0000 (UTC)
commit 76a88cc60ad76982fadb91f30c2fbdcaa6ac32fc
Author: Ell <ell_se yahoo com>
Date: Sun Mar 25 09:54:13 2018 -0400
app: fix layer-group mask cropping during move operation undo
In gimp_group_layer_{start,end}_move(), push corresponding undo
steps, which perform the opposite operation during undo, and make
sure that mask-cropping is frozen during group-layer move
operations.
This fixed erroneous group-layer mask cropping when undoing/redoing
a group-layer move operation multiple times.
app/core/core-enums.c | 4 ++
app/core/core-enums.h | 2 +
app/core/gimpgrouplayer.c | 68 +++++++++++++++++++++++++++++++--------
app/core/gimpgrouplayer.h | 5 +++
app/core/gimpgrouplayerundo.c | 21 ++++++++++++
app/core/gimpimage-undo-push.c | 32 +++++++++++++++++++
app/core/gimpimage-undo-push.h | 8 +++++
7 files changed, 126 insertions(+), 14 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index c50fc52..2433381 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -830,6 +830,8 @@ gimp_undo_type_get_type (void)
{ GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE, "GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE",
"group-layer-resume-resize" },
{ GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK, "GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK", "group-layer-suspend-mask" },
{ GIMP_UNDO_GROUP_LAYER_RESUME_MASK, "GIMP_UNDO_GROUP_LAYER_RESUME_MASK", "group-layer-resume-mask" },
+ { GIMP_UNDO_GROUP_LAYER_START_MOVE, "GIMP_UNDO_GROUP_LAYER_START_MOVE", "group-layer-start-move" },
+ { GIMP_UNDO_GROUP_LAYER_END_MOVE, "GIMP_UNDO_GROUP_LAYER_END_MOVE", "group-layer-end-move" },
{ GIMP_UNDO_GROUP_LAYER_CONVERT, "GIMP_UNDO_GROUP_LAYER_CONVERT", "group-layer-convert" },
{ GIMP_UNDO_TEXT_LAYER, "GIMP_UNDO_TEXT_LAYER", "text-layer" },
{ GIMP_UNDO_TEXT_LAYER_MODIFIED, "GIMP_UNDO_TEXT_LAYER_MODIFIED", "text-layer-modified" },
@@ -925,6 +927,8 @@ gimp_undo_type_get_type (void)
{ GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE, NC_("undo-type", "Resume group layer resize"), NULL },
{ GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK, NC_("undo-type", "Suspend group layer mask"), NULL },
{ GIMP_UNDO_GROUP_LAYER_RESUME_MASK, NC_("undo-type", "Resume group layer mask"), NULL },
+ { GIMP_UNDO_GROUP_LAYER_START_MOVE, NC_("undo-type", "Start moving group layer"), NULL },
+ { GIMP_UNDO_GROUP_LAYER_END_MOVE, NC_("undo-type", "End moving group layer"), NULL },
{ GIMP_UNDO_GROUP_LAYER_CONVERT, NC_("undo-type", "Convert group layer"), NULL },
{ GIMP_UNDO_TEXT_LAYER, NC_("undo-type", "Text layer"), NULL },
{ GIMP_UNDO_TEXT_LAYER_MODIFIED, NC_("undo-type", "Text layer modification"), NULL },
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index f73d867..e0705d5 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -426,6 +426,8 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE,/*< desc="Resume group layer resize" >*/
GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK, /*< desc="Suspend group layer mask" >*/
GIMP_UNDO_GROUP_LAYER_RESUME_MASK, /*< desc="Resume group layer mask" >*/
+ GIMP_UNDO_GROUP_LAYER_START_MOVE, /*< desc="Start moving group layer" >*/
+ GIMP_UNDO_GROUP_LAYER_END_MOVE, /*< desc="End moving group layer" >*/
GIMP_UNDO_GROUP_LAYER_CONVERT, /*< desc="Convert group layer" >*/
GIMP_UNDO_TEXT_LAYER, /*< desc="Text layer" >*/
GIMP_UNDO_TEXT_LAYER_MODIFIED, /*< desc="Text layer modification" >*/
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 1862841..8188122 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -607,11 +607,7 @@ static void
gimp_group_layer_start_move (GimpItem *item,
gboolean push_undo)
{
- GimpGroupLayerPrivate *private = GET_PRIVATE (item);
-
- g_return_if_fail (private->suspend_mask == 0);
-
- private->moving++;
+ _gimp_group_layer_start_move (GIMP_GROUP_LAYER (item), push_undo);
if (GIMP_ITEM_CLASS (parent_class)->start_move)
GIMP_ITEM_CLASS (parent_class)->start_move (item, push_undo);
@@ -621,18 +617,10 @@ static void
gimp_group_layer_end_move (GimpItem *item,
gboolean push_undo)
{
- GimpGroupLayerPrivate *private = GET_PRIVATE (item);
-
- g_return_if_fail (private->suspend_mask == 0);
- g_return_if_fail (private->moving > 0);
-
if (GIMP_ITEM_CLASS (parent_class)->end_move)
GIMP_ITEM_CLASS (parent_class)->end_move (item, push_undo);
- private->moving--;
-
- if (private->moving == 0)
- gimp_group_layer_update_mask_size (GIMP_GROUP_LAYER (item));
+ _gimp_group_layer_end_move (GIMP_GROUP_LAYER (item), push_undo);
}
static void
@@ -1609,6 +1597,58 @@ _gimp_group_layer_get_suspended_mask (GimpGroupLayer *group,
return NULL;
}
+void
+_gimp_group_layer_start_move (GimpGroupLayer *group,
+ gboolean push_undo)
+{
+ GimpGroupLayerPrivate *private;
+ GimpItem *item;
+
+ g_return_if_fail (GIMP_IS_GROUP_LAYER (group));
+
+ private = GET_PRIVATE (group);
+ item = GIMP_ITEM (group);
+
+ g_return_if_fail (private->suspend_mask == 0);
+
+ if (! gimp_item_is_attached (item))
+ push_undo = FALSE;
+
+ if (push_undo)
+ gimp_image_undo_push_group_layer_start_move (gimp_item_get_image (item),
+ NULL, group);
+
+ private->moving++;
+}
+
+void
+_gimp_group_layer_end_move (GimpGroupLayer *group,
+ gboolean push_undo)
+{
+ GimpGroupLayerPrivate *private;
+ GimpItem *item;
+
+ g_return_if_fail (GIMP_IS_GROUP_LAYER (group));
+
+ private = GET_PRIVATE (group);
+ item = GIMP_ITEM (group);
+
+ g_return_if_fail (private->suspend_mask == 0);
+ g_return_if_fail (private->moving > 0);
+
+ if (! gimp_item_is_attached (item))
+ push_undo = FALSE;
+
+ if (push_undo)
+ gimp_image_undo_push_group_layer_end_move (gimp_item_get_image (item),
+ NULL, group);
+
+ private->moving--;
+
+ if (private->moving == 0)
+ gimp_group_layer_update_mask_size (GIMP_GROUP_LAYER (item));
+}
+
/* private functions */
diff --git a/app/core/gimpgrouplayer.h b/app/core/gimpgrouplayer.h
index 6603fe6..8a0a6c1 100644
--- a/app/core/gimpgrouplayer.h
+++ b/app/core/gimpgrouplayer.h
@@ -69,5 +69,10 @@ void _gimp_group_layer_set_suspended_mask (GimpGroupLayer *grou
GeglBuffer * _gimp_group_layer_get_suspended_mask (GimpGroupLayer *group,
GeglRectangle *bounds);
+void _gimp_group_layer_start_move (GimpGroupLayer *group,
+ gboolean push_undo);
+void _gimp_group_layer_end_move (GimpGroupLayer *group,
+ gboolean push_undo);
+
#endif /* __GIMP_GROUP_LAYER_H__ */
diff --git a/app/core/gimpgrouplayerundo.c b/app/core/gimpgrouplayerundo.c
index 2850d4f..cef6c29 100644
--- a/app/core/gimpgrouplayerundo.c
+++ b/app/core/gimpgrouplayerundo.c
@@ -82,6 +82,8 @@ gimp_group_layer_undo_constructed (GObject *object)
case GIMP_UNDO_GROUP_LAYER_SUSPEND_RESIZE:
case GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE:
case GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK:
+ case GIMP_UNDO_GROUP_LAYER_START_MOVE:
+ case GIMP_UNDO_GROUP_LAYER_END_MOVE:
break;
case GIMP_UNDO_GROUP_LAYER_RESUME_MASK:
@@ -190,6 +192,25 @@ gimp_group_layer_undo_pop (GimpUndo *undo,
}
break;
+ case GIMP_UNDO_GROUP_LAYER_START_MOVE:
+ case GIMP_UNDO_GROUP_LAYER_END_MOVE:
+ if ((undo_mode == GIMP_UNDO_MODE_UNDO &&
+ undo->undo_type == GIMP_UNDO_GROUP_LAYER_START_MOVE) ||
+ (undo_mode == GIMP_UNDO_MODE_REDO &&
+ undo->undo_type == GIMP_UNDO_GROUP_LAYER_END_MOVE))
+ {
+ /* end group layer move operation */
+
+ _gimp_group_layer_end_move (group, FALSE);
+ }
+ else
+ {
+ /* start group layer move operation */
+
+ _gimp_group_layer_start_move (group, FALSE);
+ }
+ break;
+
case GIMP_UNDO_GROUP_LAYER_CONVERT:
{
GimpImageBaseType type;
diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c
index 77c55fd..4eae6ef 100644
--- a/app/core/gimpimage-undo-push.c
+++ b/app/core/gimpimage-undo-push.c
@@ -672,6 +672,38 @@ gimp_image_undo_push_group_layer_resume_mask (GimpImage *image,
}
GimpUndo *
+gimp_image_undo_push_group_layer_start_move (GimpImage *image,
+ const gchar *undo_desc,
+ GimpGroupLayer *group)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+ g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
+ g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
+
+ return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
+ GIMP_UNDO_GROUP_LAYER_START_MOVE, undo_desc,
+ GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
+ "item", group,
+ NULL);
+}
+
+GimpUndo *
+gimp_image_undo_push_group_layer_end_move (GimpImage *image,
+ const gchar *undo_desc,
+ GimpGroupLayer *group)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+ g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
+ g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
+
+ return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
+ GIMP_UNDO_GROUP_LAYER_END_MOVE, undo_desc,
+ GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
+ "item", group,
+ NULL);
+}
+
+GimpUndo *
gimp_image_undo_push_group_layer_convert (GimpImage *image,
const gchar *undo_desc,
GimpGroupLayer *group)
diff --git a/app/core/gimpimage-undo-push.h b/app/core/gimpimage-undo-push.h
index d2c1530..d83398a 100644
--- a/app/core/gimpimage-undo-push.h
+++ b/app/core/gimpimage-undo-push.h
@@ -161,6 +161,14 @@ GimpUndo *
gimp_image_undo_push_group_layer_resume_mask (GimpImage *image,
const gchar *undo_desc,
GimpGroupLayer *group);
+GimpUndo *
+ gimp_image_undo_push_group_layer_start_move (GimpImage *image,
+ const gchar *undo_desc,
+ GimpGroupLayer *group);
+GimpUndo *
+ gimp_image_undo_push_group_layer_end_move (GimpImage *image,
+ const gchar *undo_desc,
+ GimpGroupLayer *group);
GimpUndo * gimp_image_undo_push_group_layer_convert (GimpImage *image,
const gchar *undo_desc,
GimpGroupLayer *group);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]