Commit 76a88cc6 authored by Ell's avatar Ell

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.
parent 6a825f18
......@@ -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 },
......
......@@ -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" >*/
......
......@@ -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 */
......
......@@ -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__ */
......@@ -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;
......
......@@ -671,6 +671,38 @@ gimp_image_undo_push_group_layer_resume_mask (GimpImage *image,
NULL);
}
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,
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment