[gimp] app: update custom guides when moved past display bounds



commit 9a25ae7171f27b0930d33170a776adfd4eaabda8
Author: Ell <ell_se yahoo com>
Date:   Thu Jun 11 20:10:25 2020 +0300

    app: update custom guides when moved past display bounds
    
    In GimpGuideTool, when a custom guide (whose position is updated
    directly on motion) is moved past the display bounds, keep updating
    the corresponding GimpGuide's position, even though the guide will
    be removed on release, to avoid leaving the guide at its old
    position.
    
    This affects the filter tool's split-preview guide.

 app/tools/gimpguidetool.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/app/tools/gimpguidetool.c b/app/tools/gimpguidetool.c
index f52f9d28ba..55d5732155 100644
--- a/app/tools/gimpguidetool.c
+++ b/app/tools/gimpguidetool.c
@@ -292,12 +292,20 @@ gimp_guide_tool_motion (GimpTool         *tool,
     {
       GimpGuideToolGuide *guide = &guide_tool->guides[i];
       gint                max_position;
+      gint                position;
 
       if (guide->orientation == GIMP_ORIENTATION_HORIZONTAL)
         max_position = gimp_image_get_height (image);
       else
         max_position = gimp_image_get_width (image);
 
+      if (guide->orientation == GIMP_ORIENTATION_HORIZONTAL)
+        guide->position = RINT (coords->y);
+      else
+        guide->position = RINT (coords->x);
+
+      position = CLAMP (guide->position, 0, max_position);
+
       if (tx < 0 || tx >= shell->disp_width ||
           ty < 0 || ty >= shell->disp_height)
         {
@@ -307,22 +315,13 @@ gimp_guide_tool_motion (GimpTool         *tool,
         }
       else
         {
-          if (guide->orientation == GIMP_ORIENTATION_HORIZONTAL)
-            guide->position = RINT (coords->y);
-          else
-            guide->position = RINT (coords->x);
-
           if (guide->position < 0 || guide->position > max_position)
             remove_guides = TRUE;
-
-          /* custom guides are moved live */
-          if (guide->custom)
-            {
-              gimp_image_move_guide (image, guide->guide,
-                                     CLAMP (guide->position, 0, max_position),
-                                     TRUE);
-            }
         }
+
+      /* custom guides are moved live */
+      if (guide->custom)
+        gimp_image_move_guide (image, guide->guide, position, TRUE);
     }
 
   gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));


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