added GIMP_UNDO_GROUP_MASK.

2003-03-19  Michael Natterer  <mitch@gimp.org>

	* app/core/core-enums.[ch]: added GIMP_UNDO_GROUP_MASK.

	* app/tools/gimpeditselectiontool.c: use it for mask moving.
	Made the "undo_desc" strings more specific.

	* app/core/gimpundo.c: add it to the list of undo types for
	which mask previews are created.

	* app/core/gimpimage.c: s/Add Layer to Image/Add Layer/g etc.
This commit is contained in:
Michael Natterer
2003-03-19 16:58:17 +00:00
committed by Michael Natterer
parent 43accc1d93
commit 1d7ba472cd
6 changed files with 77 additions and 60 deletions

View File

@ -1,3 +1,15 @@
2003-03-19 Michael Natterer <mitch@gimp.org>
* app/core/core-enums.[ch]: added GIMP_UNDO_GROUP_MASK.
* app/tools/gimpeditselectiontool.c: use it for mask moving.
Made the "undo_desc" strings more specific.
* app/core/gimpundo.c: add it to the list of undo types for
which mask previews are created.
* app/core/gimpimage.c: s/Add Layer to Image/Add Layer/g etc.
2003-03-19 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcomponenteditor.c: need to connect to the cell

View File

@ -435,6 +435,7 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE, N_("Merge Layers"), "group-image-layers-merge" },
{ GIMP_UNDO_GROUP_IMAGE_QMASK, N_("QuickMask"), "group-image-qmask" },
{ GIMP_UNDO_GROUP_IMAGE_GUIDE, N_("Guide"), "group-image-guide" },
{ GIMP_UNDO_GROUP_MASK, N_("Selection Mask"), "group-mask" },
{ GIMP_UNDO_GROUP_ITEM_PROPERTIES, N_("Item Properties"), "group-item-properties" },
{ GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY, N_("Drawable Visilibity"), "group-drawable-visibility" },
{ GIMP_UNDO_GROUP_LAYER_SCALE, N_("Scale Layer"), "group-layer-scale" },

View File

@ -329,6 +329,7 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE, /*< desc="Merge Layers" >*/
GIMP_UNDO_GROUP_IMAGE_QMASK, /*< desc="QuickMask" >*/
GIMP_UNDO_GROUP_IMAGE_GUIDE, /*< desc="Guide" >*/
GIMP_UNDO_GROUP_MASK, /*< desc="Selection Mask" >*/
GIMP_UNDO_GROUP_ITEM_PROPERTIES, /*< desc="Item Properties" >*/
GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY,/*< desc="Drawable Visilibity" >*/
GIMP_UNDO_GROUP_LAYER_SCALE, /*< desc="Scale Layer" >*/

View File

@ -2745,10 +2745,8 @@ gimp_image_add_layer (GimpImage *gimage,
return FALSE;
}
gimp_image_undo_push_layer_add (gimage,
_("Add Layer to Image"),
layer,
0,
gimp_image_undo_push_layer_add (gimage, _("Add Layer"),
layer, 0,
gimp_image_get_active_layer (gimage));
/* If the layer is a floating selection, set the ID */
@ -2829,12 +2827,11 @@ gimp_image_remove_layer (GimpImage *gimage,
g_return_if_fail (gimp_container_have (gimage->layers, GIMP_OBJECT (layer)));
gimp_image_undo_push_layer_remove (gimage,
_("Remove Layer from Image"),
gimp_image_undo_push_layer_remove (gimage, _("Remove Layer"),
layer,
gimp_container_get_child_index (gimage->layers,
GIMP_OBJECT (layer)),
layer);
gimp_image_get_active_layer (gimage));
g_object_ref (layer);
@ -3071,10 +3068,8 @@ gimp_image_add_channel (GimpImage *gimage,
return FALSE;
}
gimp_image_undo_push_channel_add (gimage,
_("Add Channel to Image"),
channel,
0,
gimp_image_undo_push_channel_add (gimage, _("Add Channel"),
channel, 0,
gimp_image_get_active_channel (gimage));
/* add the layer to the list at the specified position */
@ -3125,8 +3120,7 @@ gimp_image_remove_channel (GimpImage *gimage,
g_return_if_fail (gimp_container_have (gimage->channels,
GIMP_OBJECT (channel)));
gimp_image_undo_push_channel_remove (gimage,
_("Remove Layer from Image"),
gimp_image_undo_push_channel_remove (gimage, _("Remove Layer"),
channel,
gimp_container_get_child_index (gimage->channels,
GIMP_OBJECT (channel)),
@ -3265,10 +3259,8 @@ gimp_image_add_vectors (GimpImage *gimage,
return FALSE;
}
gimp_image_undo_push_vectors_add (gimage,
_("Add Path to Image"),
vectors,
0,
gimp_image_undo_push_vectors_add (gimage, _("Add Path"),
vectors, 0,
gimp_image_get_active_vectors (gimage));
gimp_item_set_image (GIMP_ITEM (vectors), gimage);
@ -3314,8 +3306,7 @@ gimp_image_remove_vectors (GimpImage *gimage,
g_return_if_fail (gimp_container_have (gimage->vectors,
GIMP_OBJECT (vectors)));
gimp_image_undo_push_vectors_remove (gimage,
_("Remove Path from Image"),
gimp_image_undo_push_vectors_remove (gimage, _("Remove Path"),
vectors,
gimp_container_get_child_index (gimage->vectors,
GIMP_OBJECT (vectors)),

View File

@ -368,7 +368,7 @@ gimp_undo_create_preview_idle (gpointer data)
}
void
gimp_undo_create_preview_private (GimpUndo *undo)
gimp_undo_create_preview_private (GimpUndo *undo)
{
GimpViewable *preview_viewable;
gint width;
@ -377,6 +377,7 @@ gimp_undo_create_preview_private (GimpUndo *undo)
switch (undo->undo_type)
{
case GIMP_UNDO_GROUP_IMAGE_QMASK:
case GIMP_UNDO_GROUP_MASK:
case GIMP_UNDO_IMAGE_QMASK:
case GIMP_UNDO_MASK:
preview_viewable = GIMP_VIEWABLE (gimp_image_get_mask (undo->gimage));

View File

@ -238,26 +238,12 @@ init_edit_selection (GimpTool *tool,
GimpEditSelectionTool *edit_select;
GimpDisplayShell *shell;
gint off_x, off_y;
const gchar *undo_desc;
edit_select = g_object_new (GIMP_TYPE_EDIT_SELECTION_TOOL, NULL);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_image_undo_group_start (gdisp->gimage, GIMP_UNDO_GROUP_LAYER_DISPLACE,
_("Move Layer"));
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&off_x, &off_y);
edit_select->x = edit_select->origx = coords->x - off_x;
edit_select->y = edit_select->origy = coords->y - off_y;
gimp_image_mask_boundary (gdisp->gimage,
&edit_select->segs_in,
&edit_select->segs_out,
&edit_select->num_segs_in,
&edit_select->num_segs_out);
/* Make a check to see if it should be a floating selection translation */
if (edit_type == EDIT_MASK_TO_LAYER_TRANSLATE &&
gimp_image_floating_sel (gdisp->gimage))
@ -275,8 +261,33 @@ init_edit_selection (GimpTool *tool,
edit_type = EDIT_FLOATING_SEL_TRANSLATE;
}
if (edit_type == EDIT_MASK_TRANSLATE)
undo_desc = _("Move Selection Mask");
else if (edit_type == EDIT_LAYER_TRANSLATE)
undo_desc = _("Move Layer");
else
undo_desc = _("Move Floating Layer");
gimp_image_undo_group_start (gdisp->gimage,
edit_type == EDIT_MASK_TRANSLATE ?
GIMP_UNDO_GROUP_MASK :
GIMP_UNDO_GROUP_LAYER_DISPLACE,
undo_desc);
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
&off_x, &off_y);
edit_select->edit_type = edit_type;
edit_select->x = edit_select->origx = coords->x - off_x;
edit_select->y = edit_select->origy = coords->y - off_y;
gimp_image_mask_boundary (gdisp->gimage,
&edit_select->segs_in,
&edit_select->segs_out,
&edit_select->num_segs_in,
&edit_select->num_segs_out);
/* find the bounding box of the selection mask -
* this is used for the case of a EDIT_MASK_TO_LAYER_TRANSLATE,
* where the translation will result in floating the selection
@ -472,7 +483,9 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
break;
case EDIT_LAYER_TRANSLATE:
if ((floating_layer = gimp_image_floating_sel (gdisp->gimage)))
floating_layer = gimp_image_floating_sel (gdisp->gimage);
if (floating_layer)
floating_sel_relax (floating_layer, TRUE);
/* translate the layer--and any "linked" layers as well */
@ -510,8 +523,9 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
return;
}
/* this is always the first move, since we switch to
EDIT_FLOATING_SEL_TRANSLATE when finished here */
/* this is always the first move, since we switch to
* EDIT_FLOATING_SEL_TRANSLATE when finished here
*/
gimp_image_undo_freeze (gdisp->gimage);
edit_select->first_move = FALSE;
@ -535,7 +549,6 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
if (edit_select->first_move)
{
gimp_image_undo_freeze (gdisp->gimage);
edit_select->first_move = FALSE;
}
break;
@ -780,8 +793,6 @@ process_event_queue_keys (GdkEventKey *kevent,
va_end (argp);
g_print ("process_key: state == %d\n", kevent->state);
for (i = 0; i < n_keys; i++)
if (kevent->keyval == keys[i] &&
(kevent->state & modifiers[i]) == modifiers[i])
@ -803,8 +814,6 @@ process_event_queue_keys (GdkEventKey *kevent,
{
if (event->any.type == GDK_KEY_PRESS)
{
g_print ("process_key: state == %d\n", event->key.state);
for (i = 0; i < n_keys; i++)
if (event->key.keyval == keys[i] &&
(event->key.state & modifiers[i]) == modifiers[i])
@ -852,16 +861,17 @@ gimp_edit_selection_tool_arrow_key (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
{
gint mask_inc_x = 0;
gint mask_inc_y = 0;
gint inc_x = 0;
gint inc_y = 0;
GimpUndo *undo;
gboolean push_undo = TRUE;
gboolean translate_mask = FALSE;
gboolean translate_layer = FALSE;
GimpLayer *layer = NULL;
EditType edit_type = EDIT_MASK_TRANSLATE;
gint mask_inc_x = 0;
gint mask_inc_y = 0;
gint inc_x = 0;
gint inc_y = 0;
GimpUndo *undo;
gboolean push_undo = TRUE;
gboolean translate_mask = FALSE;
gboolean translate_layer = FALSE;
GimpLayer *layer = NULL;
EditType edit_type = EDIT_MASK_TRANSLATE;
GimpUndoType undo_type;
/* check for mask translation first because the translate_layer
* modifiers match the translate_mask ones...
@ -951,10 +961,14 @@ gimp_edit_selection_tool_arrow_key (GimpTool *tool,
}
}
if (translate_mask)
undo_type = GIMP_UNDO_GROUP_MASK;
else
undo_type = GIMP_UNDO_GROUP_LAYER_DISPLACE;
undo = gimp_undo_stack_peek (gdisp->gimage->undo_stack);
if (GIMP_IS_UNDO_STACK (undo) &&
undo->undo_type == GIMP_UNDO_GROUP_LAYER_DISPLACE)
if (GIMP_IS_UNDO_STACK (undo) && undo->undo_type == undo_type)
{
if (g_object_get_data (G_OBJECT (undo), "edit-selection-tool") ==
(gpointer) tool &&
@ -980,14 +994,11 @@ gimp_edit_selection_tool_arrow_key (GimpTool *tool,
else
undo_desc = _("Move Layer");
if (gimp_image_undo_group_start (gdisp->gimage,
GIMP_UNDO_GROUP_LAYER_DISPLACE,
undo_desc))
if (gimp_image_undo_group_start (gdisp->gimage, undo_type, undo_desc))
{
undo = gimp_undo_stack_peek (gdisp->gimage->undo_stack);
if (GIMP_IS_UNDO_STACK (undo) &&
undo->undo_type == GIMP_UNDO_GROUP_LAYER_DISPLACE)
if (GIMP_IS_UNDO_STACK (undo) && undo->undo_type == undo_type)
{
g_object_set_data (G_OBJECT (undo), "edit-selection-tool",
tool);