[gimp/gimp-2-10] Issue #2540 - block width / height slider of the pixelize filter don't...



commit 23cc540f62ec9d5852b14979fc338905c21cf90b
Author: Michael Natterer <mitch gimp org>
Date:   Thu Jan 3 22:19:48 2019 +0100

    Issue #2540 - block width / height slider of the pixelize filter don't...
    
    ...have the same scaling
    
    gimp_prop_widget_new_from_pspec(): when restricting the scale to the
    actual op area for pixel-coordinate and pixel-distance properties,
    only use the max value in the axis direction for pixel-coordinate; for
    pixel-distance make sure we use the same value on both axes, simply
    use MAX (area.width, area.height).
    
    (cherry picked from commit 0a1ecdf4ee16b91915b8e4f4611246edcbc99103)

 app/propgui/gimppropgui.c | 48 +++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/app/propgui/gimppropgui.c b/app/propgui/gimppropgui.c
index 26ea0feaba..580bee905d 100644
--- a/app/propgui/gimppropgui.c
+++ b/app/propgui/gimppropgui.c
@@ -245,37 +245,45 @@ gimp_prop_widget_new_from_pspec (GObject                  *config,
         {
           gimp_prop_gui_bind_label (widget, widget);
 
-          if (area)
+          if (area &&
+              (HAS_KEY (pspec, "unit", "pixel-coordinate") ||
+               HAS_KEY (pspec, "unit", "pixel-distance")) &&
+              (HAS_KEY (pspec, "axis", "x") ||
+               HAS_KEY (pspec, "axis", "y")))
             {
-              if (HAS_KEY (pspec, "unit", "pixel-coordinate") ||
-                  HAS_KEY (pspec, "unit", "pixel-distance"))
+              gdouble min = lower;
+              gdouble max = upper;
+
+              if (HAS_KEY (pspec, "unit", "pixel-coordinate"))
                 {
-                  gint off_x = 0;
-                  gint off_y = 0;
+                  /* limit pixel coordinate scales to the actual area */
 
-                  if (HAS_KEY (pspec, "unit", "pixel-coordinate"))
-                    {
-                      off_x = area->x;
-                      off_y = area->y;
-                    }
+                  gint off_x = area->x;
+                  gint off_y = area->y;
 
                   if (HAS_KEY (pspec, "axis", "x"))
                     {
-                      gdouble min = MAX (lower, off_x);
-                      gdouble max = MIN (upper, off_x + area->width);
-
-                      gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (widget),
-                                                        min, max);
+                      min = MAX (lower, off_x);
+                      max = MIN (upper, off_x + area->width);
                     }
                   else if (HAS_KEY (pspec, "axis","y"))
                     {
-                      gdouble min = MAX (lower, off_y);
-                      gdouble max = MIN (upper, off_y + area->height);
-
-                      gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (widget),
-                                                        min, max);
+                      min = MAX (lower, off_y);
+                      max = MIN (upper, off_y + area->height);
                     }
                 }
+              else if (HAS_KEY (pspec, "unit", "pixel-distance"))
+                {
+                  /* limit pixel distance scales to the same value on the
+                   * x and y axes, so linked values have the same range,
+                   * we use MAX (width, height), see issue #2540
+                   */
+
+                  max = MIN (upper, MAX (area->width, area->height));
+                }
+
+              gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (widget),
+                                                min, max);
             }
         }
     }


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