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



commit ed20393f0eebd8299a42a7ddd28e5f653d5732fa
Author: Ell <ell_se yahoo com>
Date:   Sat Sep 29 12:25:51 2018 -0400

    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.

 app/display/gimpdisplayshell-tool-events.c | 18 ++++++++++++------
 app/tools/gimpgradienttool.c               |  2 ++
 app/tools/gimptoolcontrol.c                | 18 ++++++++++++++++++
 app/tools/gimptoolcontrol.h                |  9 ++++++++-
 app/tools/gimpwarptool.c                   |  2 ++
 app/tools/tool_manager.c                   |  8 ++++++--
 6 files changed, 48 insertions(+), 9 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index 19064dcbd7..b918a029e5 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -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)
diff --git a/app/tools/gimpgradienttool.c b/app/tools/gimpgradienttool.c
index 0bc37aa599..c3050ba2ad 100644
--- a/app/tools/gimpgradienttool.c
+++ b/app/tools/gimpgradienttool.c
@@ -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,
diff --git a/app/tools/gimptoolcontrol.c b/app/tools/gimptoolcontrol.c
index 74c4311a54..d8b138683f 100644
--- a/app/tools/gimptoolcontrol.c
+++ b/app/tools/gimptoolcontrol.c
@@ -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)
diff --git a/app/tools/gimptoolcontrol.h b/app/tools/gimptoolcontrol.h
index f50e8a700b..855180698f 100644
--- a/app/tools/gimptoolcontrol.h
+++ b/app/tools/gimptoolcontrol.h
@@ -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);
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index 6e88ebce23..077c45b09f 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -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);
diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c
index 0921a35fc7..45decdca28 100644
--- a/app/tools/tool_manager.c
+++ b/app/tools/tool_manager.c
@@ -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);
+        }
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]