[gimp] app/tools: don't use -1 as invalid guide position



commit 5e0fbc66a09c828ecb3586362c6cf99ccec5f2a7
Author: Sven Neumann <sven gimp org>
Date:   Mon Oct 4 21:22:28 2010 +0200

    app/tools: don't use -1 as invalid guide position
    
    Introduce a define for the invalid guide position that is used when
    creating a new guide and define it as G_MININT. The value of -1
    that used to be used for this caused the moving guide to disappear
    at position -1.

 app/tools/gimpmovetool.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c
index 7a17959..d38ee28 100644
--- a/app/tools/gimpmovetool.c
+++ b/app/tools/gimpmovetool.c
@@ -60,6 +60,8 @@
 #include "gimp-intl.h"
 
 
+#define GUIDE_POSITION_INVALID G_MININT
+
 #define SWAP_ORIENT(orient) ((orient) == GIMP_ORIENTATION_HORIZONTAL ? \
                              GIMP_ORIENTATION_VERTICAL : \
                              GIMP_ORIENTATION_HORIZONTAL)
@@ -157,7 +159,7 @@ gimp_move_tool_init (GimpMoveTool *move_tool)
   move_tool->guide              = NULL;
 
   move_tool->moving_guide       = FALSE;
-  move_tool->guide_position     = -1;
+  move_tool->guide_position     = GUIDE_POSITION_INVALID;
   move_tool->guide_orientation  = GIMP_ORIENTATION_UNKNOWN;
 
   move_tool->saved_type         = GIMP_TRANSFORM_TYPE_LAYER;
@@ -216,9 +218,9 @@ gimp_move_tool_button_press (GimpTool            *tool,
         }
       else if (options->move_type == GIMP_TRANSFORM_TYPE_LAYER)
         {
-          GimpGuide *guide;
-          GimpLayer *layer;
-          gint       snap_distance = display->config->snap_distance;
+          GimpGuide  *guide;
+          GimpLayer  *layer;
+          const gint  snap_distance = display->config->snap_distance;
 
           if (gimp_display_shell_get_show_guides (shell) &&
               (guide = gimp_image_find_guide (image,
@@ -347,7 +349,7 @@ gimp_move_tool_button_release (GimpTool              *tool,
       if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
         {
           move->moving_guide      = FALSE;
-          move->guide_position    = -1;
+          move->guide_position    = GUIDE_POSITION_INVALID;
           move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
 
           gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME);
@@ -415,7 +417,7 @@ gimp_move_tool_button_release (GimpTool              *tool,
       gimp_image_flush (image);
 
       move->moving_guide      = FALSE;
-      move->guide_position    = -1;
+      move->guide_position    = GUIDE_POSITION_INVALID;
       move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
 
       if (move->guide)
@@ -485,7 +487,7 @@ gimp_move_tool_motion (GimpTool         *tool,
       if (tx < 0 || tx >= shell->disp_width ||
           ty < 0 || ty >= shell->disp_height)
         {
-          move->guide_position = -1;
+          move->guide_position = GUIDE_POSITION_INVALID;
 
           delete_guide = TRUE;
         }
@@ -627,7 +629,7 @@ gimp_move_tool_oper_update (GimpTool         *tool,
       gimp_display_shell_get_show_guides (shell)      &&
       proximity)
     {
-      gint snap_distance = display->config->snap_distance;
+      const gint snap_distance = display->config->snap_distance;
 
       guide = gimp_image_find_guide (image, coords->x, coords->y,
                                      FUNSCALEX (shell, snap_distance),
@@ -705,9 +707,9 @@ gimp_move_tool_cursor_update (GimpTool         *tool,
     }
   else
     {
-      GimpGuide *guide;
-      GimpLayer *layer;
-      gint       snap_distance = display->config->snap_distance;
+      GimpGuide  *guide;
+      GimpLayer  *layer;
+      const gint  snap_distance = display->config->snap_distance;
 
       if (gimp_display_shell_get_show_guides (shell) &&
           (guide = gimp_image_find_guide (image, coords->x, coords->y,
@@ -762,7 +764,7 @@ gimp_move_tool_draw (GimpDrawTool *draw_tool)
       gimp_canvas_item_set_highlight (item, TRUE);
     }
 
-  if (move->moving_guide && move->guide_position != -1)
+  if (move->moving_guide && move->guide_position != GUIDE_POSITION_INVALID)
     {
       gimp_draw_tool_add_guide (draw_tool,
                                 move->guide_orientation,
@@ -812,7 +814,7 @@ gimp_move_tool_start_guide (GimpMoveTool        *move,
 
   move->guide             = NULL;
   move->moving_guide      = TRUE;
-  move->guide_position    = -1;
+  move->guide_position    = GUIDE_POSITION_INVALID;
   move->guide_orientation = orientation;
 
   gimp_tool_set_cursor (tool, display,



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