[gimp] app: add "Fade" options to filter tools
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add "Fade" options to filter tools
- Date: Tue, 7 Apr 2020 16:43:14 +0000 (UTC)
commit 8384d37e66365332ee26e19123624dcedf77a510
Author: Ell <ell_se yahoo com>
Date: Tue Apr 7 18:45:17 2020 +0300
app: add "Fade" options to filter tools
As per commit ed7ea51fb739d1651946fd122a147f5d8415b7ff, reintroduce
the "Fade" functionality for filters, by incorporating it directly
into GimpFilterTool.
Add "mode" and "opacity" options to GimpOperationSettings, and add
a corresponding "Fade" expander to the GimpFilterTool dialog
allowing to control them.
Reintroduce the FADE layer-mode context, and use it to mark the
layer modes avaialable for fading.
app/operations/gimpoperationsettings.c | 47 ++++++++++++++++++++++++---
app/operations/gimpoperationsettings.h | 2 ++
app/operations/layer-modes/gimp-layer-modes.c | 16 ++++++---
app/operations/operations-enums.c | 2 ++
app/operations/operations-enums.h | 4 ++-
app/tools/gimpfiltertool.c | 47 +++++++++++++++++++++++++--
6 files changed, 106 insertions(+), 12 deletions(-)
---
diff --git a/app/operations/gimpoperationsettings.c b/app/operations/gimpoperationsettings.c
index eeb36fd7e8..13d7dc5e19 100644
--- a/app/operations/gimpoperationsettings.c
+++ b/app/operations/gimpoperationsettings.c
@@ -42,6 +42,8 @@ enum
PROP_0,
PROP_CLIP,
PROP_REGION,
+ PROP_MODE,
+ PROP_OPACITY,
PROP_GAMMA_HACK
};
@@ -85,6 +87,21 @@ gimp_operation_settings_class_init (GimpOperationSettingsClass *klass)
GIMP_FILTER_REGION_SELECTION,
GIMP_CONFIG_PARAM_DEFAULTS);
+ GIMP_CONFIG_PROP_ENUM (object_class, PROP_MODE,
+ "gimp-mode",
+ _("Mode"),
+ NULL,
+ GIMP_TYPE_LAYER_MODE,
+ GIMP_LAYER_MODE_REPLACE,
+ GIMP_CONFIG_PARAM_DEFAULTS);
+
+ GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_OPACITY,
+ "gimp-opacity",
+ _("Opacity"),
+ NULL,
+ 0.0, 1.0, 1.0,
+ GIMP_CONFIG_PARAM_DEFAULTS);
+
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_GAMMA_HACK,
"gimp-gamma-hack",
"Gamma hack (temp hack, please ignore)",
@@ -116,6 +133,14 @@ gimp_operation_settings_get_property (GObject *object,
g_value_set_enum (value, settings->region);
break;
+ case PROP_MODE:
+ g_value_set_enum (value, settings->mode);
+ break;
+
+ case PROP_OPACITY:
+ g_value_set_double (value, settings->opacity);
+ break;
+
case PROP_GAMMA_HACK:
g_value_set_boolean (value, settings->gamma_hack);
break;
@@ -144,8 +169,12 @@ gimp_operation_settings_set_property (GObject *object,
settings->region = g_value_get_enum (value);
break;
- case PROP_COLOR_MANAGED:
- settings->color_managed = g_value_get_boolean (value);
+ case PROP_MODE:
+ settings->mode = g_value_get_enum (value);
+ break;
+
+ case PROP_OPACITY:
+ settings->opacity = g_value_get_double (value);
break;
case PROP_GAMMA_HACK:
@@ -175,6 +204,12 @@ gimp_operation_settings_sync_drawable_filter (GimpOperationSettings *settings,
gimp_drawable_filter_set_region (filter, settings->region);
gimp_drawable_filter_set_clip (filter, clip);
+ gimp_drawable_filter_set_mode (filter,
+ settings->mode,
+ GIMP_LAYER_COLOR_SPACE_AUTO,
+ GIMP_LAYER_COLOR_SPACE_AUTO,
+ GIMP_LAYER_COMPOSITE_AUTO);
+ gimp_drawable_filter_set_opacity (filter, settings->opacity);
gimp_drawable_filter_set_gamma_hack (filter, settings->gamma_hack);
}
@@ -186,6 +221,8 @@ static const gchar * const base_properties[] =
"time",
"gimp-clip",
"gimp-region",
+ "gimp-mode",
+ "gimp-opacity",
"gimp-gamma-hack"
};
@@ -216,8 +253,10 @@ gimp_operation_settings_config_equal_base (GimpConfig *a,
GimpOperationSettings *settings_a = GIMP_OPERATION_SETTINGS (a);
GimpOperationSettings *settings_b = GIMP_OPERATION_SETTINGS (b);
- return settings_a->clip == settings_b->clip &&
- settings_a->region == settings_b->region &&
+ return settings_a->clip == settings_b->clip &&
+ settings_a->region == settings_b->region &&
+ settings_a->mode == settings_b->mode &&
+ settings_a->opacity == settings_b->opacity &&
settings_a->gamma_hack == settings_b->gamma_hack;
}
diff --git a/app/operations/gimpoperationsettings.h b/app/operations/gimpoperationsettings.h
index 9b970e03ba..1033faef4c 100644
--- a/app/operations/gimpoperationsettings.h
+++ b/app/operations/gimpoperationsettings.h
@@ -41,6 +41,8 @@ struct _GimpOperationSettings
GimpTransformResize clip;
GimpFilterRegion region;
+ GimpLayerMode mode;
+ gdouble opacity;
gboolean gamma_hack;
};
diff --git a/app/operations/layer-modes/gimp-layer-modes.c b/app/operations/layer-modes/gimp-layer-modes.c
index 7778dbca2d..7a009dd7e9 100644
--- a/app/operations/layer-modes/gimp-layer-modes.c
+++ b/app/operations/layer-modes/gimp-layer-modes.c
@@ -86,7 +86,8 @@ static const GimpLayerModeInfo layer_mode_infos[] =
GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE,
- .context = GIMP_LAYER_MODE_CONTEXT_PAINT,
+ .context = GIMP_LAYER_MODE_CONTEXT_PAINT |
+ GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION,
.composite_mode = GIMP_LAYER_COMPOSITE_UNION,
.composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL
@@ -367,7 +368,8 @@ static const GimpLayerModeInfo layer_mode_infos[] =
GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_SUBTRACTIVE,
- .context = GIMP_LAYER_MODE_CONTEXT_PAINT,
+ .context = GIMP_LAYER_MODE_CONTEXT_PAINT |
+ GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP,
.composite_mode = GIMP_LAYER_COMPOSITE_CLIP_TO_BACKDROP,
.composite_space = GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL,
@@ -448,7 +450,8 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:behind",
.flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE,
- .context = GIMP_LAYER_MODE_CONTEXT_PAINT,
+ .context = GIMP_LAYER_MODE_CONTEXT_PAINT |
+ GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION,
.composite_mode = GIMP_LAYER_COMPOSITE_UNION,
.composite_space = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR
@@ -823,6 +826,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.op_name = "gimp:replace",
.flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_TRIVIAL,
+ .context = GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION,
.composite_mode = GIMP_LAYER_COMPOSITE_UNION,
.composite_space = GIMP_LAYER_COLOR_SPACE_RGB_LINEAR
@@ -834,6 +838,7 @@ static const GimpLayerModeInfo layer_mode_infos[] =
.flags = GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE |
GIMP_LAYER_MODE_FLAG_ALPHA_ONLY,
+ .context = GIMP_LAYER_MODE_CONTEXT_FADE,
.paint_composite_mode = GIMP_LAYER_COMPOSITE_UNION,
.composite_mode = GIMP_LAYER_COMPOSITE_UNION
}
@@ -845,8 +850,11 @@ static const GimpLayerMode layer_mode_group_default[] =
GIMP_LAYER_MODE_SEPARATOR,
- GIMP_LAYER_MODE_NORMAL,
GIMP_LAYER_MODE_REPLACE,
+
+ GIMP_LAYER_MODE_SEPARATOR,
+
+ GIMP_LAYER_MODE_NORMAL,
GIMP_LAYER_MODE_DISSOLVE,
GIMP_LAYER_MODE_BEHIND,
GIMP_LAYER_MODE_COLOR_ERASE,
diff --git a/app/operations/operations-enums.c b/app/operations/operations-enums.c
index dabf1fca01..a0d67b88e0 100644
--- a/app/operations/operations-enums.c
+++ b/app/operations/operations-enums.c
@@ -338,6 +338,7 @@ gimp_layer_mode_context_get_type (void)
{ GIMP_LAYER_MODE_CONTEXT_LAYER, "GIMP_LAYER_MODE_CONTEXT_LAYER", "layer" },
{ GIMP_LAYER_MODE_CONTEXT_GROUP, "GIMP_LAYER_MODE_CONTEXT_GROUP", "group" },
{ GIMP_LAYER_MODE_CONTEXT_PAINT, "GIMP_LAYER_MODE_CONTEXT_PAINT", "paint" },
+ { GIMP_LAYER_MODE_CONTEXT_FADE, "GIMP_LAYER_MODE_CONTEXT_FADE", "fade" },
{ GIMP_LAYER_MODE_CONTEXT_ALL, "GIMP_LAYER_MODE_CONTEXT_ALL", "all" },
{ 0, NULL, NULL }
};
@@ -347,6 +348,7 @@ gimp_layer_mode_context_get_type (void)
{ GIMP_LAYER_MODE_CONTEXT_LAYER, "GIMP_LAYER_MODE_CONTEXT_LAYER", NULL },
{ GIMP_LAYER_MODE_CONTEXT_GROUP, "GIMP_LAYER_MODE_CONTEXT_GROUP", NULL },
{ GIMP_LAYER_MODE_CONTEXT_PAINT, "GIMP_LAYER_MODE_CONTEXT_PAINT", NULL },
+ { GIMP_LAYER_MODE_CONTEXT_FADE, "GIMP_LAYER_MODE_CONTEXT_FADE", NULL },
{ GIMP_LAYER_MODE_CONTEXT_ALL, "GIMP_LAYER_MODE_CONTEXT_ALL", NULL },
{ 0, NULL, NULL }
};
diff --git a/app/operations/operations-enums.h b/app/operations/operations-enums.h
index 8bcfb06e00..e9cb41b3b3 100644
--- a/app/operations/operations-enums.h
+++ b/app/operations/operations-enums.h
@@ -153,10 +153,12 @@ typedef enum /*< pdb-skip >*/
GIMP_LAYER_MODE_CONTEXT_LAYER = 1 << 0,
GIMP_LAYER_MODE_CONTEXT_GROUP = 1 << 1,
GIMP_LAYER_MODE_CONTEXT_PAINT = 1 << 2,
+ GIMP_LAYER_MODE_CONTEXT_FADE = 1 << 3,
GIMP_LAYER_MODE_CONTEXT_ALL = (GIMP_LAYER_MODE_CONTEXT_LAYER |
GIMP_LAYER_MODE_CONTEXT_GROUP |
- GIMP_LAYER_MODE_CONTEXT_PAINT)
+ GIMP_LAYER_MODE_CONTEXT_PAINT |
+ GIMP_LAYER_MODE_CONTEXT_FADE)
} GimpLayerModeContext;
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index c8838135fc..3b6aeb6ef7 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -60,6 +60,8 @@
#include "core/gimpsettings.h"
#include "core/gimptoolinfo.h"
+#include "widgets/gimplayermodebox.h"
+#include "widgets/gimppropwidgets.h"
#include "widgets/gimpsettingsbox.h"
#include "widgets/gimpwidgets-utils.h"
@@ -909,7 +911,9 @@ gimp_filter_tool_real_config_notify (GimpFilterTool *filter_tool,
if (filter_tool->filter)
{
- if (! strcmp (pspec->name, "gimp-clip") ||
+ if (! strcmp (pspec->name, "gimp-clip") ||
+ ! strcmp (pspec->name, "gimp-mode") ||
+ ! strcmp (pspec->name, "gimp-opacity") ||
! strcmp (pspec->name, "gimp-gamma-hack"))
{
gimp_filter_tool_update_filter (filter_tool);
@@ -1046,8 +1050,9 @@ gimp_filter_tool_dialog (GimpFilterTool *filter_tool)
static void
gimp_filter_tool_update_dialog_operation_settings (GimpFilterTool *filter_tool)
{
- GimpTool *tool = GIMP_TOOL (filter_tool);
- GimpImage *image = gimp_display_get_image (tool->display);
+ GimpTool *tool = GIMP_TOOL (filter_tool);
+ GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
+ GimpImage *image = gimp_display_get_image (tool->display);
if (filter_tool->operation_settings_box)
{
@@ -1060,6 +1065,8 @@ gimp_filter_tool_update_dialog_operation_settings (GimpFilterTool *filter_tool)
GtkWidget *expander;
GtkWidget *frame;
GtkWidget *vbox2;
+ GtkWidget *mode_box;
+ GtkWidget *scale;
GtkWidget *toggle;
vbox = filter_tool->operation_settings_box;
@@ -1083,6 +1090,40 @@ gimp_filter_tool_update_dialog_operation_settings (GimpFilterTool *filter_tool)
gtk_box_pack_start (GTK_BOX (vbox), filter_tool->region_combo,
FALSE, FALSE, 0);
+ /* The Fade expander */
+ expander = gtk_expander_new (_("Fade"));
+ gtk_box_pack_start (GTK_BOX (vbox), expander,
+ FALSE, FALSE, 0);
+ gtk_widget_show (expander);
+
+ frame = gimp_frame_new (NULL);
+ gtk_container_add (GTK_CONTAINER (expander), frame);
+ gtk_widget_show (frame);
+
+ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
+ gtk_container_add (GTK_CONTAINER (frame), vbox2);
+ gtk_widget_show (vbox2);
+
+ /* The mode box */
+ mode_box = gimp_prop_layer_mode_box_new (
+ filter_tool->config, "gimp-mode",
+ GIMP_LAYER_MODE_CONTEXT_FADE);
+ gimp_layer_mode_box_set_label (GIMP_LAYER_MODE_BOX (mode_box),
+ _("Mode"));
+ gtk_box_pack_start (GTK_BOX (vbox2), mode_box,
+ FALSE, FALSE, 0);
+ gtk_widget_show (mode_box);
+
+ /* The opacity scale */
+ scale = gimp_prop_spin_scale_new (filter_tool->config,
+ "gimp-opacity",
+ NULL,
+ 1.0, 10.0, 1);
+ gimp_prop_widget_set_factor (scale, 100.0, 1.0, 10.0, 1);
+ gtk_box_pack_start (GTK_BOX (vbox2), scale,
+ FALSE, FALSE, 0);
+ gtk_widget_show (scale);
+
/* The Color Options expander */
expander = gtk_expander_new (_("Advanced Color Options"));
gtk_box_pack_start (GTK_BOX (vbox), expander,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]