mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
app: add a modifier action for opacity change.
Opacity and brush size are among the 2 most common tool options which people might want to often change, though we should likely later add all other common types of tool settings angle, aspect ratio, spacing, etc. I am also unsure using the enum action is the right call because what it does is just taking into account the distance from initial click to compute an opacity. Instead it might be more interesting to increase or decrease slowly or rapidly by going right or left from the initial click. We'll see. But it's a first step.
This commit is contained in:
parent
76ddf4421c
commit
d72a42ed20
3 changed files with 36 additions and 0 deletions
|
@ -607,6 +607,7 @@ gimp_modifier_action_get_type (void)
|
|||
{ GIMP_MODIFIER_ACTION_ACTION, "GIMP_MODIFIER_ACTION_ACTION", "action" },
|
||||
{ GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE, "GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE", "brush-pixel-size" },
|
||||
{ GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE, "GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE", "brush-radius-pixel-size" },
|
||||
{ GIMP_MODIFIER_ACTION_TOOL_OPACITY, "GIMP_MODIFIER_ACTION_TOOL_OPACITY", "tool-opacity" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -622,6 +623,7 @@ gimp_modifier_action_get_type (void)
|
|||
{ GIMP_MODIFIER_ACTION_ACTION, NC_("modifier-action", "Custom action"), NULL },
|
||||
{ GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE, NC_("modifier-action", "Change brush size in canvas pixels"), NULL },
|
||||
{ GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE, NC_("modifier-action", "Change brush radius' size in canvas pixels"), NULL },
|
||||
{ GIMP_MODIFIER_ACTION_TOOL_OPACITY, NC_("modifier-action", "Change tool opacity"), NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -280,6 +280,7 @@ typedef enum
|
|||
|
||||
GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE, /*< desc="Change brush size in canvas pixels" >*/
|
||||
GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE, /*< desc="Change brush radius' size in canvas pixels" >*/
|
||||
GIMP_MODIFIER_ACTION_TOOL_OPACITY, /*< desc="Change tool opacity" >*/
|
||||
} GimpModifierAction;
|
||||
|
||||
|
||||
|
|
|
@ -593,6 +593,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|||
case GIMP_MODIFIER_ACTION_LAYER_PICKING:
|
||||
case GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE:
|
||||
case GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE:
|
||||
case GIMP_MODIFIER_ACTION_TOOL_OPACITY:
|
||||
gimp_display_shell_start_scrolling (shell, event, state,
|
||||
bevent->x, bevent->y);
|
||||
break;
|
||||
|
@ -753,6 +754,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|||
break;
|
||||
case GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE:
|
||||
case GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE:
|
||||
case GIMP_MODIFIER_ACTION_TOOL_OPACITY:
|
||||
gimp_display_shell_stop_scrolling (shell, event);
|
||||
break;
|
||||
case GIMP_MODIFIER_ACTION_ACTION:
|
||||
|
@ -1756,6 +1758,7 @@ gimp_display_shell_start_scrolling (GimpDisplayShell *shell,
|
|||
break;
|
||||
case GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE:
|
||||
case GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE:
|
||||
case GIMP_MODIFIER_ACTION_TOOL_OPACITY:
|
||||
{
|
||||
Gimp *gimp = gimp_display_get_gimp (shell->display);
|
||||
GimpTool *active_tool = tool_manager_get_active (gimp);
|
||||
|
@ -1928,6 +1931,36 @@ gimp_display_shell_handle_scrolling (GimpDisplayShell *shell,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case GIMP_MODIFIER_ACTION_TOOL_OPACITY:
|
||||
{
|
||||
GimpDisplay *display = shell->display;
|
||||
Gimp *gimp = gimp_display_get_gimp (display);
|
||||
GimpTool *active_tool = tool_manager_get_active (gimp);
|
||||
const gchar *action;
|
||||
gint size;
|
||||
|
||||
/* Size in image pixels: distance between start and current
|
||||
* position.
|
||||
*/
|
||||
size = (gint) (sqrt (pow ((x - shell->scroll_start_x) / shell->scale_x, 2) +
|
||||
pow ((y - shell->scroll_start_y) / shell->scale_y, 2)));
|
||||
|
||||
action = gimp_tool_control_get_action_opacity (active_tool->control);
|
||||
|
||||
if (action)
|
||||
{
|
||||
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
||||
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
|
||||
|
||||
/* Special trick with these enum actions. If using any
|
||||
* positive value, we get the GIMP_ACTION_SELECT_SET behavior
|
||||
* which sets to the given value.
|
||||
*/
|
||||
gimp_display_shell_activate_action (manager, action,
|
||||
g_variant_new_int32 (size));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GIMP_MODIFIER_ACTION_PANNING:
|
||||
gimp_display_shell_scroll (shell,
|
||||
shell->scroll_last_x - x,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue