1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2001-02-04 12:51:17 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-06-09 20:53:42 +08:00
|
|
|
#include <errno.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2002-01-30 22:54:27 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning GTK_DISABLE_DEPRECATED
|
|
|
|
#endif
|
|
|
|
#undef GTK_DISABLE_DEPRECATED
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
#include "base/curves.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "base/gimphistogram.h"
|
|
|
|
#include "base/gimplut.h"
|
|
|
|
|
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
2002-08-26 19:35:56 +08:00
|
|
|
#include "core/gimpimagemap.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
|
|
|
|
#include "widgets/gimpcursor.h"
|
2002-03-18 00:35:05 +08:00
|
|
|
#include "widgets/gimpenummenu.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "gimpcurvestool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "tool_manager.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
#define XRANGE_TOP (1 << 0)
|
|
|
|
#define XRANGE_BOTTOM (1 << 1)
|
|
|
|
#define YRANGE (1 << 2)
|
|
|
|
#define ALL (XRANGE_TOP | XRANGE_BOTTOM | YRANGE)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-23 23:24:46 +08:00
|
|
|
/* NB: take care when changing these values: make sure the curve[] array in
|
2002-08-26 19:35:56 +08:00
|
|
|
* base/curves.h is large enough.
|
1999-06-23 23:24:46 +08:00
|
|
|
*/
|
1999-11-22 19:14:29 +08:00
|
|
|
#define GRAPH_WIDTH 256
|
|
|
|
#define GRAPH_HEIGHT 256
|
|
|
|
#define XRANGE_WIDTH 256
|
|
|
|
#define XRANGE_HEIGHT 16
|
|
|
|
#define YRANGE_WIDTH 16
|
|
|
|
#define YRANGE_HEIGHT 256
|
1997-11-25 06:05:25 +08:00
|
|
|
#define RADIUS 3
|
|
|
|
#define MIN_DISTANCE 8
|
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
#define GRAPH_MASK (GDK_EXPOSURE_MASK | \
|
|
|
|
GDK_LEAVE_NOTIFY_MASK | \
|
|
|
|
GDK_POINTER_MOTION_MASK | \
|
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
|
|
|
GDK_BUTTON_RELEASE_MASK)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void gimp_curves_tool_class_init (GimpCurvesToolClass *klass);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void gimp_curves_tool_init (GimpCurvesTool *c_tool);
|
|
|
|
|
|
|
|
static void gimp_curves_tool_finalize (GObject *object);
|
|
|
|
|
|
|
|
static void gimp_curves_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_curves_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_curves_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_curves_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2002-10-14 21:39:35 +08:00
|
|
|
static void gimp_curves_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
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 void curves_color_update (GimpTool *tool,
|
|
|
|
GimpDisplay *gdisp,
|
|
|
|
GimpDrawable *drawable,
|
2002-10-14 21:39:35 +08:00
|
|
|
GimpCoords *coords);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void curves_add_point (GimpCurvesTool *c_tool,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint cchan);
|
|
|
|
|
|
|
|
static void curves_update (GimpCurvesTool *c_tool,
|
|
|
|
gint update);
|
|
|
|
|
|
|
|
static void curves_channel_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpCurvesTool *c_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void curves_channel_reset_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpCurvesTool *c_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
static gboolean curves_set_sensitive_callback (gpointer item_data,
|
|
|
|
GimpCurvesTool *c_tool);
|
2003-03-15 07:24:37 +08:00
|
|
|
static void curves_curve_type_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpCurvesTool *c_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void curves_load_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpCurvesTool *c_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void curves_save_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpCurvesTool *c_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static gint curves_graph_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpCurvesTool *c_tool);
|
2003-03-14 21:42:39 +08:00
|
|
|
static void curves_graph_expose (GtkWidget *widget,
|
|
|
|
GdkRectangle *area,
|
|
|
|
GimpCurvesTool *c_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
static void file_dialog_create (GimpCurvesTool *c_tool);
|
|
|
|
static void file_dialog_ok_callback (GimpCurvesTool *c_tool);
|
|
|
|
|
|
|
|
static gboolean curves_read_from_file (GimpCurvesTool *c_tool,
|
|
|
|
FILE *file);
|
|
|
|
static void curves_write_to_file (GimpCurvesTool *c_tool,
|
|
|
|
FILE *file);
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
static GimpImageMapToolClass *parent_class = NULL;
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
/* public functions */
|
2001-05-25 07:57:08 +08:00
|
|
|
|
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_curves_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_CURVES_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
G_TYPE_NONE, NULL,
|
2001-11-21 07:00:47 +08:00
|
|
|
FALSE,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-curves-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Curves"),
|
|
|
|
_("Adjust color curves"),
|
2001-12-04 01:59:48 +08:00
|
|
|
N_("/Layer/Colors/Curves..."), NULL,
|
2001-11-21 07:00:47 +08:00
|
|
|
NULL, "tools/curves.html",
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_CURVES,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-05-25 07:57:08 +08:00
|
|
|
gimp_curves_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
2001-05-25 07:57:08 +08:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpCurvesToolClass),
|
2001-08-14 22:53:55 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_curves_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpCurvesTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_curves_tool_init,
|
2001-05-25 07:57:08 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_IMAGE_MAP_TOOL,
|
|
|
|
"GimpCurvesTool",
|
|
|
|
&tool_info, 0);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
|
|
|
gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GObjectClass *object_class;
|
|
|
|
GimpToolClass *tool_class;
|
|
|
|
GimpImageMapToolClass *image_map_tool_class;
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
image_map_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
object_class->finalize = gimp_curves_tool_finalize;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
tool_class->initialize = gimp_curves_tool_initialize;
|
|
|
|
tool_class->button_press = gimp_curves_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_curves_tool_button_release;
|
|
|
|
tool_class->motion = gimp_curves_tool_motion;
|
|
|
|
tool_class->cursor_update = gimp_curves_tool_cursor_update;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
image_map_tool_class->map = gimp_curves_tool_map;
|
|
|
|
image_map_tool_class->dialog = gimp_curves_tool_dialog;
|
|
|
|
image_map_tool_class->reset = gimp_curves_tool_reset;
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_curves_tool_init (GimpCurvesTool *c_tool)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpImageMapTool *image_map_tool;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
image_map_tool = GIMP_IMAGE_MAP_TOOL (c_tool);
|
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
image_map_tool->shell_identifier = "gimp-curves-tool-dialog";
|
|
|
|
image_map_tool->shell_desc = _("Adjust Color Curves");
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
c_tool->curves = g_new0 (Curves, 1);
|
|
|
|
c_tool->lut = gimp_lut_new ();
|
|
|
|
c_tool->channel = GIMP_HISTOGRAM_VALUE;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
curves_init (c_tool->curves);
|
|
|
|
|
2002-12-18 23:57:25 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (c_tool->col_value); i++)
|
2002-10-14 21:39:35 +08:00
|
|
|
c_tool->col_value[i] = -1;
|
2003-03-14 21:42:39 +08:00
|
|
|
|
|
|
|
c_tool->cursor_x = -1;
|
|
|
|
c_tool->cursor_y = -1;
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_curves_tool_finalize (GObject *object)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpCurvesTool *c_tool;
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool = GIMP_CURVES_TOOL (object);
|
|
|
|
|
|
|
|
if (c_tool->curves)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-12-18 23:57:25 +08:00
|
|
|
g_free (c_tool->curves);
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->curves = NULL;
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->lut)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_lut_free (c_tool->lut);
|
|
|
|
c_tool->lut = NULL;
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->cursor_layout)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
g_object_unref (c_tool->cursor_layout);
|
|
|
|
c_tool->cursor_layout = NULL;
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->xpos_layout)
|
|
|
|
{
|
|
|
|
g_object_unref (c_tool->xpos_layout);
|
|
|
|
c_tool->xpos_layout = NULL;
|
|
|
|
}
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_curves_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *gdisp)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpCurvesTool *c_tool;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
|
|
|
c_tool = GIMP_CURVES_TOOL (tool);
|
2002-08-29 03:47:07 +08:00
|
|
|
|
|
|
|
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
g_message (_("Curves for indexed drawables cannot be adjusted."));
|
|
|
|
return;
|
|
|
|
}
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_init (c_tool->curves);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->color = gimp_drawable_is_rgb (drawable);
|
|
|
|
c_tool->channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
|
|
|
|
c_tool->grab_point = -1;
|
|
|
|
c_tool->last = 0;
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
|
|
|
|
|
|
|
|
/* set the sensitivity of the channel menu based on the drawable type */
|
|
|
|
gimp_option_menu_set_sensitive (GTK_OPTION_MENU (c_tool->channel_menu),
|
|
|
|
(GimpOptionMenuSensitivityCallback) curves_set_sensitive_callback,
|
|
|
|
c_tool);
|
|
|
|
|
|
|
|
/* set the current selection */
|
2002-08-29 03:47:07 +08:00
|
|
|
gimp_option_menu_set_history (GTK_OPTION_MENU (c_tool->channel_menu),
|
|
|
|
GINT_TO_POINTER (c_tool->channel));
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_update (c_tool, ALL);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_curves_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpCurvesTool *c_tool;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
|
|
|
c_tool = GIMP_CURVES_TOOL (tool);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
|
|
|
|
|
|
|
tool->gdisp = gdisp;
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
g_assert (drawable == tool->drawable);
|
|
|
|
|
|
|
|
#if 0
|
2001-05-25 07:57:08 +08:00
|
|
|
if (drawable != tool->drawable)
|
|
|
|
{
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_set_preserve (tool->control, TRUE);
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_abort (GIMP_IMAGE_MAP_TOOL (tool)->image_map);
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_set_preserve (tool->control, FALSE);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
|
|
|
tool->drawable = drawable;
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->color = gimp_drawable_is_rgb (drawable);
|
|
|
|
|
|
|
|
GIMP_IMAGE_MAP_TOOL (tool)->drawable = drawable;
|
2002-10-14 21:39:35 +08:00
|
|
|
GIMP_IMAGE_MAP_TOOL (tool)->image_map = gimp_image_map_new (TRUE,
|
|
|
|
drawable);
|
2002-03-18 00:35:05 +08:00
|
|
|
|
|
|
|
gimp_option_menu_set_sensitive
|
2002-08-26 19:35:56 +08:00
|
|
|
(GTK_OPTION_MENU (c_tool->channel_menu),
|
2002-03-18 00:35:05 +08:00
|
|
|
(GimpOptionMenuSensitivityCallback) curves_set_sensitive_callback,
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
#endif
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_activate (tool->control);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
curves_color_update (tool, gdisp, drawable, coords);
|
2003-03-14 21:42:39 +08:00
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_curves_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpCurvesTool *c_tool;
|
|
|
|
GimpDrawable *drawable;
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool = GIMP_CURVES_TOOL (tool);
|
|
|
|
|
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
curves_color_update (tool, gdisp, drawable, coords);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (state & GDK_SHIFT_MASK)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-29 03:47:07 +08:00
|
|
|
curves_add_point (c_tool, coords->x, coords->y, c_tool->channel);
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_calculate_curve (c_tool->curves, c_tool->channel);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
else if (state & GDK_CONTROL_MASK)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-29 03:47:07 +08:00
|
|
|
gint i;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-08-29 03:47:07 +08:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
curves_add_point (c_tool, coords->x, coords->y, i);
|
|
|
|
curves_calculate_curve (c_tool->curves, c_tool->channel);
|
|
|
|
}
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_tool_control_halt (tool->control);
|
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_curves_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpCurvesTool *c_tool;
|
|
|
|
GimpDrawable *drawable;
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool = GIMP_CURVES_TOOL (tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
curves_color_update (tool, gdisp, drawable, coords);
|
2003-03-14 21:42:39 +08:00
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
static void
|
|
|
|
gimp_curves_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
if (gimp_display_coords_in_active_drawable (gdisp, coords))
|
|
|
|
{
|
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_COLOR_PICKER_TOOL_CURSOR);
|
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control,
|
|
|
|
(state & (GDK_SHIFT_MASK |
|
|
|
|
GDK_CONTROL_MASK) ?
|
|
|
|
GIMP_CURSOR_MODIFIER_PLUS :
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_TOOL_CURSOR_NONE);
|
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
|
|
|
}
|
|
|
|
|
1999-04-08 06:02:26 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
curves_color_update (GimpTool *tool,
|
|
|
|
GimpDisplay *gdisp,
|
|
|
|
GimpDrawable *drawable,
|
2002-10-14 21:39:35 +08:00
|
|
|
GimpCoords *coords)
|
1999-04-08 06:02:26 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpCurvesTool *c_tool;
|
|
|
|
guchar *color;
|
2002-10-14 21:39:35 +08:00
|
|
|
gint x;
|
|
|
|
gint y;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
if (! (tool && gimp_tool_control_is_active (tool->control)))
|
1999-04-08 06:02:26 +08:00
|
|
|
return;
|
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
c_tool = GIMP_CURVES_TOOL (tool);
|
1999-04-08 06:02:26 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &x, &y);
|
1999-04-08 06:02:26 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
x = RINT (coords->x) - x;
|
|
|
|
y = RINT (coords->y) - y;
|
1999-04-08 06:02:26 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
color = gimp_image_map_get_color_at (GIMP_IMAGE_MAP_TOOL (tool)->image_map,
|
|
|
|
x, y);
|
|
|
|
if (color)
|
|
|
|
{
|
|
|
|
gint maxval;
|
1999-04-08 06:02:26 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
c_tool->col_value[GIMP_HISTOGRAM_RED] = color[RED_PIX];
|
|
|
|
c_tool->col_value[GIMP_HISTOGRAM_GREEN] = color[GREEN_PIX];
|
|
|
|
c_tool->col_value[GIMP_HISTOGRAM_BLUE] = color[BLUE_PIX];
|
|
|
|
|
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
|
|
|
c_tool->col_value[GIMP_HISTOGRAM_ALPHA] = color[3];
|
|
|
|
|
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
|
|
|
c_tool->col_value[GIMP_HISTOGRAM_ALPHA] = color[4];
|
|
|
|
|
|
|
|
maxval = MAX (color[RED_PIX], color[GREEN_PIX]);
|
|
|
|
c_tool->col_value[GIMP_HISTOGRAM_VALUE] = MAX (maxval, color[BLUE_PIX]);
|
|
|
|
|
|
|
|
g_free (color);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint i;
|
1999-04-08 06:02:26 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
for (i = 0; i <= GIMP_HISTOGRAM_ALPHA; i++)
|
|
|
|
c_tool->col_value[i] = -1;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
1999-05-14 06:53:40 +08:00
|
|
|
}
|
1999-04-08 06:02:26 +08:00
|
|
|
|
1999-05-14 06:53:40 +08:00
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_add_point (GimpCurvesTool *c_tool,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint cchan)
|
1999-05-14 06:53:40 +08:00
|
|
|
{
|
|
|
|
/* Add point onto the curve */
|
2000-12-14 02:53:35 +08:00
|
|
|
gint closest_point = 0;
|
|
|
|
gint distance;
|
|
|
|
gint curvex;
|
|
|
|
gint i;
|
1999-05-14 06:53:40 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
switch (c_tool->curves->curve_type[cchan])
|
1999-05-14 06:53:40 +08:00
|
|
|
{
|
2003-03-15 03:58:59 +08:00
|
|
|
case GIMP_CURVE_SMOOTH:
|
2002-08-26 19:35:56 +08:00
|
|
|
curvex = c_tool->col_value[cchan];
|
1999-09-04 05:58:41 +08:00
|
|
|
distance = G_MAXINT;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1999-09-04 05:58:41 +08:00
|
|
|
for (i = 0; i < 17; i++)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->curves->points[cchan][i][0] != -1)
|
|
|
|
if (abs (curvex - c_tool->curves->points[cchan][i][0]) < distance)
|
1999-09-04 05:58:41 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
distance = abs (curvex - c_tool->curves->points[cchan][i][0]);
|
1999-09-04 05:58:41 +08:00
|
|
|
closest_point = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (distance > MIN_DISTANCE)
|
|
|
|
closest_point = (curvex + 8) / 16;
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->curves->points[cchan][closest_point][0] = curvex;
|
|
|
|
c_tool->curves->points[cchan][closest_point][1] = c_tool->curves->curve[cchan][curvex];
|
1999-09-04 05:58:41 +08:00
|
|
|
break;
|
|
|
|
|
2003-03-15 03:58:59 +08:00
|
|
|
case GIMP_CURVE_FREE:
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->curves->curve[cchan][x] = 255 - y;
|
1999-09-04 05:58:41 +08:00
|
|
|
break;
|
1999-05-14 06:53:40 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
static void
|
|
|
|
gimp_curves_tool_map (GimpImageMapTool *image_map_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpCurvesTool *c_tool;
|
1999-06-23 23:24:46 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool = GIMP_CURVES_TOOL (image_map_tool);
|
1999-06-23 23:24:46 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_lut_setup (c_tool->lut,
|
|
|
|
(GimpLutFunc) curves_lut_func,
|
|
|
|
c_tool->curves,
|
|
|
|
gimp_drawable_bytes (image_map_tool->drawable));
|
2002-10-14 21:39:35 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_apply (image_map_tool->image_map,
|
|
|
|
(GimpImageMapApplyFunc) gimp_lut_process_2,
|
|
|
|
c_tool->lut);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
/*******************/
|
|
|
|
/* Curves dialog */
|
|
|
|
/*******************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
static void
|
|
|
|
gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpCurvesTool *c_tool;
|
|
|
|
GtkWidget *hbox;
|
2002-08-29 03:47:07 +08:00
|
|
|
GtkWidget *vbox;
|
2002-08-26 19:35:56 +08:00
|
|
|
GtkWidget *hbbox;
|
|
|
|
GtkWidget *frame;
|
2003-03-25 02:04:11 +08:00
|
|
|
GtkWidget *menu;
|
2002-08-26 19:35:56 +08:00
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *button;
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool = GIMP_CURVES_TOOL (image_map_tool);
|
1999-04-08 06:02:26 +08:00
|
|
|
|
2002-08-29 03:47:07 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, FALSE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
2002-08-29 03:47:07 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (table);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
/* The option menu for selecting channels */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
2003-03-25 02:04:11 +08:00
|
|
|
menu = gimp_enum_option_menu_new (GIMP_TYPE_HISTOGRAM_CHANNEL,
|
|
|
|
G_CALLBACK (curves_channel_callback),
|
|
|
|
c_tool);
|
|
|
|
gimp_enum_option_menu_set_stock_prefix (GTK_OPTION_MENU (menu),
|
|
|
|
"gimp-channel");
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (menu);
|
|
|
|
|
|
|
|
c_tool->channel_menu = menu;
|
2001-11-24 07:04:49 +08:00
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("R_eset Channel"));
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2002-08-26 19:35:56 +08:00
|
|
|
G_CALLBACK (curves_channel_reset_callback),
|
|
|
|
c_tool);
|
2001-11-24 07:04:49 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
|
|
|
_("Modify Curves for Channel:"), 1.0, 0.5,
|
|
|
|
hbox, 1, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The table for the yrange and the graph */
|
2002-10-14 21:39:35 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
2002-10-14 21:39:35 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The range drawing area */
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), frame, 0, 1, 0, 1,
|
|
|
|
GTK_EXPAND, GTK_EXPAND, 0, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->yrange = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (c_tool->yrange), YRANGE_WIDTH, YRANGE_HEIGHT);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), c_tool->yrange);
|
|
|
|
gtk_widget_show (c_tool->yrange);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* The curves graph */
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), frame, 1, 2, 0, 1,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SHRINK | GTK_FILL,
|
|
|
|
GTK_SHRINK | GTK_FILL, 0, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (frame);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->graph = gtk_drawing_area_new ();
|
|
|
|
gtk_widget_set_size_request (c_tool->graph,
|
|
|
|
GRAPH_WIDTH + RADIUS * 2,
|
2001-12-29 21:26:29 +08:00
|
|
|
GRAPH_HEIGHT + RADIUS * 2);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_set_events (c_tool->graph, GRAPH_MASK);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), c_tool->graph);
|
|
|
|
gtk_widget_show (c_tool->graph);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (c_tool->graph, "event",
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
G_CALLBACK (curves_graph_events),
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The range drawing area */
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), frame, 1, 2, 1, 2,
|
|
|
|
GTK_EXPAND, GTK_EXPAND, 0, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->xrange = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (c_tool->xrange), XRANGE_WIDTH, XRANGE_HEIGHT);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), c_tool->xrange);
|
|
|
|
gtk_widget_show (c_tool->xrange);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (table);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-15 07:24:37 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* Horizontal button box for load / save */
|
2002-08-29 03:47:07 +08:00
|
|
|
frame = gtk_frame_new (_("All Channels"));
|
2003-03-15 07:24:37 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
2002-08-29 03:47:07 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2000-01-20 20:22:54 +08:00
|
|
|
hbbox = gtk_hbutton_box_new ();
|
2002-08-29 03:47:07 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbbox), 2);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (hbbox), 4);
|
2000-01-20 20:22:54 +08:00
|
|
|
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbbox), GTK_BUTTONBOX_SPREAD);
|
2002-08-29 03:47:07 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbbox);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (hbbox);
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-08-29 03:47:07 +08:00
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_OPEN);
|
2000-01-20 20:22:54 +08:00
|
|
|
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
2002-08-29 03:47:07 +08:00
|
|
|
gimp_help_set_help_data (button, _("Read curves settings from file"), NULL);
|
2000-01-20 20:22:54 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
G_CALLBACK (curves_load_callback),
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
|
2002-08-29 03:47:07 +08:00
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
|
2000-01-20 20:22:54 +08:00
|
|
|
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
2002-08-29 03:47:07 +08:00
|
|
|
gimp_help_set_help_data (button, _("Save curves settings to file"), NULL);
|
2000-01-20 20:22:54 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
G_CALLBACK (curves_save_callback),
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool);
|
2003-03-15 07:24:37 +08:00
|
|
|
|
|
|
|
/* The radio box for selecting the curve type */
|
|
|
|
frame = gtk_frame_new (_("Curve Type"));
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
hbox = gimp_enum_stock_box_new (GIMP_TYPE_CURVE_TYPE,
|
2003-03-31 20:09:09 +08:00
|
|
|
"gimp-curve", GTK_ICON_SIZE_MENU,
|
2003-03-15 07:24:37 +08:00
|
|
|
G_CALLBACK (curves_curve_type_callback),
|
|
|
|
c_tool,
|
|
|
|
&c_tool->curve_type);
|
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
|
|
|
|
gtk_box_set_spacing (GTK_BOX (hbox), 4);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_curves_tool_reset (GimpImageMapTool *image_map_tool)
|
2001-10-17 19:33:43 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
GimpCurvesTool *c_tool;
|
|
|
|
GimpHistogramChannel channel;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
c_tool = GIMP_CURVES_TOOL (image_map_tool);
|
|
|
|
|
|
|
|
c_tool->grab_point = -1;
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
for (channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
channel <= GIMP_HISTOGRAM_ALPHA;
|
|
|
|
channel++)
|
|
|
|
curves_channel_reset (c_tool->curves, channel);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
curves_update (c_tool, XRANGE_TOP);
|
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
2001-10-17 19:33:43 +08:00
|
|
|
}
|
|
|
|
|
1999-09-04 05:58:41 +08:00
|
|
|
|
1999-05-20 23:43:56 +08:00
|
|
|
/* TODO: preview alpha channel stuff correctly. -- austin, 20/May/99 */
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_update (GimpCurvesTool *c_tool,
|
|
|
|
gint update)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-29 03:47:07 +08:00
|
|
|
GimpHistogramChannel sel_channel;
|
|
|
|
gint i, j;
|
2000-12-01 07:23:59 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->color)
|
2002-05-03 19:31:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
sel_channel = c_tool->channel;
|
2002-08-29 03:47:07 +08:00
|
|
|
}
|
2002-05-03 19:31:08 +08:00
|
|
|
else
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->channel == 2)
|
2002-05-03 19:31:08 +08:00
|
|
|
sel_channel = GIMP_HISTOGRAM_ALPHA;
|
|
|
|
else
|
|
|
|
sel_channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
}
|
2000-12-01 07:23:59 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & XRANGE_TOP)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
guchar buf[XRANGE_WIDTH * 3];
|
1999-05-20 23:43:56 +08:00
|
|
|
|
2000-12-01 07:23:59 +08:00
|
|
|
switch (sel_channel)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
2000-12-19 22:43:54 +08:00
|
|
|
case GIMP_HISTOGRAM_VALUE:
|
|
|
|
case GIMP_HISTOGRAM_ALPHA:
|
1999-05-20 23:43:56 +08:00
|
|
|
for (i = 0; i < XRANGE_HEIGHT / 2; i++)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
1999-05-20 23:43:56 +08:00
|
|
|
for (j = 0; j < XRANGE_WIDTH ; j++)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
buf[j * 3 + 0] = c_tool->curves->curve[sel_channel][j];
|
|
|
|
buf[j * 3 + 1] = c_tool->curves->curve[sel_channel][j];
|
|
|
|
buf[j * 3 + 2] = c_tool->curves->curve[sel_channel][j];
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (c_tool->xrange),
|
1999-05-20 23:43:56 +08:00
|
|
|
buf, 0, i, XRANGE_WIDTH);
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1999-05-20 23:43:56 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-19 22:43:54 +08:00
|
|
|
case GIMP_HISTOGRAM_RED:
|
|
|
|
case GIMP_HISTOGRAM_GREEN:
|
|
|
|
case GIMP_HISTOGRAM_BLUE:
|
1999-05-20 23:43:56 +08:00
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
for (i = 0; i < XRANGE_HEIGHT / 2; i++)
|
1999-05-20 23:43:56 +08:00
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
for (j = 0; j < XRANGE_WIDTH; j++)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
buf[j * 3 + 0] = c_tool->curves->curve[GIMP_HISTOGRAM_RED][j];
|
|
|
|
buf[j * 3 + 1] = c_tool->curves->curve[GIMP_HISTOGRAM_GREEN][j];
|
|
|
|
buf[j * 3 + 2] = c_tool->curves->curve[GIMP_HISTOGRAM_BLUE][j];
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (c_tool->xrange),
|
1999-11-22 19:14:29 +08:00
|
|
|
buf, 0, i, XRANGE_WIDTH);
|
1999-05-20 23:43:56 +08:00
|
|
|
}
|
1999-11-22 19:14:29 +08:00
|
|
|
break;
|
1999-05-20 23:43:56 +08:00
|
|
|
}
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
default:
|
1999-05-20 23:43:56 +08:00
|
|
|
g_warning ("unknown channel type %d, can't happen!?!?",
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->channel);
|
1999-05-20 23:43:56 +08:00
|
|
|
break;
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
gtk_widget_queue_draw_area (c_tool->xrange,
|
|
|
|
0, 0,
|
|
|
|
XRANGE_WIDTH, XRANGE_HEIGHT / 2);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & XRANGE_BOTTOM)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
guchar buf[XRANGE_WIDTH * 3];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 0; i < XRANGE_WIDTH; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
{
|
|
|
|
buf[i * 3 + 0] = i;
|
|
|
|
buf[i * 3 + 1] = i;
|
|
|
|
buf[i * 3 + 2] = i;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = XRANGE_HEIGHT / 2; i < XRANGE_HEIGHT; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (c_tool->xrange),
|
|
|
|
buf, 0, i, XRANGE_WIDTH);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
gtk_widget_queue_draw_area (c_tool->xrange,
|
|
|
|
0, XRANGE_HEIGHT / 2,
|
|
|
|
XRANGE_WIDTH, XRANGE_HEIGHT / 2);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & YRANGE)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
guchar buf[YRANGE_WIDTH * 3];
|
|
|
|
guchar pix[3];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 0; i < YRANGE_HEIGHT; i++)
|
|
|
|
{
|
2000-12-01 07:23:59 +08:00
|
|
|
switch (sel_channel)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
2000-12-19 22:43:54 +08:00
|
|
|
case GIMP_HISTOGRAM_VALUE:
|
|
|
|
case GIMP_HISTOGRAM_ALPHA:
|
1999-05-20 23:43:56 +08:00
|
|
|
pix[0] = pix[1] = pix[2] = (255 - i);
|
|
|
|
break;
|
|
|
|
|
2000-12-19 22:43:54 +08:00
|
|
|
case GIMP_HISTOGRAM_RED:
|
|
|
|
case GIMP_HISTOGRAM_GREEN:
|
|
|
|
case GIMP_HISTOGRAM_BLUE:
|
1999-05-20 23:43:56 +08:00
|
|
|
pix[0] = pix[1] = pix[2] = 0;
|
2000-12-01 07:23:59 +08:00
|
|
|
pix[sel_channel - 1] = (255 - i);
|
1999-05-20 23:43:56 +08:00
|
|
|
break;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
default:
|
1999-05-20 23:43:56 +08:00
|
|
|
g_warning ("unknown channel type %d, can't happen!?!?",
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->channel);
|
1999-05-20 23:43:56 +08:00
|
|
|
break;
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1999-05-20 23:43:56 +08:00
|
|
|
|
|
|
|
for (j = 0; j < YRANGE_WIDTH * 3; j++)
|
1999-11-22 19:14:29 +08:00
|
|
|
buf[j] = pix[j%3];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (c_tool->yrange),
|
1999-11-22 19:14:29 +08:00
|
|
|
buf, 0, i, YRANGE_WIDTH);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
gtk_widget_queue_draw (c_tool->yrange);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
curves_channel_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *c_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_menu_item_update (widget, &c_tool->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (! c_tool->color)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->channel > 1)
|
|
|
|
c_tool->channel = 2;
|
|
|
|
else
|
|
|
|
c_tool->channel = 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-03-15 07:24:37 +08:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (c_tool->curve_type),
|
|
|
|
GINT_TO_POINTER (c_tool->curves->curve_type[c_tool->channel]));
|
1999-02-16 16:53:54 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
curves_update (c_tool, XRANGE_TOP | YRANGE);
|
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
curves_channel_reset_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *c_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->grab_point = -1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_channel_reset (c_tool->curves, c_tool->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
curves_update (c_tool, XRANGE_TOP);
|
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (c_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-03-18 00:35:05 +08:00
|
|
|
static gboolean
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_set_sensitive_callback (gpointer item_data,
|
|
|
|
GimpCurvesTool *c_tool)
|
2002-03-18 00:35:05 +08:00
|
|
|
{
|
|
|
|
GimpHistogramChannel channel = GPOINTER_TO_INT (item_data);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-03-18 00:35:05 +08:00
|
|
|
switch (channel)
|
|
|
|
{
|
|
|
|
case GIMP_HISTOGRAM_VALUE:
|
|
|
|
return TRUE;
|
|
|
|
case GIMP_HISTOGRAM_RED:
|
|
|
|
case GIMP_HISTOGRAM_GREEN:
|
|
|
|
case GIMP_HISTOGRAM_BLUE:
|
2002-08-26 19:35:56 +08:00
|
|
|
return c_tool->color;
|
2002-03-18 00:35:05 +08:00
|
|
|
case GIMP_HISTOGRAM_ALPHA:
|
2002-08-26 19:35:56 +08:00
|
|
|
return gimp_drawable_has_alpha (GIMP_IMAGE_MAP_TOOL (c_tool)->drawable);
|
2002-03-18 00:35:05 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-03-18 00:35:05 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2003-03-15 07:24:37 +08:00
|
|
|
curves_curve_type_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *c_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-03-15 03:58:59 +08:00
|
|
|
GimpCurveType curve_type;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-15 07:24:37 +08:00
|
|
|
gimp_radio_button_update (widget, &curve_type);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-15 03:58:59 +08:00
|
|
|
if (c_tool->curves->curve_type[c_tool->channel] != curve_type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-03-15 03:58:59 +08:00
|
|
|
c_tool->curves->curve_type[c_tool->channel] = curve_type;
|
|
|
|
|
|
|
|
if (curve_type == GIMP_CURVE_SMOOTH)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gint32 index;
|
|
|
|
|
|
|
|
/* pick representative points from the curve
|
|
|
|
* and make them control points
|
|
|
|
*/
|
|
|
|
for (i = 0; i <= 8; i++)
|
|
|
|
{
|
|
|
|
index = CLAMP0255 (i * 32);
|
|
|
|
c_tool->curves->points[c_tool->channel][i * 2][0] = index;
|
|
|
|
c_tool->curves->points[c_tool->channel][i * 2][1] = c_tool->curves->curve[c_tool->channel][index];
|
|
|
|
}
|
|
|
|
}
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_calculate_curve (c_tool->curves, c_tool->channel);
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2003-03-15 03:58:59 +08:00
|
|
|
curves_update (c_tool, XRANGE_TOP);
|
2003-03-14 21:42:39 +08:00
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (c_tool));
|
2000-05-09 13:43:29 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
static gboolean
|
|
|
|
curves_graph_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpCurvesTool *c_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
static GdkCursorType cursor_type = GDK_TOP_LEFT_ARROW;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
GdkCursorType new_cursor = GDK_X_CURSOR;
|
1997-11-25 06:05:25 +08:00
|
|
|
GdkEventButton *bevent;
|
|
|
|
GdkEventMotion *mevent;
|
2002-08-26 19:35:56 +08:00
|
|
|
gint i;
|
|
|
|
gint tx, ty;
|
|
|
|
gint x, y;
|
|
|
|
gint closest_point;
|
|
|
|
gint distance;
|
|
|
|
gint x1, x2, y1, y2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
if (event->type == GDK_EXPOSE)
|
|
|
|
{
|
|
|
|
curves_graph_expose (widget, &((GdkEventExpose *) event)->area, c_tool);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* get the pointer position */
|
2002-08-26 19:35:56 +08:00
|
|
|
gdk_window_get_pointer (c_tool->graph->window, &tx, &ty, NULL);
|
2000-01-26 07:06:12 +08:00
|
|
|
x = CLAMP ((tx - RADIUS), 0, 255);
|
|
|
|
y = CLAMP ((ty - RADIUS), 0, 255);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
distance = G_MAXINT;
|
2003-03-14 21:42:39 +08:00
|
|
|
for (i = 0, closest_point = 0; i < 17; i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->curves->points[c_tool->channel][i][0] != -1)
|
|
|
|
if (abs (x - c_tool->curves->points[c_tool->channel][i][0]) < distance)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
distance = abs (x - c_tool->curves->points[c_tool->channel][i][0]);
|
1997-11-25 06:05:25 +08:00
|
|
|
closest_point = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (distance > MIN_DISTANCE)
|
|
|
|
closest_point = (x + 8) / 16;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
2003-03-14 21:42:39 +08:00
|
|
|
|
|
|
|
new_cursor = GDK_TCROSS;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
switch (c_tool->curves->curve_type[c_tool->channel])
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-03-15 03:58:59 +08:00
|
|
|
case GIMP_CURVE_SMOOTH:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* determine the leftmost and rightmost points */
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->leftmost = -1;
|
1997-11-25 06:05:25 +08:00
|
|
|
for (i = closest_point - 1; i >= 0; i--)
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->curves->points[c_tool->channel][i][0] != -1)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->leftmost = c_tool->curves->points[c_tool->channel][i][0];
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->rightmost = 256;
|
1997-11-25 06:05:25 +08:00
|
|
|
for (i = closest_point + 1; i < 17; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->curves->points[c_tool->channel][i][0] != -1)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->rightmost = c_tool->curves->points[c_tool->channel][i][0];
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->grab_point = closest_point;
|
|
|
|
c_tool->curves->points[c_tool->channel][c_tool->grab_point][0] = x;
|
|
|
|
c_tool->curves->points[c_tool->channel][c_tool->grab_point][1] = 255 - y;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2003-03-15 03:58:59 +08:00
|
|
|
case GIMP_CURVE_FREE:
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->curves->curve[c_tool->channel][x] = 255 - y;
|
|
|
|
c_tool->grab_point = x;
|
|
|
|
c_tool->last = y;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
1999-04-08 06:58:44 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
gtk_grab_add (widget);
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_calculate_curve (c_tool->curves, c_tool->channel);
|
1999-04-08 06:02:26 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
curves_update (c_tool, XRANGE_TOP);
|
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2003-03-14 21:42:39 +08:00
|
|
|
new_cursor = GDK_FLEUR;
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->grab_point = -1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (c_tool));
|
1999-04-08 06:02:26 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_grab_remove (widget);
|
2003-03-14 21:42:39 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
mevent = (GdkEventMotion *) event;
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
switch (c_tool->curves->curve_type[c_tool->channel])
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-03-15 03:58:59 +08:00
|
|
|
case GIMP_CURVE_SMOOTH:
|
1997-11-25 06:05:25 +08:00
|
|
|
/* If no point is grabbed... */
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->grab_point == -1)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->curves->points[c_tool->channel][closest_point][0] != -1)
|
2003-03-14 21:42:39 +08:00
|
|
|
new_cursor = GDK_FLEUR;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2003-03-14 21:42:39 +08:00
|
|
|
new_cursor = GDK_TCROSS;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
/* Else, drag the grabbed point */
|
|
|
|
else
|
|
|
|
{
|
2003-03-14 21:42:39 +08:00
|
|
|
new_cursor = GDK_TCROSS;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->curves->points[c_tool->channel][c_tool->grab_point][0] = -1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (x > c_tool->leftmost && x < c_tool->rightmost)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
closest_point = (x + 8) / 16;
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->curves->points[c_tool->channel][closest_point][0] == -1)
|
|
|
|
c_tool->grab_point = closest_point;
|
|
|
|
|
|
|
|
c_tool->curves->points[c_tool->channel][c_tool->grab_point][0] = x;
|
|
|
|
c_tool->curves->points[c_tool->channel][c_tool->grab_point][1] = 255 - y;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_calculate_curve (c_tool->curves, c_tool->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-03-15 03:58:59 +08:00
|
|
|
case GIMP_CURVE_FREE:
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->grab_point != -1)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (c_tool->grab_point > x)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
x1 = x;
|
2002-08-26 19:35:56 +08:00
|
|
|
x2 = c_tool->grab_point;
|
1997-11-25 06:05:25 +08:00
|
|
|
y1 = y;
|
2002-08-26 19:35:56 +08:00
|
|
|
y2 = c_tool->last;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
x1 = c_tool->grab_point;
|
1997-11-25 06:05:25 +08:00
|
|
|
x2 = x;
|
2002-08-26 19:35:56 +08:00
|
|
|
y1 = c_tool->last;
|
1997-11-25 06:05:25 +08:00
|
|
|
y2 = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x2 != x1)
|
|
|
|
for (i = x1; i <= x2; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->curves->curve[c_tool->channel][i] = 255 - (y1 + ((y2 - y1) * (i - x1)) / (x2 - x1));
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->curves->curve[c_tool->channel][x] = 255 - y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->grab_point = x;
|
|
|
|
c_tool->last = y;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mevent->state & GDK_BUTTON1_MASK)
|
2003-03-14 21:42:39 +08:00
|
|
|
new_cursor = GDK_TCROSS;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2003-03-14 21:42:39 +08:00
|
|
|
new_cursor = GDK_PENCIL;
|
2003-03-15 03:58:59 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
if (new_cursor != cursor_type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-05-25 07:57:08 +08:00
|
|
|
GdkCursor *cursor;
|
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
cursor_type = new_cursor;
|
2001-05-25 07:57:08 +08:00
|
|
|
|
|
|
|
cursor = gimp_cursor_new (cursor_type,
|
|
|
|
GIMP_TOOL_CURSOR_NONE,
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
2002-08-26 19:35:56 +08:00
|
|
|
gdk_window_set_cursor (c_tool->graph->window, cursor);
|
2001-08-01 08:35:59 +08:00
|
|
|
gdk_cursor_unref (cursor);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-09-04 05:58:41 +08:00
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
curves_update (c_tool, XRANGE_TOP);
|
|
|
|
|
|
|
|
c_tool->cursor_x = tx - RADIUS;
|
|
|
|
c_tool->cursor_y = ty - RADIUS;
|
|
|
|
|
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
case GDK_LEAVE_NOTIFY:
|
2003-03-14 21:42:39 +08:00
|
|
|
c_tool->cursor_x = -1;
|
|
|
|
c_tool->cursor_y = -1;
|
|
|
|
|
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
|
|
|
return TRUE;
|
2002-10-14 21:39:35 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-03-14 21:42:39 +08:00
|
|
|
static void
|
|
|
|
curve_print_loc (GimpCurvesTool *c_tool)
|
|
|
|
{
|
|
|
|
gchar buf[32];
|
|
|
|
gint x, y;
|
|
|
|
gint w, h;
|
|
|
|
|
|
|
|
if (c_tool->cursor_x < 0 || c_tool->cursor_x > 255)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (c_tool->cursor_y < 0 || c_tool->cursor_y > 255)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! c_tool->cursor_layout)
|
|
|
|
{
|
|
|
|
c_tool->cursor_layout = gtk_widget_create_pango_layout (c_tool->graph,
|
|
|
|
"x:888 y:888");
|
|
|
|
pango_layout_get_pixel_extents (c_tool->cursor_layout,
|
|
|
|
NULL, &c_tool->cursor_rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
x = RADIUS * 2 + 2;
|
|
|
|
y = RADIUS * 2 + 2;
|
|
|
|
w = c_tool->cursor_rect.width + 4;
|
|
|
|
h = c_tool->cursor_rect.height + 4;
|
|
|
|
|
|
|
|
gdk_draw_rectangle (c_tool->graph->window,
|
|
|
|
c_tool->graph->style->bg_gc[GTK_STATE_ACTIVE],
|
|
|
|
TRUE,
|
|
|
|
x, y, w + 1, h + 1);
|
|
|
|
gdk_draw_rectangle (c_tool->graph->window,
|
|
|
|
c_tool->graph->style->black_gc,
|
|
|
|
FALSE,
|
|
|
|
x, y, w, h);
|
|
|
|
|
|
|
|
g_snprintf (buf, sizeof (buf), "x:%3d y:%3d",
|
|
|
|
c_tool->cursor_x, 255 - c_tool->cursor_y);
|
|
|
|
pango_layout_set_text (c_tool->cursor_layout, buf, 11);
|
|
|
|
|
|
|
|
gdk_draw_layout (c_tool->graph->window,
|
|
|
|
c_tool->graph->style->black_gc,
|
|
|
|
x + 2, y + 2,
|
|
|
|
c_tool->cursor_layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
curves_graph_expose (GtkWidget *widget,
|
|
|
|
GdkRectangle *area,
|
|
|
|
GimpCurvesTool *c_tool)
|
|
|
|
{
|
|
|
|
GimpHistogramChannel sel_channel;
|
|
|
|
|
|
|
|
gchar buf[32];
|
|
|
|
gint offset;
|
|
|
|
gint height;
|
|
|
|
gint i;
|
|
|
|
GdkPoint points[256];
|
|
|
|
|
|
|
|
if (c_tool->color)
|
|
|
|
{
|
|
|
|
sel_channel = c_tool->channel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (c_tool->channel == 2)
|
|
|
|
sel_channel = GIMP_HISTOGRAM_ALPHA;
|
|
|
|
else
|
|
|
|
sel_channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the grid lines */
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
gdk_draw_line (widget->window,
|
|
|
|
c_tool->graph->style->dark_gc[GTK_STATE_NORMAL],
|
|
|
|
RADIUS, i * (GRAPH_HEIGHT / 4) + RADIUS,
|
|
|
|
GRAPH_WIDTH + RADIUS, i * (GRAPH_HEIGHT / 4) + RADIUS);
|
|
|
|
gdk_draw_line (widget->window,
|
|
|
|
c_tool->graph->style->dark_gc[GTK_STATE_NORMAL],
|
|
|
|
i * (GRAPH_WIDTH / 4) + RADIUS, RADIUS,
|
|
|
|
i * (GRAPH_WIDTH / 4) + RADIUS, GRAPH_HEIGHT + RADIUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the curve */
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
points[i].x = i + RADIUS;
|
|
|
|
points[i].y = 255 - c_tool->curves->curve[c_tool->channel][i] + RADIUS;
|
|
|
|
}
|
|
|
|
|
2003-03-15 03:58:59 +08:00
|
|
|
if (c_tool->curves->curve_type[c_tool->channel] == GIMP_CURVE_FREE)
|
2003-03-14 21:42:39 +08:00
|
|
|
{
|
|
|
|
gdk_draw_points (widget->window,
|
|
|
|
c_tool->graph->style->black_gc,
|
|
|
|
points, 256);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdk_draw_lines (widget->window,
|
|
|
|
c_tool->graph->style->black_gc,
|
|
|
|
points, 256);
|
|
|
|
|
|
|
|
/* Draw the points */
|
|
|
|
for (i = 0; i < 17; i++)
|
|
|
|
{
|
|
|
|
if (c_tool->curves->points[c_tool->channel][i][0] != -1)
|
|
|
|
gdk_draw_arc (widget->window,
|
|
|
|
c_tool->graph->style->black_gc,
|
|
|
|
TRUE,
|
|
|
|
c_tool->curves->points[c_tool->channel][i][0],
|
|
|
|
255 - c_tool->curves->points[c_tool->channel][i][1],
|
|
|
|
RADIUS * 2, RADIUS * 2, 0, 23040);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c_tool->col_value[sel_channel] >= 0)
|
|
|
|
{
|
|
|
|
/* draw the color line */
|
|
|
|
gdk_draw_line (widget->window,
|
|
|
|
c_tool->graph->style->black_gc,
|
|
|
|
c_tool->col_value[sel_channel] + RADIUS,
|
|
|
|
RADIUS,
|
|
|
|
c_tool->col_value[sel_channel] + RADIUS,
|
|
|
|
GRAPH_HEIGHT + RADIUS);
|
|
|
|
|
|
|
|
/* and xpos indicator */
|
|
|
|
g_snprintf (buf, sizeof (buf), "x:%d",
|
|
|
|
c_tool->col_value[sel_channel]);
|
|
|
|
|
|
|
|
if (! c_tool->xpos_layout)
|
|
|
|
c_tool->xpos_layout = gtk_widget_create_pango_layout (c_tool->graph,
|
|
|
|
buf);
|
|
|
|
else
|
|
|
|
pango_layout_set_text (c_tool->xpos_layout, buf, -1);
|
|
|
|
|
|
|
|
pango_layout_get_pixel_size (c_tool->xpos_layout, &offset, &height);
|
|
|
|
|
|
|
|
if ((c_tool->col_value[sel_channel] + RADIUS) < 127)
|
|
|
|
offset = RADIUS + 4;
|
|
|
|
else
|
|
|
|
offset = - (offset + 2);
|
|
|
|
|
|
|
|
gdk_draw_layout (widget->window,
|
|
|
|
c_tool->graph->style->black_gc,
|
|
|
|
c_tool->col_value[sel_channel] + offset,
|
|
|
|
GRAPH_HEIGHT - height - 2,
|
|
|
|
c_tool->xpos_layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
curve_print_loc (c_tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
curves_load_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *c_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (! c_tool->file_dialog)
|
|
|
|
file_dialog_create (c_tool);
|
|
|
|
else if (GTK_WIDGET_VISIBLE (c_tool->file_dialog))
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->is_save = FALSE;
|
|
|
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (c_tool->file_dialog), _("Load Curves"));
|
|
|
|
gtk_widget_show (c_tool->file_dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
curves_save_callback (GtkWidget *widget,
|
|
|
|
GimpCurvesTool *c_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (! c_tool->file_dialog)
|
|
|
|
file_dialog_create (c_tool);
|
|
|
|
else if (GTK_WIDGET_VISIBLE (c_tool->file_dialog))
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->is_save = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_window_set_title (GTK_WINDOW (c_tool->file_dialog), _("Save Curves"));
|
|
|
|
gtk_widget_show (c_tool->file_dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-01-20 20:22:54 +08:00
|
|
|
|
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
file_dialog_create (GimpCurvesTool *c_tool)
|
2000-01-20 20:22:54 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GtkFileSelection *file_dlg;
|
|
|
|
gchar *temp;
|
|
|
|
|
|
|
|
c_tool->file_dialog = gtk_file_selection_new ("");
|
|
|
|
|
|
|
|
file_dlg = GTK_FILE_SELECTION (c_tool->file_dialog);
|
2000-01-20 20:22:54 +08:00
|
|
|
|
|
|
|
gtk_window_set_wmclass (GTK_WINDOW (file_dlg), "load_save_curves", "Gimp");
|
|
|
|
gtk_window_set_position (GTK_WINDOW (file_dlg), GTK_WIN_POS_MOUSE);
|
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (file_dlg), 2);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (file_dlg->button_area), 2);
|
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (file_dlg),
|
|
|
|
(gpointer) &c_tool->file_dialog);
|
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (file_dlg),
|
|
|
|
GTK_WINDOW (GIMP_IMAGE_MAP_TOOL (c_tool)->shell));
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (file_dlg), TRUE);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_swapped (file_dlg->ok_button, "clicked",
|
2002-08-26 19:35:56 +08:00
|
|
|
G_CALLBACK (file_dialog_ok_callback),
|
|
|
|
c_tool);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_swapped (file_dlg->cancel_button, "clicked",
|
2002-10-14 21:39:35 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
file_dlg);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
temp = g_build_filename (gimp_directory (), "curves", ".", NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_file_selection_set_filename (file_dlg, temp);
|
2000-01-20 20:22:54 +08:00
|
|
|
g_free (temp);
|
2000-02-14 06:26:41 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_help_connect (c_tool->file_dialog, tool_manager_help_func, NULL);
|
2000-01-20 20:22:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
file_dialog_ok_callback (GimpCurvesTool *c_tool)
|
2000-01-20 20:22:54 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
FILE *file = NULL;
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
const gchar *filename;
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
filename =
|
|
|
|
gtk_file_selection_get_filename (GTK_FILE_SELECTION (c_tool->file_dialog));
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
file = fopen (filename, c_tool->is_save ? "wt" : "rt");
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
if (! file)
|
2000-01-20 20:22:54 +08:00
|
|
|
{
|
2002-10-15 21:36:28 +08:00
|
|
|
g_message (_("Failed to open file: '%s': %s"),
|
|
|
|
filename, g_strerror (errno));
|
|
|
|
return;
|
|
|
|
}
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
if (c_tool->is_save)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_write_to_file (c_tool, file);
|
2000-01-20 20:22:54 +08:00
|
|
|
}
|
2002-10-15 21:36:28 +08:00
|
|
|
else if (! curves_read_from_file (c_tool, file))
|
|
|
|
{
|
|
|
|
g_message (("Error in reading file '%s'."), filename);
|
|
|
|
}
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (file)
|
|
|
|
fclose (file);
|
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
gtk_widget_destroy (c_tool->file_dialog);
|
2000-01-20 20:22:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_read_from_file (GimpCurvesTool *c_tool,
|
|
|
|
FILE *file)
|
2000-01-20 20:22:54 +08:00
|
|
|
{
|
2000-12-14 02:53:35 +08:00
|
|
|
gint i, j;
|
|
|
|
gint fields;
|
2000-01-20 20:22:54 +08:00
|
|
|
gchar buf[50];
|
2000-12-14 02:53:35 +08:00
|
|
|
gint index[5][17];
|
|
|
|
gint value[5][17];
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (! fgets (buf, 50, file))
|
2000-01-20 20:22:54 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (strcmp (buf, "# GIMP Curves File\n") != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 17; j++)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
fields = fscanf (file, "%d %d ", &index[i][j], &value[i][j]);
|
2000-01-20 20:22:54 +08:00
|
|
|
if (fields != 2)
|
|
|
|
{
|
|
|
|
g_print ("fields != 2");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
2003-03-15 03:58:59 +08:00
|
|
|
c_tool->curves->curve_type[i] = GIMP_CURVE_SMOOTH;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2000-01-20 20:22:54 +08:00
|
|
|
for (j = 0; j < 17; j++)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->curves->points[i][j][0] = index[i][j];
|
|
|
|
c_tool->curves->points[i][j][1] = value[i][j];
|
2000-01-20 20:22:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_calculate_curve (c_tool->curves, i);
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_update (c_tool, ALL);
|
2003-03-14 21:42:39 +08:00
|
|
|
gtk_widget_queue_draw (c_tool->graph);
|
2002-08-29 03:47:07 +08:00
|
|
|
|
2003-03-15 07:24:37 +08:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (c_tool->curve_type),
|
|
|
|
GINT_TO_POINTER (GIMP_CURVE_SMOOTH));
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (c_tool));
|
2000-01-20 20:22:54 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
curves_write_to_file (GimpCurvesTool *c_tool,
|
|
|
|
FILE *file)
|
2000-01-20 20:22:54 +08:00
|
|
|
{
|
2000-12-14 02:53:35 +08:00
|
|
|
gint i, j;
|
2000-01-20 20:22:54 +08:00
|
|
|
gint32 index;
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
2003-03-15 03:58:59 +08:00
|
|
|
if (c_tool->curves->curve_type[i] == GIMP_CURVE_FREE)
|
2000-01-20 20:22:54 +08:00
|
|
|
{
|
2002-10-14 21:39:35 +08:00
|
|
|
/* pick representative points from the curve
|
|
|
|
and make them control points */
|
2000-01-20 20:22:54 +08:00
|
|
|
for (j = 0; j <= 8; j++)
|
|
|
|
{
|
|
|
|
index = CLAMP0255 (j * 32);
|
2002-08-26 19:35:56 +08:00
|
|
|
c_tool->curves->points[i][j * 2][0] = index;
|
|
|
|
c_tool->curves->points[i][j * 2][1] = c_tool->curves->curve[i][index];
|
2000-01-20 20:22:54 +08:00
|
|
|
}
|
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
fprintf (file, "# GIMP Curves File\n");
|
2000-01-20 20:22:54 +08:00
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 17; j++)
|
2002-08-26 19:35:56 +08:00
|
|
|
fprintf (file, "%d %d ",
|
|
|
|
c_tool->curves->points[i][j][0],
|
|
|
|
c_tool->curves->points[i][j][1]);
|
2000-01-20 20:22:54 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
fprintf (file, "\n");
|
2000-01-20 20:22:54 +08:00
|
|
|
}
|
|
|
|
}
|