[gimp/gimp-2-10] app: in GimpFilterTool, add "clipping" option
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: in GimpFilterTool, add "clipping" option
- Date: Thu, 1 Aug 2019 21:41:45 +0000 (UTC)
commit 2c8006896d3422a871717d4d405382ce17fd9434
Author: Ell <ell_se yahoo com>
Date: Thu Aug 1 23:41:30 2019 +0300
app: in GimpFilterTool, add "clipping" option
In GimpFilterTool, add a new "clipping" option, which can be either
Adjust or Clip. This option is controllable for layers, when
there's no selection mask.
When set to Adjust, which is used by default, the filter's output
may extent past the drawable's boundary, and the drawable will be
resized to match the output when committed.
(cherry picked from commit eaec9443c33f459ad6164af2704ad9f15a8c08a3)
app/tools/gimpfilteroptions.c | 17 ++++++++
app/tools/gimpfilteroptions.h | 21 +++++-----
app/tools/gimpfiltertool.c | 98 ++++++++++++++++++++++++++++++-------------
app/tools/gimpfiltertool.h | 1 +
4 files changed, 98 insertions(+), 39 deletions(-)
---
diff --git a/app/tools/gimpfilteroptions.c b/app/tools/gimpfilteroptions.c
index f9acd9e705..13b47cfbbb 100644
--- a/app/tools/gimpfilteroptions.c
+++ b/app/tools/gimpfilteroptions.c
@@ -37,6 +37,7 @@ enum
PROP_PREVIEW_ALIGNMENT,
PROP_PREVIEW_POSITION,
PROP_CONTROLLER,
+ PROP_CLIP,
PROP_REGION,
PROP_COLOR_MANAGED,
PROP_GAMMA_HACK
@@ -104,6 +105,14 @@ gimp_filter_options_class_init (GimpFilterOptionsClass *klass)
TRUE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_ENUM (object_class, PROP_CLIP,
+ "clip",
+ _("Clipping"),
+ _("How to clip"),
+ GIMP_TYPE_TRANSFORM_RESIZE,
+ GIMP_TRANSFORM_RESIZE_ADJUST,
+ GIMP_PARAM_STATIC_STRINGS);
+
g_object_class_install_property (object_class, PROP_REGION,
g_param_spec_enum ("region",
NULL, NULL,
@@ -164,6 +173,10 @@ gimp_filter_options_set_property (GObject *object,
options->controller = g_value_get_boolean (value);
break;
+ case PROP_CLIP:
+ options->clip = g_value_get_enum (value);
+ break;
+
case PROP_REGION:
options->region = g_value_get_enum (value);
break;
@@ -212,6 +225,10 @@ gimp_filter_options_get_property (GObject *object,
g_value_set_boolean (value, options->controller);
break;
+ case PROP_CLIP:
+ g_value_set_enum (value, options->clip);
+ break;
+
case PROP_REGION:
g_value_set_enum (value, options->region);
break;
diff --git a/app/tools/gimpfilteroptions.h b/app/tools/gimpfilteroptions.h
index 3bf38cebbb..0c35c68ac0 100644
--- a/app/tools/gimpfilteroptions.h
+++ b/app/tools/gimpfilteroptions.h
@@ -34,16 +34,17 @@ typedef struct _GimpFilterOptionsClass GimpFilterOptionsClass;
struct _GimpFilterOptions
{
- GimpColorOptions parent_instance;
-
- gboolean preview;
- gboolean preview_split;
- GimpAlignmentType preview_alignment;
- gdouble preview_position;
- gboolean controller;
- GimpFilterRegion region;
- gboolean color_managed;
- gboolean gamma_hack;
+ GimpColorOptions parent_instance;
+
+ gboolean preview;
+ gboolean preview_split;
+ GimpAlignmentType preview_alignment;
+ gdouble preview_position;
+ gboolean controller;
+ GimpTransformResize clip;
+ GimpFilterRegion region;
+ gboolean color_managed;
+ gboolean gamma_hack;
};
struct _GimpFilterOptionsClass
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index fe87a8ba90..04f9250526 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -51,6 +51,7 @@
#include "core/gimpimage.h"
#include "core/gimpimage-guides.h"
#include "core/gimpimage-pick-color.h"
+#include "core/gimplayer.h"
#include "core/gimplist.h"
#include "core/gimppickable.h"
#include "core/gimpprogress.h"
@@ -156,6 +157,8 @@ static void gimp_filter_tool_reset (GimpFilterTool *filter_to
static void gimp_filter_tool_create_filter (GimpFilterTool *filter_tool);
+static void gimp_filter_tool_update_dialog (GimpFilterTool *filter_tool);
+
static void gimp_filter_tool_region_changed (GimpFilterTool *filter_tool);
static void gimp_filter_tool_flush (GimpDrawableFilter *filter,
@@ -252,6 +255,7 @@ gimp_filter_tool_finalize (GObject *object)
g_clear_object (&filter_tool->gui);
filter_tool->settings_box = NULL;
filter_tool->controller_toggle = NULL;
+ filter_tool->clip_combo = NULL;
filter_tool->region_combo = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -317,7 +321,6 @@ gimp_filter_tool_initialize (GimpTool *tool,
GtkWidget *frame;
GtkWidget *vbox2;
GtkWidget *combo;
- gchar *operation_name;
/* disabled for at least GIMP 2.8 */
filter_tool->overlay = FALSE;
@@ -424,10 +427,6 @@ gimp_filter_tool_initialize (GimpTool *tool,
gtk_widget_show (toggle);
/* The area combo */
- gegl_node_get (filter_tool->operation,
- "operation", &operation_name,
- NULL);
-
filter_tool->region_combo =
gimp_prop_enum_combo_box_new (G_OBJECT (tool_info->tool_options),
"region",
@@ -435,14 +434,16 @@ gimp_filter_tool_initialize (GimpTool *tool,
gtk_box_pack_end (GTK_BOX (vbox), filter_tool->region_combo,
FALSE, FALSE, 0);
- if (! gimp_gegl_node_is_point_operation (filter_tool->operation) ||
- (operation_name &&
- gegl_operation_get_key (operation_name, "position-dependent")))
- {
- gtk_widget_show (filter_tool->region_combo);
- }
-
- g_free (operation_name);
+ /* The clipping combo */
+ filter_tool->clip_combo =
+ gimp_prop_enum_combo_box_new (G_OBJECT (tool_info->tool_options),
+ "clip",
+ GIMP_TRANSFORM_RESIZE_ADJUST,
+ GIMP_TRANSFORM_RESIZE_CLIP);
+ gimp_int_combo_box_set_label (
+ GIMP_INT_COMBO_BOX (filter_tool->clip_combo), _("Clipping"));
+ gtk_box_pack_end (GTK_BOX (vbox), filter_tool->clip_combo,
+ FALSE, FALSE, 0);
/* Fill in subclass widgets */
gimp_filter_tool_dialog (filter_tool);
@@ -808,6 +809,13 @@ gimp_filter_tool_options_notify (GimpTool *tool,
gimp_tool_widget_set_visible (filter_tool->widget,
filter_options->controller);
}
+ else if (! strcmp (pspec->name, "clip") &&
+ filter_tool->filter)
+ {
+ gimp_drawable_filter_set_clip (filter_tool->filter,
+ filter_options->clip ==
+ GIMP_TRANSFORM_RESIZE_CLIP);
+ }
else if (! strcmp (pspec->name, "region") &&
filter_tool->filter)
{
@@ -1002,6 +1010,7 @@ gimp_filter_tool_halt (GimpFilterTool *filter_tool)
g_clear_object (&filter_tool->gui);
filter_tool->settings_box = NULL;
filter_tool->controller_toggle = NULL;
+ filter_tool->clip_combo = NULL;
filter_tool->region_combo = NULL;
}
@@ -1115,6 +1124,9 @@ gimp_filter_tool_create_filter (GimpFilterTool *filter_tool)
filter_tool->operation,
gimp_tool_get_icon_name (tool));
+ gimp_drawable_filter_set_clip (filter_tool->filter,
+ options->clip ==
+ GIMP_TRANSFORM_RESIZE_CLIP);
gimp_drawable_filter_set_region (filter_tool->filter,
options->region);
gimp_drawable_filter_set_color_managed (filter_tool->filter,
@@ -1134,6 +1146,45 @@ gimp_filter_tool_create_filter (GimpFilterTool *filter_tool)
gimp_drawable_filter_apply (filter_tool->filter, NULL);
}
+static void
+gimp_filter_tool_update_dialog (GimpFilterTool *filter_tool)
+{
+ GimpTool *tool = GIMP_TOOL (filter_tool);
+
+ if (filter_tool->gui)
+ {
+ GimpImage *image = gimp_display_get_image (tool->display);
+ GimpChannel *mask = gimp_image_get_mask (image);
+ gchar *operation_name;
+
+ gegl_node_get (filter_tool->operation,
+ "operation", &operation_name,
+ NULL);
+
+ if (gimp_channel_is_empty (mask))
+ {
+ gtk_widget_set_visible (
+ filter_tool->clip_combo,
+ GIMP_IS_LAYER (tool->drawable) &&
+ ! gimp_gegl_node_is_point_operation (filter_tool->operation));
+
+ gtk_widget_hide (filter_tool->region_combo);
+ }
+ else
+ {
+ gtk_widget_hide (filter_tool->clip_combo);
+
+ gtk_widget_set_visible (
+ filter_tool->region_combo,
+ ! gimp_gegl_node_is_point_operation (filter_tool->operation) ||
+ (operation_name &&
+ gegl_operation_get_key (operation_name, "position-dependent")));
+ }
+
+ g_free (operation_name);
+ }
+}
+
static void
gimp_filter_tool_region_changed (GimpFilterTool *filter_tool)
{
@@ -1182,13 +1233,7 @@ gimp_filter_tool_mask_changed (GimpImage *image,
{
GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
- if (filter_tool->gui)
- {
- GimpChannel *mask = gimp_image_get_mask (image);
-
- gtk_widget_set_sensitive (filter_tool->region_combo,
- ! gimp_channel_is_empty (mask));
- }
+ gimp_filter_tool_update_dialog (filter_tool);
if (options->region == GIMP_FILTER_REGION_SELECTION)
gimp_filter_tool_region_changed (filter_tool);
@@ -1518,21 +1563,16 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
gimp_tool_get_help_id (tool));
}
- if (gegl_operation_get_key (operation_name, "position-dependent"))
+ if (gimp_gegl_node_is_point_operation (filter_tool->operation) &&
+ ! gegl_operation_get_key (operation_name, "position-dependent"))
{
- if (filter_tool->gui)
- gtk_widget_show (filter_tool->region_combo);
- }
- else
- {
- if (filter_tool->gui)
- gtk_widget_hide (filter_tool->region_combo);
-
g_object_set (GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool),
"region", GIMP_FILTER_REGION_SELECTION,
NULL);
}
+ gimp_filter_tool_update_dialog (filter_tool);
+
g_free (operation_name);
g_object_set (GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool),
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index feb6df685d..559f0288ac 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -59,6 +59,7 @@ struct _GimpFilterTool
GimpToolGui *gui;
GtkWidget *settings_box;
GtkWidget *controller_toggle;
+ GtkWidget *clip_combo;
GtkWidget *region_combo;
GtkWidget *active_picker;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]