2003-10-30 04:57:21 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2002-10-29 04:13:17 +08:00
|
|
|
* gimpcolorselect.c
|
|
|
|
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2002-10-29 04:13:17 +08:00
|
|
|
* based on color_notebook module
|
|
|
|
* Copyright (C) 1998 Austin Donnelly <austin@greenend.org.uk>
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2002-10-29 04:13:17 +08:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
2003-10-30 04:57:21 +08:00
|
|
|
*
|
|
|
|
* This library 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
|
2002-10-29 04:13:17 +08:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software 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
|
|
|
|
1999-06-07 03:44:36 +08:00
|
|
|
#include "config.h"
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-05-25 15:50:44 +08:00
|
|
|
|
2005-05-23 04:57:23 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2003-06-14 00:44:21 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-09 03:29:15 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
#include "gimpwidgetstypes.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
#include "gimpcolorselector.h"
|
|
|
|
#include "gimpcolorselect.h"
|
2002-11-05 08:02:56 +08:00
|
|
|
#include "gimphelpui.h"
|
2004-09-10 21:04:45 +08:00
|
|
|
#include "gimppreviewarea.h"
|
2002-11-05 08:02:56 +08:00
|
|
|
#include "gimpstock.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2002-10-29 20:09:46 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2003-06-11 21:59:42 +08:00
|
|
|
#define COLOR_AREA_EVENT_MASK (GDK_EXPOSURE_MASK | \
|
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
2004-09-10 21:16:55 +08:00
|
|
|
GDK_BUTTON_MOTION_MASK | \
|
2003-06-11 21:59:42 +08:00
|
|
|
GDK_ENTER_NOTIFY_MASK)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-03 21:50:19 +08:00
|
|
|
|
1999-08-24 07:05:46 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
1999-10-28 23:05:49 +08:00
|
|
|
COLOR_SELECT_HUE = 0,
|
|
|
|
COLOR_SELECT_SATURATION,
|
|
|
|
COLOR_SELECT_VALUE,
|
|
|
|
COLOR_SELECT_RED,
|
|
|
|
COLOR_SELECT_GREEN,
|
|
|
|
COLOR_SELECT_BLUE,
|
2001-01-08 05:07:14 +08:00
|
|
|
COLOR_SELECT_ALPHA,
|
1999-10-28 23:05:49 +08:00
|
|
|
COLOR_SELECT_HUE_SATURATION,
|
|
|
|
COLOR_SELECT_HUE_VALUE,
|
|
|
|
COLOR_SELECT_SATURATION_VALUE,
|
|
|
|
COLOR_SELECT_RED_GREEN,
|
|
|
|
COLOR_SELECT_RED_BLUE,
|
|
|
|
COLOR_SELECT_GREEN_BLUE
|
1997-11-25 06:05:25 +08:00
|
|
|
} ColorSelectFillType;
|
|
|
|
|
1999-08-24 07:05:46 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
UPDATE_VALUES = 1 << 0,
|
|
|
|
UPDATE_POS = 1 << 1,
|
|
|
|
UPDATE_XY_COLOR = 1 << 2,
|
|
|
|
UPDATE_Z_COLOR = 1 << 3,
|
|
|
|
UPDATE_CALLER = 1 << 6
|
1997-11-25 06:05:25 +08:00
|
|
|
} ColorSelectUpdateType;
|
|
|
|
|
1999-10-03 21:50:19 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
#define GIMP_COLOR_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_SELECT, GimpColorSelectClass))
|
|
|
|
#define GIMP_IS_COLOR_SELECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_SELECT))
|
|
|
|
#define GIMP_COLOR_SELECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_SELECT, GimpColorSelectClass))
|
|
|
|
|
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
typedef struct _GimpColorSelectClass GimpColorSelectClass;
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
struct _GimpColorSelect
|
1999-10-03 21:50:19 +08:00
|
|
|
{
|
2002-10-30 22:52:58 +08:00
|
|
|
GimpColorSelector parent_instance;
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
GtkWidget *toggle_box;
|
|
|
|
|
2002-10-30 22:52:58 +08:00
|
|
|
GtkWidget *xy_color;
|
|
|
|
GtkWidget *z_color;
|
2001-01-15 20:20:38 +08:00
|
|
|
|
2002-10-30 22:52:58 +08:00
|
|
|
gint pos[3];
|
2001-01-15 20:20:38 +08:00
|
|
|
|
2002-10-30 22:52:58 +08:00
|
|
|
ColorSelectFillType z_color_fill;
|
|
|
|
ColorSelectFillType xy_color_fill;
|
|
|
|
GdkGC *gc;
|
2002-10-20 18:14:17 +08:00
|
|
|
};
|
1999-10-03 21:50:19 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
struct _GimpColorSelectClass
|
|
|
|
{
|
|
|
|
GimpColorSelectorClass parent_class;
|
1999-10-03 21:50:19 +08:00
|
|
|
};
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
typedef struct _ColorSelectFill ColorSelectFill;
|
1999-08-24 07:05:46 +08:00
|
|
|
|
2001-01-08 10:24:29 +08:00
|
|
|
typedef void (* ColorSelectFillUpdateProc) (ColorSelectFill *color_select_fill);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-08-24 07:05:46 +08:00
|
|
|
struct _ColorSelectFill
|
|
|
|
{
|
2001-01-15 20:20:38 +08:00
|
|
|
guchar *buffer;
|
|
|
|
gint y;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
GimpRGB rgb;
|
2002-10-29 04:13:17 +08:00
|
|
|
GimpHSV hsv;
|
1999-08-24 07:05:46 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
ColorSelectFillUpdateProc update;
|
|
|
|
};
|
|
|
|
|
2001-01-08 10:24:29 +08:00
|
|
|
|
2004-09-10 21:04:45 +08:00
|
|
|
static void gimp_color_select_unrealize (GtkWidget *widget);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
static void gimp_color_select_togg_visible (GimpColorSelector *selector,
|
|
|
|
gboolean visible);
|
|
|
|
static void gimp_color_select_togg_sensitive (GimpColorSelector *selector,
|
|
|
|
gboolean sensitive);
|
|
|
|
static void gimp_color_select_set_color (GimpColorSelector *selector,
|
|
|
|
const GimpRGB *rgb,
|
|
|
|
const GimpHSV *hsv);
|
|
|
|
static void gimp_color_select_set_channel (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorChannel channel);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
static void gimp_color_select_channel_toggled (GtkWidget *widget,
|
|
|
|
GimpColorSelect *select);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
static void gimp_color_select_update (GimpColorSelect *select,
|
|
|
|
ColorSelectUpdateType type);
|
|
|
|
static void gimp_color_select_update_values (GimpColorSelect *select);
|
|
|
|
static void gimp_color_select_update_pos (GimpColorSelect *select);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
#if 0
|
2002-11-05 08:02:56 +08:00
|
|
|
static void gimp_color_select_drop_color (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2002-11-05 08:02:56 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data);
|
2002-10-20 18:14:17 +08:00
|
|
|
#endif
|
|
|
|
|
2004-02-07 03:03:13 +08:00
|
|
|
static void gimp_color_select_xy_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
GimpColorSelect *select);
|
2002-11-05 08:02:56 +08:00
|
|
|
static gboolean gimp_color_select_xy_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *eevent,
|
|
|
|
GimpColorSelect *select);
|
|
|
|
static gboolean gimp_color_select_xy_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpColorSelect *select);
|
2004-02-07 03:03:13 +08:00
|
|
|
static void gimp_color_select_z_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
GimpColorSelect *select);
|
2002-11-05 08:02:56 +08:00
|
|
|
static gboolean gimp_color_select_z_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *eevent,
|
|
|
|
GimpColorSelect *select);
|
|
|
|
static gboolean gimp_color_select_z_events (GtkWidget *widet,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpColorSelect *select);
|
|
|
|
|
|
|
|
static void gimp_color_select_image_fill (GtkWidget *widget,
|
|
|
|
ColorSelectFillType fill_type,
|
|
|
|
const GimpHSV *hsv,
|
|
|
|
const GimpRGB *rgb);
|
|
|
|
|
|
|
|
static void gimp_color_select_draw_z_marker (GimpColorSelect *select,
|
|
|
|
GdkRectangle *clip);
|
|
|
|
static void gimp_color_select_draw_xy_marker (GimpColorSelect *select,
|
|
|
|
GdkRectangle *clip);
|
2001-01-08 10:24:29 +08:00
|
|
|
|
2001-01-15 20:20:38 +08:00
|
|
|
static void color_select_update_red (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_green (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_blue (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_hue (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_saturation (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_value (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_red_green (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_red_blue (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_green_blue (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_hue_saturation (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_hue_value (ColorSelectFill *csf);
|
|
|
|
static void color_select_update_saturation_value (ColorSelectFill *csf);
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
G_DEFINE_TYPE (GimpColorSelect, gimp_color_select, GIMP_TYPE_COLOR_SELECTOR);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_color_select_parent_class
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2006-04-06 20:43:58 +08:00
|
|
|
static const ColorSelectFillUpdateProc update_procs[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
color_select_update_hue,
|
|
|
|
color_select_update_saturation,
|
|
|
|
color_select_update_value,
|
|
|
|
color_select_update_red,
|
|
|
|
color_select_update_green,
|
|
|
|
color_select_update_blue,
|
2001-01-08 05:07:14 +08:00
|
|
|
NULL, /* alpha */
|
1997-11-25 06:05:25 +08:00
|
|
|
color_select_update_hue_saturation,
|
|
|
|
color_select_update_hue_value,
|
|
|
|
color_select_update_saturation_value,
|
|
|
|
color_select_update_red_green,
|
|
|
|
color_select_update_red_blue,
|
|
|
|
color_select_update_green_blue,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
static void
|
|
|
|
gimp_color_select_class_init (GimpColorSelectClass *klass)
|
|
|
|
{
|
2004-09-10 21:04:45 +08:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2004-09-10 21:04:45 +08:00
|
|
|
widget_class->unrealize = gimp_color_select_unrealize;
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2003-07-19 09:43:51 +08:00
|
|
|
selector_class->name = "GIMP";
|
2003-11-19 07:44:35 +08:00
|
|
|
selector_class->help_id = "gimp-colorselector-gimp";
|
2002-11-05 08:02:56 +08:00
|
|
|
selector_class->stock_id = GIMP_STOCK_WILBER;
|
|
|
|
selector_class->set_toggles_visible = gimp_color_select_togg_visible;
|
|
|
|
selector_class->set_toggles_sensitive = gimp_color_select_togg_sensitive;
|
|
|
|
selector_class->set_color = gimp_color_select_set_color;
|
|
|
|
selector_class->set_channel = gimp_color_select_set_channel;
|
2002-10-20 18:14:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_select_init (GimpColorSelect *select)
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
{
|
2001-01-09 09:23:54 +08:00
|
|
|
GtkWidget *hbox;
|
2004-02-07 03:03:13 +08:00
|
|
|
GtkWidget *frame;
|
2002-10-30 22:52:58 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
select->z_color_fill = COLOR_SELECT_HUE;
|
|
|
|
select->xy_color_fill = COLOR_SELECT_SATURATION_VALUE;
|
|
|
|
select->gc = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-30 08:20:48 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
2004-02-07 03:03:13 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (select), hbox, TRUE, TRUE, 0);
|
2001-01-09 09:23:54 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
1999-08-24 07:05:46 +08:00
|
|
|
/* The x/y component preview */
|
2004-02-07 03:03:13 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:04:45 +08:00
|
|
|
select->xy_color = gimp_preview_area_new ();
|
|
|
|
gtk_widget_set_size_request (select->xy_color,
|
|
|
|
GIMP_COLOR_SELECTOR_SIZE,
|
|
|
|
GIMP_COLOR_SELECTOR_SIZE);
|
2003-06-11 21:59:42 +08:00
|
|
|
gtk_widget_set_events (select->xy_color, COLOR_AREA_EVENT_MASK);
|
2004-02-07 03:03:13 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), select->xy_color);
|
2002-10-20 18:14:17 +08:00
|
|
|
gtk_widget_show (select->xy_color);
|
|
|
|
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect (select->xy_color, "size-allocate",
|
2004-09-10 21:16:55 +08:00
|
|
|
G_CALLBACK (gimp_color_select_xy_size_allocate),
|
|
|
|
select);
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect_after (select->xy_color, "expose-event",
|
2004-09-10 21:16:55 +08:00
|
|
|
G_CALLBACK (gimp_color_select_xy_expose),
|
|
|
|
select);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (select->xy_color, "event",
|
2004-09-10 21:16:55 +08:00
|
|
|
G_CALLBACK (gimp_color_select_xy_events),
|
|
|
|
select);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
gimp_dnd_color_dest_add (select->xy_color, gimp_color_select_drop_color,
|
|
|
|
select);
|
|
|
|
#endif
|
1999-08-24 07:05:46 +08:00
|
|
|
|
|
|
|
/* The z component preview */
|
2004-02-07 03:03:13 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:04:45 +08:00
|
|
|
select->z_color = gimp_preview_area_new ();
|
|
|
|
gtk_widget_set_size_request (select->z_color,
|
2005-05-24 18:48:47 +08:00
|
|
|
GIMP_COLOR_SELECTOR_BAR_SIZE, -1);
|
2003-06-11 21:59:42 +08:00
|
|
|
gtk_widget_set_events (select->z_color, COLOR_AREA_EVENT_MASK);
|
2004-02-07 03:03:13 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), select->z_color);
|
2002-10-20 18:14:17 +08:00
|
|
|
gtk_widget_show (select->z_color);
|
|
|
|
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect (select->z_color, "size-allocate",
|
2004-09-10 21:16:55 +08:00
|
|
|
G_CALLBACK (gimp_color_select_z_size_allocate),
|
|
|
|
select);
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect_after (select->z_color, "expose-event",
|
2004-09-10 21:16:55 +08:00
|
|
|
G_CALLBACK (gimp_color_select_z_expose),
|
|
|
|
select);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (select->z_color, "event",
|
2004-09-10 21:16:55 +08:00
|
|
|
G_CALLBACK (gimp_color_select_z_events),
|
|
|
|
select);
|
2002-11-05 08:02:56 +08:00
|
|
|
|
|
|
|
select->toggle_box = gtk_vbox_new (FALSE, 2);
|
2004-02-07 03:03:13 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), select->toggle_box, FALSE, FALSE, 0);
|
2002-11-05 08:02:56 +08:00
|
|
|
gtk_widget_show (select->toggle_box);
|
|
|
|
|
|
|
|
/* channel toggles */
|
|
|
|
{
|
|
|
|
GimpColorSelectorChannel channel;
|
2005-05-23 04:57:23 +08:00
|
|
|
GEnumClass *enum_class;
|
2002-11-05 08:02:56 +08:00
|
|
|
GSList *group = NULL;
|
|
|
|
|
2005-05-23 04:57:23 +08:00
|
|
|
enum_class = g_type_class_ref (GIMP_TYPE_COLOR_SELECTOR_CHANNEL);
|
2002-11-05 08:02:56 +08:00
|
|
|
|
|
|
|
for (channel = GIMP_COLOR_SELECTOR_HUE;
|
|
|
|
channel < GIMP_COLOR_SELECTOR_ALPHA;
|
|
|
|
channel++)
|
|
|
|
{
|
2005-05-23 04:57:23 +08:00
|
|
|
GimpEnumDesc *enum_desc;
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
enum_desc = gimp_enum_get_desc (enum_class, channel);
|
2002-11-05 08:02:56 +08:00
|
|
|
|
|
|
|
button = gtk_radio_button_new_with_mnemonic (group,
|
2005-05-23 04:57:23 +08:00
|
|
|
gettext (enum_desc->value_desc));
|
2002-11-05 08:02:56 +08:00
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (select->toggle_box), button,
|
|
|
|
TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (button), "channel",
|
|
|
|
GINT_TO_POINTER (channel));
|
|
|
|
|
|
|
|
if (channel == GIMP_COLOR_SELECTOR_HUE)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
|
|
|
2005-05-23 04:57:23 +08:00
|
|
|
gimp_help_set_help_data (button, gettext (enum_desc->value_help), NULL);
|
2002-11-05 08:02:56 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "toggled",
|
2002-11-05 08:02:56 +08:00
|
|
|
G_CALLBACK (gimp_color_select_channel_toggled),
|
|
|
|
select);
|
|
|
|
}
|
2005-05-23 04:57:23 +08:00
|
|
|
|
|
|
|
g_type_class_unref (enum_class);
|
2002-11-05 08:02:56 +08:00
|
|
|
}
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-08-24 07:05:46 +08:00
|
|
|
static void
|
2004-09-10 21:04:45 +08:00
|
|
|
gimp_color_select_unrealize (GtkWidget *widget)
|
1999-08-24 07:05:46 +08:00
|
|
|
{
|
2004-09-10 21:04:45 +08:00
|
|
|
GimpColorSelect *select = GIMP_COLOR_SELECT (widget);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
if (select->gc)
|
|
|
|
{
|
|
|
|
g_object_unref (select->gc);
|
|
|
|
select->gc = NULL;
|
|
|
|
}
|
1999-08-24 07:05:46 +08:00
|
|
|
|
2004-09-10 21:04:45 +08:00
|
|
|
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
2002-10-20 18:14:17 +08:00
|
|
|
}
|
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
static void
|
|
|
|
gimp_color_select_togg_visible (GimpColorSelector *selector,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
|
2002-11-05 08:02:56 +08:00
|
|
|
|
|
|
|
if (visible)
|
|
|
|
gtk_widget_show (select->toggle_box);
|
|
|
|
else
|
|
|
|
gtk_widget_hide (select->toggle_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_select_togg_sensitive (GimpColorSelector *selector,
|
|
|
|
gboolean sensitive)
|
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
|
2002-11-05 08:02:56 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (select->toggle_box, sensitive);
|
|
|
|
}
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
static void
|
|
|
|
gimp_color_select_set_color (GimpColorSelector *selector,
|
|
|
|
const GimpRGB *rgb,
|
|
|
|
const GimpHSV *hsv)
|
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
|
1999-08-24 07:05:46 +08:00
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
gimp_color_select_update (select,
|
|
|
|
UPDATE_POS | UPDATE_XY_COLOR | UPDATE_Z_COLOR);
|
1999-08-24 07:05:46 +08:00
|
|
|
}
|
|
|
|
|
1999-10-03 21:50:19 +08:00
|
|
|
static void
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_set_channel (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorChannel channel)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
switch ((ColorSelectFillType) channel)
|
|
|
|
{
|
|
|
|
case COLOR_SELECT_HUE:
|
|
|
|
select->z_color_fill = COLOR_SELECT_HUE;
|
|
|
|
select->xy_color_fill = COLOR_SELECT_SATURATION_VALUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLOR_SELECT_SATURATION:
|
|
|
|
select->z_color_fill = COLOR_SELECT_SATURATION;
|
|
|
|
select->xy_color_fill = COLOR_SELECT_HUE_VALUE;
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
case COLOR_SELECT_VALUE:
|
|
|
|
select->z_color_fill = COLOR_SELECT_VALUE;
|
|
|
|
select->xy_color_fill = COLOR_SELECT_HUE_SATURATION;
|
|
|
|
break;
|
2001-01-08 05:07:14 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
case COLOR_SELECT_RED:
|
|
|
|
select->z_color_fill = COLOR_SELECT_RED;
|
|
|
|
select->xy_color_fill = COLOR_SELECT_GREEN_BLUE;
|
|
|
|
break;
|
2001-01-08 05:07:14 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
case COLOR_SELECT_GREEN:
|
|
|
|
select->z_color_fill = COLOR_SELECT_GREEN;
|
|
|
|
select->xy_color_fill = COLOR_SELECT_RED_BLUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLOR_SELECT_BLUE:
|
|
|
|
select->z_color_fill = COLOR_SELECT_BLUE;
|
|
|
|
select->xy_color_fill = COLOR_SELECT_RED_GREEN;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
gimp_color_select_update (select,
|
|
|
|
UPDATE_POS | UPDATE_Z_COLOR | UPDATE_XY_COLOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_select_channel_toggled (GtkWidget *widget,
|
|
|
|
GimpColorSelect *select)
|
|
|
|
{
|
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active)
|
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
2002-11-05 08:02:56 +08:00
|
|
|
GimpColorSelectorChannel channel;
|
|
|
|
|
|
|
|
channel = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
|
|
|
|
"channel"));
|
|
|
|
|
|
|
|
selector->channel = channel;
|
|
|
|
gimp_color_select_set_channel (selector, channel);
|
|
|
|
|
|
|
|
gimp_color_selector_channel_changed (selector);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_update (GimpColorSelect *select,
|
|
|
|
ColorSelectUpdateType update)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-02-07 03:03:13 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
if (update & UPDATE_POS)
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_update_pos (select);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
if (update & UPDATE_VALUES)
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_update_values (select);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
if (update & UPDATE_XY_COLOR)
|
|
|
|
{
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_image_fill (select->xy_color, select->xy_color_fill,
|
2002-10-29 04:13:17 +08:00
|
|
|
&selector->hsv, &selector->rgb);
|
2002-10-20 18:14:17 +08:00
|
|
|
gtk_widget_queue_draw (select->xy_color);
|
2001-01-08 05:07:14 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
if (update & UPDATE_Z_COLOR)
|
|
|
|
{
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_image_fill (select->z_color, select->z_color_fill,
|
2002-10-29 04:13:17 +08:00
|
|
|
&selector->hsv, &selector->rgb);
|
2002-10-20 18:14:17 +08:00
|
|
|
gtk_widget_queue_draw (select->z_color);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-01-08 05:07:14 +08:00
|
|
|
|
2001-01-09 09:23:54 +08:00
|
|
|
if (update & UPDATE_CALLER)
|
2002-10-29 04:13:17 +08:00
|
|
|
gimp_color_selector_color_changed (GIMP_COLOR_SELECTOR (select));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_update_values (GimpColorSelect *select)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-02-07 03:03:13 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
switch (select->z_color_fill)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-08 05:07:14 +08:00
|
|
|
case COLOR_SELECT_RED:
|
2002-10-29 04:13:17 +08:00
|
|
|
selector->rgb.b = select->pos[0] / 255.0;
|
|
|
|
selector->rgb.g = select->pos[1] / 255.0;
|
|
|
|
selector->rgb.r = select->pos[2] / 255.0;
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
|
|
|
case COLOR_SELECT_GREEN:
|
2002-10-29 04:13:17 +08:00
|
|
|
selector->rgb.b = select->pos[0] / 255.0;
|
|
|
|
selector->rgb.r = select->pos[1] / 255.0;
|
|
|
|
selector->rgb.g = select->pos[2] / 255.0;
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
|
|
|
case COLOR_SELECT_BLUE:
|
2002-10-29 04:13:17 +08:00
|
|
|
selector->rgb.g = select->pos[0] / 255.0;
|
|
|
|
selector->rgb.r = select->pos[1] / 255.0;
|
|
|
|
selector->rgb.b = select->pos[2] / 255.0;
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
2001-01-15 20:20:38 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
case COLOR_SELECT_HUE:
|
2002-10-29 04:13:17 +08:00
|
|
|
selector->hsv.v = select->pos[0] / 255.0;
|
|
|
|
selector->hsv.s = select->pos[1] / 255.0;
|
|
|
|
selector->hsv.h = select->pos[2] / 255.0;
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
|
|
|
case COLOR_SELECT_SATURATION:
|
2002-10-29 04:13:17 +08:00
|
|
|
selector->hsv.v = select->pos[0] / 255.0;
|
|
|
|
selector->hsv.h = select->pos[1] / 255.0;
|
|
|
|
selector->hsv.s = select->pos[2] / 255.0;
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
|
|
|
case COLOR_SELECT_VALUE:
|
2002-10-29 04:13:17 +08:00
|
|
|
selector->hsv.s = select->pos[0] / 255.0;
|
|
|
|
selector->hsv.h = select->pos[1] / 255.0;
|
|
|
|
selector->hsv.v = select->pos[2] / 255.0;
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
2002-10-30 22:52:58 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2001-01-08 05:07:14 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
switch (select->z_color_fill)
|
2001-01-08 05:07:14 +08:00
|
|
|
{
|
|
|
|
case COLOR_SELECT_RED:
|
|
|
|
case COLOR_SELECT_GREEN:
|
|
|
|
case COLOR_SELECT_BLUE:
|
2002-10-29 04:13:17 +08:00
|
|
|
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
2001-01-15 20:20:38 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
case COLOR_SELECT_HUE:
|
|
|
|
case COLOR_SELECT_SATURATION:
|
|
|
|
case COLOR_SELECT_VALUE:
|
2002-10-29 04:13:17 +08:00
|
|
|
gimp_hsv_to_rgb (&selector->hsv, &selector->rgb);
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
2002-10-30 22:52:58 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-10-29 04:13:17 +08:00
|
|
|
gimp_color_select_update_pos (GimpColorSelect *select)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-02-07 03:03:13 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
switch (select->z_color_fill)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-08 05:07:14 +08:00
|
|
|
case COLOR_SELECT_RED:
|
2003-06-14 00:44:21 +08:00
|
|
|
select->pos[0] = ROUND (selector->rgb.b * 255.0);
|
|
|
|
select->pos[1] = ROUND (selector->rgb.g * 255.0);
|
|
|
|
select->pos[2] = ROUND (selector->rgb.r * 255.0);
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
|
|
|
case COLOR_SELECT_GREEN:
|
2003-06-14 00:44:21 +08:00
|
|
|
select->pos[0] = ROUND (selector->rgb.b * 255.0);
|
|
|
|
select->pos[1] = ROUND (selector->rgb.r * 255.0);
|
|
|
|
select->pos[2] = ROUND (selector->rgb.g * 255.0);
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
|
|
|
case COLOR_SELECT_BLUE:
|
2003-06-14 00:44:21 +08:00
|
|
|
select->pos[0] = ROUND (selector->rgb.g * 255.0);
|
|
|
|
select->pos[1] = ROUND (selector->rgb.r * 255.0);
|
|
|
|
select->pos[2] = ROUND (selector->rgb.b * 255.0);
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
2001-01-15 20:20:38 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
case COLOR_SELECT_HUE:
|
2003-06-14 00:44:21 +08:00
|
|
|
select->pos[0] = ROUND (selector->hsv.v * 255.0);
|
|
|
|
select->pos[1] = ROUND (selector->hsv.s * 255.0);
|
|
|
|
select->pos[2] = ROUND (selector->hsv.h * 255.0);
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
|
|
|
case COLOR_SELECT_SATURATION:
|
2003-06-14 00:44:21 +08:00
|
|
|
select->pos[0] = ROUND (selector->hsv.v * 255.0);
|
|
|
|
select->pos[1] = ROUND (selector->hsv.h * 255.0);
|
|
|
|
select->pos[2] = ROUND (selector->hsv.s * 255.0);
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
|
|
|
case COLOR_SELECT_VALUE:
|
2003-06-14 00:44:21 +08:00
|
|
|
select->pos[0] = ROUND (selector->hsv.s * 255.0);
|
|
|
|
select->pos[1] = ROUND (selector->hsv.h * 255.0);
|
|
|
|
select->pos[2] = ROUND (selector->hsv.v * 255.0);
|
2001-01-08 05:07:14 +08:00
|
|
|
break;
|
2002-10-30 22:52:58 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
#if 0
|
|
|
|
static void
|
|
|
|
gimp_color_select_drop_color (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2002-10-20 18:14:17 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-02-07 03:03:13 +08:00
|
|
|
GimpColorSelect *select = GIMP_COLOR_SELECT (data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
select->rgb = *color;
|
|
|
|
|
|
|
|
gimp_color_select_update_hsv_values (select);
|
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
gimp_color_select_update (select,
|
|
|
|
UPDATE_POS | UPDATE_XY_COLOR | UPDATE_Z_COLOR |
|
|
|
|
UPDATE_CALLER);
|
2002-10-20 18:14:17 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-02-07 03:03:13 +08:00
|
|
|
static void
|
|
|
|
gimp_color_select_xy_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
GimpColorSelect *select)
|
|
|
|
{
|
|
|
|
gimp_color_select_update (select, UPDATE_XY_COLOR);
|
|
|
|
}
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_color_select_xy_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event,
|
|
|
|
GimpColorSelect *select)
|
|
|
|
{
|
|
|
|
if (! select->gc)
|
|
|
|
select->gc = gdk_gc_new (widget->window);
|
|
|
|
|
|
|
|
gimp_color_select_draw_xy_marker (select, &event->area);
|
|
|
|
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_color_select_xy_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpColorSelect *select)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GdkEventMotion *mevent;
|
2004-02-07 03:03:13 +08:00
|
|
|
gint width, height;
|
2003-06-11 21:59:42 +08:00
|
|
|
gint x, y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
2003-06-11 21:59:42 +08:00
|
|
|
x = bevent->x;
|
|
|
|
y = bevent->y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
gdk_pointer_grab (select->xy_color->window, FALSE,
|
2004-09-10 21:16:55 +08:00
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
|
|
|
NULL, NULL, bevent->time);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
bevent = (GdkEventButton *) event;
|
2003-06-11 21:59:42 +08:00
|
|
|
x = bevent->x;
|
|
|
|
y = bevent->y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-10-30 04:57:21 +08:00
|
|
|
gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
|
|
|
|
bevent->time);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
mevent = (GdkEventMotion *) event;
|
|
|
|
if (mevent->is_hint)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
gdk_window_get_pointer (widget->window, &x, &y, NULL);
|
|
|
|
}
|
2003-06-11 21:59:42 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
x = mevent->x;
|
|
|
|
y = mevent->y;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2003-06-11 21:59:42 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-06-11 21:59:42 +08:00
|
|
|
gimp_color_select_draw_xy_marker (select, NULL);
|
|
|
|
|
2004-02-07 03:03:13 +08:00
|
|
|
width = select->xy_color->allocation.width;
|
|
|
|
height = select->xy_color->allocation.height;
|
|
|
|
|
|
|
|
if (width > 1 && height > 1)
|
|
|
|
{
|
|
|
|
select->pos[0] = (x * 255) / (width - 1);
|
|
|
|
select->pos[1] = 255 - (y * 255) / (height - 1);
|
|
|
|
}
|
2003-10-30 04:57:21 +08:00
|
|
|
|
2003-06-14 00:44:21 +08:00
|
|
|
select->pos[0] = CLAMP (select->pos[0], 0, 255);
|
|
|
|
select->pos[1] = CLAMP (select->pos[1], 0, 255);
|
2003-10-30 04:57:21 +08:00
|
|
|
|
2003-06-11 21:59:42 +08:00
|
|
|
gimp_color_select_draw_xy_marker (select, NULL);
|
2004-09-20 08:17:38 +08:00
|
|
|
|
2003-06-11 21:59:42 +08:00
|
|
|
gimp_color_select_update (select, UPDATE_VALUES | UPDATE_CALLER);
|
|
|
|
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-02-07 03:03:13 +08:00
|
|
|
static void
|
|
|
|
gimp_color_select_z_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
GimpColorSelect *select)
|
|
|
|
{
|
|
|
|
gimp_color_select_update (select, UPDATE_Z_COLOR);
|
|
|
|
}
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_color_select_z_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event,
|
|
|
|
GimpColorSelect *select)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-10-20 18:14:17 +08:00
|
|
|
if (! select->gc)
|
|
|
|
select->gc = gdk_gc_new (widget->window);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_draw_z_marker (select, &event->area);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_color_select_z_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpColorSelect *select)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GdkEventMotion *mevent;
|
2004-02-07 03:03:13 +08:00
|
|
|
gint height;
|
2003-06-11 21:59:42 +08:00
|
|
|
gint z;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
2003-06-11 21:59:42 +08:00
|
|
|
z = bevent->y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
gdk_pointer_grab (select->z_color->window, FALSE,
|
2004-09-10 21:16:55 +08:00
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON_MOTION_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK,
|
|
|
|
NULL, NULL, bevent->time);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
bevent = (GdkEventButton *) event;
|
2003-06-11 21:59:42 +08:00
|
|
|
z = bevent->y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-10-30 04:57:21 +08:00
|
|
|
gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
|
|
|
|
bevent->time);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
mevent = (GdkEventMotion *) event;
|
|
|
|
if (mevent->is_hint)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
gdk_window_get_pointer (widget->window, NULL, &z, NULL);
|
|
|
|
}
|
2003-06-11 21:59:42 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
z = mevent->y;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2003-06-11 21:59:42 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-06-11 21:59:42 +08:00
|
|
|
gimp_color_select_draw_z_marker (select, NULL);
|
2003-10-30 04:57:21 +08:00
|
|
|
|
2004-02-07 03:03:13 +08:00
|
|
|
height = select->z_color->allocation.height;
|
|
|
|
|
|
|
|
if (height > 1)
|
|
|
|
select->pos[2] = 255 - (z * 255) / (height - 1);
|
|
|
|
|
2003-06-11 21:59:42 +08:00
|
|
|
select->pos[2] = CLAMP (select->pos[2], 0, 255);
|
|
|
|
|
|
|
|
gimp_color_select_draw_z_marker (select, NULL);
|
2003-06-11 23:55:48 +08:00
|
|
|
gimp_color_select_update (select,
|
|
|
|
UPDATE_VALUES | UPDATE_XY_COLOR | UPDATE_CALLER);
|
2003-06-11 21:59:42 +08:00
|
|
|
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_image_fill (GtkWidget *preview,
|
2002-10-30 22:52:58 +08:00
|
|
|
ColorSelectFillType fill_type,
|
2002-10-20 18:14:17 +08:00
|
|
|
const GimpHSV *hsv,
|
|
|
|
const GimpRGB *rgb)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
ColorSelectFill csf;
|
|
|
|
|
2002-10-30 22:52:58 +08:00
|
|
|
csf.update = update_procs[fill_type];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-02-07 03:03:13 +08:00
|
|
|
csf.width = preview->allocation.width;
|
|
|
|
csf.height = preview->allocation.height;
|
2001-01-15 20:20:38 +08:00
|
|
|
csf.hsv = *hsv;
|
|
|
|
csf.rgb = *rgb;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-07-31 09:59:46 +08:00
|
|
|
csf.buffer = g_alloca (csf.width * 3);
|
|
|
|
|
|
|
|
for (csf.y = 0; csf.y < csf.height; csf.y++)
|
2004-02-21 20:25:09 +08:00
|
|
|
{
|
2004-07-31 09:59:46 +08:00
|
|
|
{
|
|
|
|
if (csf.update)
|
|
|
|
(* csf.update) (&csf);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:04:45 +08:00
|
|
|
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview),
|
|
|
|
0, csf.y, csf.width, 1,
|
|
|
|
GIMP_RGB_IMAGE,
|
|
|
|
csf.buffer, csf.width * 3);
|
2004-07-31 09:59:46 +08:00
|
|
|
}
|
2004-02-21 20:25:09 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_draw_z_marker (GimpColorSelect *select,
|
|
|
|
GdkRectangle *clip)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint y;
|
|
|
|
gint minx;
|
|
|
|
gint miny;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
if (! select->gc)
|
2001-01-08 05:07:14 +08:00
|
|
|
return;
|
|
|
|
|
2004-02-07 03:03:13 +08:00
|
|
|
width = select->z_color->allocation.width;
|
|
|
|
height = select->z_color->allocation.height;
|
|
|
|
|
|
|
|
if (width < 1 || height < 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
y = (height - 1) - ((height - 1) * select->pos[2]) / 255;
|
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
minx = 0;
|
|
|
|
miny = 0;
|
|
|
|
|
|
|
|
if (clip)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-10-20 18:14:17 +08:00
|
|
|
width = MIN (width, clip->x + clip->width);
|
|
|
|
height = MIN (height, clip->y + clip->height);
|
|
|
|
minx = MAX (0, clip->x);
|
|
|
|
miny = MAX (0, clip->y);
|
2001-01-08 05:07:14 +08:00
|
|
|
}
|
1998-10-12 06:50:03 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
if (y >= miny && y < height)
|
|
|
|
{
|
2002-10-20 18:14:17 +08:00
|
|
|
gdk_gc_set_function (select->gc, GDK_INVERT);
|
2003-06-11 21:59:42 +08:00
|
|
|
gdk_draw_line (select->z_color->window,
|
|
|
|
select->gc, minx, y, width - 1, y);
|
2002-10-20 18:14:17 +08:00
|
|
|
gdk_gc_set_function (select->gc, GDK_COPY);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-10-20 18:14:17 +08:00
|
|
|
gimp_color_select_draw_xy_marker (GimpColorSelect *select,
|
|
|
|
GdkRectangle *clip)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint x, y;
|
|
|
|
gint minx, miny;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
if (! select->gc)
|
2001-01-08 05:07:14 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-02-07 03:03:13 +08:00
|
|
|
width = select->xy_color->allocation.width;
|
|
|
|
height = select->xy_color->allocation.height;
|
|
|
|
|
|
|
|
if (width < 1 || height < 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
x = ((width - 1) * select->pos[0]) / 255;
|
|
|
|
y = (height - 1) - ((height - 1) * select->pos[1]) / 255;
|
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
minx = 0;
|
|
|
|
miny = 0;
|
1998-10-12 06:50:03 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
gdk_gc_set_function (select->gc, GDK_INVERT);
|
1998-10-12 06:50:03 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
if (clip)
|
|
|
|
{
|
2002-10-20 18:14:17 +08:00
|
|
|
width = MIN (width, clip->x + clip->width);
|
|
|
|
height = MIN (height, clip->y + clip->height);
|
|
|
|
minx = MAX (0, clip->x);
|
|
|
|
miny = MAX (0, clip->y);
|
2001-01-08 05:07:14 +08:00
|
|
|
}
|
1998-10-12 06:50:03 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
if (y >= miny && y < height)
|
2003-06-11 21:59:42 +08:00
|
|
|
gdk_draw_line (select->xy_color->window,
|
|
|
|
select->gc, minx, y, width - 1, y);
|
1998-10-12 06:50:03 +08:00
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
if (x >= minx && x < width)
|
2003-06-11 21:59:42 +08:00
|
|
|
gdk_draw_line (select->xy_color->window,
|
|
|
|
select->gc, x, miny, x, height - 1);
|
2001-01-08 05:07:14 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
gdk_gc_set_function (select->gc, GDK_COPY);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_red (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gint i, r;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
|
|
|
r = (csf->height - csf->y + 1) * 255 / csf->height;
|
|
|
|
|
|
|
|
if (r < 0)
|
|
|
|
r = 0;
|
|
|
|
if (r > 255)
|
|
|
|
r = 255;
|
|
|
|
|
|
|
|
for (i = 0; i < csf->width; i++)
|
|
|
|
{
|
|
|
|
*p++ = r;
|
|
|
|
*p++ = 0;
|
|
|
|
*p++ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_green (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gint i, g;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
|
|
|
g = (csf->height - csf->y + 1) * 255 / csf->height;
|
|
|
|
|
|
|
|
if (g < 0)
|
|
|
|
g = 0;
|
|
|
|
if (g > 255)
|
|
|
|
g = 255;
|
|
|
|
|
|
|
|
for (i = 0; i < csf->width; i++)
|
|
|
|
{
|
|
|
|
*p++ = 0;
|
|
|
|
*p++ = g;
|
|
|
|
*p++ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_blue (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gint i, b;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
|
|
|
b = (csf->height - csf->y + 1) * 255 / csf->height;
|
|
|
|
|
|
|
|
if (b < 0)
|
|
|
|
b = 0;
|
|
|
|
if (b > 255)
|
|
|
|
b = 255;
|
|
|
|
|
|
|
|
for (i = 0; i < csf->width; i++)
|
|
|
|
{
|
|
|
|
*p++ = 0;
|
|
|
|
*p++ = 0;
|
|
|
|
*p++ = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_hue (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gfloat h, f;
|
|
|
|
gint r, g, b;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
2001-01-15 20:20:38 +08:00
|
|
|
h = csf->y * 360.0 / csf->height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 20:20:38 +08:00
|
|
|
h = CLAMP (360 - h, 0, 360);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
h /= 60;
|
|
|
|
f = (h - (int) h) * 255;
|
|
|
|
|
|
|
|
r = g = b = 0;
|
|
|
|
|
|
|
|
switch ((int) h)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
r = 255;
|
|
|
|
g = f;
|
|
|
|
b = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
r = 255 - f;
|
|
|
|
g = 255;
|
|
|
|
b = 0;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
r = 0;
|
|
|
|
g = 255;
|
|
|
|
b = f;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
r = 0;
|
|
|
|
g = 255 - f;
|
|
|
|
b = 255;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
r = f;
|
|
|
|
g = 0;
|
|
|
|
b = 255;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
r = 255;
|
|
|
|
g = 0;
|
|
|
|
b = 255 - f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < csf->width; i++)
|
|
|
|
{
|
|
|
|
*p++ = r;
|
|
|
|
*p++ = g;
|
|
|
|
*p++ = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_saturation (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gint s;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
|
|
|
s = csf->y * 255 / csf->height;
|
|
|
|
|
|
|
|
if (s < 0)
|
|
|
|
s = 0;
|
|
|
|
if (s > 255)
|
|
|
|
s = 255;
|
|
|
|
|
|
|
|
s = 255 - s;
|
|
|
|
|
|
|
|
for (i = 0; i < csf->width; i++)
|
|
|
|
{
|
|
|
|
*p++ = s;
|
|
|
|
*p++ = s;
|
|
|
|
*p++ = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_value (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gint v;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
|
|
|
v = csf->y * 255 / csf->height;
|
|
|
|
|
|
|
|
if (v < 0)
|
|
|
|
v = 0;
|
|
|
|
if (v > 255)
|
|
|
|
v = 255;
|
|
|
|
|
|
|
|
v = 255 - v;
|
|
|
|
|
|
|
|
for (i = 0; i < csf->width; i++)
|
|
|
|
{
|
|
|
|
*p++ = v;
|
|
|
|
*p++ = v;
|
|
|
|
*p++ = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_red_green (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gint i, r, b;
|
|
|
|
gfloat g, dg;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
2003-06-14 00:44:21 +08:00
|
|
|
b = ROUND (csf->rgb.b * 255.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
r = (csf->height - csf->y + 1) * 255 / csf->height;
|
|
|
|
|
|
|
|
if (r < 0)
|
|
|
|
r = 0;
|
|
|
|
if (r > 255)
|
|
|
|
r = 255;
|
|
|
|
|
|
|
|
g = 0;
|
|
|
|
dg = 255.0 / csf->width;
|
|
|
|
|
|
|
|
for (i = 0; i < csf->width; i++)
|
|
|
|
{
|
|
|
|
*p++ = r;
|
|
|
|
*p++ = g;
|
|
|
|
*p++ = b;
|
|
|
|
|
|
|
|
g += dg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_red_blue (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gint i, r, g;
|
|
|
|
gfloat b, db;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
2003-06-14 00:44:21 +08:00
|
|
|
g = ROUND (csf->rgb.g * 255.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
r = (csf->height - csf->y + 1) * 255 / csf->height;
|
|
|
|
|
|
|
|
if (r < 0)
|
|
|
|
r = 0;
|
|
|
|
if (r > 255)
|
|
|
|
r = 255;
|
|
|
|
|
|
|
|
b = 0;
|
|
|
|
db = 255.0 / csf->width;
|
|
|
|
|
|
|
|
for (i = 0; i < csf->width; i++)
|
|
|
|
{
|
|
|
|
*p++ = r;
|
|
|
|
*p++ = g;
|
|
|
|
*p++ = b;
|
|
|
|
|
|
|
|
b += db;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_green_blue (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gint i, g, r;
|
|
|
|
gfloat b, db;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
2003-06-14 00:44:21 +08:00
|
|
|
r = ROUND (csf->rgb.r * 255.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
g = (csf->height - csf->y + 1) * 255 / csf->height;
|
|
|
|
|
|
|
|
if (g < 0)
|
|
|
|
g = 0;
|
|
|
|
if (g > 255)
|
|
|
|
g = 255;
|
|
|
|
|
|
|
|
b = 0;
|
|
|
|
db = 255.0 / csf->width;
|
|
|
|
|
|
|
|
for (i = 0; i < csf->width; i++)
|
|
|
|
{
|
|
|
|
*p++ = r;
|
|
|
|
*p++ = g;
|
|
|
|
*p++ = b;
|
|
|
|
|
|
|
|
b += db;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_hue_saturation (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gfloat h, v, s, ds;
|
|
|
|
gint f;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
|
|
|
h = 360 - (csf->y * 360 / csf->height);
|
|
|
|
|
|
|
|
if (h < 0)
|
|
|
|
h = 0;
|
|
|
|
if (h > 359)
|
|
|
|
h = 359;
|
|
|
|
|
|
|
|
h /= 60;
|
|
|
|
f = (h - (int) h) * 255;
|
|
|
|
|
|
|
|
s = 0;
|
|
|
|
ds = 1.0 / csf->width;
|
|
|
|
|
2001-01-15 20:20:38 +08:00
|
|
|
v = csf->hsv.v;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch ((int) h)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255;
|
|
|
|
*p++ = v * (255 - (s * (255 - f)));
|
|
|
|
*p++ = v * 255 * (1 - s);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
s += ds;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * (255 - s * f);
|
|
|
|
*p++ = v * 255;
|
|
|
|
*p++ = v * 255 * (1 - s);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
s += ds;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255 * (1 - s);
|
|
|
|
*p++ = v *255;
|
|
|
|
*p++ = v * (255 - (s * (255 - f)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
s += ds;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255 * (1 - s);
|
|
|
|
*p++ = v * (255 - s * f);
|
|
|
|
*p++ = v * 255;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
s += ds;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * (255 - (s * (255 - f)));
|
|
|
|
*p++ = v * (255 * (1 - s));
|
|
|
|
*p++ = v * 255;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
s += ds;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255;
|
|
|
|
*p++ = v * 255 * (1 - s);
|
|
|
|
*p++ = v * (255 - s * f);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
s += ds;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_hue_value (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gfloat h, v, dv, s;
|
|
|
|
gint f;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
|
|
|
h = 360 - (csf->y * 360 / csf->height);
|
|
|
|
|
|
|
|
if (h < 0)
|
|
|
|
h = 0;
|
|
|
|
if (h > 359)
|
|
|
|
h = 359;
|
|
|
|
|
|
|
|
h /= 60;
|
|
|
|
f = (h - (int) h) * 255;
|
|
|
|
|
|
|
|
v = 0;
|
|
|
|
dv = 1.0 / csf->width;
|
|
|
|
|
2001-01-15 20:20:38 +08:00
|
|
|
s = csf->hsv.s;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch ((int) h)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255;
|
|
|
|
*p++ = v * (255 - (s * (255 - f)));
|
|
|
|
*p++ = v * 255 * (1 - s);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * (255 - s * f);
|
|
|
|
*p++ = v * 255;
|
|
|
|
*p++ = v * 255 * (1 - s);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255 * (1 - s);
|
|
|
|
*p++ = v *255;
|
|
|
|
*p++ = v * (255 - (s * (255 - f)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255 * (1 - s);
|
|
|
|
*p++ = v * (255 - s * f);
|
|
|
|
*p++ = v * 255;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * (255 - (s * (255 - f)));
|
|
|
|
*p++ = v * (255 * (1 - s));
|
|
|
|
*p++ = v * 255;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255;
|
|
|
|
*p++ = v * 255 * (1 - s);
|
|
|
|
*p++ = v * (255 - s * f);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
color_select_update_saturation_value (ColorSelectFill *csf)
|
|
|
|
{
|
1999-08-24 07:05:46 +08:00
|
|
|
guchar *p;
|
2001-01-08 10:24:29 +08:00
|
|
|
gfloat h, v, dv, s;
|
|
|
|
gint f;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
p = csf->buffer;
|
|
|
|
|
2001-01-09 09:23:54 +08:00
|
|
|
s = (gfloat) csf->y / csf->height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (s < 0)
|
|
|
|
s = 0;
|
|
|
|
if (s > 1)
|
|
|
|
s = 1;
|
|
|
|
|
|
|
|
s = 1 - s;
|
|
|
|
|
2001-01-15 20:20:38 +08:00
|
|
|
h = (gfloat) csf->hsv.h * 360.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
if (h >= 360)
|
|
|
|
h -= 360;
|
|
|
|
h /= 60;
|
2001-01-09 09:23:54 +08:00
|
|
|
f = (h - (gint) h) * 255;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
v = 0;
|
|
|
|
dv = 1.0 / csf->width;
|
|
|
|
|
2001-01-09 09:23:54 +08:00
|
|
|
switch ((gint) h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255;
|
|
|
|
*p++ = v * (255 - (s * (255 - f)));
|
|
|
|
*p++ = v * 255 * (1 - s);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * (255 - s * f);
|
|
|
|
*p++ = v * 255;
|
|
|
|
*p++ = v * 255 * (1 - s);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255 * (1 - s);
|
|
|
|
*p++ = v *255;
|
|
|
|
*p++ = v * (255 - (s * (255 - f)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255 * (1 - s);
|
|
|
|
*p++ = v * (255 - s * f);
|
|
|
|
*p++ = v * 255;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * (255 - (s * (255 - f)));
|
|
|
|
*p++ = v * (255 * (1 - s));
|
|
|
|
*p++ = v * 255;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
for (i = 0; i < csf->width; i++)
|
2004-09-10 21:16:55 +08:00
|
|
|
{
|
|
|
|
*p++ = v * 255;
|
|
|
|
*p++ = v * 255 * (1 - s);
|
|
|
|
*p++ = v * (255 - s * f);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-10 21:16:55 +08:00
|
|
|
v += dv;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|