[gimp] app: remove GimpColorizeConfig, merge its props into GimpOperationColorize
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: remove GimpColorizeConfig, merge its props into GimpOperationColorize
- Date: Tue, 5 Sep 2017 19:28:52 +0000 (UTC)
commit 723c4d7f87a6293647cafb3fd90e1d7259694497
Author: Michael Natterer <mitch gimp org>
Date: Tue Sep 5 21:26:59 2017 +0200
app: remove GimpColorizeConfig, merge its props into GimpOperationColorize
Colorize doesn't need a config object just because it has a generated
property for the GUI only.
app/operations/Makefile.am | 2 -
app/operations/gimp-operations.c | 9 --
app/operations/gimpcolorizeconfig.c | 236 --------------------------------
app/operations/gimpcolorizeconfig.h | 56 --------
app/operations/gimpoperationcolorize.c | 187 +++++++++++++++++++++----
app/operations/gimpoperationcolorize.h | 4 +
app/pdb/color-cmds.c | 22 ++--
app/pdb/drawable-color-cmds.c | 24 ++--
po/POTFILES.in | 1 -
tools/pdbgen/pdb/color.pdb | 22 ++--
tools/pdbgen/pdb/drawable_color.pdb | 24 ++--
11 files changed, 210 insertions(+), 377 deletions(-)
---
diff --git a/app/operations/Makefile.am b/app/operations/Makefile.am
index 748b9ad..f76c73e 100644
--- a/app/operations/Makefile.am
+++ b/app/operations/Makefile.am
@@ -33,8 +33,6 @@ libappoperations_a_sources = \
gimpcageconfig.h \
gimpcolorbalanceconfig.c \
gimpcolorbalanceconfig.h \
- gimpcolorizeconfig.c \
- gimpcolorizeconfig.h \
gimpcurvesconfig.c \
gimpcurvesconfig.h \
gimphuesaturationconfig.c \
diff --git a/app/operations/gimp-operations.c b/app/operations/gimp-operations.c
index aba46c4..962978f 100644
--- a/app/operations/gimp-operations.c
+++ b/app/operations/gimp-operations.c
@@ -61,7 +61,6 @@
#include "gimp-operation-config.h"
#include "gimpbrightnesscontrastconfig.h"
#include "gimpcolorbalanceconfig.h"
-#include "gimpcolorizeconfig.h"
#include "gimpcurvesconfig.h"
#include "gimphuesaturationconfig.h"
#include "gimplevelsconfig.h"
@@ -197,14 +196,6 @@ gimp_operations_init (Gimp *gimp)
"color-balance");
gimp_operation_config_register (gimp,
- "gimp:colorize",
- GIMP_TYPE_COLORIZE_CONFIG);
- set_compat_file (GIMP_TYPE_COLORIZE_CONFIG,
- "gimp-colorize-tool.settings");
- set_settings_folder (GIMP_TYPE_COLORIZE_CONFIG,
- "colorize");
-
- gimp_operation_config_register (gimp,
"gimp:curves",
GIMP_TYPE_CURVES_CONFIG);
set_compat_file (GIMP_TYPE_CURVES_CONFIG,
diff --git a/app/operations/gimpoperationcolorize.c b/app/operations/gimpoperationcolorize.c
index 0612aa3..2d29543 100644
--- a/app/operations/gimpoperationcolorize.c
+++ b/app/operations/gimpoperationcolorize.c
@@ -21,19 +21,38 @@
#include "config.h"
#include <cairo.h>
-#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"
+#include "libgimpconfig/gimpconfig.h"
#include "operations-types.h"
-#include "gimpcolorizeconfig.h"
#include "gimpoperationcolorize.h"
#include "gimp-intl.h"
+enum
+{
+ PROP_0,
+ PROP_HUE,
+ PROP_SATURATION,
+ PROP_LIGHTNESS,
+ PROP_COLOR
+};
+
+
+static void gimp_operation_colorize_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_operation_colorize_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
static gboolean gimp_operation_colorize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
@@ -54,9 +73,11 @@ gimp_operation_colorize_class_init (GimpOperationColorizeClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+ GimpHSL hsl;
+ GimpRGB rgb;
- object_class->set_property = gimp_operation_point_filter_set_property;
- object_class->get_property = gimp_operation_point_filter_get_property;
+ object_class->set_property = gimp_operation_colorize_set_property;
+ object_class->get_property = gimp_operation_colorize_get_property;
gegl_operation_class_set_keys (operation_class,
"name", "gimp:colorize",
@@ -66,14 +87,34 @@ gimp_operation_colorize_class_init (GimpOperationColorizeClass *klass)
point_class->process = gimp_operation_colorize_process;
- g_object_class_install_property (object_class,
- GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
- g_param_spec_object ("config",
- "Config",
- "The config object",
- GIMP_TYPE_COLORIZE_CONFIG,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
+ GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_HUE,
+ "hue",
+ _("Hue"),
+ _("Hue"),
+ 0.0, 1.0, 0.5, 0);
+
+ GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_SATURATION,
+ "saturation",
+ _("Saturation"),
+ _("Saturation"),
+ 0.0, 1.0, 0.5, 0);
+
+ GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_LIGHTNESS,
+ "lightness",
+ _("Lightness"),
+ _("Lightness"),
+ -1.0, 1.0, 0.0, 0);
+
+ gimp_hsl_set (&hsl, 0.5, 0.5, 0.5);
+ gimp_hsl_set_alpha (&hsl, 1.0);
+ gimp_hsl_to_rgb (&hsl, &rgb);
+
+ g_object_class_install_property (object_class, PROP_COLOR,
+ gimp_param_spec_rgb ("color",
+ _("Color"),
+ _("Color"),
+ FALSE, &rgb,
+ G_PARAM_READWRITE));
}
static void
@@ -81,6 +122,102 @@ gimp_operation_colorize_init (GimpOperationColorize *self)
{
}
+static void
+gimp_operation_colorize_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
+
+ switch (property_id)
+ {
+ case PROP_HUE:
+ g_value_set_double (value, self->hue);
+ break;
+
+ case PROP_SATURATION:
+ g_value_set_double (value, self->saturation);
+ break;
+
+ case PROP_LIGHTNESS:
+ g_value_set_double (value, self->lightness);
+ break;
+
+ case PROP_COLOR:
+ {
+ GimpHSL hsl;
+ GimpRGB rgb;
+
+ gimp_hsl_set (&hsl,
+ self->hue,
+ self->saturation,
+ (self->lightness + 1.0) / 2.0);
+ gimp_hsl_set_alpha (&hsl, 1.0);
+ gimp_hsl_to_rgb (&hsl, &rgb);
+ gimp_value_set_rgb (value, &rgb);
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_operation_colorize_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
+
+ switch (property_id)
+ {
+ case PROP_HUE:
+ self->hue = g_value_get_double (value);
+ g_object_notify (object, "color");
+ break;
+
+ case PROP_SATURATION:
+ self->saturation = g_value_get_double (value);
+ g_object_notify (object, "color");
+ break;
+
+ case PROP_LIGHTNESS:
+ self->lightness = g_value_get_double (value);
+ g_object_notify (object, "color");
+ break;
+
+ case PROP_COLOR:
+ {
+ GimpRGB rgb;
+ GimpHSL hsl;
+
+ gimp_value_get_rgb (value, &rgb);
+ gimp_rgb_to_hsl (&rgb, &hsl);
+
+ if (hsl.h == -1)
+ hsl.h = self->hue;
+
+ if (hsl.l == 0.0 || hsl.l == 1.0)
+ hsl.s = self->saturation;
+
+ g_object_set (self,
+ "hue", hsl.h,
+ "saturation", hsl.s,
+ "lightness", hsl.l * 2.0 - 1.0,
+ NULL);
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
static gboolean
gimp_operation_colorize_process (GeglOperation *operation,
void *in_buf,
@@ -89,17 +226,13 @@ gimp_operation_colorize_process (GeglOperation *operation,
const GeglRectangle *roi,
gint level)
{
- GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
- GimpColorizeConfig *config = GIMP_COLORIZE_CONFIG (point->config);
- gfloat *src = in_buf;
- gfloat *dest = out_buf;
- GimpHSL hsl;
-
- if (! config)
- return FALSE;
+ GimpOperationColorize *colorize = GIMP_OPERATION_COLORIZE (operation);
+ gfloat *src = in_buf;
+ gfloat *dest = out_buf;
+ GimpHSL hsl;
- hsl.h = config->hue;
- hsl.s = config->saturation;
+ hsl.h = colorize->hue;
+ hsl.s = colorize->saturation;
while (samples--)
{
@@ -108,15 +241,15 @@ gimp_operation_colorize_process (GeglOperation *operation,
src[GREEN],
src[BLUE]);
- if (config->lightness > 0)
+ if (colorize->lightness > 0)
{
- lum = lum * (1.0 - config->lightness);
+ lum = lum * (1.0 - colorize->lightness);
- lum += 1.0 - (1.0 - config->lightness);
+ lum += 1.0 - (1.0 - colorize->lightness);
}
- else if (config->lightness < 0)
+ else if (colorize->lightness < 0)
{
- lum = lum * (config->lightness + 1.0);
+ lum = lum * (colorize->lightness + 1.0);
}
hsl.l = lum;
diff --git a/app/operations/gimpoperationcolorize.h b/app/operations/gimpoperationcolorize.h
index 1ad3c57..c694fb2 100644
--- a/app/operations/gimpoperationcolorize.h
+++ b/app/operations/gimpoperationcolorize.h
@@ -39,6 +39,10 @@ typedef struct _GimpOperationColorizeClass GimpOperationColorizeClass;
struct _GimpOperationColorize
{
GimpOperationPointFilter parent_instance;
+
+ gdouble hue;
+ gdouble saturation;
+ gdouble lightness;
};
struct _GimpOperationColorizeClass
diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c
index bd47641..d515ce3 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -39,7 +39,6 @@
#include "core/gimpparamspecs.h"
#include "operations/gimpbrightnesscontrastconfig.h"
#include "operations/gimpcolorbalanceconfig.h"
-#include "operations/gimpcolorizeconfig.h"
#include "operations/gimpcurvesconfig.h"
#include "operations/gimphuesaturationconfig.h"
#include "operations/gimplevelsconfig.h"
@@ -573,17 +572,18 @@ colorize_invoker (GimpProcedure *procedure,
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
! gimp_drawable_is_gray (drawable))
{
- GObject *config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG,
- "hue", hue / 360.0,
- "saturation", saturation / 100.0,
- "lightness", lightness / 100.0,
- NULL);
+ GeglNode *node =
+ gegl_node_new_child (NULL,
+ "operation", "gimp:colorize",
+ "hue", hue / 360.0,
+ "saturation", saturation / 100.0,
+ "lightness", lightness / 100.0,
+ NULL);
- gimp_drawable_apply_operation_by_name (drawable, progress,
- C_("undo-type", "Colorize"),
- "gimp:colorize",
- config);
- g_object_unref (config);
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Colorize"),
+ node);
+ g_object_unref (node);
}
else
success = FALSE;
diff --git a/app/pdb/drawable-color-cmds.c b/app/pdb/drawable-color-cmds.c
index d91a15c..22836ef 100644
--- a/app/pdb/drawable-color-cmds.c
+++ b/app/pdb/drawable-color-cmds.c
@@ -39,7 +39,6 @@
#include "core/gimpparamspecs.h"
#include "operations/gimpbrightnesscontrastconfig.h"
#include "operations/gimpcolorbalanceconfig.h"
-#include "operations/gimpcolorizeconfig.h"
#include "operations/gimpcurvesconfig.h"
#include "operations/gimphuesaturationconfig.h"
#include "operations/gimplevelsconfig.h"
@@ -176,17 +175,18 @@ drawable_colorize_hsl_invoker (GimpProcedure *procedure,
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
! gimp_drawable_is_gray (drawable))
{
- GObject *config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG,
- "hue", hue / 360.0,
- "saturation", saturation / 100.0,
- "lightness", lightness / 100.0,
- NULL);
+ GeglNode *node =
+ gegl_node_new_child (NULL,
+ "operation", "gimp:colorize",
+ "hue", hue / 360.0,
+ "saturation", saturation / 100.0,
+ "lightness", lightness / 100.0,
+ NULL);
- gimp_drawable_apply_operation_by_name (drawable, progress,
- C_("undo-type", "Colorize"),
- "gimp:colorize",
- config);
- g_object_unref (config);
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Colorize"),
+ node);
+ g_object_unref (node);
}
else
success = FALSE;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b00587f..f88aa56 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -274,7 +274,6 @@ app/gegl/gimp-gegl-enums.c
app/operations/operations-enums.c
app/operations/gimpbrightnesscontrastconfig.c
app/operations/gimpcolorbalanceconfig.c
-app/operations/gimpcolorizeconfig.c
app/operations/gimpcurvesconfig.c
app/operations/gimphuesaturationconfig.c
app/operations/gimplevelsconfig.c
diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb
index 2908152..0091e36 100644
--- a/tools/pdbgen/pdb/color.pdb
+++ b/tools/pdbgen/pdb/color.pdb
@@ -489,7 +489,6 @@ sub colorize {
);
%invoke = (
- headers => [ qw("operations/gimpcolorizeconfig.h") ],
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
@@ -497,17 +496,18 @@ sub colorize {
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
! gimp_drawable_is_gray (drawable))
{
- GObject *config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG,
- "hue", hue / 360.0,
- "saturation", saturation / 100.0,
- "lightness", lightness / 100.0,
- NULL);
+ GeglNode *node =
+ gegl_node_new_child (NULL,
+ "operation", "gimp:colorize",
+ "hue", hue / 360.0,
+ "saturation", saturation / 100.0,
+ "lightness", lightness / 100.0,
+ NULL);
- gimp_drawable_apply_operation_by_name (drawable, progress,
- C_("undo-type", "Colorize"),
- "gimp:colorize",
- config);
- g_object_unref (config);
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Colorize"),
+ node);
+ g_object_unref (node);
}
else
success = FALSE;
diff --git a/tools/pdbgen/pdb/drawable_color.pdb b/tools/pdbgen/pdb/drawable_color.pdb
index b2d53f4..3d8a745 100644
--- a/tools/pdbgen/pdb/drawable_color.pdb
+++ b/tools/pdbgen/pdb/drawable_color.pdb
@@ -150,7 +150,6 @@ HELP
);
%invoke = (
- headers => [ qw("operations/gimpcolorizeconfig.h") ],
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
@@ -158,17 +157,18 @@ HELP
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
! gimp_drawable_is_gray (drawable))
{
- GObject *config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG,
- "hue", hue / 360.0,
- "saturation", saturation / 100.0,
- "lightness", lightness / 100.0,
- NULL);
+ GeglNode *node =
+ gegl_node_new_child (NULL,
+ "operation", "gimp:colorize",
+ "hue", hue / 360.0,
+ "saturation", saturation / 100.0,
+ "lightness", lightness / 100.0,
+ NULL);
- gimp_drawable_apply_operation_by_name (drawable, progress,
- C_("undo-type", "Colorize"),
- "gimp:colorize",
- config);
- g_object_unref (config);
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Colorize"),
+ node);
+ g_object_unref (node);
}
else
success = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]