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> 2003-03-19 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcomponenteditor.c: need to connect to the cell * 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_LAYERS_MERGE, N_("Merge Layers"), "group-image-layers-merge" },
{ GIMP_UNDO_GROUP_IMAGE_QMASK, N_("QuickMask"), "group-image-qmask" }, { GIMP_UNDO_GROUP_IMAGE_QMASK, N_("QuickMask"), "group-image-qmask" },
{ GIMP_UNDO_GROUP_IMAGE_GUIDE, N_("Guide"), "group-image-guide" }, { 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_ITEM_PROPERTIES, N_("Item Properties"), "group-item-properties" },
{ GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY, N_("Drawable Visilibity"), "group-drawable-visibility" }, { GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY, N_("Drawable Visilibity"), "group-drawable-visibility" },
{ GIMP_UNDO_GROUP_LAYER_SCALE, N_("Scale Layer"), "group-layer-scale" }, { 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_LAYERS_MERGE, /*< desc="Merge Layers" >*/
GIMP_UNDO_GROUP_IMAGE_QMASK, /*< desc="QuickMask" >*/ GIMP_UNDO_GROUP_IMAGE_QMASK, /*< desc="QuickMask" >*/
GIMP_UNDO_GROUP_IMAGE_GUIDE, /*< desc="Guide" >*/ 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_ITEM_PROPERTIES, /*< desc="Item Properties" >*/
GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY,/*< desc="Drawable Visilibity" >*/ GIMP_UNDO_GROUP_DRAWABLE_VISIBILITY,/*< desc="Drawable Visilibity" >*/
GIMP_UNDO_GROUP_LAYER_SCALE, /*< desc="Scale Layer" >*/ GIMP_UNDO_GROUP_LAYER_SCALE, /*< desc="Scale Layer" >*/

View File

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

View File

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

View File

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