app: new gimp_spin_scale_set_constrain_drag() and use it on paint...
... tools' brush options. After discussions, it turned out that many people disliked that the spin scale for brush size (and some other options) get you fractional values. How often do you actually need to get a 4.32 pixel-size brush? And even how meaningful is it? On the other hand, you usually want a 4 or a 5 pixel size brush and it's nearly impossible to get (exactly) by dragging the scale widget. It is so annoying that some even resort to edit the value with keyboard! So I am adding an optional "constrain" feature to GimpSpinScale. It will still be possible to get fractional values when constraining is on, for instance with keyboard edit (the arrow incrementation also will keep any fractional part). So the interaction for such scales is simply reversed so that you get integers easily, and fractional parts with a bit more effort. It is not turned on by default (some feature actually need precision and we don't want to break the sliders for these) and for the time being, I only applied it to all the brush settings in paint tools. Now that it exist, we may want to apply this to more scales in various parts of GIMP.
This commit is contained in:
@ -524,6 +524,8 @@ gimp_paint_options_gui_scale_with_buttons (GObject *config,
|
||||
|
||||
scale = gimp_prop_spin_scale_new (config, prop_name, NULL,
|
||||
step_increment, page_increment, digits);
|
||||
gimp_spin_scale_set_constrain_drag (GIMP_SPIN_SCALE (scale), TRUE);
|
||||
|
||||
gimp_prop_widget_set_factor (scale, factor,
|
||||
step_increment, page_increment, digits);
|
||||
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale),
|
||||
|
||||
@ -62,6 +62,8 @@ struct _GimpSpinScalePrivate
|
||||
guint mnemonic_keyval;
|
||||
gboolean mnemonics_visible;
|
||||
|
||||
gboolean constrain_drag;
|
||||
|
||||
gboolean scale_limits_set;
|
||||
gdouble scale_lower;
|
||||
gdouble scale_upper;
|
||||
@ -760,6 +762,9 @@ gimp_spin_scale_change_value (GtkWidget *widget,
|
||||
value = RINT (value);
|
||||
value /= power;
|
||||
|
||||
if (private->constrain_drag)
|
||||
value = rint (value);
|
||||
|
||||
gtk_adjustment_set_value (adjustment, value);
|
||||
}
|
||||
|
||||
@ -1382,3 +1387,35 @@ gimp_spin_scale_get_gamma (GimpSpinScale *scale)
|
||||
|
||||
return GET_PRIVATE (scale)->gamma;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_spin_scale_set_constrain_drag:
|
||||
* @scale: the #GimpSpinScale.
|
||||
* @constrain: whether constraining to integer values when dragging with
|
||||
* pointer.
|
||||
*
|
||||
* If @constrain_drag is TRUE, dragging the scale with the pointer will
|
||||
* only result into integer values. It will still possible to set the
|
||||
* scale to fractional values (if the spin scale "digits" is above 0)
|
||||
* for instance with keyboard edit.
|
||||
*/
|
||||
void
|
||||
gimp_spin_scale_set_constrain_drag (GimpSpinScale *scale,
|
||||
gboolean constrain)
|
||||
{
|
||||
GimpSpinScalePrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_SPIN_SCALE (scale));
|
||||
|
||||
private = GET_PRIVATE (scale);
|
||||
|
||||
private->constrain_drag = constrain;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_spin_scale_get_constrain_drag (GimpSpinScale *scale)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_SPIN_SCALE (scale), 1.0);
|
||||
|
||||
return GET_PRIVATE (scale)->constrain_drag;
|
||||
}
|
||||
|
||||
@ -66,5 +66,8 @@ void gimp_spin_scale_set_gamma (GimpSpinScale *scale,
|
||||
gdouble gamma);
|
||||
gdouble gimp_spin_scale_get_gamma (GimpSpinScale *scale);
|
||||
|
||||
void gimp_spin_scale_set_constrain_drag (GimpSpinScale *scale,
|
||||
gboolean constrain);
|
||||
gboolean gimp_spin_scale_get_constrain_drag (GimpSpinScale *scale);
|
||||
|
||||
#endif /* __GIMP_SPIN_SCALE_H__ */
|
||||
|
||||
Reference in New Issue
Block a user