gimp r24683 - in trunk: . app/gegl app/tools
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r24683 - in trunk: . app/gegl app/tools
- Date: Wed, 23 Jan 2008 09:28:16 +0000 (GMT)
Author: mitch
Date: Wed Jan 23 09:28:16 2008
New Revision: 24683
URL: http://svn.gnome.org/viewvc/gimp?rev=24683&view=rev
Log:
2008-01-23 Michael Natterer <mitch gimp org>
* app/gegl/Makefile.am
* app/gegl/gegl-types.h
* app/gegl/gimpcurvesconfig.[ch]
* app/gegl/gimpoperationcurves.[ch]: add curves operation and its
config object. Hack around badly to be able to use GimpCurve from
app/core.
* app/gegl/gimp-gegl.c: register the curves operation.
* app/tools/gimpcurvestool.[ch]: added get_operation() implemenetation
and use the new config object instead of keeping around 5 curves.
Added:
trunk/app/gegl/gimpcurvesconfig.c
trunk/app/gegl/gimpcurvesconfig.h
trunk/app/gegl/gimpoperationcurves.c
trunk/app/gegl/gimpoperationcurves.h
Modified:
trunk/ChangeLog
trunk/app/gegl/Makefile.am
trunk/app/gegl/gegl-types.h
trunk/app/gegl/gimp-gegl.c
trunk/app/tools/gimpcurvestool.c
trunk/app/tools/gimpcurvestool.h
Modified: trunk/app/gegl/Makefile.am
==============================================================================
--- trunk/app/gegl/Makefile.am (original)
+++ trunk/app/gegl/Makefile.am Wed Jan 23 09:28:16 2008
@@ -10,6 +10,8 @@
\
gimpcolorizeconfig.c \
gimpcolorizeconfig.h \
+ gimpcurvesconfig.c \
+ gimpcurvesconfig.h \
gimphuesaturationconfig.c \
gimphuesaturationconfig.h \
gimplevelsconfig.c \
@@ -19,6 +21,8 @@
gimpoperationcolorbalance.h \
gimpoperationcolorize.c \
gimpoperationcolorize.h \
+ gimpoperationcurves.c \
+ gimpoperationcurves.h \
gimpoperationdesaturate.c \
gimpoperationdesaturate.h \
gimpoperationhuesaturation.c \
@@ -41,4 +45,5 @@
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(GEGL_CFLAGS) \
+ $(GDK_PIXBUF_CFLAGS) \
-I$(includedir)
Modified: trunk/app/gegl/gegl-types.h
==============================================================================
--- trunk/app/gegl/gegl-types.h (original)
+++ trunk/app/gegl/gegl-types.h Wed Jan 23 09:28:16 2008
@@ -30,6 +30,7 @@
typedef struct _GimpOperationColorBalance GimpOperationColorBalance;
typedef struct _GimpOperationColorize GimpOperationColorize;
+typedef struct _GimpOperationCurves GimpOperationCurves;
typedef struct _GimpOperationDesaturate GimpOperationDesaturate;
typedef struct _GimpOperationHueSaturation GimpOperationHueSaturation;
typedef struct _GimpOperationLevels GimpOperationLevels;
@@ -42,6 +43,7 @@
/* operation config objects */
typedef struct _GimpColorizeConfig GimpColorizeConfig;
+typedef struct _GimpCurvesConfig GimpCurvesConfig;
typedef struct _GimpHueSaturationConfig GimpHueSaturationConfig;
typedef struct _GimpLevelsConfig GimpLevelsConfig;
Modified: trunk/app/gegl/gimp-gegl.c
==============================================================================
--- trunk/app/gegl/gimp-gegl.c (original)
+++ trunk/app/gegl/gimp-gegl.c Wed Jan 23 09:28:16 2008
@@ -28,6 +28,7 @@
#include "gimp-gegl.h"
#include "gimpoperationcolorbalance.h"
#include "gimpoperationcolorize.h"
+#include "gimpoperationcurves.h"
#include "gimpoperationdesaturate.h"
#include "gimpoperationhuesaturation.h"
#include "gimpoperationlevels.h"
@@ -42,6 +43,7 @@
{
g_type_class_ref (GIMP_TYPE_OPERATION_COLOR_BALANCE);
g_type_class_ref (GIMP_TYPE_OPERATION_COLORIZE);
+ g_type_class_ref (GIMP_TYPE_OPERATION_CURVES);
g_type_class_ref (GIMP_TYPE_OPERATION_DESATURATE);
g_type_class_ref (GIMP_TYPE_OPERATION_HUE_SATURATION);
g_type_class_ref (GIMP_TYPE_OPERATION_LEVELS);
Added: trunk/app/gegl/gimpcurvesconfig.c
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpcurvesconfig.c Wed Jan 23 09:28:16 2008
@@ -0,0 +1,227 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpcurvesconfig.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 "libgimpcolor/gimpcolor.h"
+#include "libgimpmath/gimpmath.h"
+
+#include "gegl-types.h"
+
+#include "base/gimphistogram.h"
+
+/* temp cruft */
+#include "base/curves.h"
+
+#include "gimpcurvesconfig.h"
+
+
+enum
+{
+ PROP_0,
+ PROP_CHANNEL,
+ PROP_CURVE
+};
+
+
+static void gimp_curves_config_finalize (GObject *object);
+static void gimp_curves_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_curves_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+
+G_DEFINE_TYPE (GimpCurvesConfig, gimp_curves_config, G_TYPE_OBJECT)
+
+#define parent_class gimp_curves_config_parent_class
+
+
+static void
+gimp_curves_config_class_init (GimpCurvesConfigClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gimp_curves_config_finalize;
+ object_class->set_property = gimp_curves_config_set_property;
+ object_class->get_property = gimp_curves_config_get_property;
+
+ g_object_class_install_property (object_class, PROP_CHANNEL,
+ g_param_spec_enum ("channel",
+ "Channel",
+ "The affected channel",
+ GIMP_TYPE_HISTOGRAM_CHANNEL,
+ GIMP_HISTOGRAM_VALUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (object_class, PROP_CURVE,
+ g_param_spec_object ("curve",
+ "Curve",
+ "Curve",
+ GIMP_TYPE_CURVE,
+ G_PARAM_READWRITE));
+}
+
+static void
+gimp_curves_config_init (GimpCurvesConfig *self)
+{
+ GimpHistogramChannel channel;
+
+ for (channel = GIMP_HISTOGRAM_VALUE;
+ channel <= GIMP_HISTOGRAM_ALPHA;
+ channel++)
+ {
+ self->curve[channel] = GIMP_CURVE (gimp_curve_new ("curves config"));
+ }
+
+ gimp_curves_config_reset (self);
+}
+
+static void
+gimp_curves_config_finalize (GObject *object)
+{
+ GimpCurvesConfig *self = GIMP_CURVES_CONFIG (object);
+ GimpHistogramChannel channel;
+
+ for (channel = GIMP_HISTOGRAM_VALUE;
+ channel <= GIMP_HISTOGRAM_ALPHA;
+ channel++)
+ {
+ if (self->curve[channel])
+ {
+ g_object_unref (self->curve[channel]);
+ self->curve[channel] = NULL;
+ }
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gimp_curves_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpCurvesConfig *self = GIMP_CURVES_CONFIG (object);
+
+ switch (property_id)
+ {
+ case PROP_CHANNEL:
+ g_value_set_enum (value, self->channel);
+ break;
+
+ case PROP_CURVE:
+ g_value_set_object (value, self->curve[self->channel]);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_curves_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpCurvesConfig *self = GIMP_CURVES_CONFIG (object);
+
+ switch (property_id)
+ {
+ case PROP_CHANNEL:
+ self->channel = g_value_get_enum (value);
+ break;
+
+ case PROP_CURVE:
+ if (self->curve[self->channel])
+ g_object_unref (self->curve[self->channel]);
+ self->curve[self->channel] = g_value_dup_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+/* public functions */
+
+void
+gimp_curves_config_reset (GimpCurvesConfig *config)
+{
+ GimpHistogramChannel channel;
+
+ g_return_if_fail (GIMP_IS_CURVES_CONFIG (config));
+
+ config->channel = GIMP_HISTOGRAM_VALUE;
+
+ for (channel = GIMP_HISTOGRAM_VALUE;
+ channel <= GIMP_HISTOGRAM_ALPHA;
+ channel++)
+ {
+ gimp_curve_reset (config->curve[channel], FALSE);
+ }
+}
+
+void
+gimp_curves_config_reset_channel (GimpCurvesConfig *config,
+ GimpHistogramChannel channel)
+{
+ g_return_if_fail (GIMP_IS_CURVES_CONFIG (config));
+
+ gimp_curve_reset (config->curve[channel], FALSE);
+}
+
+
+/* temp cruft */
+
+void
+gimp_curves_config_to_cruft (GimpCurvesConfig *config,
+ Curves *cruft,
+ gboolean is_color)
+{
+ GimpHistogramChannel channel;
+
+ g_return_if_fail (GIMP_IS_CURVES_CONFIG (config));
+ g_return_if_fail (cruft != NULL);
+
+ for (channel = GIMP_HISTOGRAM_VALUE;
+ channel <= GIMP_HISTOGRAM_ALPHA;
+ channel++)
+ {
+ gimp_curve_get_uchar (config->curve[channel], cruft->curve[channel]);
+ }
+
+ if (! is_color)
+ {
+ gimp_curve_get_uchar (config->curve[GIMP_HISTOGRAM_ALPHA], cruft->curve[1]);
+ }
+}
Added: trunk/app/gegl/gimpcurvesconfig.h
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpcurvesconfig.h Wed Jan 23 09:28:16 2008
@@ -0,0 +1,69 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpcurvesconfig.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_CURVES_CONFIG_H__
+#define __GIMP_CURVES_CONFIG_H__
+
+
+#include <gdk-pixbuf/gdk-pixbuf.h> /* eek */
+#include "core/core-types.h" /* eek */
+#include "core/gimpcurve.h" /* eek */
+
+
+#define GIMP_TYPE_CURVES_CONFIG (gimp_curves_config_get_type ())
+#define GIMP_CURVES_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CURVES_CONFIG, GimpCurvesConfig))
+#define GIMP_CURVES_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CURVES_CONFIG, GimpCurvesConfigClass))
+#define GIMP_IS_CURVES_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CURVES_CONFIG))
+#define GIMP_IS_CURVES_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CURVES_CONFIG))
+#define GIMP_CURVES_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CURVES_CONFIG, GimpCurvesConfigClass))
+
+
+typedef struct _GimpCurvesConfigClass GimpCurvesConfigClass;
+
+struct _GimpCurvesConfig
+{
+ GObject parent_instance;
+
+ GimpHistogramChannel channel;
+
+ GimpCurve *curve[5];
+};
+
+struct _GimpCurvesConfigClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType gimp_curves_config_get_type (void) G_GNUC_CONST;
+
+void gimp_curves_config_reset (GimpCurvesConfig *config);
+void gimp_curves_config_reset_channel (GimpCurvesConfig *config,
+ GimpHistogramChannel channel);
+
+
+/* temp cruft */
+void gimp_curves_config_to_cruft (GimpCurvesConfig *config,
+ Curves *cruft,
+ gboolean is_color);
+
+
+#endif /* __GIMP_CURVES_CONFIG_H__ */
Added: trunk/app/gegl/gimpoperationcurves.c
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpoperationcurves.c Wed Jan 23 09:28:16 2008
@@ -0,0 +1,212 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationcurves.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 "libgimpcolor/gimpcolor.h"
+#include "libgimpmath/gimpmath.h"
+
+#include "gegl-types.h"
+
+#include "gimpcurvesconfig.h"
+#include "gimpoperationcurves.h"
+
+
+enum
+{
+ PROP_0,
+ PROP_CONFIG
+};
+
+
+static void gimp_operation_curves_finalize (GObject *object);
+static void gimp_operation_curves_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_operation_curves_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static gboolean gimp_operation_curves_process (GeglOperation *operation,
+ void *in_buf,
+ void *out_buf,
+ glong samples);
+
+
+G_DEFINE_TYPE (GimpOperationCurves, gimp_operation_curves,
+ GEGL_TYPE_OPERATION_POINT_FILTER)
+
+#define parent_class gimp_operation_curves_parent_class
+
+
+static void
+gimp_operation_curves_class_init (GimpOperationCurvesClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+ GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+ object_class->finalize = gimp_operation_curves_finalize;
+ object_class->set_property = gimp_operation_curves_set_property;
+ object_class->get_property = gimp_operation_curves_get_property;
+
+ point_class->process = gimp_operation_curves_process;
+
+ gegl_operation_class_set_name (operation_class, "gimp-curves");
+
+ g_object_class_install_property (object_class, PROP_CONFIG,
+ g_param_spec_object ("config",
+ "Config",
+ "The config object",
+ GIMP_TYPE_CURVES_CONFIG,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+}
+
+static void
+gimp_operation_curves_init (GimpOperationCurves *self)
+{
+}
+
+static void
+gimp_operation_curves_finalize (GObject *object)
+{
+ GimpOperationCurves *self = GIMP_OPERATION_CURVES (object);
+
+ if (self->config)
+ {
+ g_object_unref (self->config);
+ self->config = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gimp_operation_curves_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpOperationCurves *self = GIMP_OPERATION_CURVES (object);
+
+ switch (property_id)
+ {
+ case PROP_CONFIG:
+ g_value_set_object (value, self->config);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_operation_curves_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpOperationCurves *self = GIMP_OPERATION_CURVES (object);
+
+ switch (property_id)
+ {
+ case PROP_CONFIG:
+ if (self->config)
+ g_object_unref (self->config);
+ self->config = g_value_dup_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static inline gdouble
+gimp_operation_curves_map (gdouble value,
+ GimpCurve *curve)
+{
+ if (value < 0.0)
+ {
+ value = curve->curve[0] / 255.0;
+ }
+ else if (value >= 1.0)
+ {
+ value = curve->curve[255] / 255.0;
+ }
+ else /* interpolate the curve */
+ {
+ gint index = floor (value * 255.0);
+ gdouble f = value * 255.0 - index;
+
+ value = ((1.0 - f) * curve->curve[index ] +
+ f * curve->curve[index + 1] ) / 255.0;
+ }
+
+ return value;
+}
+
+static gboolean
+gimp_operation_curves_process (GeglOperation *operation,
+ void *in_buf,
+ void *out_buf,
+ glong samples)
+{
+ GimpOperationCurves *self = GIMP_OPERATION_CURVES (operation);
+ GimpCurvesConfig *config = self->config;
+ gfloat *src = in_buf;
+ gfloat *dest = out_buf;
+ glong sample;
+
+ if (! config)
+ return FALSE;
+
+ for (sample = 0; sample < samples; sample++)
+ {
+ gint channel;
+
+ for (channel = 0; channel < 4; channel++)
+ {
+ gdouble value;
+
+ value = gimp_operation_curves_map (src[channel],
+ config->curve[channel + 1]);
+
+ /* don't apply the overall curve to the alpha channel */
+ if (channel != ALPHA_PIX)
+ value = gimp_operation_curves_map (value,
+ config->curve[0]);
+
+ dest[channel] = value;
+ }
+
+ src += 4;
+ dest += 4;
+ }
+
+ return TRUE;
+}
Added: trunk/app/gegl/gimpoperationcurves.h
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpoperationcurves.h Wed Jan 23 09:28:16 2008
@@ -0,0 +1,56 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationcurves.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_OPERATION_CURVES_H__
+#define __GIMP_OPERATION_CURVES_H__
+
+
+#include <gegl-plugin.h>
+#include <operation/gegl-operation-point-filter.h>
+
+
+#define GIMP_TYPE_OPERATION_CURVES (gimp_operation_curves_get_type ())
+#define GIMP_OPERATION_CURVES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_CURVES, GimpOperationCurves))
+#define GIMP_OPERATION_CURVES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_CURVES, GimpOperationCurvesClass))
+#define GIMP_IS_OPERATION_CURVES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_CURVES))
+#define GIMP_IS_OPERATION_CURVES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_CURVES))
+#define GIMP_OPERATION_CURVES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_CURVES, GimpOperationCurvesClass))
+
+
+typedef struct _GimpOperationCurvesClass GimpOperationCurvesClass;
+
+struct _GimpOperationCurves
+{
+ GeglOperationPointFilter parent_instance;
+
+ GimpCurvesConfig *config;
+};
+
+struct _GimpOperationCurvesClass
+{
+ GeglOperationPointFilterClass parent_class;
+};
+
+
+GType gimp_operation_curves_get_type (void) G_GNUC_CONST;
+
+
+#endif /* __GIMP_OPERATION_CURVES_H__ */
Modified: trunk/app/tools/gimpcurvestool.c
==============================================================================
--- trunk/app/tools/gimpcurvestool.c (original)
+++ trunk/app/tools/gimpcurvestool.c Wed Jan 23 09:28:16 2008
@@ -36,6 +36,9 @@
#include "base/gimphistogram.h"
#include "base/gimplut.h"
+#include "gegl/gimpcurvesconfig.h"
+#include "gegl/gimpoperationcurves.h"
+
#include "core/gimp.h"
#include "core/gimpcurve.h"
#include "core/gimpdrawable.h"
@@ -62,52 +65,53 @@
/* local function prototypes */
-static void gimp_curves_tool_finalize (GObject *object);
+static void gimp_curves_tool_finalize (GObject *object);
-static gboolean gimp_curves_tool_initialize (GimpTool *tool,
- GimpDisplay *display,
- GError **error);
-static void gimp_curves_tool_button_release (GimpTool *tool,
- GimpCoords *coords,
- guint32 time,
- GdkModifierType state,
- GimpButtonReleaseType release_type,
- GimpDisplay *display);
-static gboolean gimp_curves_tool_key_press (GimpTool *tool,
- GdkEventKey *kevent,
- GimpDisplay *display);
-static void gimp_curves_tool_oper_update (GimpTool *tool,
- GimpCoords *coords,
- GdkModifierType state,
- gboolean proximity,
- GimpDisplay *display);
-
-static void gimp_curves_tool_color_picked (GimpColorTool *color_tool,
- GimpColorPickState pick_state,
- GimpImageType sample_type,
- GimpRGB *color,
- gint color_index);
-static void gimp_curves_tool_map (GimpImageMapTool *image_map_tool);
-static void gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool);
-static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool);
-static gboolean gimp_curves_tool_settings_load (GimpImageMapTool *image_map_tool,
- gpointer fp,
- GError **error);
-static gboolean gimp_curves_tool_settings_save (GimpImageMapTool *image_map_tool,
- gpointer fp);
-
-static void curves_curve_callback (GimpCurve *curve,
- GimpCurvesTool *tool);
-static void curves_channel_callback (GtkWidget *widget,
- GimpCurvesTool *tool);
-static void curves_channel_reset_callback (GtkWidget *widget,
- GimpCurvesTool *tool);
+static gboolean gimp_curves_tool_initialize (GimpTool *tool,
+ GimpDisplay *display,
+ GError **error);
+static void gimp_curves_tool_button_release (GimpTool *tool,
+ GimpCoords *coords,
+ guint32 time,
+ GdkModifierType state,
+ GimpButtonReleaseType release_type,
+ GimpDisplay *display);
+static gboolean gimp_curves_tool_key_press (GimpTool *tool,
+ GdkEventKey *kevent,
+ GimpDisplay *display);
+static void gimp_curves_tool_oper_update (GimpTool *tool,
+ GimpCoords *coords,
+ GdkModifierType state,
+ gboolean proximity,
+ GimpDisplay *display);
+
+static void gimp_curves_tool_color_picked (GimpColorTool *color_tool,
+ GimpColorPickState pick_state,
+ GimpImageType sample_type,
+ GimpRGB *color,
+ gint color_index);
+static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool);
+static void gimp_curves_tool_map (GimpImageMapTool *image_map_tool);
+static void gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool);
+static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool);
+static gboolean gimp_curves_tool_settings_load (GimpImageMapTool *image_map_tool,
+ gpointer fp,
+ GError **error);
+static gboolean gimp_curves_tool_settings_save (GimpImageMapTool *image_map_tool,
+ gpointer fp);
+
+static void curves_curve_callback (GimpCurve *curve,
+ GimpCurvesTool *tool);
+static void curves_channel_callback (GtkWidget *widget,
+ GimpCurvesTool *tool);
+static void curves_channel_reset_callback (GtkWidget *widget,
+ GimpCurvesTool *tool);
-static gboolean curves_menu_sensitivity (gint value,
- gpointer data);
+static gboolean curves_menu_sensitivity (gint value,
+ gpointer data);
-static void curves_curve_type_callback (GtkWidget *widget,
- GimpCurvesTool *tool);
+static void curves_curve_type_callback (GtkWidget *widget,
+ GimpCurvesTool *tool);
G_DEFINE_TYPE (GimpCurvesTool, gimp_curves_tool, GIMP_TYPE_IMAGE_MAP_TOOL)
@@ -161,6 +165,7 @@
im_tool_class->save_dialog_title = _("Save Curves");
im_tool_class->save_button_tip = _("Save curves settings to file");
+ im_tool_class->get_operation = gimp_curves_tool_get_operation;
im_tool_class->map = gimp_curves_tool_map;
im_tool_class->dialog = gimp_curves_tool_dialog;
im_tool_class->reset = gimp_curves_tool_reset;
@@ -174,15 +179,6 @@
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
gint i;
- for (i = 0; i < G_N_ELEMENTS (tool->curve); i++)
- {
- tool->curve[i] = GIMP_CURVE (gimp_curve_new ("curves tool"));
-
- g_signal_connect_object (tool->curve[i], "dirty",
- G_CALLBACK (curves_curve_callback),
- tool, 0);
- }
-
tool->lut = gimp_lut_new ();
tool->channel = GIMP_HISTOGRAM_VALUE;
@@ -197,10 +193,12 @@
gimp_curves_tool_finalize (GObject *object)
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (object);
- gint i;
- for (i = 0; i < G_N_ELEMENTS (tool->curve); i++)
- g_object_unref (tool->curve[i]);
+ if (tool->config)
+ {
+ g_object_unref (tool->config);
+ tool->config = NULL;
+ }
gimp_lut_free (tool->lut);
@@ -232,13 +230,13 @@
return FALSE;
}
- for (i = 0; i < G_N_ELEMENTS (c_tool->curve); i++)
- gimp_curve_reset (c_tool->curve[i], TRUE);
+ for (i = 0; i < G_N_ELEMENTS (c_tool->config->curve); i++)
+ gimp_curve_reset (c_tool->config->curve[i], TRUE);
if (! c_tool->hist)
c_tool->hist = gimp_histogram_new ();
- c_tool->channel = GIMP_HISTOGRAM_VALUE;
+ c_tool->channel = c_tool->config->channel;
c_tool->color = gimp_drawable_is_rgb (drawable);
c_tool->alpha = gimp_drawable_has_alpha (drawable);
@@ -254,15 +252,11 @@
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (c_tool->channel_menu),
c_tool->channel);
- /* FIXME: hack */
- if (! c_tool->color)
- c_tool->channel = (c_tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0;
-
gimp_drawable_calculate_histogram (drawable, c_tool->hist);
gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (c_tool->graph),
c_tool->hist);
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (c_tool->graph),
- c_tool->curve[c_tool->channel]);
+ c_tool->config->curve[c_tool->channel]);
return TRUE;
}
@@ -279,7 +273,7 @@
if (state & GDK_SHIFT_MASK)
{
- GimpCurve *curve = c_tool->curve[c_tool->channel];
+ GimpCurve *curve = c_tool->config->curve[c_tool->channel];
gint closest;
closest =
@@ -300,7 +294,7 @@
for (i = 0; i < 5; i++)
{
- GimpCurve *curve = c_tool->curve[i];
+ GimpCurve *curve = c_tool->config->curve[i];
gint closest;
closest =
@@ -371,10 +365,9 @@
GimpRGB *color,
gint color_index)
{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (color_tool);
- GimpDrawable *drawable;
- guchar r, g, b, a;
- GimpHistogramChannel channel;
+ GimpCurvesTool *tool = GIMP_CURVES_TOOL (color_tool);
+ GimpDrawable *drawable;
+ guchar r, g, b, a;
drawable = GIMP_IMAGE_MAP_TOOL (tool)->drawable;
@@ -392,13 +385,35 @@
tool->col_value[GIMP_HISTOGRAM_VALUE] = MAX (MAX (r, g), b);
- if (tool->color)
- channel = tool->channel;
- else
- channel = (tool->channel == 1) ? GIMP_HISTOGRAM_ALPHA : GIMP_HISTOGRAM_VALUE;
-
gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
- tool->col_value[channel]);
+ tool->col_value[tool->channel]);
+}
+
+static GeglNode *
+gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool)
+{
+ GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
+ GeglNode *node;
+ gint i;
+
+ node = g_object_new (GEGL_TYPE_NODE,
+ "operation", "gimp-curves",
+ NULL);
+
+ tool->config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (tool->config->curve); i++)
+ {
+ g_signal_connect_object (tool->config->curve[i], "dirty",
+ G_CALLBACK (curves_curve_callback),
+ tool, 0);
+ }
+
+ gegl_node_set (node,
+ "config", tool->config,
+ NULL);
+
+ return node;
}
static void
@@ -406,10 +421,8 @@
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
Curves curves;
- gint i;
- for (i = 0; i < G_N_ELEMENTS (tool->curve); i++)
- gimp_curve_get_uchar (tool->curve[i], curves.curve[i]);
+ gimp_curves_config_to_cruft (tool->config, &curves, tool->color);
gimp_lut_setup (tool->lut,
(GimpLutFunc) curves_lut_func,
@@ -600,15 +613,9 @@
static void
gimp_curves_tool_reset (GimpImageMapTool *image_map_tool)
{
- GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
- GimpHistogramChannel channel;
+ GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
- for (channel = GIMP_HISTOGRAM_VALUE;
- channel <= GIMP_HISTOGRAM_ALPHA;
- channel++)
- {
- gimp_curve_reset (tool->curve[channel], FALSE);
- }
+ gimp_curves_config_reset (tool->config);
}
static gboolean
@@ -650,7 +657,7 @@
for (i = 0; i < 5; i++)
{
- GimpCurve *curve = tool->curve[i];
+ GimpCurve *curve = tool->config->curve[i];
gimp_data_freeze (GIMP_DATA (curve));
@@ -681,7 +688,7 @@
for (i = 0; i < 5; i++)
{
- GimpCurve *curve = tool->curve[i];
+ GimpCurve *curve = tool->config->curve[i];
if (curve->curve_type == GIMP_CURVE_FREE)
{
@@ -712,37 +719,29 @@
curves_curve_callback (GimpCurve *curve,
GimpCurvesTool *tool)
{
- if (curve != tool->curve[tool->channel])
+ if (curve != tool->config->curve[tool->channel])
return;
if (tool->xrange)
{
- GimpHistogramChannel channel;
-
- if (tool->color)
- channel = tool->channel;
- else
- channel = ((tool->channel == 1) ?
- GIMP_HISTOGRAM_ALPHA : GIMP_HISTOGRAM_VALUE);
-
- switch (channel)
+ switch (tool->channel)
{
case GIMP_HISTOGRAM_VALUE:
case GIMP_HISTOGRAM_ALPHA:
case GIMP_HISTOGRAM_RGB:
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
- tool->curve[tool->channel]->curve,
- tool->curve[tool->channel]->curve,
- tool->curve[tool->channel]->curve);
+ tool->config->curve[tool->channel]->curve,
+ tool->config->curve[tool->channel]->curve,
+ tool->config->curve[tool->channel]->curve);
break;
case GIMP_HISTOGRAM_RED:
case GIMP_HISTOGRAM_GREEN:
case GIMP_HISTOGRAM_BLUE:
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
- tool->curve[GIMP_HISTOGRAM_RED]->curve,
- tool->curve[GIMP_HISTOGRAM_GREEN]->curve,
- tool->curve[GIMP_HISTOGRAM_BLUE]->curve);
+ tool->config->curve[GIMP_HISTOGRAM_RED]->curve,
+ tool->config->curve[GIMP_HISTOGRAM_GREEN]->curve,
+ tool->config->curve[GIMP_HISTOGRAM_BLUE]->curve);
break;
}
}
@@ -760,6 +759,11 @@
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
{
tool->channel = value;
+
+ g_object_set (tool->config,
+ "channel", tool->channel,
+ NULL);
+
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->graph),
tool->channel);
gimp_curve_view_set_xpos (GIMP_CURVE_VIEW (tool->graph),
@@ -767,17 +771,13 @@
gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->yrange), tool->channel);
- /* FIXME: hack */
- if (! tool->color)
- tool->channel = (tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0;
-
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph),
- tool->curve[tool->channel]);
+ tool->config->curve[tool->channel]);
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
- tool->curve[tool->channel]->curve_type);
+ tool->config->curve[tool->channel]->curve_type);
- curves_curve_callback (tool->curve[tool->channel], tool);
+ curves_curve_callback (tool->config->curve[tool->channel], tool);
}
}
@@ -785,7 +785,7 @@
curves_channel_reset_callback (GtkWidget *widget,
GimpCurvesTool *tool)
{
- gimp_curve_reset (tool->curve[tool->channel], FALSE);
+ gimp_curves_config_reset_channel (tool->config, tool->channel);
}
static gboolean
@@ -823,8 +823,8 @@
gimp_radio_button_update (widget, &curve_type);
- if (tool->curve[tool->channel]->curve_type != curve_type)
+ if (tool->config->curve[tool->channel]->curve_type != curve_type)
{
- gimp_curve_set_curve_type (tool->curve[tool->channel], curve_type);
+ gimp_curve_set_curve_type (tool->config->curve[tool->channel], curve_type);
}
}
Modified: trunk/app/tools/gimpcurvestool.h
==============================================================================
--- trunk/app/tools/gimpcurvestool.h (original)
+++ trunk/app/tools/gimpcurvestool.h Wed Jan 23 09:28:16 2008
@@ -37,7 +37,7 @@
{
GimpImageMapTool parent_instance;
- GimpCurve *curve[5];
+ GimpCurvesConfig *config;
GimpLut *lut;
/* dialog */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]