mirror of https://github.com/GNOME/gimp.git
app, libgimp: add increment parameters to gimp_prop_widget_set_factor()
Step and page increments can't be reasonable calculated or guessed based on the GUI widget's factor, so pass them each time we call set_factor(). This change reintroduces sane ranges for the levels tool for != u8 images again.
This commit is contained in:
parent
55b299f63d
commit
7385e030dd
|
@ -144,13 +144,17 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
|
|||
|
||||
if (gimp_drawable_get_component_type (drawable) == GIMP_COMPONENT_TYPE_U8)
|
||||
{
|
||||
gimp_prop_widget_set_factor (bc_tool->brightness_scale, 127.0, 0);
|
||||
gimp_prop_widget_set_factor (bc_tool->contrast_scale, 127.0, 0);
|
||||
gimp_prop_widget_set_factor (bc_tool->brightness_scale,
|
||||
127.0, 1.0, 8.0, 0);
|
||||
gimp_prop_widget_set_factor (bc_tool->contrast_scale,
|
||||
127.0, 1.0, 8.0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_prop_widget_set_factor (bc_tool->brightness_scale, 0.5, 3);
|
||||
gimp_prop_widget_set_factor (bc_tool->contrast_scale, 0.5, 3);
|
||||
gimp_prop_widget_set_factor (bc_tool->brightness_scale,
|
||||
0.5, 0.01, 0.1, 3);
|
||||
gimp_prop_widget_set_factor (bc_tool->contrast_scale,
|
||||
0.5, 0.01, 0.1, 3);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -249,8 +253,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
|
||||
/* Create the brightness scale widget */
|
||||
scale = gimp_prop_spin_scale_new (image_map_tool->config, "brightness",
|
||||
_("_Brightness"), 1.0 / 127.0, 10.0 / 127.0,
|
||||
0);
|
||||
_("_Brightness"), 0.01, 0.1, 3);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
|
@ -258,8 +261,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
|
||||
/* Create the contrast scale widget */
|
||||
scale = gimp_prop_spin_scale_new (image_map_tool->config, "contrast",
|
||||
_("_Contrast"), 1.0 / 127.0, 10.0 / 127.0,
|
||||
0);
|
||||
_("_Contrast"), 0.01, 0.1, 3);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ create_levels_scale (GObject *config,
|
|||
|
||||
scale = gimp_prop_spin_scale_new (config, property_name,
|
||||
NULL, 0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 1);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), scale, 1, 2, col, col + 1);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
|
|
|
@ -171,22 +171,22 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
|
||||
/* Create the hue scale widget */
|
||||
scale = gimp_prop_spin_scale_new (image_map_tool->config, "hue",
|
||||
_("_Hue"), 1.0 / 230.0, 15.0 / 360.0, 0);
|
||||
gimp_prop_widget_set_factor (scale, 360.0, 1);
|
||||
_("_Hue"), 1.0 / 360.0, 15.0 / 360.0, 0);
|
||||
gimp_prop_widget_set_factor (scale, 360.0, 0.0, 0.0, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
/* Create the saturation scale widget */
|
||||
scale = gimp_prop_spin_scale_new (image_map_tool->config, "saturation",
|
||||
_("_Saturation"), 0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 1);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
/* Create the lightness scale widget */
|
||||
scale = gimp_prop_spin_scale_new (image_map_tool->config, "lightness",
|
||||
_("_Lightness"), 0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 1);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
/* Create the 'Overlap' option slider */
|
||||
scale = gimp_prop_spin_scale_new (image_map_tool->config, "overlap",
|
||||
_("_Overlap"), 0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 1);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
|
@ -301,21 +301,21 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
/* Create the hue scale widget */
|
||||
scale = gimp_prop_spin_scale_new (image_map_tool->config, "hue",
|
||||
_("_Hue"), 1.0 / 180.0, 15.0 / 180.0, 0);
|
||||
gimp_prop_widget_set_factor (scale, 180.0, 1);
|
||||
gimp_prop_widget_set_factor (scale, 180.0, 0.0, 0.0, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
/* Create the lightness scale widget */
|
||||
scale = gimp_prop_spin_scale_new (image_map_tool->config, "lightness",
|
||||
_("_Lightness"), 0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 1);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
/* Create the saturation scale widget */
|
||||
scale = gimp_prop_spin_scale_new (image_map_tool->config, "saturation",
|
||||
_("_Saturation"), 0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 1);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
|
|
|
@ -194,6 +194,8 @@ gimp_levels_tool_initialize (GimpTool *tool,
|
|||
GimpImage *image = gimp_display_get_image (display);
|
||||
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
||||
gdouble scale_factor;
|
||||
gdouble step_increment;
|
||||
gdouble page_increment;
|
||||
gint digits;
|
||||
|
||||
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
|
||||
|
@ -210,23 +212,31 @@ gimp_levels_tool_initialize (GimpTool *tool,
|
|||
|
||||
if (gimp_drawable_get_component_type (drawable) == GIMP_COMPONENT_TYPE_U8)
|
||||
{
|
||||
scale_factor = 255.0;
|
||||
digits = 0;
|
||||
scale_factor = 255.0;
|
||||
step_increment = 1.0;
|
||||
page_increment = 8.0;
|
||||
digits = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale_factor = 10000;
|
||||
digits = 0;
|
||||
scale_factor = 100;
|
||||
step_increment = 0.01;
|
||||
page_increment = 1.0;
|
||||
digits = 2;
|
||||
}
|
||||
|
||||
gimp_prop_widget_set_factor (l_tool->low_input_spinbutton,
|
||||
scale_factor, digits);
|
||||
scale_factor, step_increment, page_increment,
|
||||
digits);
|
||||
gimp_prop_widget_set_factor (l_tool->high_input_spinbutton,
|
||||
scale_factor, digits);
|
||||
scale_factor, step_increment, page_increment,
|
||||
digits);
|
||||
gimp_prop_widget_set_factor (l_tool->low_output_spinbutton,
|
||||
scale_factor, digits);
|
||||
scale_factor, step_increment, page_increment,
|
||||
digits);
|
||||
gimp_prop_widget_set_factor (l_tool->high_output_spinbutton,
|
||||
scale_factor, digits);
|
||||
scale_factor, step_increment, page_increment,
|
||||
digits);
|
||||
|
||||
gtk_adjustment_configure (l_tool->gamma_linear,
|
||||
scale_factor / 2.0,
|
||||
|
@ -435,7 +445,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
|
||||
tool->low_input_spinbutton = spinbutton =
|
||||
gimp_prop_spin_button_new (image_map_tool->config, "low-input",
|
||||
0.0001, 0.1, 1);
|
||||
0.01, 0.1, 1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
|
@ -472,7 +482,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
gtk_widget_show (button);
|
||||
|
||||
spinbutton = gimp_prop_spin_button_new (image_map_tool->config, "high-input",
|
||||
0.0001, 0.1, 1);
|
||||
0.01, 0.1, 1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show (spinbutton);
|
||||
tool->high_input_spinbutton = spinbutton;
|
||||
|
@ -521,7 +531,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
/* low output spin */
|
||||
tool->low_output_spinbutton = spinbutton =
|
||||
gimp_prop_spin_button_new (image_map_tool->config, "low-output",
|
||||
0.0001, 0.1, 1);
|
||||
0.01, 0.1, 1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
|
@ -531,7 +541,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||
/* high output spin */
|
||||
tool->high_output_spinbutton = spinbutton =
|
||||
gimp_prop_spin_button_new (image_map_tool->config, "high-output",
|
||||
0.0001, 0.1, 1);
|
||||
0.01, 0.1, 1);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
|
|||
scale = gimp_prop_spin_scale_new (config, "opacity",
|
||||
_("Opacity"),
|
||||
0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 1);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
|
|||
scale = gimp_prop_spin_scale_new (config, "preview-opacity",
|
||||
_("Image opacity"),
|
||||
0.01, 0.1, 0);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 1);
|
||||
gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1);
|
||||
frame = gimp_prop_expanding_frame_new (config, "show-preview",
|
||||
_("Show image preview"),
|
||||
scale, NULL);
|
||||
|
|
|
@ -531,6 +531,8 @@ gimp_prop_spin_scale_new (GObject *config,
|
|||
void
|
||||
gimp_prop_widget_set_factor (GtkWidget *widget,
|
||||
gdouble factor,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gint digits)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
|
@ -564,12 +566,18 @@ gimp_prop_widget_set_factor (GtkWidget *widget,
|
|||
|
||||
f = factor / old_factor;
|
||||
|
||||
if (step_increment <= 0)
|
||||
step_increment = f * gtk_adjustment_get_step_increment (adjustment);
|
||||
|
||||
if (page_increment <= 0)
|
||||
page_increment = f * gtk_adjustment_get_page_increment (adjustment);
|
||||
|
||||
gtk_adjustment_configure (adjustment,
|
||||
f * gtk_adjustment_get_value (adjustment),
|
||||
f * gtk_adjustment_get_lower (adjustment),
|
||||
f * gtk_adjustment_get_upper (adjustment),
|
||||
f * gtk_adjustment_get_step_increment (adjustment),
|
||||
f * gtk_adjustment_get_page_increment (adjustment),
|
||||
step_increment,
|
||||
page_increment,
|
||||
f * gtk_adjustment_get_page_size (adjustment));
|
||||
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), digits);
|
||||
|
|
|
@ -62,6 +62,8 @@ GtkWidget * gimp_prop_spin_scale_new (GObject *config,
|
|||
|
||||
void gimp_prop_widget_set_factor (GtkWidget *widget,
|
||||
gdouble factor,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gint digits);
|
||||
|
||||
|
||||
|
|
|
@ -1237,6 +1237,8 @@ static void
|
|||
gimp_prop_widget_set_factor (GtkWidget *widget,
|
||||
GtkAdjustment *adjustment,
|
||||
gdouble factor,
|
||||
gdouble step_increment,
|
||||
gdouble page_increment,
|
||||
gint digits)
|
||||
{
|
||||
gdouble *factor_store;
|
||||
|
@ -1271,12 +1273,18 @@ gimp_prop_widget_set_factor (GtkWidget *widget,
|
|||
|
||||
f = factor / old_factor;
|
||||
|
||||
if (step_increment <= 0)
|
||||
step_increment = f * gtk_adjustment_get_step_increment (adjustment);
|
||||
|
||||
if (page_increment <= 0)
|
||||
page_increment = f * gtk_adjustment_get_page_increment (adjustment);
|
||||
|
||||
gtk_adjustment_configure (adjustment,
|
||||
f * gtk_adjustment_get_value (adjustment),
|
||||
f * gtk_adjustment_get_lower (adjustment),
|
||||
f * gtk_adjustment_get_upper (adjustment),
|
||||
f * gtk_adjustment_get_step_increment (adjustment),
|
||||
f * gtk_adjustment_get_page_increment (adjustment),
|
||||
step_increment,
|
||||
page_increment,
|
||||
f * gtk_adjustment_get_page_size (adjustment));
|
||||
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), digits);
|
||||
|
@ -1323,7 +1331,7 @@ gimp_prop_opacity_entry_new (GObject *config,
|
|||
{
|
||||
gimp_prop_widget_set_factor (GIMP_SCALE_ENTRY_SPINBUTTON (adjustment),
|
||||
GTK_ADJUSTMENT (adjustment),
|
||||
100.0, 1);
|
||||
100.0, 0.0, 0.0, 1);
|
||||
}
|
||||
|
||||
return adjustment;
|
||||
|
|
Loading…
Reference in New Issue