diff --git a/app/propgui/gimppropgui.c b/app/propgui/gimppropgui.c index 0680b4dffc..1825570197 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")) - { - gint off_x = 0; - gint off_y = 0; + gdouble min = lower; + gdouble max = upper; - if (HAS_KEY (pspec, "unit", "pixel-coordinate")) - { - off_x = area->x; - off_y = area->y; - } + if (HAS_KEY (pspec, "unit", "pixel-coordinate")) + { + /* limit pixel coordinate scales to the actual area */ + + 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); } } }