Commit 8354a781 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Applied slightly modified patch from Martin Nordholts which implements

2006-10-15  Michael Natterer  <mitch@gimp.org>

	Applied slightly modified patch from Martin Nordholts which
	implements more fine-grained steps for actions. Fixes bug #165612.

	* app/actions/actions-types.h: add additional values to
	enum GimpActionSelectType.

	* app/actions/actions.[ch] (action_select_value)
	(action_select_property): handle them here and added "small_inc"
	and "delta_factor" parameters.

	* app/actions/context-actions.c: added small and percent actions
	for the brush radius.

	* app/actions/context-commands.c
	* app/actions/layers-commands.c
	* app/actions/tools-commands.c
	* app/actions/view-commands.c: pass small and percent increase
	values to the action_select_foo() functions.

	* app/actions/context-commands.c (context_brush_radius_cmd_callback):
	make sure we don't end up with 1.1, 2.1 etc brush radius values.
parent 634a00e9
2006-10-15 Michael Natterer <mitch@gimp.org>
Applied slightly modified patch from Martin Nordholts which
implements more fine-grained steps for actions. Fixes bug #165612.
* app/actions/actions-types.h: add additional values to
enum GimpActionSelectType.
* app/actions/actions.[ch] (action_select_value)
(action_select_property): handle them here and added "small_inc"
and "delta_factor" parameters.
* app/actions/context-actions.c: added small and percent actions
for the brush radius.
* app/actions/context-commands.c
* app/actions/layers-commands.c
* app/actions/tools-commands.c
* app/actions/view-commands.c: pass small and percent increase
values to the action_select_foo() functions.
* app/actions/context-commands.c (context_brush_radius_cmd_callback):
make sure we don't end up with 1.1, 2.1 etc brush radius values.
2006-10-14 Michael Natterer <mitch@gimp.org>
* plug-ins/rcm/rcm_callback.c: use GDK_INVERT instead of GDK_XOR
......
......@@ -26,13 +26,17 @@
typedef enum
{
GIMP_ACTION_SELECT_SET = 0,
GIMP_ACTION_SELECT_FIRST = -1,
GIMP_ACTION_SELECT_LAST = -2,
GIMP_ACTION_SELECT_PREVIOUS = -3,
GIMP_ACTION_SELECT_NEXT = -4,
GIMP_ACTION_SELECT_SKIP_PREVIOUS = -5,
GIMP_ACTION_SELECT_SKIP_NEXT = -6
GIMP_ACTION_SELECT_SET = 0,
GIMP_ACTION_SELECT_FIRST = -1,
GIMP_ACTION_SELECT_LAST = -2,
GIMP_ACTION_SELECT_SMALL_PREVIOUS = -3,
GIMP_ACTION_SELECT_SMALL_NEXT = -4,
GIMP_ACTION_SELECT_PREVIOUS = -5,
GIMP_ACTION_SELECT_NEXT = -6,
GIMP_ACTION_SELECT_SKIP_PREVIOUS = -7,
GIMP_ACTION_SELECT_SKIP_NEXT = -8,
GIMP_ACTION_SELECT_PERCENT_PREVIOUS = -9,
GIMP_ACTION_SELECT_PERCENT_NEXT = -10
} GimpActionSelectType;
......
......@@ -46,6 +46,7 @@
#include "dialogs/dialogs.h"
#include "actions.h"
#include "brush-editor-actions.h"
#include "brushes-actions.h"
#include "buffers-actions.h"
......@@ -371,8 +372,10 @@ action_select_value (GimpActionSelectType select_type,
gdouble value,
gdouble min,
gdouble max,
gdouble small_inc,
gdouble inc,
gdouble skip_inc,
gdouble delta_factor,
gboolean wrap)
{
switch (select_type)
......@@ -385,6 +388,14 @@ action_select_value (GimpActionSelectType select_type,
value = max;
break;
case GIMP_ACTION_SELECT_SMALL_PREVIOUS:
value -= small_inc;
break;
case GIMP_ACTION_SELECT_SMALL_NEXT:
value += small_inc;
break;
case GIMP_ACTION_SELECT_PREVIOUS:
value -= inc;
break;
......@@ -401,6 +412,16 @@ action_select_value (GimpActionSelectType select_type,
value += skip_inc;
break;
case GIMP_ACTION_SELECT_PERCENT_PREVIOUS:
g_return_val_if_fail (delta_factor >= 0.0, value);
value /= (1.0 + delta_factor);
break;
case GIMP_ACTION_SELECT_PERCENT_NEXT:
g_return_val_if_fail (delta_factor >= 0.0, value);
value *= (1.0 + delta_factor);
break;
default:
if ((gint) select_type >= 0)
value = (gdouble) select_type * (max - min) / 1000.0 + min;
......@@ -429,6 +450,7 @@ void
action_select_property (GimpActionSelectType select_type,
GObject *object,
const gchar *property_name,
gdouble small_inc,
gdouble inc,
gdouble skip_inc,
gboolean wrap)
......@@ -450,7 +472,7 @@ action_select_property (GimpActionSelectType select_type,
value,
G_PARAM_SPEC_DOUBLE (pspec)->minimum,
G_PARAM_SPEC_DOUBLE (pspec)->maximum,
inc, skip_inc, wrap);
small_inc, inc, skip_inc, 0, wrap);
g_object_set (object, property_name, value, NULL);
}
......
......@@ -36,12 +36,15 @@ gdouble action_select_value (GimpActionSelectType select_type,
gdouble value,
gdouble min,
gdouble max,
gdouble small_inc,
gdouble inc,
gdouble skip_inc,
gdouble delta_factor,
gboolean wrap);
void action_select_property (GimpActionSelectType select_type,
GObject *object,
const gchar *property_name,
gdouble small_inc,
gdouble inc,
gdouble skip_inc,
gboolean wrap);
......
......@@ -876,6 +876,14 @@ static const GimpEnumActionEntry context_brush_radius_actions[] =
"Maximum Radius", NULL, NULL,
GIMP_ACTION_SELECT_LAST, FALSE,
NULL },
{ "context-brush-radius-decrease-less", GIMP_STOCK_BRUSH,
"Decrease Radius Less", NULL, NULL,
GIMP_ACTION_SELECT_SMALL_PREVIOUS, FALSE,
NULL },
{ "context-brush-radius-increase-less", GIMP_STOCK_BRUSH,
"Increase Radius Less", NULL, NULL,
GIMP_ACTION_SELECT_SMALL_NEXT, FALSE,
NULL },
{ "context-brush-radius-decrease", GIMP_STOCK_BRUSH,
"Decrease Radius", "bracketleft", NULL,
GIMP_ACTION_SELECT_PREVIOUS, FALSE,
......@@ -892,6 +900,14 @@ static const GimpEnumActionEntry context_brush_radius_actions[] =
"Increase Radius More", "<shift>bracketright", NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
{ "context-brush-radius-decrease-percent", GIMP_STOCK_BRUSH,
"Decrease Radius Relative", NULL, NULL,
GIMP_ACTION_SELECT_PERCENT_PREVIOUS, FALSE,
NULL },
{ "context-brush-radius-increase-percent", GIMP_STOCK_BRUSH,
"Increase Radius Relative", NULL, NULL,
GIMP_ACTION_SELECT_PERCENT_NEXT, FALSE,
NULL }
};
static const GimpEnumActionEntry context_brush_spikes_actions[] =
......@@ -923,7 +939,7 @@ static const GimpEnumActionEntry context_brush_spikes_actions[] =
{ "context-brush-spikes-increase-skip", GIMP_STOCK_BRUSH,
"Increase Spikes More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
NULL }
};
static const GimpEnumActionEntry context_brush_hardness_actions[] =
......@@ -955,7 +971,7 @@ static const GimpEnumActionEntry context_brush_hardness_actions[] =
{ "context-brush-hardness-increase-skip", GIMP_STOCK_BRUSH,
"Increase Hardness More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
NULL }
};
static const GimpEnumActionEntry context_brush_aspect_actions[] =
......@@ -987,7 +1003,7 @@ static const GimpEnumActionEntry context_brush_aspect_actions[] =
{ "context-brush-aspect-increase-skip", GIMP_STOCK_BRUSH,
"Increase Aspect More", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
NULL }
};
static const GimpEnumActionEntry context_brush_angle_actions[] =
......@@ -1019,7 +1035,7 @@ static const GimpEnumActionEntry context_brush_angle_actions[] =
{ "context-brush-angle-increase-skip", GIMP_STOCK_BRUSH,
"Rotate Left 15 degrees", NULL, NULL,
GIMP_ACTION_SELECT_SKIP_NEXT, FALSE,
NULL },
NULL }
};
......
......@@ -153,7 +153,7 @@ context_foreground_red_cmd_callback (GtkAction *action,
color.r = action_select_value ((GimpActionSelectType) value,
color.r,
0.0, 1.0,
0.01, 0.1, FALSE);
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gimp_context_set_foreground (context, &color);
}
......@@ -170,7 +170,7 @@ context_foreground_green_cmd_callback (GtkAction *action,
color.g = action_select_value ((GimpActionSelectType) value,
color.g,
0.0, 1.0,
0.01, 0.1, FALSE);
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gimp_context_set_foreground (context, &color);
}
......@@ -187,7 +187,7 @@ context_foreground_blue_cmd_callback (GtkAction *action,
color.b = action_select_value ((GimpActionSelectType) value,
color.b,
0.0, 1.0,
0.01, 0.1, FALSE);
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gimp_context_set_foreground (context, &color);
}
......@@ -204,7 +204,7 @@ context_background_red_cmd_callback (GtkAction *action,
color.r = action_select_value ((GimpActionSelectType) value,
color.r,
0.0, 1.0,
0.01, 0.1, FALSE);
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gimp_context_set_background (context, &color);
}
......@@ -221,7 +221,7 @@ context_background_green_cmd_callback (GtkAction *action,
color.g = action_select_value ((GimpActionSelectType) value,
color.g,
0.0, 1.0,
0.01, 0.1, FALSE);
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gimp_context_set_background (context, &color);
}
......@@ -238,7 +238,7 @@ context_background_blue_cmd_callback (GtkAction *action,
color.b = action_select_value ((GimpActionSelectType) value,
color.b,
0.0, 1.0,
0.01, 0.1, FALSE);
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gimp_context_set_background (context, &color);
}
......@@ -257,7 +257,7 @@ context_foreground_hue_cmd_callback (GtkAction *action,
hsv.h = action_select_value ((GimpActionSelectType) value,
hsv.h,
0.0, 1.0,
0.01, 0.1, FALSE);
1.0 / 360.0, 0.01, 0.1, 0.0, FALSE);
gimp_hsv_to_rgb (&hsv, &color);
gimp_context_set_foreground (context, &color);
}
......@@ -277,7 +277,7 @@ context_foreground_saturation_cmd_callback (GtkAction *action,
hsv.s = action_select_value ((GimpActionSelectType) value,
hsv.s,
0.0, 1.0,
0.01, 0.1, FALSE);
0.01, 0.01, 0.1, 0.0, FALSE);
gimp_hsv_to_rgb (&hsv, &color);
gimp_context_set_foreground (context, &color);
}
......@@ -297,7 +297,7 @@ context_foreground_value_cmd_callback (GtkAction *action,
hsv.v = action_select_value ((GimpActionSelectType) value,
hsv.v,
0.0, 1.0,
0.01, 0.1, FALSE);
0.01, 0.01, 0.1, 0.0, FALSE);
gimp_hsv_to_rgb (&hsv, &color);
gimp_context_set_foreground (context, &color);
}
......@@ -317,7 +317,7 @@ context_background_hue_cmd_callback (GtkAction *action,
hsv.h = action_select_value ((GimpActionSelectType) value,
hsv.h,
0.0, 1.0,
0.01, 0.1, FALSE);
1.0 / 360.0, 0.01, 0.1, 0.0, FALSE);
gimp_hsv_to_rgb (&hsv, &color);
gimp_context_set_background (context, &color);
}
......@@ -337,7 +337,7 @@ context_background_saturation_cmd_callback (GtkAction *action,
hsv.s = action_select_value ((GimpActionSelectType) value,
hsv.s,
0.0, 1.0,
0.01, 0.1, FALSE);
0.01, 0.01, 0.1, 0.0, FALSE);
gimp_hsv_to_rgb (&hsv, &color);
gimp_context_set_background (context, &color);
}
......@@ -357,7 +357,7 @@ context_background_value_cmd_callback (GtkAction *action,
hsv.v = action_select_value ((GimpActionSelectType) value,
hsv.v,
0.0, 1.0,
0.01, 0.1, FALSE);
0.01, 0.01, 0.1, 0.0, FALSE);
gimp_hsv_to_rgb (&hsv, &color);
gimp_context_set_background (context, &color);
}
......@@ -375,7 +375,7 @@ context_opacity_cmd_callback (GtkAction *action,
gimp_context_get_opacity (context),
GIMP_OPACITY_TRANSPARENT,
GIMP_OPACITY_OPAQUE,
0.01, 0.1, FALSE);
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gimp_context_set_opacity (context, opacity);
}
......@@ -394,7 +394,7 @@ context_paint_mode_cmd_callback (GtkAction *action,
index = action_select_value ((GimpActionSelectType) value,
context_paint_mode_index (paint_mode),
0, G_N_ELEMENTS (paint_modes) - 1,
1.0, 1.0, FALSE);
0.0, 1.0, 1.0, 0.0, FALSE);
gimp_context_set_paint_mode (context, paint_modes[index]);
}
......@@ -505,12 +505,37 @@ context_brush_radius_cmd_callback (GtkAction *action,
{
GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush);
gdouble radius;
gdouble min_radius;
radius = gimp_brush_generated_get_radius (generated);
/* If the user uses a high precision radius adjustment command
* then we allow a minimum radius of 0.1 px, otherwise we set the
* minimum radius to 1.0 px and adjust the radius to 1.0 px if it
* is less than 1.0 px. This prevents irritating 0.1, 1.1, 2.1 etc
* radius sequences when 1.0 px steps are used.
*/
switch ((GimpActionSelectType) value)
{
case GIMP_ACTION_SELECT_SMALL_PREVIOUS:
case GIMP_ACTION_SELECT_SMALL_NEXT:
case GIMP_ACTION_SELECT_PERCENT_PREVIOUS:
case GIMP_ACTION_SELECT_PERCENT_NEXT:
min_radius = 0.1;
break;
default:
min_radius = 1.0;
if (radius < 1.0)
radius = 1.0;
break;
}
radius = action_select_value ((GimpActionSelectType) value,
radius,
1.0, 4000.0,
1.0, 10.0, FALSE);
min_radius, 4000.0,
0.1, 1.0, 10.0, 0.05, FALSE);
gimp_brush_generated_set_radius (generated, radius);
}
}
......@@ -535,7 +560,7 @@ context_brush_spikes_cmd_callback (GtkAction *action,
spikes = action_select_value ((GimpActionSelectType) value,
spikes,
2.0, 20.0,
1.0, 4.0, FALSE);
0.0, 1.0, 4.0, 0.0, FALSE);
gimp_brush_generated_set_spikes (generated, spikes);
}
}
......@@ -560,7 +585,7 @@ context_brush_hardness_cmd_callback (GtkAction *action,
hardness = action_select_value ((GimpActionSelectType) value,
hardness,
0.0, 1.0,
0.01, 0.1, FALSE);
0.001, 0.01, 0.1, 0.0, FALSE);
gimp_brush_generated_set_hardness (generated, hardness);
}
}
......@@ -585,7 +610,7 @@ context_brush_aspect_cmd_callback (GtkAction *action,
aspect = action_select_value ((GimpActionSelectType) value,
aspect,
1.0, 20.0,
1.0, 4.0, FALSE);
0.1, 1.0, 4.0, 0.0, FALSE);
gimp_brush_generated_set_aspect_ratio (generated, aspect);
}
}
......@@ -616,7 +641,7 @@ context_brush_angle_cmd_callback (GtkAction *action,
angle = action_select_value ((GimpActionSelectType) value,
angle,
0.0, 180.0,
1.0, 15.0, TRUE);
0.1, 1.0, 15.0, 0.0, TRUE);
gimp_brush_generated_set_angle (generated, angle);
}
......@@ -666,7 +691,7 @@ context_select_color (GimpActionSelectType select_type,
index = action_select_value (select_type,
index,
0, max,
1, 4, FALSE);
0, 1, 4, 0, FALSE);
context_set_color_index (index, use_colormap, use_palette, color);
}
......
......@@ -822,7 +822,7 @@ layers_opacity_cmd_callback (GtkAction *action,
opacity = action_select_value ((GimpActionSelectType) value,
gimp_layer_get_opacity (layer),
0.0, 1.0,
0.01, 0.1, FALSE);
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
gimp_layer_set_opacity (layer, opacity, push_undo);
gimp_image_flush (image);
}
......@@ -851,7 +851,7 @@ layers_mode_cmd_callback (GtkAction *action,
index = action_select_value ((GimpActionSelectType) value,
layers_mode_index (layer_mode),
0, G_N_ELEMENTS (layer_modes) - 1,
1.0, 1.0, FALSE);
0.0, 1.0, 1.0, 0.0, FALSE);
gimp_layer_set_mode (layer, layer_modes[index], push_undo);
gimp_image_flush (image);
}
......
......@@ -266,7 +266,7 @@ tools_color_average_radius_cmd_callback (GtkAction *action,
action_select_property ((GimpActionSelectType) value,
G_OBJECT (tool_info->tool_options),
"average-radius",
1.0, 10.0, FALSE);
1.0, 1.0, 10.0, FALSE);
}
}
......@@ -286,7 +286,7 @@ tools_ink_blob_size_cmd_callback (GtkAction *action,
action_select_property ((GimpActionSelectType) value,
G_OBJECT (tool_info->tool_options),
"size",
1.0, 10.0, FALSE);
1.0, 1.0, 10.0, FALSE);
}
}
......@@ -306,7 +306,7 @@ tools_ink_blob_aspect_cmd_callback (GtkAction *action,
action_select_property ((GimpActionSelectType) value,
G_OBJECT (tool_info->tool_options),
"blob-aspect",
0.1, 1.0, FALSE);
1.0, 0.1, 1.0, FALSE);
}
}
......@@ -326,7 +326,7 @@ tools_ink_blob_angle_cmd_callback (GtkAction *action,
action_select_property ((GimpActionSelectType) value,
G_OBJECT (tool_info->tool_options),
"blob-angle",
1.0, 15.0, TRUE);
1.0, 1.0, 15.0, TRUE);
}
}
......@@ -361,7 +361,6 @@ tools_rectangle_toggle_fixed_aspect (GtkAction *action,
}
}
void
tools_rectangle_toggle_fixed_center (GtkAction *action,
gpointer data)
......@@ -393,7 +392,6 @@ tools_rectangle_toggle_fixed_center (GtkAction *action,
}
}
void
tools_value_1_cmd_callback (GtkAction *action,
gint value,
......
......@@ -152,7 +152,7 @@ view_zoom_cmd_callback (GtkAction *action,
scale = action_select_value ((GimpActionSelectType) value,
scale,
0.0, 512.0,
1.0, 16.0,
1.0 / 8.0, 1.0, 16.0, 0.0,
FALSE);
/* min = 1.0 / 256, max = 256.0 */
......@@ -249,8 +249,10 @@ view_scroll_horizontal_cmd_callback (GtkAction *action,
shell->hsbdata->lower,
shell->hsbdata->upper -
shell->hsbdata->page_size,
1,
shell->hsbdata->step_increment,
shell->hsbdata->page_increment,
0,
FALSE);
gtk_adjustment_set_value (shell->hsbdata, offset);
}
......@@ -272,8 +274,10 @@ view_scroll_vertical_cmd_callback (GtkAction *action,
shell->vsbdata->lower,
shell->vsbdata->upper -
shell->vsbdata->page_size,
1,
shell->vsbdata->step_increment,
shell->vsbdata->page_increment,
0,
FALSE);
gtk_adjustment_set_value (shell->vsbdata, offset);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment