mirror of https://github.com/GNOME/gimp.git
Bug 749902 - Add Hue-Chroma operation/tool and LCH color selector
Add LCH to the color selectors, patch by Elle Stone and myself. - Extend enum GimpColorSelectorChannel by LCH channels - Support them in GimpColorScale, GimpColorScales and GimpColorSelect - Did not yet remove the HSV channels until things are working 100% ok - Change drawing in GimpColorSelect to be much faster, to compensate for babl_process() making the LCH modes pretty slow - Clean up stuff in GimpColorSelect This is WIP and should not be considered finished, biggest TODO is displaying out-of-gamut values in GimpColorScales' spinbuttons.
This commit is contained in:
parent
127e7daeb2
commit
2b167d6337
|
@ -54,12 +54,21 @@ enum
|
|||
};
|
||||
|
||||
|
||||
typedef struct _GimpLCH GimpLCH;
|
||||
|
||||
struct _GimpLCH
|
||||
{
|
||||
gdouble l, c, h, a;
|
||||
};
|
||||
|
||||
|
||||
typedef struct _GimpColorScalePrivate GimpColorScalePrivate;
|
||||
|
||||
struct _GimpColorScalePrivate
|
||||
{
|
||||
GimpColorConfig *config;
|
||||
GimpColorTransform *transform;
|
||||
guchar oog_color[3];
|
||||
};
|
||||
|
||||
#define GET_PRIVATE(obj) \
|
||||
|
@ -98,12 +107,18 @@ static void gimp_color_scale_render_stipple (GimpColorScale *scale);
|
|||
|
||||
static void gimp_color_scale_create_transform (GimpColorScale *scale);
|
||||
static void gimp_color_scale_destroy_transform (GimpColorScale *scale);
|
||||
static void gimp_color_scale_notify_config (GimpColorConfig *config,
|
||||
const GParamSpec *pspec,
|
||||
GimpColorScale *scale);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpColorScale, gimp_color_scale, GTK_TYPE_SCALE)
|
||||
|
||||
#define parent_class gimp_color_scale_parent_class
|
||||
|
||||
static const Babl *fish_rgb_to_lch = NULL;
|
||||
static const Babl *fish_lch_to_rgb = NULL;
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_scale_class_init (GimpColorScaleClass *klass)
|
||||
|
@ -138,6 +153,18 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
|
|||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (GimpColorScalePrivate));
|
||||
|
||||
/* This is so ugly... we have to babl_init() here so the binary
|
||||
* generated by gtk-doc to scan libgimpwidgets' types won't crash.
|
||||
* I didn't find a way to inject this line of code into the
|
||||
* generated source.
|
||||
*/
|
||||
babl_init ();
|
||||
|
||||
fish_rgb_to_lch = babl_fish (babl_format ("R'G'B'A double"),
|
||||
babl_format ("CIE LCH(ab) double"));
|
||||
fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) double"),
|
||||
babl_format ("R'G'B' double"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -706,7 +733,7 @@ gimp_color_scale_set_color_config (GimpColorScale *scale,
|
|||
if (priv->config)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (priv->config,
|
||||
gimp_color_scale_destroy_transform,
|
||||
gimp_color_scale_notify_config,
|
||||
scale);
|
||||
g_object_unref (priv->config);
|
||||
|
||||
|
@ -719,9 +746,11 @@ gimp_color_scale_set_color_config (GimpColorScale *scale,
|
|||
{
|
||||
g_object_ref (priv->config);
|
||||
|
||||
g_signal_connect_swapped (priv->config, "notify",
|
||||
G_CALLBACK (gimp_color_scale_destroy_transform),
|
||||
scale);
|
||||
g_signal_connect (priv->config, "notify",
|
||||
G_CALLBACK (gimp_color_scale_notify_config),
|
||||
scale);
|
||||
|
||||
gimp_color_scale_notify_config (priv->config, NULL, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -753,15 +782,19 @@ should_invert (GtkRange *range)
|
|||
static void
|
||||
gimp_color_scale_render (GimpColorScale *scale)
|
||||
{
|
||||
GtkRange *range = GTK_RANGE (scale);
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
guint x, y;
|
||||
gdouble *channel_value = NULL; /* shut up compiler */
|
||||
gboolean to_rgb = FALSE;
|
||||
gboolean invert;
|
||||
guchar *buf;
|
||||
guchar *d;
|
||||
GimpColorScalePrivate *priv = GET_PRIVATE (scale);
|
||||
GtkRange *range = GTK_RANGE (scale);
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
GimpLCH lch;
|
||||
gint multiplier = 1;
|
||||
guint x, y;
|
||||
gdouble *channel_value = NULL; /* shut up compiler */
|
||||
gboolean from_hsv = FALSE;
|
||||
gboolean from_lch = FALSE;
|
||||
gboolean invert;
|
||||
guchar *buf;
|
||||
guchar *d;
|
||||
|
||||
if ((buf = scale->buf) == NULL)
|
||||
return;
|
||||
|
@ -774,16 +807,22 @@ gimp_color_scale_render (GimpColorScale *scale)
|
|||
|
||||
rgb = scale->rgb;
|
||||
hsv = scale->hsv;
|
||||
babl_process (fish_rgb_to_lch, &rgb, &lch, 1);
|
||||
|
||||
switch (scale->channel)
|
||||
{
|
||||
case GIMP_COLOR_SELECTOR_HUE: channel_value = &hsv.h; break;
|
||||
case GIMP_COLOR_SELECTOR_SATURATION: channel_value = &hsv.s; break;
|
||||
case GIMP_COLOR_SELECTOR_VALUE: channel_value = &hsv.v; break;
|
||||
|
||||
case GIMP_COLOR_SELECTOR_RED: channel_value = &rgb.r; break;
|
||||
case GIMP_COLOR_SELECTOR_GREEN: channel_value = &rgb.g; break;
|
||||
case GIMP_COLOR_SELECTOR_BLUE: channel_value = &rgb.b; break;
|
||||
case GIMP_COLOR_SELECTOR_ALPHA: channel_value = &rgb.a; break;
|
||||
|
||||
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS: channel_value = &lch.l; break;
|
||||
case GIMP_COLOR_SELECTOR_LCH_CHROMA: channel_value = &lch.c; break;
|
||||
case GIMP_COLOR_SELECTOR_LCH_HUE: channel_value = &lch.h; break;
|
||||
}
|
||||
|
||||
switch (scale->channel)
|
||||
|
@ -791,7 +830,20 @@ gimp_color_scale_render (GimpColorScale *scale)
|
|||
case GIMP_COLOR_SELECTOR_HUE:
|
||||
case GIMP_COLOR_SELECTOR_SATURATION:
|
||||
case GIMP_COLOR_SELECTOR_VALUE:
|
||||
to_rgb = TRUE;
|
||||
from_hsv = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS:
|
||||
multiplier = 100;
|
||||
from_lch = TRUE;
|
||||
break;
|
||||
case GIMP_COLOR_SELECTOR_LCH_CHROMA:
|
||||
multiplier = 100;
|
||||
from_lch = TRUE;
|
||||
break;
|
||||
case GIMP_COLOR_SELECTOR_LCH_HUE:
|
||||
multiplier = 360;
|
||||
from_lch = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -805,18 +857,31 @@ gimp_color_scale_render (GimpColorScale *scale)
|
|||
case GTK_ORIENTATION_HORIZONTAL:
|
||||
for (x = 0, d = buf; x < scale->width; x++, d += 4)
|
||||
{
|
||||
gdouble value = (gdouble) x / (gdouble) (scale->width - 1);
|
||||
gdouble value = (gdouble) x * multiplier / (gdouble) (scale->width - 1);
|
||||
guchar r, g, b;
|
||||
|
||||
if (invert)
|
||||
value = 1.0 - value;
|
||||
value = multiplier - value;
|
||||
|
||||
*channel_value = value;
|
||||
|
||||
if (to_rgb)
|
||||
if (from_hsv)
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
else if (from_lch)
|
||||
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
||||
|
||||
gimp_rgb_get_uchar (&rgb, &r, &g, &b);
|
||||
if (rgb.r < 0.0 || rgb.r > 1.0 ||
|
||||
rgb.g < 0.0 || rgb.g > 1.0 ||
|
||||
rgb.b < 0.0 || rgb.b > 1.0)
|
||||
{
|
||||
r = priv->oog_color[0];
|
||||
g = priv->oog_color[1];
|
||||
b = priv->oog_color[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_rgb_get_uchar (&rgb, &r, &g, &b);
|
||||
}
|
||||
|
||||
GIMP_CAIRO_RGB24_SET_PIXEL (d, r, g, b);
|
||||
}
|
||||
|
@ -832,18 +897,31 @@ gimp_color_scale_render (GimpColorScale *scale)
|
|||
case GTK_ORIENTATION_VERTICAL:
|
||||
for (y = 0; y < scale->height; y++)
|
||||
{
|
||||
gdouble value = (gdouble) y / (gdouble) (scale->height - 1);
|
||||
gdouble value = (gdouble) y * multiplier / (gdouble) (scale->height - 1);
|
||||
guchar r, g, b;
|
||||
|
||||
if (invert)
|
||||
value = 1.0 - value;
|
||||
value = multiplier - value;
|
||||
|
||||
*channel_value = value;
|
||||
|
||||
if (to_rgb)
|
||||
if (from_hsv)
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
else if (from_lch)
|
||||
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
||||
|
||||
gimp_rgb_get_uchar (&rgb, &r, &g, &b);
|
||||
if (rgb.r < 0.0 || rgb.r > 1.0 ||
|
||||
rgb.g < 0.0 || rgb.g > 1.0 ||
|
||||
rgb.b < 0.0 || rgb.b > 1.0)
|
||||
{
|
||||
r = priv->oog_color[0];
|
||||
g = priv->oog_color[1];
|
||||
b = priv->oog_color[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_rgb_get_uchar (&rgb, &r, &g, &b);
|
||||
}
|
||||
|
||||
for (x = 0, d = buf; x < scale->width; x++, d += 4)
|
||||
{
|
||||
|
@ -1053,3 +1131,19 @@ gimp_color_scale_destroy_transform (GimpColorScale *scale)
|
|||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (scale));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_scale_notify_config (GimpColorConfig *config,
|
||||
const GParamSpec *pspec,
|
||||
GimpColorScale *scale)
|
||||
{
|
||||
GimpColorScalePrivate *priv = GET_PRIVATE (scale);
|
||||
|
||||
gimp_color_scale_destroy_transform (scale);
|
||||
|
||||
gimp_rgb_get_uchar (&config->out_of_gamut_color,
|
||||
priv->oog_color,
|
||||
priv->oog_color + 1,
|
||||
priv->oog_color + 2);
|
||||
scale->needs_render = TRUE;
|
||||
}
|
||||
|
|
|
@ -49,10 +49,18 @@
|
|||
*
|
||||
* The #GimpColorScales widget is an implementation of a
|
||||
* #GimpColorSelector. It shows a group of #GimpColorScale widgets
|
||||
* that allow to adjust the HSV and RGB color channels.
|
||||
* that allow to adjust the HSV, LCH, and RGB color channels.
|
||||
**/
|
||||
|
||||
|
||||
typedef struct _GimpLCH GimpLCH;
|
||||
|
||||
struct _GimpLCH
|
||||
{
|
||||
gdouble l, c, h, a;
|
||||
};
|
||||
|
||||
|
||||
#define GIMP_COLOR_SCALES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_SCALES, GimpColorScalesClass))
|
||||
#define GIMP_IS_COLOR_SCALES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_SCALES))
|
||||
#define GIMP_COLOR_SCALES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_SCALES, GimpColorScalesClass))
|
||||
|
@ -64,9 +72,9 @@ struct _GimpColorScales
|
|||
{
|
||||
GimpColorSelector parent_instance;
|
||||
|
||||
GtkWidget *toggles[7];
|
||||
GtkWidget *sliders[7];
|
||||
GtkObject *slider_data[7];
|
||||
GtkWidget *toggles[10];
|
||||
GtkWidget *sliders[10];
|
||||
GtkObject *slider_data[10];
|
||||
};
|
||||
|
||||
struct _GimpColorScalesClass
|
||||
|
@ -92,9 +100,9 @@ static void gimp_color_scales_set_config (GimpColorSelector *selector,
|
|||
|
||||
static void gimp_color_scales_update_scales (GimpColorScales *scales,
|
||||
gint skip);
|
||||
static void gimp_color_scales_toggle_update (GtkWidget *widget,
|
||||
static void gimp_color_scales_toggle_changed (GtkWidget *widget,
|
||||
GimpColorScales *scales);
|
||||
static void gimp_color_scales_scale_update (GtkAdjustment *adjustment,
|
||||
static void gimp_color_scales_scale_changed (GtkAdjustment *adjustment,
|
||||
GimpColorScales *scales);
|
||||
|
||||
|
||||
|
@ -102,6 +110,9 @@ G_DEFINE_TYPE (GimpColorScales, gimp_color_scales, GIMP_TYPE_COLOR_SELECTOR)
|
|||
|
||||
#define parent_class gimp_color_scales_parent_class
|
||||
|
||||
static const Babl *fish_rgb_to_lch = NULL;
|
||||
static const Babl *fish_lch_to_rgb = NULL;
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_scales_class_init (GimpColorScalesClass *klass)
|
||||
|
@ -117,6 +128,11 @@ gimp_color_scales_class_init (GimpColorScalesClass *klass)
|
|||
selector_class->set_color = gimp_color_scales_set_color;
|
||||
selector_class->set_channel = gimp_color_scales_set_channel;
|
||||
selector_class->set_config = gimp_color_scales_set_config;
|
||||
|
||||
fish_rgb_to_lch = babl_fish (babl_format ("R'G'B'A double"),
|
||||
babl_format ("CIE LCH(ab) double"));
|
||||
fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) double"),
|
||||
babl_format ("R'G'B' double"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -129,19 +145,21 @@ gimp_color_scales_init (GimpColorScales *scales)
|
|||
gint i;
|
||||
|
||||
static const gdouble slider_initial_vals[] =
|
||||
{ 0, 0, 0, 0, 0, 0, 0 };
|
||||
/*{ H, S, V, R, G, B, A, L, C, H }*/
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
static const gdouble slider_max_vals[] =
|
||||
{ 360, 100, 100, 100, 100, 100, 100 };
|
||||
{ 360, 100, 100, 100, 100, 100, 100, 100, 100, 360 };
|
||||
static const gdouble slider_incs[] =
|
||||
{ 30, 10, 10, 16, 16, 16, 10 };
|
||||
{ 30, 10, 10, 16, 16, 16, 10, 10, 10, 30 };
|
||||
|
||||
/* don't needs the toggles for our own operation */
|
||||
selector->toggles_visible = FALSE;
|
||||
|
||||
table = gtk_table_new (7, 4, FALSE);
|
||||
table = gtk_table_new (11, 4, FALSE);
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 1);
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), 2, 5); /* hsv <-> rgb */
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), 5, 5); /* rgb <-> alpha */
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), 2, 5); /* hsv <-> rgb */
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), 5, 5); /* rgb <-> alpha */
|
||||
gtk_table_set_row_spacing (GTK_TABLE (table), 6, 5); /* alpha <-> lch */
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (scales), table, FALSE, FALSE, 0);
|
||||
|
@ -151,11 +169,9 @@ gimp_color_scales_init (GimpColorScales *scales)
|
|||
|
||||
group = NULL;
|
||||
|
||||
for (i = GIMP_COLOR_SELECTOR_HUE; i <= GIMP_COLOR_SELECTOR_ALPHA; i++)
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
GimpEnumDesc *enum_desc;
|
||||
|
||||
enum_desc = gimp_enum_get_desc (enum_class, i);
|
||||
GimpEnumDesc *enum_desc = gimp_enum_get_desc (enum_class, i);
|
||||
|
||||
if (i == GIMP_COLOR_SELECTOR_ALPHA)
|
||||
{
|
||||
|
@ -176,7 +192,7 @@ gimp_color_scales_init (GimpColorScales *scales)
|
|||
gettext (enum_desc->value_help), NULL);
|
||||
|
||||
g_signal_connect (scales->toggles[i], "toggled",
|
||||
G_CALLBACK (gimp_color_scales_toggle_update),
|
||||
G_CALLBACK (gimp_color_scales_toggle_changed),
|
||||
scales);
|
||||
}
|
||||
|
||||
|
@ -198,7 +214,7 @@ gimp_color_scales_init (GimpColorScales *scales)
|
|||
gimp_color_scale_set_channel (GIMP_COLOR_SCALE (scales->sliders[i]), i);
|
||||
|
||||
g_signal_connect (scales->slider_data[i], "value-changed",
|
||||
G_CALLBACK (gimp_color_scales_scale_update),
|
||||
G_CALLBACK (gimp_color_scales_scale_changed),
|
||||
scales);
|
||||
}
|
||||
|
||||
|
@ -212,8 +228,9 @@ gimp_color_scales_togg_sensitive (GimpColorSelector *selector,
|
|||
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
gtk_widget_set_sensitive (scales->toggles[i], sensitive);
|
||||
for (i = 0; i < 10; i++)
|
||||
if (scales->toggles[i])
|
||||
gtk_widget_set_sensitive (scales->toggles[i], sensitive);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -223,8 +240,9 @@ gimp_color_scales_togg_visible (GimpColorSelector *selector,
|
|||
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
gtk_widget_set_visible (scales->toggles[i], visible);
|
||||
for (i = 0; i < 10; i++)
|
||||
if (scales->toggles[i])
|
||||
gtk_widget_set_visible (scales->toggles[i], visible);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -269,17 +287,17 @@ gimp_color_scales_set_channel (GimpColorSelector *selector,
|
|||
{
|
||||
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
||||
|
||||
if (channel < 7)
|
||||
if (scales->toggles[channel])
|
||||
{
|
||||
g_signal_handlers_block_by_func (scales->toggles[channel],
|
||||
gimp_color_scales_toggle_update,
|
||||
gimp_color_scales_toggle_changed,
|
||||
scales);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scales->toggles[channel]),
|
||||
TRUE);
|
||||
|
||||
g_signal_handlers_unblock_by_func (scales->toggles[channel],
|
||||
gimp_color_scales_toggle_update,
|
||||
gimp_color_scales_toggle_changed,
|
||||
scales);
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +309,7 @@ gimp_color_scales_set_config (GimpColorSelector *selector,
|
|||
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
if (scales->sliders[i])
|
||||
gimp_color_scale_set_color_config (GIMP_COLOR_SCALE (scales->sliders[i]),
|
||||
|
@ -304,30 +322,38 @@ gimp_color_scales_update_scales (GimpColorScales *scales,
|
|||
gint skip)
|
||||
{
|
||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
||||
gint values[7];
|
||||
GimpLCH lch;
|
||||
gdouble values[10];
|
||||
gint i;
|
||||
|
||||
values[GIMP_COLOR_SELECTOR_HUE] = ROUND (selector->hsv.h * 360.0);
|
||||
values[GIMP_COLOR_SELECTOR_SATURATION] = ROUND (selector->hsv.s * 100.0);
|
||||
values[GIMP_COLOR_SELECTOR_VALUE] = ROUND (selector->hsv.v * 100.0);
|
||||
values[GIMP_COLOR_SELECTOR_RED] = ROUND (selector->rgb.r * 100.0);
|
||||
values[GIMP_COLOR_SELECTOR_GREEN] = ROUND (selector->rgb.g * 100.0);
|
||||
values[GIMP_COLOR_SELECTOR_BLUE] = ROUND (selector->rgb.b * 100.0);
|
||||
values[GIMP_COLOR_SELECTOR_ALPHA] = ROUND (selector->rgb.a * 100.0);
|
||||
babl_process (fish_rgb_to_lch, &selector->rgb, &lch, 1);
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
values[GIMP_COLOR_SELECTOR_HUE] = selector->hsv.h * 360.0;
|
||||
values[GIMP_COLOR_SELECTOR_SATURATION] = selector->hsv.s * 100.0;
|
||||
values[GIMP_COLOR_SELECTOR_VALUE] = selector->hsv.v * 100.0;
|
||||
|
||||
values[GIMP_COLOR_SELECTOR_RED] = selector->rgb.r * 100.0;
|
||||
values[GIMP_COLOR_SELECTOR_GREEN] = selector->rgb.g * 100.0;
|
||||
values[GIMP_COLOR_SELECTOR_BLUE] = selector->rgb.b * 100.0;
|
||||
values[GIMP_COLOR_SELECTOR_ALPHA] = selector->rgb.a * 100.0;
|
||||
|
||||
values[GIMP_COLOR_SELECTOR_LCH_LIGHTNESS] = lch.l;
|
||||
values[GIMP_COLOR_SELECTOR_LCH_CHROMA] = lch.c;
|
||||
values[GIMP_COLOR_SELECTOR_LCH_HUE] = lch.h;
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
if (i != skip)
|
||||
{
|
||||
g_signal_handlers_block_by_func (scales->slider_data[i],
|
||||
gimp_color_scales_scale_update,
|
||||
gimp_color_scales_scale_changed,
|
||||
scales);
|
||||
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (scales->slider_data[i]),
|
||||
values[i]);
|
||||
|
||||
g_signal_handlers_unblock_by_func (scales->slider_data[i],
|
||||
gimp_color_scales_scale_update,
|
||||
gimp_color_scales_scale_changed,
|
||||
scales);
|
||||
}
|
||||
|
||||
|
@ -337,8 +363,8 @@ gimp_color_scales_update_scales (GimpColorScales *scales,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_color_scales_toggle_update (GtkWidget *widget,
|
||||
GimpColorScales *scales)
|
||||
gimp_color_scales_toggle_changed (GtkWidget *widget,
|
||||
GimpColorScales *scales)
|
||||
{
|
||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
||||
|
||||
|
@ -346,7 +372,7 @@ gimp_color_scales_toggle_update (GtkWidget *widget,
|
|||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
for (i = 0; i < 10; i++)
|
||||
if (widget == scales->toggles[i])
|
||||
{
|
||||
selector->channel = (GimpColorSelectorChannel) i;
|
||||
|
@ -358,14 +384,15 @@ gimp_color_scales_toggle_update (GtkWidget *widget,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_color_scales_scale_update (GtkAdjustment *adjustment,
|
||||
GimpColorScales *scales)
|
||||
gimp_color_scales_scale_changed (GtkAdjustment *adjustment,
|
||||
GimpColorScales *scales)
|
||||
{
|
||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
||||
gdouble value = gtk_adjustment_get_value (adjustment);
|
||||
GimpLCH lch;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < 7; i++)
|
||||
for (i = 0; i < 10; i++)
|
||||
if (scales->slider_data[i] == GTK_OBJECT (adjustment))
|
||||
break;
|
||||
|
||||
|
@ -398,13 +425,36 @@ gimp_color_scales_scale_update (GtkAdjustment *adjustment,
|
|||
case GIMP_COLOR_SELECTOR_ALPHA:
|
||||
selector->hsv.a = selector->rgb.a = value / 100.0;
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS:
|
||||
babl_process (fish_rgb_to_lch, &selector->rgb, &lch, 1);
|
||||
lch.l = value;
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_SELECTOR_LCH_CHROMA:
|
||||
babl_process (fish_rgb_to_lch, &selector->rgb, &lch, 1);
|
||||
lch.c = value;
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_SELECTOR_LCH_HUE:
|
||||
babl_process (fish_rgb_to_lch, &selector->rgb, &lch, 1);
|
||||
lch.h = value;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((i >= GIMP_COLOR_SELECTOR_HUE) && (i <= GIMP_COLOR_SELECTOR_VALUE))
|
||||
if ((i >= GIMP_COLOR_SELECTOR_HUE) &&
|
||||
(i <= GIMP_COLOR_SELECTOR_VALUE))
|
||||
{
|
||||
gimp_hsv_to_rgb (&selector->hsv, &selector->rgb);
|
||||
}
|
||||
else if ((i >= GIMP_COLOR_SELECTOR_RED) && (i <= GIMP_COLOR_SELECTOR_BLUE))
|
||||
else if ((i >= GIMP_COLOR_SELECTOR_LCH_LIGHTNESS) &&
|
||||
(i <= GIMP_COLOR_SELECTOR_LCH_HUE))
|
||||
{
|
||||
babl_process (fish_lch_to_rgb, &lch, &selector->rgb, 1);
|
||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
||||
}
|
||||
else if ((i >= GIMP_COLOR_SELECTOR_RED) &&
|
||||
(i <= GIMP_COLOR_SELECTOR_BLUE))
|
||||
{
|
||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -118,18 +118,24 @@ gimp_color_selector_channel_get_type (void)
|
|||
{ GIMP_COLOR_SELECTOR_GREEN, "GIMP_COLOR_SELECTOR_GREEN", "green" },
|
||||
{ GIMP_COLOR_SELECTOR_BLUE, "GIMP_COLOR_SELECTOR_BLUE", "blue" },
|
||||
{ GIMP_COLOR_SELECTOR_ALPHA, "GIMP_COLOR_SELECTOR_ALPHA", "alpha" },
|
||||
{ GIMP_COLOR_SELECTOR_LCH_LIGHTNESS, "GIMP_COLOR_SELECTOR_LCH_LIGHTNESS", "lch-lightness" },
|
||||
{ GIMP_COLOR_SELECTOR_LCH_CHROMA, "GIMP_COLOR_SELECTOR_LCH_CHROMA", "lch-chroma" },
|
||||
{ GIMP_COLOR_SELECTOR_LCH_HUE, "GIMP_COLOR_SELECTOR_LCH_HUE", "lch-hue" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_COLOR_SELECTOR_HUE, NC_("color-selector-channel", "_H"), N_("Hue") },
|
||||
{ GIMP_COLOR_SELECTOR_SATURATION, NC_("color-selector-channel", "_S"), N_("Saturation") },
|
||||
{ GIMP_COLOR_SELECTOR_VALUE, NC_("color-selector-channel", "_V"), N_("Value") },
|
||||
{ GIMP_COLOR_SELECTOR_HUE, NC_("color-selector-channel", "_H"), N_("HSV Hue") },
|
||||
{ GIMP_COLOR_SELECTOR_SATURATION, NC_("color-selector-channel", "_S"), N_("HSV Saturation") },
|
||||
{ GIMP_COLOR_SELECTOR_VALUE, NC_("color-selector-channel", "_V"), N_("HSV Value") },
|
||||
{ GIMP_COLOR_SELECTOR_RED, NC_("color-selector-channel", "_R"), N_("Red") },
|
||||
{ GIMP_COLOR_SELECTOR_GREEN, NC_("color-selector-channel", "_G"), N_("Green") },
|
||||
{ GIMP_COLOR_SELECTOR_BLUE, NC_("color-selector-channel", "_B"), N_("Blue") },
|
||||
{ GIMP_COLOR_SELECTOR_ALPHA, NC_("color-selector-channel", "_A"), N_("Alpha") },
|
||||
{ GIMP_COLOR_SELECTOR_LCH_LIGHTNESS, NC_("color-selector-channel", "_L"), N_("LCH Lightness") },
|
||||
{ GIMP_COLOR_SELECTOR_LCH_CHROMA, NC_("color-selector-channel", "_C"), N_("LCH Chroma") },
|
||||
{ GIMP_COLOR_SELECTOR_LCH_HUE, NC_("color-selector-channel", "_H"), N_("LCH Hue") },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -89,13 +89,16 @@ typedef enum
|
|||
|
||||
/**
|
||||
* GimpColorSelectorChannel:
|
||||
* @GIMP_COLOR_SELECTOR_HUE: the hue channel
|
||||
* @GIMP_COLOR_SELECTOR_SATURATION: the saturation channel
|
||||
* @GIMP_COLOR_SELECTOR_VALUE: the value channel
|
||||
* @GIMP_COLOR_SELECTOR_RED: the red channel
|
||||
* @GIMP_COLOR_SELECTOR_GREEN: the green channel
|
||||
* @GIMP_COLOR_SELECTOR_BLUE: the blue channel
|
||||
* @GIMP_COLOR_SELECTOR_ALPHA: the alpha channel
|
||||
* @GIMP_COLOR_SELECTOR_HUE: the hue channel
|
||||
* @GIMP_COLOR_SELECTOR_SATURATION: the saturation channel
|
||||
* @GIMP_COLOR_SELECTOR_VALUE: the value channel
|
||||
* @GIMP_COLOR_SELECTOR_RED: the red channel
|
||||
* @GIMP_COLOR_SELECTOR_GREEN: the green channel
|
||||
* @GIMP_COLOR_SELECTOR_BLUE: the blue channel
|
||||
* @GIMP_COLOR_SELECTOR_ALPHA: the alpha channel
|
||||
* @GIMP_COLOR_SELECTOR_LCH_LIGHTNESS: the lightness channel
|
||||
* @GIMP_COLOR_SELECTOR_LCH_CHOMA: the chroma channel
|
||||
* @GIMP_COLOR_SELECTOR_LCH_HUE: the hue channel
|
||||
*
|
||||
* An enum to specify the types of color channels edited in
|
||||
* #GimpColorSelector widgets.
|
||||
|
@ -106,13 +109,16 @@ GType gimp_color_selector_channel_get_type (void) G_GNUC_CONST;
|
|||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_COLOR_SELECTOR_HUE, /*< desc="_H", help="Hue" >*/
|
||||
GIMP_COLOR_SELECTOR_SATURATION, /*< desc="_S", help="Saturation" >*/
|
||||
GIMP_COLOR_SELECTOR_VALUE, /*< desc="_V", help="Value" >*/
|
||||
GIMP_COLOR_SELECTOR_RED, /*< desc="_R", help="Red" >*/
|
||||
GIMP_COLOR_SELECTOR_GREEN, /*< desc="_G", help="Green" >*/
|
||||
GIMP_COLOR_SELECTOR_BLUE, /*< desc="_B", help="Blue" >*/
|
||||
GIMP_COLOR_SELECTOR_ALPHA /*< desc="_A", help="Alpha" >*/
|
||||
GIMP_COLOR_SELECTOR_HUE, /*< desc="_H", help="HSV Hue" >*/
|
||||
GIMP_COLOR_SELECTOR_SATURATION, /*< desc="_S", help="HSV Saturation" >*/
|
||||
GIMP_COLOR_SELECTOR_VALUE, /*< desc="_V", help="HSV Value" >*/
|
||||
GIMP_COLOR_SELECTOR_RED, /*< desc="_R", help="Red" >*/
|
||||
GIMP_COLOR_SELECTOR_GREEN, /*< desc="_G", help="Green" >*/
|
||||
GIMP_COLOR_SELECTOR_BLUE, /*< desc="_B", help="Blue" >*/
|
||||
GIMP_COLOR_SELECTOR_ALPHA, /*< desc="_A", help="Alpha" >*/
|
||||
GIMP_COLOR_SELECTOR_LCH_LIGHTNESS, /*< desc="_L", help="LCH Lightness" >*/
|
||||
GIMP_COLOR_SELECTOR_LCH_CHROMA, /*< desc="_C", help="LCH Chroma" >*/
|
||||
GIMP_COLOR_SELECTOR_LCH_HUE /*< desc="_H", help="LCH Hue" >*/
|
||||
} GimpColorSelectorChannel;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue