[gimp/wip/Jehan/issue-498-quick-brush-edit: 10/26] app: new "tools-warp-effect-pixel-size-set" pixel size set action.




commit 67d5e59ffb03b4069702ef85373f385fc0478b3b
Author: Jehan <jehan girinstud io>
Date:   Sat Apr 2 23:57:08 2022 +0200

    app: new "tools-warp-effect-pixel-size-set" pixel size set action.

 app/actions/tools-actions.c  | 11 +++++++++++
 app/actions/tools-commands.c | 29 +++++++++++++++++++++++++++++
 app/actions/tools-commands.h |  3 +++
 app/tools/gimpwarptool.c     | 11 +++++++----
 4 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/app/actions/tools-actions.c b/app/actions/tools-actions.c
index 828c9ef22b..5745e11624 100644
--- a/app/actions/tools-actions.c
+++ b/app/actions/tools-actions.c
@@ -270,6 +270,13 @@ static const GimpEnumActionEntry tools_transform_preview_opacity_actions[] =
     NULL }
 };
 
+static const GimpDoubleActionEntry tools_warp_effect_pixel_size_actions[] =
+{
+  { "tools-warp-effect-pixel-size-set", GIMP_ICON_TOOL_WARP,
+    "Set Warp Effect Size in Pixel", NULL, NULL,
+    1.0, NULL }
+};
+
 static const GimpEnumActionEntry tools_warp_effect_size_actions[] =
 {
   { "tools-warp-effect-size-set", GIMP_ICON_TOOL_WARP,
@@ -745,6 +752,10 @@ tools_actions_setup (GimpActionGroup *group)
                                       G_N_ELEMENTS (tools_transform_preview_opacity_actions),
                                       tools_transform_preview_opacity_cmd_callback);
 
+  gimp_action_group_add_double_actions (group, NULL,
+                                        tools_warp_effect_pixel_size_actions,
+                                        G_N_ELEMENTS (tools_warp_effect_pixel_size_actions),
+                                        tools_warp_effect_pixel_size_cmd_callback);
   gimp_action_group_add_enum_actions (group, NULL,
                                       tools_warp_effect_size_actions,
                                       G_N_ELEMENTS (tools_warp_effect_size_actions),
diff --git a/app/actions/tools-commands.c b/app/actions/tools-commands.c
index 2373bf4522..8ff3b681e5 100644
--- a/app/actions/tools-commands.c
+++ b/app/actions/tools-commands.c
@@ -632,6 +632,35 @@ tools_transform_preview_opacity_cmd_callback (GimpAction *action,
     }
 }
 
+void
+tools_warp_effect_pixel_size_cmd_callback (GimpAction *action,
+                                           GVariant   *value,
+                                           gpointer    data)
+{
+  GimpContext          *context;
+  GimpToolInfo         *tool_info;
+  gdouble               dvalue;
+  return_if_no_context (context, data);
+
+  dvalue = g_variant_get_double (value);
+  tool_info = gimp_context_get_tool (context);
+
+  if (tool_info && GIMP_IS_WARP_OPTIONS (tool_info->tool_options))
+    {
+      GParamSpec *pspec;
+
+      pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool_info->tool_options),
+                                            "effect-size");
+      dvalue = CLAMP (dvalue,
+                      G_PARAM_SPEC_DOUBLE (pspec)->minimum,
+                      G_PARAM_SPEC_DOUBLE (pspec)->maximum);
+
+      g_object_set (G_OBJECT (tool_info->tool_options),
+                    "effect-size", dvalue,
+                    NULL);
+    }
+}
+
 void
 tools_warp_effect_size_cmd_callback (GimpAction *action,
                                      GVariant   *value,
diff --git a/app/actions/tools-commands.h b/app/actions/tools-commands.h
index adc83abc61..b9e93ec983 100644
--- a/app/actions/tools-commands.h
+++ b/app/actions/tools-commands.h
@@ -89,6 +89,9 @@ void   tools_transform_preview_opacity_cmd_callback (GimpAction *action,
                                                      GVariant   *value,
                                                      gpointer    data);
 
+void   tools_warp_effect_pixel_size_cmd_callback    (GimpAction *action,
+                                                     GVariant   *value,
+                                                     gpointer    data);
 void   tools_warp_effect_size_cmd_callback          (GimpAction *action,
                                                      GVariant   *value,
                                                      gpointer    data);
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index 6108d3f960..d02974439b 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -225,10 +225,13 @@ gimp_warp_tool_init (GimpWarpTool *self)
                                          GIMP_CURSOR_PRECISION_SUBPIXEL);
   gimp_tool_control_set_tool_cursor     (tool->control,
                                          GIMP_TOOL_CURSOR_WARP);
-  gimp_tool_control_set_action_size     (tool->control,
-                                         "tools/tools-warp-effect-size-set");
-  gimp_tool_control_set_action_hardness (tool->control,
-                                         "tools/tools-warp-effect-hardness-set");
+
+  gimp_tool_control_set_action_pixel_size (tool->control,
+                                           "tools/tools-warp-effect-pixel-size-set");
+  gimp_tool_control_set_action_size       (tool->control,
+                                           "tools/tools-warp-effect-size-set");
+  gimp_tool_control_set_action_hardness   (tool->control,
+                                           "tools/tools-warp-effect-hardness-set");
 
   self->show_cursor = TRUE;
   self->draw_brush  = TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]