Commit ed20393f authored by Ell's avatar Ell

Issue #1180 - Warp tool aborts changes to layer A when ...

... changing layers and warping layer B

Add a new GimpToolControl::dirty_action field, which specifies the
tool action to perform when the a dirty event matching the tool
control's dirty mask occurs; this field defaults to HALT.  Apply
this action to the active tool in tool-manager in response to a
matching dirty event, instead of unconditionally halting the tool.
Likewise, use this action to stop the active tool in response to a
button-press event on a different drawable in the same image.

Set the dirty action of the gradient and warp tools to COMMIT, so
that they get comitted, rather than stopped, in cases such as
switching layers (including switching to/from quick-mask mode),
and, for the warp tool, changing the selection.
parent 1742e761
......@@ -1861,14 +1861,20 @@ gimp_display_shell_initialize_tool (GimpDisplayShell *shell,
if (image == gimp_item_get_image (GIMP_ITEM (active_tool->drawable)))
{
/* When changing between drawables if the *same* image,
* halt the tool so it doesn't get committed on tool
* change. This is a pure "probably better this way"
* stop the tool using its dirty action, so it doesn't
* get committed on tool change, in case its dirty action
* is HALT. This is a pure "probably better this way"
* decision because the user is likely changing their
* mind or was simply on the wrong layer. See bug
* #776370.
* mind or was simply on the wrong layer. See bug #776370.
*
* See also issues #1180 and #1202 for cases where we
* actually *don't* want to halt the tool here, but rather
* commit it, hence the use of the tool's dirty action.
*/
tool_manager_control_active (gimp, GIMP_TOOL_ACTION_HALT,
active_tool->display);
tool_manager_control_active (
gimp,
gimp_tool_control_get_dirty_action (active_tool->control),
active_tool->display);
}
if (procedure)
......
......@@ -198,6 +198,8 @@ gimp_gradient_tool_init (GimpGradientTool *gradient_tool)
GIMP_DIRTY_IMAGE_STRUCTURE |
GIMP_DIRTY_DRAWABLE |
GIMP_DIRTY_ACTIVE_DRAWABLE);
gimp_tool_control_set_dirty_action (tool->control,
GIMP_TOOL_ACTION_COMMIT);
gimp_tool_control_set_wants_click (tool->control, TRUE);
gimp_tool_control_set_wants_double_click (tool->control, TRUE);
gimp_tool_control_set_active_modifiers (tool->control,
......
......@@ -52,6 +52,7 @@ gimp_tool_control_init (GimpToolControl *control)
control->handle_empty_image = FALSE;
control->dirty_mask = GIMP_DIRTY_NONE;
control->dirty_action = GIMP_TOOL_ACTION_HALT;
control->motion_mode = GIMP_MOTION_MODE_COMPRESS;
control->auto_snap_to = TRUE;
......@@ -247,6 +248,23 @@ gimp_tool_control_get_dirty_mask (GimpToolControl *control)
return control->dirty_mask;
}
void
gimp_tool_control_set_dirty_action (GimpToolControl *control,
GimpToolAction action)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
control->dirty_action = action;
}
GimpToolAction
gimp_tool_control_get_dirty_action (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control), GIMP_TOOL_ACTION_HALT);
return control->dirty_action;
}
void
gimp_tool_control_set_motion_mode (GimpToolControl *control,
GimpMotionMode motion_mode)
......
......@@ -47,8 +47,11 @@ struct _GimpToolControl
gboolean scroll_lock; /* allow scrolling or not */
gboolean handle_empty_image; /* invoke the tool on images *
* without active drawable */
GimpDirtyMask dirty_mask; /* if preserve is FALSE, cancel *
GimpDirtyMask dirty_mask; /* if preserve is FALSE, stop *
* the tool on these events */
GimpToolAction dirty_action; /* use this action to stop the *
* tool when one of the dirty *
* events occurs */
GimpMotionMode motion_mode; /* how to process motion events *
* before they go to the tool */
gboolean auto_snap_to; /* snap to guides automatically */
......@@ -125,6 +128,10 @@ void gimp_tool_control_set_dirty_mask (GimpToolControl *control,
GimpDirtyMask dirty_mask);
GimpDirtyMask gimp_tool_control_get_dirty_mask (GimpToolControl *control);
void gimp_tool_control_set_dirty_action (GimpToolControl *control,
GimpToolAction action);
GimpToolAction gimp_tool_control_get_dirty_action (GimpToolControl *control);
void gimp_tool_control_set_motion_mode (GimpToolControl *control,
GimpMotionMode motion_mode);
GimpMotionMode gimp_tool_control_get_motion_mode (GimpToolControl *control);
......
......@@ -193,6 +193,8 @@ gimp_warp_tool_init (GimpWarpTool *self)
GIMP_DIRTY_DRAWABLE |
GIMP_DIRTY_SELECTION |
GIMP_DIRTY_ACTIVE_DRAWABLE);
gimp_tool_control_set_dirty_action (tool->control,
GIMP_TOOL_ACTION_COMMIT);
gimp_tool_control_set_wants_click (tool->control, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_WARP);
......
......@@ -776,8 +776,12 @@ tool_manager_image_clean_dirty (GimpImage *image,
GimpDisplay *display = gimp_tool_has_image (tool, image);
if (display)
tool_manager_control_active (image->gimp, GIMP_TOOL_ACTION_HALT,
display);
{
tool_manager_control_active (
image->gimp,
gimp_tool_control_get_dirty_action (tool->control),
display);
}
}
}
......
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