don't freeze()/thaw() the image's undo to prevent live-movement from

2004-07-26  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpeditselectiontool.c: don't freeze()/thaw() the
	image's undo to prevent live-movement from ending up on the undo
	stack. Instead, just stop pushing undo steps after the initial
	movement. Simplifies edit_select's undo code quite a bit and fixes
	bug #148458.
This commit is contained in:
Michael Natterer
2004-07-26 13:15:22 +00:00
committed by Michael Natterer
parent 0cb50e20f2
commit 674f80e155
2 changed files with 102 additions and 133 deletions

View File

@ -1,3 +1,11 @@
2004-07-26 Michael Natterer <mitch@gimp.org>
* app/tools/gimpeditselectiontool.c: don't freeze()/thaw() the
image's undo to prevent live-movement from ending up on the undo
stack. Instead, just stop pushing undo steps after the initial
movement. Simplifies edit_select's undo code quite a bit and fixes
bug #148458.
2004-07-26 Sven Neumann <sven@gimp.org> 2004-07-26 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpcolorscales.c (gimp_color_scales_hex_events): * libgimpwidgets/gimpcolorscales.c (gimp_color_scales_hex_events):

View File

@ -77,20 +77,20 @@ struct _GimpEditSelectionTool
{ {
GimpDrawTool parent_instance; GimpDrawTool parent_instance;
gint origx, origy; /* last x and y coords */ gint origx, origy; /* Last x and y coords */
gint cumlx, cumly; /* cumulative changes to x and yed */ gint cumlx, cumly; /* Cumulative changes to x and yed */
gint x, y; /* current x and y coords */ gint x, y; /* Current x and y coords */
gint num_segs_in; /* Num seg in selection boundary */ gint num_segs_in; /* Num seg in selection boundary */
gint num_segs_out; /* Num seg in selection boundary */ gint num_segs_out; /* Num seg in selection boundary */
BoundSeg *segs_in; /* Pointer to the channel sel. segs */ BoundSeg *segs_in; /* Pointer to the channel sel. segs */
BoundSeg *segs_out; /* Pointer to the channel sel. segs */ BoundSeg *segs_out; /* Pointer to the channel sel. segs */
gint x1, y1; /* bounding box of selection mask */ gint x1, y1; /* Bounding box of selection mask */
gint x2, y2; gint x2, y2;
EditType edit_type; /* translate the mask or layer? */ EditType edit_type; /* Translate the mask or layer? */
gboolean first_move; /* we undo_freeze after the first */ gboolean first_move; /* Don't push undos after the first */
}; };
struct _GimpEditSelectionToolClass struct _GimpEditSelectionToolClass
@ -152,11 +152,8 @@ gimp_edit_selection_tool_get_type (void)
static void static void
gimp_edit_selection_tool_class_init (GimpEditSelectionToolClass *klass) gimp_edit_selection_tool_class_init (GimpEditSelectionToolClass *klass)
{ {
GimpToolClass *tool_class; GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_class; GimpDrawToolClass *draw_class = GIMP_DRAW_TOOL_CLASS (klass);
tool_class = GIMP_TOOL_CLASS (klass);
draw_class = GIMP_DRAW_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
@ -169,9 +166,7 @@ gimp_edit_selection_tool_class_init (GimpEditSelectionToolClass *klass)
static void static void
gimp_edit_selection_tool_init (GimpEditSelectionTool *edit_selection_tool) gimp_edit_selection_tool_init (GimpEditSelectionTool *edit_selection_tool)
{ {
GimpTool *tool; GimpTool *tool = GIMP_TOOL (edit_selection_tool);
tool = GIMP_TOOL (edit_selection_tool);
gimp_tool_control_set_scroll_lock (tool->control, EDIT_SELECT_SCROLL_LOCK); gimp_tool_control_set_scroll_lock (tool->control, EDIT_SELECT_SCROLL_LOCK);
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_COMPRESS); gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_COMPRESS);
@ -453,8 +448,7 @@ init_edit_selection (GimpTool *tool,
gimp_tool_control_activate (GIMP_TOOL (edit_select)->control); gimp_tool_control_activate (GIMP_TOOL (edit_select)->control);
GIMP_TOOL (edit_select)->gdisp = gdisp; GIMP_TOOL (edit_select)->gdisp = gdisp;
tool_manager_push_tool (gdisp->gimage->gimp, tool_manager_push_tool (gdisp->gimage->gimp, GIMP_TOOL (edit_select));
GIMP_TOOL (edit_select));
/* pause the current selection */ /* pause the current selection */
gimp_display_shell_selection_visibility (shell, GIMP_SELECTION_PAUSE); gimp_display_shell_selection_visibility (shell, GIMP_SELECTION_PAUSE);
@ -474,13 +468,10 @@ gimp_edit_selection_tool_button_release (GimpTool *tool,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
GimpEditSelectionTool *edit_select; GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
GimpDisplayShell *shell; GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (gdisp->shell);
GimpItem *active_item; GimpItem *active_item;
edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
/* resume the current selection */ /* resume the current selection */
gimp_display_shell_selection_visibility (shell, GIMP_SELECTION_RESUME); gimp_display_shell_selection_visibility (shell, GIMP_SELECTION_RESUME);
@ -514,15 +505,6 @@ gimp_edit_selection_tool_button_release (GimpTool *tool,
TRUE); TRUE);
} }
if (edit_select->first_move)
{
gimp_image_undo_freeze (gdisp->gimage);
edit_select->first_move = FALSE;
}
/* thaw the undo again */
gimp_image_undo_thaw (gdisp->gimage);
/* EDIT_CHANNEL_TRANSLATE and EDIT_LAYER_MASK_TRANSLATE need to be /* EDIT_CHANNEL_TRANSLATE and EDIT_LAYER_MASK_TRANSLATE need to be
* preformed after thawing the undo. * preformed after thawing the undo.
*/ */
@ -596,16 +578,11 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
GimpEditSelectionTool *edit_select; GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
GimpDisplayShell *shell;
GimpItem *active_item; GimpItem *active_item;
gint off_x, off_y; gint off_x, off_y;
gdouble motion_x, motion_y; gdouble motion_x, motion_y;
edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gdk_flush (); gdk_flush ();
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
@ -667,7 +644,8 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
* on button_release. * on button_release.
*/ */
if (edit_select->edit_type != EDIT_CHANNEL_TRANSLATE) if (edit_select->edit_type != EDIT_CHANNEL_TRANSLATE)
gimp_item_translate (active_item, xoffset, yoffset, TRUE); gimp_item_translate (active_item, xoffset, yoffset,
edit_select->first_move);
if (gimp_item_get_linked (active_item)) if (gimp_item_get_linked (active_item))
{ {
@ -682,16 +660,11 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
for (list = linked; list; list = g_list_next (list)) for (list = linked; list; list = g_list_next (list))
gimp_item_translate (GIMP_ITEM (list->data), gimp_item_translate (GIMP_ITEM (list->data),
xoffset, yoffset, TRUE); xoffset, yoffset,
edit_select->first_move);
g_list_free (linked); g_list_free (linked);
} }
if (edit_select->first_move)
{
gimp_image_undo_freeze (gdisp->gimage);
edit_select->first_move = FALSE;
}
break; break;
case EDIT_MASK_TO_LAYER_TRANSLATE: case EDIT_MASK_TO_LAYER_TRANSLATE:
@ -709,12 +682,6 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
return; return;
} }
/* 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;
edit_select->origx -= edit_select->x1; edit_select->origx -= edit_select->x1;
edit_select->origy -= edit_select->y1; edit_select->origy -= edit_select->y1;
edit_select->x2 -= edit_select->x1; edit_select->x2 -= edit_select->x1;
@ -729,13 +696,8 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
/* fall through */ /* fall through */
case EDIT_FLOATING_SEL_TRANSLATE: case EDIT_FLOATING_SEL_TRANSLATE:
gimp_item_translate (active_item, xoffset, yoffset, TRUE); gimp_item_translate (active_item, xoffset, yoffset,
edit_select->first_move);
if (edit_select->first_move)
{
gimp_image_undo_freeze (gdisp->gimage);
edit_select->first_move = FALSE;
}
break; break;
default: default:
@ -748,6 +710,8 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
/********************************************************************/ /********************************************************************/
/********************************************************************/ /********************************************************************/
edit_select->first_move = FALSE;
gimp_tool_pop_status (tool); gimp_tool_pop_status (tool);
gimp_tool_push_status_coords (tool, gimp_tool_push_status_coords (tool,
@ -762,13 +726,10 @@ gimp_edit_selection_tool_motion (GimpTool *tool,
static void static void
gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool) gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool)
{ {
GimpEditSelectionTool *edit_select; GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (draw_tool);
GimpDisplay *gdisp; GimpDisplay *gdisp = GIMP_TOOL (draw_tool)->gdisp;
GimpItem *active_item; GimpItem *active_item;
edit_select = GIMP_EDIT_SELECTION_TOOL (draw_tool);
gdisp = GIMP_TOOL (draw_tool)->gdisp;
if (edit_select->edit_type == EDIT_VECTORS_TRANSLATE) if (edit_select->edit_type == EDIT_VECTORS_TRANSLATE)
active_item = GIMP_ITEM (gimp_image_get_active_vectors (gdisp->gimage)); active_item = GIMP_ITEM (gimp_image_get_active_vectors (gdisp->gimage));
else else