[gimp/wip/Jehan/issue-498-quick-brush-edit] app: new modifier action to set brush size diameter.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/Jehan/issue-498-quick-brush-edit] app: new modifier action to set brush size diameter.
- Date: Thu, 11 Aug 2022 22:36:48 +0000 (UTC)
commit fe1f9d600bcd564adc316f92a5b975aa56580e3f
Author: Jehan <jehan girinstud io>
Date: Fri Aug 12 00:18:22 2022 +0200
app: new modifier action to set brush size diameter.
Actually I am renaming GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE into
GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE, which allows to set the
brush size on-canvas, starting from center to border.
The new GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE now sets the brush size
from one border to another.
app/display/display-enums.c | 2 ++
app/display/display-enums.h | 22 ++++++++++++----------
app/display/gimpdisplayshell-tool-events.c | 30 ++++++++++++++++++++++++++----
3 files changed, 40 insertions(+), 14 deletions(-)
---
diff --git a/app/display/display-enums.c b/app/display/display-enums.c
index db317dddbc..84e719d993 100644
--- a/app/display/display-enums.c
+++ b/app/display/display-enums.c
@@ -605,6 +605,7 @@ gimp_modifier_action_get_type (void)
{ GIMP_MODIFIER_ACTION_LAYER_PICKING, "GIMP_MODIFIER_ACTION_LAYER_PICKING", "layer-picking" },
{ GIMP_MODIFIER_ACTION_MENU, "GIMP_MODIFIER_ACTION_MENU", "menu" },
{ 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_BRUSH_SIZE, "GIMP_MODIFIER_ACTION_BRUSH_SIZE", "brush-size" },
{ 0, NULL, NULL }
};
@@ -619,6 +620,7 @@ gimp_modifier_action_get_type (void)
{ GIMP_MODIFIER_ACTION_LAYER_PICKING, NC_("modifier-action", "Pick a layer"), NULL },
{ GIMP_MODIFIER_ACTION_MENU, NC_("modifier-action", "Display the menu"), 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_BRUSH_SIZE, NC_("modifier-action", "Change brush size relatively"), NULL },
{ 0, NULL, NULL }
};
diff --git a/app/display/display-enums.h b/app/display/display-enums.h
index 82d2dd7dd2..c251441837 100644
--- a/app/display/display-enums.h
+++ b/app/display/display-enums.h
@@ -267,16 +267,18 @@ GType gimp_modifier_action_get_type (void) G_GNUC_CONST;
typedef enum
{
- GIMP_MODIFIER_ACTION_NONE, /*< desc="No action" >*/
- GIMP_MODIFIER_ACTION_PANNING, /*< desc="Pan" >*/
- GIMP_MODIFIER_ACTION_ZOOMING, /*< desc="Zoom" >*/
- GIMP_MODIFIER_ACTION_ROTATING, /*< desc="Rotate" >*/
- GIMP_MODIFIER_ACTION_STEP_ROTATING, /*< desc="Rotate by 15 degree steps" >*/
- GIMP_MODIFIER_ACTION_LAYER_PICKING, /*< desc="Pick a layer" >*/
-
- GIMP_MODIFIER_ACTION_MENU, /*< desc="Display the menu" >*/
- GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE, /*< desc="Change brush size in canvas pixels" >*/
- GIMP_MODIFIER_ACTION_BRUSH_SIZE /*< desc="Change brush size relatively" >*/
+ GIMP_MODIFIER_ACTION_NONE, /*< desc="No action" >*/
+ GIMP_MODIFIER_ACTION_PANNING, /*< desc="Pan" >*/
+ GIMP_MODIFIER_ACTION_ZOOMING, /*< desc="Zoom" >*/
+ GIMP_MODIFIER_ACTION_ROTATING, /*< desc="Rotate" >*/
+ GIMP_MODIFIER_ACTION_STEP_ROTATING, /*< desc="Rotate by 15 degree steps" >*/
+ GIMP_MODIFIER_ACTION_LAYER_PICKING, /*< desc="Pick a layer" >*/
+
+ GIMP_MODIFIER_ACTION_MENU, /*< desc="Display the menu" >*/
+
+ 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_BRUSH_SIZE /*< desc="Change brush size relatively" >*/
} GimpModifierAction;
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index 06f4deae77..095f725ce8 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -592,6 +592,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GIMP_MODIFIER_ACTION_LAYER_PICKING:
case GIMP_MODIFIER_ACTION_BRUSH_SIZE:
case GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE:
+ case GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE:
gimp_display_shell_start_scrolling (shell, event, state,
bevent->x, bevent->y);
case GIMP_MODIFIER_ACTION_NONE:
@@ -743,6 +744,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
break;
case GIMP_MODIFIER_ACTION_BRUSH_SIZE:
case GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE:
+ case GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE:
gimp_display_shell_stop_scrolling (shell, event);
case GIMP_MODIFIER_ACTION_NONE:
break;
@@ -1740,6 +1742,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_BRUSH_SIZE:
{
Gimp *gimp = gimp_display_get_gimp (shell->display);
@@ -1766,6 +1769,7 @@ gimp_display_shell_stop_scrolling (GimpDisplayShell *shell,
switch (shell->mod_action)
{
case GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE:
+ case GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE:
case GIMP_MODIFIER_ACTION_BRUSH_SIZE:
{
Gimp *gimp = gimp_display_get_gimp (shell->display);
@@ -1800,8 +1804,10 @@ gimp_display_shell_handle_scrolling (GimpDisplayShell *shell,
gint x,
gint y)
{
- GimpModifierAction mod_action = shell->mod_action;
- gboolean constrain = FALSE;
+ GimpModifierAction mod_action = shell->mod_action;
+ gboolean constrain = FALSE;
+ gboolean size_update_pos = TRUE;
+ gdouble size_multiplier = 1.0;
if (mod_action == GIMP_MODIFIER_ACTION_NONE && shell->space_release_pending)
{
@@ -1837,6 +1843,9 @@ gimp_display_shell_handle_scrolling (GimpDisplayShell *shell,
shell->scroll_last_x - x,
shell->scroll_last_y - y);
break;
+ case GIMP_MODIFIER_ACTION_BRUSH_RADIUS_PIXEL_SIZE:
+ size_multiplier = 2.0;
+ size_update_pos = FALSE;
case GIMP_MODIFIER_ACTION_BRUSH_PIXEL_SIZE:
case GIMP_MODIFIER_ACTION_BRUSH_SIZE:
{
@@ -1850,7 +1859,7 @@ gimp_display_shell_handle_scrolling (GimpDisplayShell *shell,
* position.
*/
size = (gint) (sqrt (pow ((x - shell->scroll_start_x) / shell->scale_x, 2) +
- pow ((y - shell->scroll_start_y) / shell->scale_y, 2)) * 2.0);
+ pow ((y - shell->scroll_start_y) / shell->scale_y, 2)));
/* TODO: different logics with "lock brush to view". */
/* TODO 2: scale aware? */
@@ -1861,7 +1870,20 @@ gimp_display_shell_handle_scrolling (GimpDisplayShell *shell,
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
gimp_display_shell_activate_action (manager, action,
- g_variant_new_double ((gdouble) size));
+ g_variant_new_double ((gdouble) size * size_multiplier));
+
+ if (size_update_pos)
+ {
+ GimpCoords display_coords;
+ GimpCoords coords;
+
+ display_coords.x = shell->scroll_start_x + (x - shell->scroll_start_x) / 2;
+ display_coords.y = shell->scroll_start_y + (y - shell->scroll_start_y) / 2;
+ gimp_display_shell_untransform_event_coords (shell,
+ &display_coords, &coords,
+ NULL);
+ gimp_tool_oper_update (active_tool, &coords, 0, TRUE, display);
+ }
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]