[gimp] app: fix some corner cases in gimp_text_tool_button_release()



commit b9405d046a51ae4692bd30a5c9d66efe6c5414d3
Author: Michael Natterer <mitch gimp org>
Date:   Sun Mar 7 00:53:32 2010 +0100

    app: fix some corner cases in gimp_text_tool_button_release()
    
    - request "click" releases instead of trying to detect them ourselves,
      but keep a minimum reasonable text layer size anyway (reduce it from
      20 to 3 pixels though).
    - ignore RELEASE_CANCEL when selecting, we can't undo that yet.
    - properly handle RELEASE_CANCEL when creating new lext layers (don't
      leave a dead overlay style editor around).

 app/tools/gimptexttool.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index d59bfdf..16258cf 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -261,6 +261,7 @@ gimp_text_tool_init (GimpTextTool *text_tool)
   gimp_text_tool_editor_init (text_tool);
 
   gimp_tool_control_set_scroll_lock          (tool->control, TRUE);
+  gimp_tool_control_set_wants_click          (tool->control, TRUE);
   gimp_tool_control_set_wants_double_click   (tool->control, TRUE);
   gimp_tool_control_set_wants_triple_click   (tool->control, TRUE);
   gimp_tool_control_set_wants_all_key_events (tool->control, TRUE);
@@ -476,8 +477,6 @@ gimp_text_tool_button_press (GimpTool            *tool,
   gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
 }
 
-#define MIN_LAYER_WIDTH 20
-
 static void
 gimp_text_tool_button_release (GimpTool              *tool,
                                const GimpCoords      *coords,
@@ -520,14 +519,28 @@ gimp_text_tool_button_release (GimpTool              *tool,
       text_tool->selecting = FALSE;
 
       text_tool->handle_rectangle_change_complete = FALSE;
+
+      /*  there is no cancelling of selections yet  */
+      if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
+        release_type = GIMP_BUTTON_RELEASE_NORMAL;
     }
   else if (gimp_rectangle_tool_get_function (rect_tool) ==
            GIMP_RECTANGLE_TOOL_DEAD)
     {
       /*  the user clicked in dead space (like between the corner and
-       *  edge handles, completely ignore that too.
+       *  edge handles, so completely ignore that.
+       */
+
+      text_tool->handle_rectangle_change_complete = FALSE;
+    }
+  else if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
+    {
+      /*  user has clicked outside of any text layer in order to
+       *  create a new text, but cancelled the operation.
        */
 
+      gimp_text_tool_editor_halt (text_tool);
+
       text_tool->handle_rectangle_change_complete = FALSE;
     }
   else
@@ -548,7 +561,9 @@ gimp_text_tool_button_release (GimpTool              *tool,
                     "y2", &y2,
                     NULL);
 
-      if ((y2 - y1) < MIN_LAYER_WIDTH)
+      if (release_type == GIMP_BUTTON_RELEASE_CLICK ||
+          (x2 - x1) < 3                             ||
+          (y2 - y1) < 3)
         {
           /*  unless the rectangle is unreasonably small to hold any
            *  real text (the user has eitherjust clicked or just made



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