gimp r24647 - in trunk: . app/gegl app/tools
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r24647 - in trunk: . app/gegl app/tools
- Date: Fri, 18 Jan 2008 14:44:28 +0000 (GMT)
Author: mitch
Date: Fri Jan 18 14:44:27 2008
New Revision: 24647
URL: http://svn.gnome.org/viewvc/gimp?rev=24647&view=rev
Log:
2008-01-18 Michael Natterer <mitch gimp org>
* app/gegl/Makefile.am
* app/gegl/gegl-types.h
* app/gegl/gimpcolorizeconfig.[ch]: new config object.
* app/gegl/gimpoperationcolorize.[ch]: remove all properties and
add a "config" property.
* app/tools/gimpcolorizetool.[ch]: port to GimpColorizeConfig, use
the old Colorize struct only in map().
Added:
trunk/app/gegl/gimpcolorizeconfig.c
trunk/app/gegl/gimpcolorizeconfig.h
Modified:
trunk/ChangeLog
trunk/app/gegl/Makefile.am
trunk/app/gegl/gegl-types.h
trunk/app/gegl/gimpoperationcolorize.c
trunk/app/gegl/gimpoperationcolorize.h
trunk/app/tools/gimpcolorizetool.c
trunk/app/tools/gimpcolorizetool.h
Modified: trunk/app/gegl/Makefile.am
==============================================================================
--- trunk/app/gegl/Makefile.am (original)
+++ trunk/app/gegl/Makefile.am Fri Jan 18 14:44:27 2008
@@ -7,8 +7,12 @@
gimp-gegl.h \
gimp-gegl-utils.c \
gimp-gegl-utils.h \
+ \
+ gimpcolorizeconfig.c \
+ gimpcolorizeconfig.h \
gimplevelsconfig.c \
gimplevelsconfig.h \
+ \
gimpoperationcolorbalance.c \
gimpoperationcolorbalance.h \
gimpoperationcolorize.c \
Modified: trunk/app/gegl/gegl-types.h
==============================================================================
--- trunk/app/gegl/gegl-types.h (original)
+++ trunk/app/gegl/gegl-types.h Fri Jan 18 14:44:27 2008
@@ -41,6 +41,7 @@
/* operation config objects */
+typedef struct _GimpColorizeConfig GimpColorizeConfig;
typedef struct _GimpLevelsConfig GimpLevelsConfig;
Added: trunk/app/gegl/gimpcolorizeconfig.c
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpcolorizeconfig.c Fri Jan 18 14:44:27 2008
@@ -0,0 +1,147 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpcolorizeconfig.c
+ * Copyright (C) 2007 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+
+#include "gegl-types.h"
+
+#include "gimpcolorizeconfig.h"
+
+
+enum
+{
+ PROP_0,
+ PROP_HUE,
+ PROP_SATURATION,
+ PROP_LIGHTNESS
+};
+
+
+static void gimp_colorize_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_colorize_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+
+G_DEFINE_TYPE (GimpColorizeConfig, gimp_colorize_config, G_TYPE_OBJECT)
+
+#define parent_class gimp_colorize_config_parent_class
+
+
+static void
+gimp_colorize_config_class_init (GimpColorizeConfigClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->set_property = gimp_colorize_config_set_property;
+ object_class->get_property = gimp_colorize_config_get_property;
+
+ g_object_class_install_property (object_class, PROP_HUE,
+ g_param_spec_double ("hue",
+ "Hue",
+ "Hue",
+ 0.0, 1.0, 0.5,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class, PROP_SATURATION,
+ g_param_spec_double ("saturation",
+ "Saturation",
+ "Saturation",
+ 0.0, 1.0, 0.5,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class, PROP_LIGHTNESS,
+ g_param_spec_double ("lightness",
+ "Lightness",
+ "Lightness",
+ -1.0, 1.0, 0.0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+}
+
+static void
+gimp_colorize_config_init (GimpColorizeConfig *self)
+{
+}
+
+static void
+gimp_colorize_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpColorizeConfig *self = GIMP_COLORIZE_CONFIG (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;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_colorize_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpColorizeConfig *self = GIMP_COLORIZE_CONFIG (object);
+
+ switch (property_id)
+ {
+ case PROP_HUE:
+ self->hue = g_value_get_double (value);
+ break;
+
+ case PROP_SATURATION:
+ self->saturation = g_value_get_double (value);
+ break;
+
+ case PROP_LIGHTNESS:
+ self->lightness = g_value_get_double (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
Added: trunk/app/gegl/gimpcolorizeconfig.h
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpcolorizeconfig.h Fri Jan 18 14:44:27 2008
@@ -0,0 +1,52 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpcolorizeconfig.h
+ * Copyright (C) 2007 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GIMP_COLORIZE_CONFIG_H__
+#define __GIMP_COLORIZE_CONFIG_H__
+
+
+#define GIMP_TYPE_COLORIZE_CONFIG (gimp_colorize_config_get_type ())
+#define GIMP_COLORIZE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLORIZE_CONFIG, GimpColorizeConfig))
+#define GIMP_COLORIZE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLORIZE_CONFIG, GimpColorizeConfigClass))
+#define GIMP_COLORIZE_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLORIZE_CONFIG, GimpColorizeConfigClass))
+
+
+typedef struct _GimpColorizeConfigClass GimpColorizeConfigClass;
+
+struct _GimpColorizeConfig
+{
+ GObject parent_instance;
+
+ gdouble hue;
+ gdouble saturation;
+ gdouble lightness;
+};
+
+struct _GimpColorizeConfigClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType gimp_colorize_config_get_type (void) G_GNUC_CONST;
+
+
+#endif /* __GIMP_COLORIZE_CONFIG_H__ */
Modified: trunk/app/gegl/gimpoperationcolorize.c
==============================================================================
--- trunk/app/gegl/gimpoperationcolorize.c (original)
+++ trunk/app/gegl/gimpoperationcolorize.c Fri Jan 18 14:44:27 2008
@@ -27,18 +27,18 @@
#include "gegl-types.h"
+#include "gimpcolorizeconfig.h"
#include "gimpoperationcolorize.h"
enum
{
PROP_0,
- PROP_HUE,
- PROP_SATURATION,
- PROP_LIGHTNESS
+ PROP_CONFIG
};
+static void gimp_operation_colorize_finalize (GObject *object);
static void gimp_operation_colorize_get_property (GObject *object,
guint property_id,
GValue *value,
@@ -67,6 +67,7 @@
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+ object_class->finalize = gimp_operation_colorize_finalize;
object_class->set_property = gimp_operation_colorize_set_property;
object_class->get_property = gimp_operation_colorize_get_property;
@@ -74,27 +75,11 @@
gegl_operation_class_set_name (operation_class, "gimp-colorize");
- g_object_class_install_property (object_class, PROP_HUE,
- g_param_spec_double ("hue",
- "Hue",
- "Hue",
- 0.0, 1.0, 0.5,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class, PROP_SATURATION,
- g_param_spec_double ("saturation",
- "Saturation",
- "Saturation",
- 0.0, 1.0, 0.5,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class, PROP_LIGHTNESS,
- g_param_spec_double ("lightness",
- "Lightness",
- "Lightness",
- -1.0, 1.0, 0.0,
+ g_object_class_install_property (object_class, PROP_CONFIG,
+ g_param_spec_object ("config",
+ "Config",
+ "The config object",
+ GIMP_TYPE_COLORIZE_CONFIG,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
@@ -105,6 +90,20 @@
}
static void
+gimp_operation_colorize_finalize (GObject *object)
+{
+ GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
+
+ if (self->config)
+ {
+ g_object_unref (self->config);
+ self->config = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
gimp_operation_colorize_get_property (GObject *object,
guint property_id,
GValue *value,
@@ -114,16 +113,8 @@
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);
+ case PROP_CONFIG:
+ g_value_set_object (value, self->config);
break;
default:
@@ -142,16 +133,10 @@
switch (property_id)
{
- case PROP_HUE:
- self->hue = g_value_get_double (value);
- break;
-
- case PROP_SATURATION:
- self->saturation = g_value_get_double (value);
- break;
-
- case PROP_LIGHTNESS:
- self->lightness = g_value_get_double (value);
+ case PROP_CONFIG:
+ if (self->config)
+ g_object_unref (self->config);
+ self->config = g_value_dup_object (value);
break;
default:
@@ -166,14 +151,15 @@
void *out_buf,
glong samples)
{
- GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (operation);
- gfloat *src = in_buf;
- gfloat *dest = out_buf;
+ GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (operation);
+ GimpColorizeConfig *config = self->config;
+ gfloat *src = in_buf;
+ gfloat *dest = out_buf;
GimpHSL hsl;
glong sample;
- hsl.h = self->hue;
- hsl.s = self->saturation;
+ hsl.h = config->hue;
+ hsl.s = config->saturation;
for (sample = 0; sample < samples; sample++)
{
@@ -182,15 +168,15 @@
src[GREEN_PIX],
src[BLUE_PIX]);
- if (self->lightness > 0)
+ if (config->lightness > 0)
{
- lum = lum * (1.0 - self->lightness);
+ lum = lum * (1.0 - config->lightness);
- lum += 1.0 - (1.0 - self->lightness);
+ lum += 1.0 - (1.0 - config->lightness);
}
- else if (self->lightness < 0)
+ else if (config->lightness < 0)
{
- lum = lum * (self->lightness + 1.0);
+ lum = lum * (config->lightness + 1.0);
}
hsl.l = lum;
Modified: trunk/app/gegl/gimpoperationcolorize.h
==============================================================================
--- trunk/app/gegl/gimpoperationcolorize.h (original)
+++ trunk/app/gegl/gimpoperationcolorize.h Fri Jan 18 14:44:27 2008
@@ -38,9 +38,7 @@
{
GeglOperationPointFilter parent_instance;
- gdouble hue;
- gdouble saturation;
- gdouble lightness;
+ GimpColorizeConfig *config;
};
struct _GimpOperationColorizeClass
Modified: trunk/app/tools/gimpcolorizetool.c
==============================================================================
--- trunk/app/tools/gimpcolorizetool.c (original)
+++ trunk/app/tools/gimpcolorizetool.c Fri Jan 18 14:44:27 2008
@@ -27,6 +27,8 @@
#include "base/colorize.h"
+#include "gegl/gimpcolorizeconfig.h"
+
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
@@ -126,6 +128,12 @@
g_slice_free (Colorize, col_tool->colorize);
+ if (col_tool->config)
+ {
+ g_object_unref (col_tool->config);
+ col_tool->config = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -147,7 +155,11 @@
return FALSE;
}
- colorize_init (col_tool->colorize);
+ g_object_set (col_tool->config,
+ "hue", 0.5,
+ "saturation", 0.5,
+ "lightness", 0.0,
+ NULL);
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
@@ -161,23 +173,34 @@
static GeglNode *
gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool)
{
- return g_object_new (GEGL_TYPE_NODE,
+ GimpColorizeTool *tool = GIMP_COLORIZE_TOOL (im_tool);
+ GeglNode *node;
+
+ node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-colorize",
NULL);
+
+ tool->config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG, NULL);
+
+ gegl_node_set (node,
+ "config", tool->config,
+ NULL);
+
+ return node;
}
static void
gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
{
- GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
+ GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
+ GimpColorizeConfig *config = col_tool->config;
+ Colorize *colorize = col_tool->colorize;
+
+ colorize->hue = config->hue * 360.0;
+ colorize->saturation = config->saturation * 100.0;
+ colorize->lightness = config->lightness * 100.0;
- gegl_node_set (image_map_tool->operation,
- "hue", col_tool->colorize->hue / 360.0,
- "saturation", col_tool->colorize->saturation / 100.0,
- "lightness", col_tool->colorize->lightness / 100.0,
- NULL);
-
- colorize_calculate (col_tool->colorize);
+ colorize_calculate (colorize);
}
@@ -235,7 +258,7 @@
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
- g_signal_connect (col_tool->saturation_data, "value-changed",
+ g_signal_connect (data, "value-changed",
G_CALLBACK (colorize_saturation_changed),
col_tool);
@@ -259,7 +282,11 @@
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
- colorize_init (col_tool->colorize);
+ g_object_set (col_tool->config,
+ "hue", 0.5,
+ "saturation", 0.5,
+ "lightness", 0.0,
+ NULL);
colorize_update_sliders (col_tool);
}
@@ -267,21 +294,25 @@
static void
colorize_update_sliders (GimpColorizeTool *col_tool)
{
- gtk_adjustment_set_value (GTK_ADJUSTMENT (col_tool->hue_data),
- col_tool->colorize->hue);
- gtk_adjustment_set_value (GTK_ADJUSTMENT (col_tool->saturation_data),
- col_tool->colorize->saturation);
- gtk_adjustment_set_value (GTK_ADJUSTMENT (col_tool->lightness_data),
- col_tool->colorize->lightness);
+ gtk_adjustment_set_value (col_tool->hue_data,
+ col_tool->config->hue * 360.0);
+ gtk_adjustment_set_value (col_tool->saturation_data,
+ col_tool->config->saturation * 100.0);
+ gtk_adjustment_set_value (col_tool->lightness_data,
+ col_tool->config->lightness * 100.0);
}
static void
colorize_hue_changed (GtkAdjustment *adjustment,
GimpColorizeTool *col_tool)
{
- if (col_tool->colorize->hue != adjustment->value)
+ gdouble value = adjustment->value / 360.0;
+
+ if (col_tool->config->hue != value)
{
- col_tool->colorize->hue = adjustment->value;
+ g_object_set (col_tool->config,
+ "hue", value,
+ NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
@@ -291,9 +322,13 @@
colorize_saturation_changed (GtkAdjustment *adjustment,
GimpColorizeTool *col_tool)
{
- if (col_tool->colorize->saturation != adjustment->value)
+ gdouble value = adjustment->value / 100.0;
+
+ if (col_tool->config->saturation != value)
{
- col_tool->colorize->saturation = adjustment->value;
+ g_object_set (col_tool->config,
+ "saturation", value,
+ NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
@@ -303,9 +338,13 @@
colorize_lightness_changed (GtkAdjustment *adjustment,
GimpColorizeTool *col_tool)
{
- if (col_tool->colorize->lightness != adjustment->value)
+ gdouble value = adjustment->value / 100.0;
+
+ if (col_tool->config->lightness != value)
{
- col_tool->colorize->lightness = adjustment->value;
+ g_object_set (col_tool->config,
+ "lightness", value,
+ NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
Modified: trunk/app/tools/gimpcolorizetool.h
==============================================================================
--- trunk/app/tools/gimpcolorizetool.h (original)
+++ trunk/app/tools/gimpcolorizetool.h Fri Jan 18 14:44:27 2008
@@ -36,14 +36,15 @@
struct _GimpColorizeTool
{
- GimpImageMapTool parent_instance;
+ GimpImageMapTool parent_instance;
- Colorize *colorize;
+ GimpColorizeConfig *config;
+ Colorize *colorize;
/* dialog */
- GtkAdjustment *hue_data;
- GtkAdjustment *saturation_data;
- GtkAdjustment *lightness_data;
+ GtkAdjustment *hue_data;
+ GtkAdjustment *saturation_data;
+ GtkAdjustment *lightness_data;
};
struct _GimpColorizeToolClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]