void context_brush_radius_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpBrush *brush; return_if_no_context (context, data); brush = gimp_context_get_brush (context); if (GIMP_IS_BRUSH_GENERATED (brush) && gimp_data_is_writable (GIMP_DATA (brush))) { GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush); GimpDisplay *display; 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, min_radius, 4000.0, min_radius, 0.1, 1.0, 10.0, 0.05, FALSE); gimp_brush_generated_set_radius (generated, radius); display = action_data_get_display (data); if (display) { action_message (action_data_get_display (data), G_OBJECT (brush), _("Brush Radius: %2.2f"), radius); } } }
void context_background_blue_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpRGB color; return_if_no_context (context, data); gimp_context_get_background (context, &color); color.b = action_select_value ((GimpActionSelectType) value, color.b, 0.0, 1.0, 1.0, 1.0 / 255.0, 0.01, 0.1, 0.0, FALSE); gimp_context_set_background (context, &color); }
static void context_select_color (GimpActionSelectType select_type, GimpRGB *color, gboolean use_colormap, gboolean use_palette) { gint index; gint max; index = context_get_color_index (use_colormap, use_palette, color); max = context_max_color_index (use_colormap, use_palette); index = action_select_value (select_type, index, 0, max, 0, 0, 1, 4, 0, FALSE); context_set_color_index (index, use_colormap, use_palette, color); }
void context_background_value_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpRGB color; GimpHSV hsv; return_if_no_context (context, data); gimp_context_get_background (context, &color); gimp_rgb_to_hsv (&color, &hsv); hsv.v = action_select_value ((GimpActionSelectType) value, hsv.v, 0.0, 1.0, 1.0, 0.01, 0.01, 0.1, 0.0, FALSE); gimp_hsv_to_rgb (&hsv, &color); gimp_context_set_background (context, &color); }
void view_rotate_relative_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpDisplay *display; GimpDisplayShell *shell; gdouble delta = 0.0; return_if_no_display (display, data); shell = gimp_display_get_shell (display); delta = action_select_value ((GimpActionSelectType) value, 0.0, -180.0, 180.0, 0.0, 1.0, 15.0, 90.0, 0.0, TRUE); gimp_display_shell_rotate (shell, delta); }
void context_brush_angle_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpBrush *brush; return_if_no_context (context, data); brush = gimp_context_get_brush (context); if (GIMP_IS_BRUSH_GENERATED (brush) && gimp_data_is_writable (GIMP_DATA (brush))) { GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush); GimpDisplay *display; gdouble angle; angle = gimp_brush_generated_get_angle (generated); if (value == GIMP_ACTION_SELECT_FIRST) angle = 0.0; else if (value == GIMP_ACTION_SELECT_LAST) angle = 90.0; else angle = action_select_value ((GimpActionSelectType) value, angle, 0.0, 180.0, 0.0, 0.1, 1.0, 15.0, 0.1, TRUE); gimp_brush_generated_set_angle (generated, angle); display = action_data_get_display (data); if (display) { action_message (action_data_get_display (data), G_OBJECT (brush), _("Brush Angle: %2.2f"), angle); } } }
void context_paint_mode_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpContext *context; GimpToolInfo *tool_info; GimpLayerModeEffects paint_mode; gint index; return_if_no_context (context, data); paint_mode = gimp_context_get_paint_mode (context); index = action_select_value ((GimpActionSelectType) value, context_paint_mode_index (paint_mode), 0, G_N_ELEMENTS (paint_modes) - 1, 0, 0.0, 1.0, 1.0, 0.0, FALSE); gimp_context_set_paint_mode (context, paint_modes[index]); tool_info = gimp_context_get_tool (context); if (tool_info && GIMP_IS_TOOL_OPTIONS (tool_info->tool_options)) { GimpDisplay *display; const char *value_desc; gimp_enum_get_value (GIMP_TYPE_LAYER_MODE_EFFECTS, index, NULL, NULL, &value_desc, NULL); display = action_data_get_display (data); if (value_desc && display) { action_message (display, G_OBJECT (tool_info->tool_options), _("Paint Mode: %s"), value_desc); } } }
void view_scroll_vertical_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpDisplayShell *shell; gdouble offset; return_if_no_shell (shell, data); offset = action_select_value ((GimpActionSelectType) value, gtk_adjustment_get_value (shell->vsbdata), gtk_adjustment_get_lower (shell->vsbdata), gtk_adjustment_get_upper (shell->vsbdata) - gtk_adjustment_get_page_size (shell->vsbdata), gtk_adjustment_get_lower (shell->vsbdata), 1, gtk_adjustment_get_step_increment (shell->vsbdata), gtk_adjustment_get_page_increment (shell->vsbdata), 0, FALSE); gtk_adjustment_set_value (shell->vsbdata, offset); }
void view_rotate_absolute_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpDisplay *display; GimpDisplayShell *shell; gdouble angle = 0.0; return_if_no_display (display, data); shell = gimp_display_get_shell (display); angle = action_select_value ((GimpActionSelectType) value, 0.0, -180.0, 180.0, 0.0, 1.0, 15.0, 90.0, 0.0, TRUE); gimp_display_shell_rotate_to (shell, angle); if (value == GIMP_ACTION_SELECT_SET_TO_DEFAULT) gimp_display_shell_flip (shell, FALSE, FALSE); }
void view_zoom_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpDisplayShell *shell; return_if_no_shell (shell, data); switch ((GimpActionSelectType) value) { case GIMP_ACTION_SELECT_FIRST: gimp_display_shell_scale (shell, GIMP_ZOOM_OUT_MAX, 0.0, GIMP_ZOOM_FOCUS_BEST_GUESS); break; case GIMP_ACTION_SELECT_LAST: gimp_display_shell_scale (shell, GIMP_ZOOM_IN_MAX, 0.0, GIMP_ZOOM_FOCUS_BEST_GUESS); break; case GIMP_ACTION_SELECT_PREVIOUS: gimp_display_shell_scale (shell, GIMP_ZOOM_OUT, 0.0, GIMP_ZOOM_FOCUS_BEST_GUESS); break; case GIMP_ACTION_SELECT_NEXT: gimp_display_shell_scale (shell, GIMP_ZOOM_IN, 0.0, GIMP_ZOOM_FOCUS_BEST_GUESS); break; case GIMP_ACTION_SELECT_SKIP_PREVIOUS: gimp_display_shell_scale (shell, GIMP_ZOOM_OUT_MORE, 0.0, GIMP_ZOOM_FOCUS_BEST_GUESS); break; case GIMP_ACTION_SELECT_SKIP_NEXT: gimp_display_shell_scale (shell, GIMP_ZOOM_IN_MORE, 0.0, GIMP_ZOOM_FOCUS_BEST_GUESS); break; default: { gdouble scale = gimp_zoom_model_get_factor (shell->zoom); scale = action_select_value ((GimpActionSelectType) value, scale, 0.0, 512.0, 1.0, 1.0 / 8.0, 1.0, 16.0, 0.0, FALSE); /* min = 1.0 / 256, max = 256.0 */ /* scale = min * (max / min)**(i/n), i = 0..n */ scale = pow (65536.0, scale / 512.0) / 256.0; gimp_display_shell_scale (shell, GIMP_ZOOM_TO, scale, GIMP_ZOOM_FOCUS_BEST_GUESS); break; } } }
void action_select_property (GimpActionSelectType select_type, GimpDisplay *display, GObject *object, const gchar *property_name, gdouble small_inc, gdouble inc, gdouble skip_inc, gdouble delta_factor, gboolean wrap) { GParamSpec *pspec; g_return_if_fail (display == NULL || GIMP_IS_DISPLAY (display)); g_return_if_fail (G_IS_OBJECT (object)); g_return_if_fail (property_name != NULL); pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), property_name); if (G_IS_PARAM_SPEC_DOUBLE (pspec)) { gdouble value; g_object_get (object, property_name, &value, NULL); value = action_select_value (select_type, value, G_PARAM_SPEC_DOUBLE (pspec)->minimum, G_PARAM_SPEC_DOUBLE (pspec)->maximum, G_PARAM_SPEC_DOUBLE (pspec)->default_value, small_inc, inc, skip_inc, delta_factor, wrap); g_object_set (object, property_name, value, NULL); if (display) { const gchar *blurb = g_param_spec_get_blurb (pspec); if (blurb) { /* value description and new value shown in the status bar */ action_message (display, object, _("%s: %.2f"), blurb, value); } } } else if (G_IS_PARAM_SPEC_INT (pspec)) { gint value; g_object_get (object, property_name, &value, NULL); value = action_select_value (select_type, value, G_PARAM_SPEC_INT (pspec)->minimum, G_PARAM_SPEC_INT (pspec)->maximum, G_PARAM_SPEC_INT (pspec)->default_value, small_inc, inc, skip_inc, delta_factor, wrap); g_object_set (object, property_name, value, NULL); if (display) { const gchar *blurb = g_param_spec_get_blurb (pspec); if (blurb) { /* value description and new value shown in the status bar */ action_message (display, object, _("%s: %d"), blurb, value); } } } else { g_return_if_reached (); } }