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
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
1999-09-28 01:58:10 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "appenv.h"
|
|
|
|
#include "colormaps.h"
|
|
|
|
#include "drawable.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "gimage_mask.h"
|
|
|
|
#include "gdisplay.h"
|
1999-09-28 01:58:10 +08:00
|
|
|
#include "gimpui.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "hue_saturation.h"
|
|
|
|
#include "interface.h"
|
|
|
|
|
2000-01-03 09:58:43 +08:00
|
|
|
#include "libgimp/gimpcolorspace.h"
|
1998-11-23 22:47:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#define HUE_PARTITION_MASK GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK
|
|
|
|
|
|
|
|
#define SLIDER_WIDTH 200
|
|
|
|
#define DA_WIDTH 40
|
|
|
|
#define DA_HEIGHT 20
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
#define HUE_PARTITION 0x0
|
|
|
|
#define HUE_SLIDER 0x1
|
|
|
|
#define LIGHTNESS_SLIDER 0x2
|
|
|
|
#define SATURATION_SLIDER 0x4
|
|
|
|
#define DRAW 0x40
|
|
|
|
#define ALL 0xFF
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* the hue-saturation structures */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
typedef struct _HueSaturation HueSaturation;
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
struct _HueSaturation
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
gint x, y; /* coords for last mouse click */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* the hue-saturation tool options */
|
1999-04-13 01:55:06 +08:00
|
|
|
static ToolOptions *hue_saturation_options = NULL;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
/* the hue-saturation tool dialog */
|
|
|
|
static HueSaturationDialog *hue_saturation_dialog = NULL;
|
|
|
|
|
|
|
|
/* Local variables */
|
1999-11-22 19:14:29 +08:00
|
|
|
static gint hue_transfer[6][256];
|
|
|
|
static gint lightness_transfer[6][256];
|
|
|
|
static gint saturation_transfer[6][256];
|
|
|
|
static gint default_colors[6][3] =
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
{ 255, 0, 0 },
|
|
|
|
{ 255, 255, 0 },
|
|
|
|
{ 0, 255, 0 },
|
|
|
|
{ 0, 255, 255 },
|
|
|
|
{ 0, 0, 255 },
|
|
|
|
{ 255, 0, 255 }
|
1999-04-09 06:25:54 +08:00
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* hue saturation action functions */
|
1999-07-03 01:40:10 +08:00
|
|
|
static void hue_saturation_control (Tool *, ToolAction, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
static HueSaturationDialog * hue_saturation_dialog_new (void);
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
static void hue_saturation_update (HueSaturationDialog *,
|
1999-11-22 19:14:29 +08:00
|
|
|
gint);
|
1997-11-25 06:05:25 +08:00
|
|
|
static void hue_saturation_preview (HueSaturationDialog *);
|
1999-11-22 19:14:29 +08:00
|
|
|
static void hue_saturation_reset_callback (GtkWidget *, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
static void hue_saturation_ok_callback (GtkWidget *, gpointer);
|
|
|
|
static void hue_saturation_cancel_callback (GtkWidget *, gpointer);
|
1999-11-22 19:14:29 +08:00
|
|
|
static void hue_saturation_partition_callback (GtkWidget *, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
static void hue_saturation_preview_update (GtkWidget *, gpointer);
|
1999-11-22 19:14:29 +08:00
|
|
|
static void hue_saturation_hue_adjustment_update (GtkAdjustment *,
|
|
|
|
gpointer);
|
|
|
|
static void hue_saturation_lightness_adjustment_update (GtkAdjustment *,
|
|
|
|
gpointer);
|
|
|
|
static void hue_saturation_saturation_adjustment_update (GtkAdjustment *,
|
|
|
|
gpointer);
|
1999-06-22 06:12:07 +08:00
|
|
|
static gint hue_saturation_hue_partition_events (GtkWidget *, GdkEvent *,
|
|
|
|
HueSaturationDialog *);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* hue saturation machinery */
|
|
|
|
|
moved a bunch of PDB stuff here
* app/color_cmds.c: moved a bunch of PDB stuff here
* app/color_balance.[ch]: removed PDB proc, exported TransferMode
enum, ColorBalanceDialog, color_balance_create_lookup_tables, and
color_balance
* app/curves.[ch]: removed PDB procs, exported SMOOTH and GFREE
#defines, CurvesDialog, curves_lut_func and curves_calculate_curve
* app/desaturate.[ch]: removed PDB proc, exported desaturate
* app/equalize.[ch]: removed PDB proc, exported equalize
* app/histogram_tool.[ch]: removed PDB proc, exported HISTOGRAM_WIDTH
and HISTOGRAM_HEIGHT #defines, HistogramToolDialog,
histogram_tool_histogram_range
* app/hue_saturation.[ch]: removed PDB proc, exported HueRange enum,
HueSaturationDialog, hue_saturation_calculate_transfers,
hue_saturation
* app/invert.[ch]: remove PDB proc, export invert
* app/threshold.[ch]: remove PDB proc, export ThresholdDialog and
threshold_2
* internal_procs.c: changes for pdbgen
* app/gimprc.c: removed leftover declaration
* app/image_map.h: add #include "gimpdrawableF.h"
* app/lut_funcs.h: add ALPHA_LUT to ChannelLutType
-Yosh
1999-04-21 13:39:57 +08:00
|
|
|
void
|
1997-11-25 06:05:25 +08:00
|
|
|
hue_saturation_calculate_transfers (HueSaturationDialog *hsd)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
gint value;
|
|
|
|
gint hue;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Calculate transfers */
|
|
|
|
for (hue = 0; hue < 6; hue++)
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
value = (hsd->hue[0] + hsd->hue[hue + 1]) * 255.0 / 360.0;
|
|
|
|
if ((i + value) < 0)
|
|
|
|
hue_transfer[hue][i] = 255 + (i + value);
|
|
|
|
else if ((i + value) > 255)
|
|
|
|
hue_transfer[hue][i] = i + value - 255;
|
|
|
|
else
|
|
|
|
hue_transfer[hue][i] = i + value;
|
|
|
|
|
|
|
|
/* Lightness */
|
|
|
|
value = (hsd->lightness[0] + hsd->lightness[hue + 1]) * 127.0 / 100.0;
|
|
|
|
value = BOUNDS (value, -255, 255);
|
|
|
|
if (value < 0)
|
|
|
|
lightness_transfer[hue][i] = (unsigned char) ((i * (255 + value)) / 255);
|
|
|
|
else
|
|
|
|
lightness_transfer[hue][i] = (unsigned char) (i + ((255 - i) * value) / 255);
|
|
|
|
|
|
|
|
/* Saturation */
|
|
|
|
value = (hsd->saturation[0] + hsd->saturation[hue + 1]) * 255.0 / 100.0;
|
|
|
|
value = BOUNDS (value, -255, 255);
|
1999-02-26 03:38:55 +08:00
|
|
|
|
|
|
|
/* This change affects the way saturation is computed. With the
|
|
|
|
old code (different code for value < 0), increasing the
|
|
|
|
saturation affected muted colors very much, and bright colors
|
|
|
|
less. With the new code, it affects muted colors and bright
|
|
|
|
colors more or less evenly. For enhancing the color in photos,
|
|
|
|
the new behavior is exactly what you want. It's hard for me
|
|
|
|
to imagine a case in which the old behavior is better.
|
|
|
|
*/
|
|
|
|
saturation_transfer[hue][i] = BOUNDS((i * (255 + value)) / 255, 0, 255);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
moved a bunch of PDB stuff here
* app/color_cmds.c: moved a bunch of PDB stuff here
* app/color_balance.[ch]: removed PDB proc, exported TransferMode
enum, ColorBalanceDialog, color_balance_create_lookup_tables, and
color_balance
* app/curves.[ch]: removed PDB procs, exported SMOOTH and GFREE
#defines, CurvesDialog, curves_lut_func and curves_calculate_curve
* app/desaturate.[ch]: removed PDB proc, exported desaturate
* app/equalize.[ch]: removed PDB proc, exported equalize
* app/histogram_tool.[ch]: removed PDB proc, exported HISTOGRAM_WIDTH
and HISTOGRAM_HEIGHT #defines, HistogramToolDialog,
histogram_tool_histogram_range
* app/hue_saturation.[ch]: removed PDB proc, exported HueRange enum,
HueSaturationDialog, hue_saturation_calculate_transfers,
hue_saturation
* app/invert.[ch]: remove PDB proc, export invert
* app/threshold.[ch]: remove PDB proc, export ThresholdDialog and
threshold_2
* internal_procs.c: changes for pdbgen
* app/gimprc.c: removed leftover declaration
* app/image_map.h: add #include "gimpdrawableF.h"
* app/lut_funcs.h: add ALPHA_LUT to ChannelLutType
-Yosh
1999-04-21 13:39:57 +08:00
|
|
|
void
|
1997-11-25 06:05:25 +08:00
|
|
|
hue_saturation (PixelRegion *srcPR,
|
|
|
|
PixelRegion *destPR,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
|
|
|
unsigned char *src, *s;
|
|
|
|
unsigned char *dest, *d;
|
|
|
|
int alpha;
|
|
|
|
int w, h;
|
|
|
|
int r, g, b;
|
|
|
|
int hue;
|
|
|
|
|
|
|
|
hsd = (HueSaturationDialog *) user_data;
|
|
|
|
|
|
|
|
/* Set the transfer arrays (for speed) */
|
|
|
|
h = srcPR->h;
|
|
|
|
src = srcPR->data;
|
|
|
|
dest = destPR->data;
|
|
|
|
alpha = (srcPR->bytes == 4) ? TRUE : FALSE;
|
|
|
|
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
w = srcPR->w;
|
|
|
|
s = src;
|
|
|
|
d = dest;
|
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
r = s[RED_PIX];
|
|
|
|
g = s[GREEN_PIX];
|
|
|
|
b = s[BLUE_PIX];
|
|
|
|
|
2000-01-03 09:58:43 +08:00
|
|
|
gimp_rgb_to_hls (&r, &g, &b);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (r < 43)
|
|
|
|
hue = 0;
|
|
|
|
else if (r < 85)
|
|
|
|
hue = 1;
|
|
|
|
else if (r < 128)
|
|
|
|
hue = 2;
|
|
|
|
else if (r < 171)
|
|
|
|
hue = 3;
|
|
|
|
else if (r < 213)
|
|
|
|
hue = 4;
|
|
|
|
else
|
|
|
|
hue = 5;
|
|
|
|
|
|
|
|
r = hue_transfer[hue][r];
|
|
|
|
g = lightness_transfer[hue][g];
|
|
|
|
b = saturation_transfer[hue][b];
|
|
|
|
|
2000-01-03 09:58:43 +08:00
|
|
|
gimp_hls_to_rgb (&r, &g, &b);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
d[RED_PIX] = r;
|
|
|
|
d[GREEN_PIX] = g;
|
|
|
|
d[BLUE_PIX] = b;
|
|
|
|
|
|
|
|
if (alpha)
|
|
|
|
d[ALPHA_PIX] = s[ALPHA_PIX];
|
|
|
|
|
|
|
|
s += srcPR->bytes;
|
|
|
|
d += destPR->bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
src += srcPR->rowstride;
|
|
|
|
dest += destPR->rowstride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* hue saturation action functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
1999-06-22 06:12:07 +08:00
|
|
|
hue_saturation_control (Tool *tool,
|
|
|
|
ToolAction action,
|
|
|
|
gpointer gdisp_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
1999-06-22 06:12:07 +08:00
|
|
|
case PAUSE:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
case RESUME:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
case HALT:
|
1997-11-25 06:05:25 +08:00
|
|
|
if (hue_saturation_dialog)
|
1999-06-23 23:24:46 +08:00
|
|
|
hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *
|
1999-11-22 19:14:29 +08:00
|
|
|
tools_new_hue_saturation (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
Tool * tool;
|
|
|
|
HueSaturation * private;
|
|
|
|
|
|
|
|
/* The tool options */
|
|
|
|
if (!hue_saturation_options)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
1999-04-13 01:55:06 +08:00
|
|
|
hue_saturation_options = tool_options_new (_("Hue-Saturation Options"));
|
|
|
|
tools_register (HUE_SATURATION, hue_saturation_options);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool = tools_new_tool (HUE_SATURATION);
|
|
|
|
private = g_new (HueSaturation, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->scroll_lock = TRUE; /* Disallow scrolling */
|
|
|
|
tool->preserve = FALSE; /* Don't preserve on drawable change */
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
tool->private = (void *) private;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
tool->control_func = hue_saturation_control;
|
|
|
|
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_free_hue_saturation (Tool *tool)
|
|
|
|
{
|
|
|
|
HueSaturation * color_bal;
|
|
|
|
|
|
|
|
color_bal = (HueSaturation *) tool->private;
|
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* Close the hue saturation dialog */
|
1997-11-25 06:05:25 +08:00
|
|
|
if (hue_saturation_dialog)
|
1998-04-02 12:51:44 +08:00
|
|
|
hue_saturation_cancel_callback (NULL, (gpointer) hue_saturation_dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
g_free (color_bal);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-06-22 04:17:21 +08:00
|
|
|
hue_saturation_initialize (GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (! drawable_color (gimage_active_drawable (gdisp->gimage)))
|
|
|
|
{
|
1998-11-23 22:47:09 +08:00
|
|
|
g_message (_("Hue-Saturation operates only on RGB color drawables."));
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
/* The "hue-saturation" dialog */
|
1997-11-25 06:05:25 +08:00
|
|
|
if (!hue_saturation_dialog)
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_dialog = hue_saturation_dialog_new ();
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
if (!GTK_WIDGET_VISIBLE (hue_saturation_dialog->shell))
|
|
|
|
gtk_widget_show (hue_saturation_dialog->shell);
|
|
|
|
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
{
|
|
|
|
hue_saturation_dialog->hue[i] = 0.0;
|
|
|
|
hue_saturation_dialog->lightness[i] = 0.0;
|
|
|
|
hue_saturation_dialog->saturation[i] = 0.0;
|
|
|
|
}
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
hue_saturation_dialog->drawable = gimage_active_drawable (gdisp->gimage);
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_dialog->image_map =
|
|
|
|
image_map_create (gdisp, hue_saturation_dialog->drawable);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
hue_saturation_update (hue_saturation_dialog, ALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_free (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
if (hue_saturation_dialog)
|
|
|
|
{
|
|
|
|
if (hue_saturation_dialog->image_map)
|
|
|
|
{
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
image_map_abort (hue_saturation_dialog->image_map);
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = FALSE;
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
hue_saturation_dialog->image_map = NULL;
|
|
|
|
}
|
|
|
|
gtk_widget_destroy (hue_saturation_dialog->shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-23 23:24:46 +08:00
|
|
|
/***************************/
|
|
|
|
/* Hue-Saturation dialog */
|
|
|
|
/***************************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static HueSaturationDialog *
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_dialog_new (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
|
|
|
GtkWidget *main_vbox;
|
|
|
|
GtkWidget *main_hbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *slider;
|
1999-11-22 19:14:29 +08:00
|
|
|
GtkWidget *abox;
|
|
|
|
GtkWidget *spinbutton;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *toggle;
|
|
|
|
GtkWidget *radio_button;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkObject *data;
|
|
|
|
GSList *group = NULL;
|
1999-09-28 01:58:10 +08:00
|
|
|
gint i;
|
1999-06-23 23:24:46 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
gchar *hue_partition_names[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-11-23 22:47:09 +08:00
|
|
|
N_("Master"),
|
|
|
|
N_("R"),
|
|
|
|
N_("Y"),
|
|
|
|
N_("G"),
|
|
|
|
N_("C"),
|
|
|
|
N_("B"),
|
|
|
|
N_("M")
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
1999-06-23 23:24:46 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
hsd = g_new (HueSaturationDialog, 1);
|
1999-11-22 19:14:29 +08:00
|
|
|
hsd->hue_partition = ALL_HUES;
|
1999-09-28 01:58:10 +08:00
|
|
|
hsd->preview = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The shell and main vbox */
|
1999-11-22 19:14:29 +08:00
|
|
|
hsd->shell = gimp_dialog_new (_("Hue-Saturation"), "hue_saturation",
|
1999-09-28 01:58:10 +08:00
|
|
|
tools_help_func, NULL,
|
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
|
|
|
_("OK"), hue_saturation_ok_callback,
|
|
|
|
hsd, NULL, TRUE, FALSE,
|
1999-12-02 21:00:18 +08:00
|
|
|
_("Reset"), hue_saturation_reset_callback,
|
|
|
|
hsd, NULL, FALSE, FALSE,
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Cancel"), hue_saturation_cancel_callback,
|
|
|
|
hsd, NULL, FALSE, TRUE,
|
|
|
|
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
|
1999-09-28 01:58:10 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (hsd->shell)->vbox), main_vbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The main hbox containing hue partitions and sliders */
|
1999-11-22 19:14:29 +08:00
|
|
|
main_hbox = gtk_hbox_new (FALSE, 4);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* The table containing hue partitions */
|
|
|
|
table = gtk_table_new (7, 2, FALSE);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_hbox), table, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* the radio buttons for hue partitions */
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
{
|
|
|
|
radio_button = gtk_radio_button_new_with_label (group, hue_partition_names[i]);
|
|
|
|
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button));
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_object_set_data (GTK_OBJECT (radio_button), "hue_partition",
|
|
|
|
(gpointer) i);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (!i)
|
|
|
|
{
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio_button, 0, 2, 0, 1,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_table_attach (GTK_TABLE (table), radio_button, 0, 1, i, i + 1,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), frame, 1, 2, i, i + 1,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
hsd->hue_partition_da[i - 1] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_preview_size (GTK_PREVIEW (hsd->hue_partition_da[i - 1]),
|
|
|
|
DA_WIDTH, DA_HEIGHT);
|
|
|
|
gtk_widget_set_events (hsd->hue_partition_da[i - 1],
|
|
|
|
HUE_PARTITION_MASK);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (hsd->hue_partition_da[i - 1]), "event",
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SIGNAL_FUNC (hue_saturation_hue_partition_events),
|
1997-11-25 06:05:25 +08:00
|
|
|
hsd);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hsd->hue_partition_da[i - 1]);
|
|
|
|
|
|
|
|
gtk_widget_show (hsd->hue_partition_da[i - 1]);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (radio_button), "toggled",
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SIGNAL_FUNC (hue_saturation_partition_callback),
|
1997-11-25 06:05:25 +08:00
|
|
|
hsd);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (radio_button);
|
|
|
|
}
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
/* The vbox for the table and preview toggle */
|
1999-11-22 19:14:29 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0);
|
|
|
|
|
1998-11-23 22:47:09 +08:00
|
|
|
label = gtk_label_new (_("Hue / Lightness / Saturation Adjustments"));
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* The table containing sliders */
|
|
|
|
table = gtk_table_new (3, 3, FALSE);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* Create the hue scale widget */
|
1998-11-23 22:47:09 +08:00
|
|
|
label = gtk_label_new (_("Hue"));
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
data = gtk_adjustment_new (0, -180, 180.0, 1.0, 1.0, 0.0);
|
|
|
|
hsd->hue_data = GTK_ADJUSTMENT (data);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
slider = gtk_hscale_new (hsd->hue_data);
|
|
|
|
gtk_widget_set_usize (slider, SLIDER_WIDTH, -1);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_scale_set_digits (GTK_SCALE (slider), 0);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), slider, 1, 2, 0, 1,
|
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
|
|
|
|
abox = gtk_vbox_new (FALSE, 0);
|
|
|
|
spinbutton = gtk_spin_button_new (hsd->hue_data, 1.0, 0);
|
|
|
|
gtk_widget_set_usize (spinbutton, 74, -1);
|
|
|
|
gtk_box_pack_end (GTK_BOX (abox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), abox, 2, 3, 0, 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (hsd->hue_data), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (hue_saturation_hue_adjustment_update),
|
1997-11-25 06:05:25 +08:00
|
|
|
hsd);
|
|
|
|
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_widget_show (slider);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
gtk_widget_show (abox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Create the lightness scale widget */
|
1998-11-23 22:47:09 +08:00
|
|
|
label = gtk_label_new (_("Lightness"));
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
data = gtk_adjustment_new (0, -100.0, 100.0, 1.0, 1.0, 0.0);
|
|
|
|
hsd->lightness_data = GTK_ADJUSTMENT (data);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
slider = gtk_hscale_new (hsd->lightness_data);
|
|
|
|
gtk_widget_set_usize (slider, SLIDER_WIDTH, -1);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_scale_set_digits (GTK_SCALE (slider), 0);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), slider, 1, 2, 1, 2,
|
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
|
|
|
|
abox = gtk_vbox_new (FALSE, 0);
|
|
|
|
spinbutton = gtk_spin_button_new (hsd->lightness_data, 1.0, 0);
|
|
|
|
gtk_widget_set_usize (spinbutton, 75, -1);
|
|
|
|
gtk_box_pack_end (GTK_BOX (abox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), abox, 2, 3, 1, 2,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (hsd->lightness_data), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (hue_saturation_lightness_adjustment_update),
|
1997-11-25 06:05:25 +08:00
|
|
|
hsd);
|
|
|
|
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_widget_show (slider);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
gtk_widget_show (abox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Create the saturation scale widget */
|
1998-11-23 22:47:09 +08:00
|
|
|
label = gtk_label_new (_("Saturation"));
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
data = gtk_adjustment_new (0, -100.0, 100.0, 1.0, 1.0, 0.0);
|
|
|
|
hsd->saturation_data = GTK_ADJUSTMENT (data);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
slider = gtk_hscale_new (hsd->saturation_data);
|
|
|
|
gtk_widget_set_usize (slider, SLIDER_WIDTH, -1);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_scale_set_digits (GTK_SCALE (slider), 0);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), slider, 1, 2, 2, 3,
|
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
abox = gtk_vbox_new (FALSE, 0);
|
|
|
|
spinbutton = gtk_spin_button_new (hsd->saturation_data, 1.0, 0);
|
|
|
|
gtk_widget_set_usize (spinbutton, 75, -1);
|
|
|
|
gtk_box_pack_end (GTK_BOX (abox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), abox, 2, 3, 2, 3,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (hsd->saturation_data), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (hue_saturation_saturation_adjustment_update),
|
1997-11-25 06:05:25 +08:00
|
|
|
hsd);
|
|
|
|
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_widget_show (slider);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
gtk_widget_show (abox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_widget_show (table);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
/* Horizontal box for preview toggle button */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The preview toggle */
|
1998-11-23 22:47:09 +08:00
|
|
|
toggle = gtk_check_button_new_with_label (_("Preview"));
|
1999-01-16 01:35:04 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), hsd->preview);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
|
1999-11-22 19:14:29 +08:00
|
|
|
GTK_SIGNAL_FUNC (hue_saturation_preview_update),
|
1997-11-25 06:05:25 +08:00
|
|
|
hsd);
|
|
|
|
|
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (main_hbox);
|
|
|
|
gtk_widget_show (main_vbox);
|
|
|
|
gtk_widget_show (hsd->shell);
|
|
|
|
|
|
|
|
return hsd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hue_saturation_update (HueSaturationDialog *hsd,
|
1999-11-22 19:14:29 +08:00
|
|
|
gint update)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
gint i, j, b;
|
|
|
|
gint rgb[3];
|
|
|
|
guchar buf[DA_WIDTH * 3];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (update & HUE_SLIDER)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (hsd->hue_data),
|
|
|
|
hsd->hue[hsd->hue_partition]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
if (update & LIGHTNESS_SLIDER)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (hsd->lightness_data),
|
|
|
|
hsd->lightness[hsd->hue_partition]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
if (update & SATURATION_SLIDER)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (hsd->saturation_data),
|
|
|
|
hsd->saturation[hsd->hue_partition]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
hue_saturation_calculate_transfers (hsd);
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
rgb[RED_PIX] = default_colors[i][RED_PIX];
|
1997-11-25 06:05:25 +08:00
|
|
|
rgb[GREEN_PIX] = default_colors[i][GREEN_PIX];
|
1999-11-22 19:14:29 +08:00
|
|
|
rgb[BLUE_PIX] = default_colors[i][BLUE_PIX];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-03 09:58:43 +08:00
|
|
|
gimp_rgb_to_hls (rgb, rgb + 1, rgb + 2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
rgb[RED_PIX] = hue_transfer[i][rgb[RED_PIX]];
|
1997-11-25 06:05:25 +08:00
|
|
|
rgb[GREEN_PIX] = lightness_transfer[i][rgb[GREEN_PIX]];
|
1999-11-22 19:14:29 +08:00
|
|
|
rgb[BLUE_PIX] = saturation_transfer[i][rgb[BLUE_PIX]];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-01-03 09:58:43 +08:00
|
|
|
gimp_hls_to_rgb (rgb, rgb + 1, rgb + 2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (j = 0; j < DA_WIDTH; j++)
|
|
|
|
for (b = 0; b < 3; b++)
|
1999-11-22 19:14:29 +08:00
|
|
|
buf[j * 3 + b] = (guchar) rgb[b];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (j = 0; j < DA_HEIGHT; j++)
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (hsd->hue_partition_da[i]),
|
|
|
|
buf, 0, j, DA_WIDTH);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (update & DRAW)
|
|
|
|
gtk_widget_draw (hsd->hue_partition_da[i], NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hue_saturation_preview (HueSaturationDialog *hsd)
|
|
|
|
{
|
|
|
|
if (!hsd->image_map)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
|
|
|
g_warning ("hue_saturation_preview(): No image map");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
image_map_apply (hsd->image_map, hue_saturation, (void *) hsd);
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
static void
|
|
|
|
hue_saturation_reset_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
|
|
|
|
|
|
|
hsd = (HueSaturationDialog *) data;
|
|
|
|
|
|
|
|
hsd->hue[hsd->hue_partition] = 0.0;
|
|
|
|
hsd->lightness[hsd->hue_partition] = 0.0;
|
|
|
|
hsd->saturation[hsd->hue_partition] = 0.0;
|
|
|
|
|
|
|
|
hue_saturation_update (hsd, ALL);
|
|
|
|
|
|
|
|
if (hsd->preview)
|
|
|
|
hue_saturation_preview (hsd);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
|
|
|
hue_saturation_ok_callback (GtkWidget *widget,
|
1999-11-22 19:14:29 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
hsd = (HueSaturationDialog *) data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (hsd->shell))
|
|
|
|
gtk_widget_hide (hsd->shell);
|
|
|
|
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = TRUE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (!hsd->preview)
|
|
|
|
image_map_apply (hsd->image_map, hue_saturation, (void *) hsd);
|
|
|
|
|
|
|
|
if (hsd->image_map)
|
|
|
|
image_map_commit (hsd->image_map);
|
|
|
|
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = FALSE;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
hsd->image_map = NULL;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
|
|
|
active_tool->gdisp_ptr = NULL;
|
|
|
|
active_tool->drawable = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hue_saturation_cancel_callback (GtkWidget *widget,
|
1999-11-22 19:14:29 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
hsd = (HueSaturationDialog *) data;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (GTK_WIDGET_VISIBLE (hsd->shell))
|
|
|
|
gtk_widget_hide (hsd->shell);
|
|
|
|
|
|
|
|
if (hsd->image_map)
|
|
|
|
{
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
image_map_abort (hsd->image_map);
|
1998-03-31 15:23:50 +08:00
|
|
|
active_tool->preserve = FALSE;
|
1999-06-23 23:24:46 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gdisplays_flush ();
|
1999-06-26 19:16:47 +08:00
|
|
|
hsd->image_map = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-06-26 19:16:47 +08:00
|
|
|
|
|
|
|
active_tool->gdisp_ptr = NULL;
|
|
|
|
active_tool->drawable = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_partition_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
1999-11-22 19:14:29 +08:00
|
|
|
HueRange partition;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
hsd = (HueSaturationDialog *) data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
partition = (HueRange) gtk_object_get_data (GTK_OBJECT (widget),
|
|
|
|
"hue_partition");
|
|
|
|
hsd->hue_partition = partition;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
hue_saturation_update (hsd, ALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_preview_update (GtkWidget *widget,
|
1997-11-25 06:05:25 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
|
|
|
|
|
|
|
hsd = (HueSaturationDialog *) data;
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
if (GTK_TOGGLE_BUTTON (widget)->active)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
hsd->preview = TRUE;
|
|
|
|
hue_saturation_preview (hsd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hsd->preview = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_hue_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
|
|
|
|
|
|
|
hsd = (HueSaturationDialog *) data;
|
|
|
|
|
|
|
|
if (hsd->hue[hsd->hue_partition] != adjustment->value)
|
|
|
|
{
|
|
|
|
hsd->hue[hsd->hue_partition] = adjustment->value;
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_update (hsd, DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (hsd->preview)
|
|
|
|
hue_saturation_preview (hsd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_lightness_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
|
|
|
|
|
|
|
hsd = (HueSaturationDialog *) data;
|
|
|
|
|
|
|
|
if (hsd->lightness[hsd->hue_partition] != adjustment->value)
|
|
|
|
{
|
|
|
|
hsd->lightness[hsd->hue_partition] = adjustment->value;
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_update (hsd, DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (hsd->preview)
|
|
|
|
hue_saturation_preview (hsd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_saturation_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
HueSaturationDialog *hsd;
|
|
|
|
|
|
|
|
hsd = (HueSaturationDialog *) data;
|
|
|
|
|
|
|
|
if (hsd->saturation[hsd->hue_partition] != adjustment->value)
|
|
|
|
{
|
|
|
|
hsd->saturation[hsd->hue_partition] = adjustment->value;
|
1999-11-22 19:14:29 +08:00
|
|
|
hue_saturation_update (hsd, DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (hsd->preview)
|
|
|
|
hue_saturation_preview (hsd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
hue_saturation_hue_partition_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
HueSaturationDialog *hsd)
|
|
|
|
{
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
|
|
|
hue_saturation_update (hsd, HUE_PARTITION);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|