mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to GeglColor. Yet it's not **really** space-invaded yet. What we need to do now: 1. Take into account the image space, and this is what we must navigate through, in particular for various representations of RGB or HSV. I.e. that if the active image is in anyRGB, the RGB values shown must be within anyRGB. Right now, everything is still shown/used as sRGB (even though it's properly retrieved and transformed to the target space thanks to GeglColor). 2. Show space info to make things clear and explicit, by adding some label somewhere. 3. Allow to switch between image and softproof spaces, regarding out-of-gamut display. I.e. that while RGB/HSV must be shown within the image space (assuming it's anyRGB), we may want to show out-of-gamut area (pink areas) within the softproof space. This may mean adding a checkbox. Or maybe simply taking into account whether we are in softproof mode or not? 4. We can likely move off gimp_widget_get_color_transform() into using gimp_widget_get_render_space() for display drawing. We don't need any soft-proofing or black point compensation for any of these widgets so pure babl is fine. Indeed we want to show any in-gamut color correctly (and not transformed according to specific intents or through soft-proofing). We will take care of the proofing case with out-of-gamut area showing only. 5. In the various drawing functions, we should move to CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough that it makes sense to be more accurate, especially as we are essentially showing color gradients in 1 or 2 directions in these various widgets.
This commit is contained in:
parent
4d798ecfed
commit
9833ebd0ee
14 changed files with 571 additions and 602 deletions
|
@ -84,8 +84,7 @@ static void gimp_color_editor_bg_changed (GimpContext *context,
|
||||||
GeglColor *color,
|
GeglColor *color,
|
||||||
GimpColorEditor *editor);
|
GimpColorEditor *editor);
|
||||||
static void gimp_color_editor_color_changed (GimpColorSelector *selector,
|
static void gimp_color_editor_color_changed (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
|
||||||
GimpColorEditor *editor);
|
GimpColorEditor *editor);
|
||||||
static void gimp_color_editor_tab_toggled (GtkWidget *widget,
|
static void gimp_color_editor_tab_toggled (GtkWidget *widget,
|
||||||
GimpColorEditor *editor);
|
GimpColorEditor *editor);
|
||||||
|
@ -155,8 +154,7 @@ gimp_color_editor_init (GimpColorEditor *editor)
|
||||||
gint content_spacing;
|
gint content_spacing;
|
||||||
gint button_spacing;
|
gint button_spacing;
|
||||||
GtkIconSize button_icon_size;
|
GtkIconSize button_icon_size;
|
||||||
GimpRGB rgb;
|
GeglColor *color;
|
||||||
GimpHSV hsv;
|
|
||||||
GList *list;
|
GList *list;
|
||||||
GSList *group;
|
GSList *group;
|
||||||
gint icon_width = 40;
|
gint icon_width = 40;
|
||||||
|
@ -165,9 +163,6 @@ gimp_color_editor_init (GimpColorEditor *editor)
|
||||||
editor->context = NULL;
|
editor->context = NULL;
|
||||||
editor->edit_bg = FALSE;
|
editor->edit_bg = FALSE;
|
||||||
|
|
||||||
gimp_rgba_set (&rgb, 0.0, 0.0, 0.0, 1.0);
|
|
||||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
|
||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (editor),
|
gtk_widget_style_get (GTK_WIDGET (editor),
|
||||||
"content-spacing", &content_spacing,
|
"content-spacing", &content_spacing,
|
||||||
"button-spacing", &button_spacing,
|
"button-spacing", &button_spacing,
|
||||||
|
@ -179,9 +174,10 @@ gimp_color_editor_init (GimpColorEditor *editor)
|
||||||
gtk_box_pack_start (GTK_BOX (editor), editor->hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (editor), editor->hbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (editor->hbox);
|
gtk_widget_show (editor->hbox);
|
||||||
|
|
||||||
editor->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK,
|
color = gegl_color_new ("black");
|
||||||
&rgb, &hsv,
|
editor->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK, color,
|
||||||
GIMP_COLOR_SELECTOR_RED);
|
GIMP_COLOR_SELECTOR_RED);
|
||||||
|
g_object_unref (color);
|
||||||
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (editor->notebook),
|
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (editor->notebook),
|
||||||
FALSE);
|
FALSE);
|
||||||
gtk_box_pack_start (GTK_BOX (editor), editor->notebook,
|
gtk_box_pack_start (GTK_BOX (editor), editor->notebook,
|
||||||
|
@ -538,18 +534,11 @@ static void
|
||||||
gimp_color_editor_set_color (GimpColorEditor *editor,
|
gimp_color_editor_set_color (GimpColorEditor *editor,
|
||||||
GeglColor *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpRGB rgb;
|
|
||||||
GimpHSV hsv;
|
|
||||||
|
|
||||||
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
|
||||||
|
|
||||||
g_signal_handlers_block_by_func (editor->notebook,
|
g_signal_handlers_block_by_func (editor->notebook,
|
||||||
gimp_color_editor_color_changed,
|
gimp_color_editor_color_changed,
|
||||||
editor);
|
editor);
|
||||||
|
|
||||||
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (editor->notebook),
|
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (editor->notebook), color);
|
||||||
&rgb, &hsv);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (editor->notebook,
|
g_signal_handlers_unblock_by_func (editor->notebook,
|
||||||
gimp_color_editor_color_changed,
|
gimp_color_editor_color_changed,
|
||||||
|
@ -586,14 +575,9 @@ gimp_color_editor_bg_changed (GimpContext *context,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_editor_color_changed (GimpColorSelector *selector,
|
gimp_color_editor_color_changed (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
|
||||||
GimpColorEditor *editor)
|
GimpColorEditor *editor)
|
||||||
{
|
{
|
||||||
GeglColor *color = gegl_color_new ("black");
|
|
||||||
|
|
||||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
|
||||||
|
|
||||||
if (editor->context)
|
if (editor->context)
|
||||||
{
|
{
|
||||||
if (editor->edit_bg)
|
if (editor->edit_bg)
|
||||||
|
@ -631,8 +615,6 @@ gimp_color_editor_color_changed (GimpColorSelector *selector,
|
||||||
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
||||||
gimp_color_editor_entry_changed,
|
gimp_color_editor_entry_changed,
|
||||||
editor);
|
editor);
|
||||||
|
|
||||||
g_object_unref (color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -40,8 +40,7 @@
|
||||||
|
|
||||||
|
|
||||||
static void gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
static void gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
|
||||||
static void gimp_color_selector_palette_set_config (GimpColorSelector *selector,
|
static void gimp_color_selector_palette_set_config (GimpColorSelector *selector,
|
||||||
GimpColorConfig *config);
|
GimpColorConfig *config);
|
||||||
|
|
||||||
|
@ -74,8 +73,7 @@ gimp_color_selector_palette_init (GimpColorSelectorPalette *select)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color)
|
||||||
const GimpHSV *hsv)
|
|
||||||
{
|
{
|
||||||
GimpColorSelectorPalette *select = GIMP_COLOR_SELECTOR_PALETTE (selector);
|
GimpColorSelectorPalette *select = GIMP_COLOR_SELECTOR_PALETTE (selector);
|
||||||
|
|
||||||
|
@ -86,17 +84,13 @@ gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
||||||
if (palette && gimp_palette_get_n_colors (palette) > 0)
|
if (palette && gimp_palette_get_n_colors (palette) > 0)
|
||||||
{
|
{
|
||||||
GimpPaletteEntry *entry;
|
GimpPaletteEntry *entry;
|
||||||
GeglColor *color = gegl_color_new ("black");
|
|
||||||
|
|
||||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
|
||||||
entry = gimp_palette_find_entry (palette, color,
|
entry = gimp_palette_find_entry (palette, color,
|
||||||
GIMP_PALETTE_VIEW (select->view)->selected);
|
GIMP_PALETTE_VIEW (select->view)->selected);
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (select->view),
|
gimp_palette_view_select_entry (GIMP_PALETTE_VIEW (select->view),
|
||||||
entry);
|
entry);
|
||||||
|
|
||||||
g_object_unref (color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,10 +109,7 @@ gimp_color_selector_palette_entry_clicked (GimpPaletteView *view,
|
||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
GimpColorSelector *selector)
|
GimpColorSelector *selector)
|
||||||
{
|
{
|
||||||
gegl_color_get_pixel (entry->color, babl_format ("R'G'B'A double"), &selector->rgb);
|
gimp_color_selector_set_color (selector, entry->color);
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
|
||||||
|
|
||||||
gimp_color_selector_emit_color_changed (selector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -72,8 +72,7 @@ static void gimp_color_notebook_togg_sensitive (GimpColorSelector *selector,
|
||||||
static void gimp_color_notebook_set_show_alpha (GimpColorSelector *selector,
|
static void gimp_color_notebook_set_show_alpha (GimpColorSelector *selector,
|
||||||
gboolean show_alpha);
|
gboolean show_alpha);
|
||||||
static void gimp_color_notebook_set_color (GimpColorSelector *selector,
|
static void gimp_color_notebook_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
|
||||||
static void gimp_color_notebook_set_channel (GimpColorSelector *selector,
|
static void gimp_color_notebook_set_channel (GimpColorSelector *selector,
|
||||||
GimpColorSelectorChannel channel);
|
GimpColorSelectorChannel channel);
|
||||||
static void gimp_color_notebook_set_model_visible
|
static void gimp_color_notebook_set_model_visible
|
||||||
|
@ -90,8 +89,7 @@ static void gimp_color_notebook_switch_page (GtkNotebook *gtk_notebo
|
||||||
GimpColorNotebook *notebook);
|
GimpColorNotebook *notebook);
|
||||||
|
|
||||||
static void gimp_color_notebook_color_changed (GimpColorSelector *page,
|
static void gimp_color_notebook_color_changed (GimpColorSelector *page,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
|
||||||
GimpColorNotebook *notebook);
|
GimpColorNotebook *notebook);
|
||||||
static void gimp_color_notebook_channel_changed (GimpColorSelector *page,
|
static void gimp_color_notebook_channel_changed (GimpColorSelector *page,
|
||||||
GimpColorSelectorChannel channel,
|
GimpColorSelectorChannel channel,
|
||||||
|
@ -270,8 +268,7 @@ gimp_color_notebook_set_show_alpha (GimpColorSelector *selector,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_notebook_set_color (GimpColorSelector *selector,
|
gimp_color_notebook_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color)
|
||||||
const GimpHSV *hsv)
|
|
||||||
{
|
{
|
||||||
GimpColorNotebookPrivate *private = GET_PRIVATE (selector);
|
GimpColorNotebookPrivate *private = GET_PRIVATE (selector);
|
||||||
|
|
||||||
|
@ -279,7 +276,7 @@ gimp_color_notebook_set_color (GimpColorSelector *selector,
|
||||||
gimp_color_notebook_color_changed,
|
gimp_color_notebook_color_changed,
|
||||||
selector);
|
selector);
|
||||||
|
|
||||||
gimp_color_selector_set_color (private->cur_page, rgb, hsv);
|
gimp_color_selector_set_color (private->cur_page, color);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (private->cur_page,
|
g_signal_handlers_unblock_by_func (private->cur_page,
|
||||||
gimp_color_notebook_color_changed,
|
gimp_color_notebook_color_changed,
|
||||||
|
@ -345,6 +342,7 @@ gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
|
||||||
GimpColorNotebookPrivate *private = GET_PRIVATE (notebook);
|
GimpColorNotebookPrivate *private = GET_PRIVATE (notebook);
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
|
||||||
GtkWidget *page_widget;
|
GtkWidget *page_widget;
|
||||||
|
GeglColor *color;
|
||||||
GimpColorSelectorModel model;
|
GimpColorSelectorModel model;
|
||||||
|
|
||||||
page_widget = gtk_notebook_get_nth_page (gtk_notebook, page_num);
|
page_widget = gtk_notebook_get_nth_page (gtk_notebook, page_num);
|
||||||
|
@ -361,9 +359,9 @@ gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
|
||||||
gimp_color_notebook_model_visible_changed,
|
gimp_color_notebook_model_visible_changed,
|
||||||
notebook);
|
notebook);
|
||||||
|
|
||||||
gimp_color_selector_set_color (private->cur_page,
|
color = gimp_color_selector_get_color (selector);
|
||||||
&selector->rgb,
|
gimp_color_selector_set_color (private->cur_page, color);
|
||||||
&selector->hsv);
|
g_object_unref (color);
|
||||||
gimp_color_selector_set_channel (private->cur_page,
|
gimp_color_selector_set_channel (private->cur_page,
|
||||||
gimp_color_selector_get_channel (selector));
|
gimp_color_selector_get_channel (selector));
|
||||||
|
|
||||||
|
@ -390,16 +388,12 @@ gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_notebook_color_changed (GimpColorSelector *page,
|
gimp_color_notebook_color_changed (GimpColorSelector *page,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
|
||||||
GimpColorNotebook *notebook)
|
GimpColorNotebook *notebook)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
|
||||||
|
|
||||||
selector->rgb = *rgb;
|
gimp_color_selector_set_color (selector, color);
|
||||||
selector->hsv = *hsv;
|
|
||||||
|
|
||||||
gimp_color_selector_emit_color_changed (selector);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -434,12 +428,13 @@ gimp_color_notebook_add_page (GimpColorNotebook *notebook,
|
||||||
GtkWidget *menu_widget;
|
GtkWidget *menu_widget;
|
||||||
GtkWidget *image;
|
GtkWidget *image;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
|
GeglColor *color;
|
||||||
gboolean show_alpha;
|
gboolean show_alpha;
|
||||||
|
|
||||||
page = gimp_color_selector_new (page_type,
|
color = gimp_color_selector_get_color (selector);
|
||||||
&selector->rgb,
|
page = gimp_color_selector_new (page_type, color,
|
||||||
&selector->hsv,
|
|
||||||
gimp_color_selector_get_channel (selector));
|
gimp_color_selector_get_channel (selector));
|
||||||
|
g_object_unref (color);
|
||||||
|
|
||||||
if (! page)
|
if (! page)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -69,8 +69,7 @@ struct _GimpColorScalePrivate
|
||||||
guchar oog_color[3];
|
guchar oog_color[3];
|
||||||
|
|
||||||
GimpColorSelectorChannel channel;
|
GimpColorSelectorChannel channel;
|
||||||
GimpRGB rgb;
|
GeglColor *color;
|
||||||
GimpHSV hsv;
|
|
||||||
|
|
||||||
guchar *buf;
|
guchar *buf;
|
||||||
guint width;
|
guint width;
|
||||||
|
@ -115,6 +114,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GimpColorScale, gimp_color_scale, GTK_TYPE_SCALE)
|
||||||
|
|
||||||
static const Babl *fish_rgb_to_lch = NULL;
|
static const Babl *fish_rgb_to_lch = NULL;
|
||||||
static const Babl *fish_lch_to_rgb = NULL;
|
static const Babl *fish_lch_to_rgb = NULL;
|
||||||
|
static const Babl *fish_hsv_to_rgb = NULL;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -153,6 +153,8 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
|
||||||
babl_format ("CIE LCH(ab) double"));
|
babl_format ("CIE LCH(ab) double"));
|
||||||
fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) double"),
|
fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) double"),
|
||||||
babl_format ("R'G'B' double"));
|
babl_format ("R'G'B' double"));
|
||||||
|
fish_hsv_to_rgb = babl_fish (babl_format ("HSV double"),
|
||||||
|
babl_format ("R'G'B' double"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -178,8 +180,7 @@ gimp_color_scale_init (GimpColorScale *scale)
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (range),
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (range),
|
||||||
GTK_ORIENTATION_HORIZONTAL);
|
GTK_ORIENTATION_HORIZONTAL);
|
||||||
|
|
||||||
gimp_rgba_set (&priv->rgb, 0.0, 0.0, 0.0, 1.0);
|
priv->color = gegl_color_new ("black");
|
||||||
gimp_rgb_to_hsv (&priv->rgb, &priv->hsv);
|
|
||||||
|
|
||||||
gimp_widget_track_monitor (GTK_WIDGET (scale),
|
gimp_widget_track_monitor (GTK_WIDGET (scale),
|
||||||
G_CALLBACK (gimp_color_scale_destroy_transform),
|
G_CALLBACK (gimp_color_scale_destroy_transform),
|
||||||
|
@ -227,6 +228,7 @@ gimp_color_scale_finalize (GObject *object)
|
||||||
priv->width = 0;
|
priv->width = 0;
|
||||||
priv->height = 0;
|
priv->height = 0;
|
||||||
priv->rowstride = 0;
|
priv->rowstride = 0;
|
||||||
|
g_object_unref (priv->color);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -309,6 +311,7 @@ gimp_color_scale_draw (GtkWidget *widget,
|
||||||
GdkRectangle range_rect;
|
GdkRectangle range_rect;
|
||||||
GdkRectangle area = { 0, };
|
GdkRectangle area = { 0, };
|
||||||
cairo_surface_t *buffer;
|
cairo_surface_t *buffer;
|
||||||
|
guchar *buf = NULL;
|
||||||
gint slider_start;
|
gint slider_start;
|
||||||
gint slider_end;
|
gint slider_end;
|
||||||
gint slider_mid;
|
gint slider_mid;
|
||||||
|
@ -336,11 +339,11 @@ gimp_color_scale_draw (GtkWidget *widget,
|
||||||
if (priv->transform)
|
if (priv->transform)
|
||||||
{
|
{
|
||||||
const Babl *format = babl_format ("cairo-RGB24");
|
const Babl *format = babl_format ("cairo-RGB24");
|
||||||
guchar *buf = g_new (guchar, priv->rowstride * priv->height);
|
|
||||||
guchar *src = priv->buf;
|
guchar *src = priv->buf;
|
||||||
guchar *dest = buf;
|
guchar *dest = buf;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
buf = g_new (guchar, priv->rowstride * priv->height);
|
||||||
for (i = 0; i < priv->height; i++)
|
for (i = 0; i < priv->height; i++)
|
||||||
{
|
{
|
||||||
gimp_color_transform_process_pixels (priv->transform,
|
gimp_color_transform_process_pixels (priv->transform,
|
||||||
|
@ -548,29 +551,32 @@ gimp_color_scale_set_channel (GimpColorScale *scale,
|
||||||
/**
|
/**
|
||||||
* gimp_color_scale_set_color:
|
* gimp_color_scale_set_color:
|
||||||
* @scale: a #GimpColorScale widget
|
* @scale: a #GimpColorScale widget
|
||||||
* @rgb: the new color as #GimpRGB
|
* @color: the new color.
|
||||||
* @hsv: the new color as #GimpHSV
|
|
||||||
*
|
*
|
||||||
* Changes the color value of the @scale.
|
* Changes the color value of the @scale.
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_color_scale_set_color (GimpColorScale *scale,
|
gimp_color_scale_set_color (GimpColorScale *scale,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color)
|
||||||
const GimpHSV *hsv)
|
|
||||||
{
|
{
|
||||||
GimpColorScalePrivate *priv;
|
GimpColorScalePrivate *priv;
|
||||||
|
GeglColor *old_color;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SCALE (scale));
|
g_return_if_fail (GIMP_IS_COLOR_SCALE (scale));
|
||||||
g_return_if_fail (rgb != NULL);
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
g_return_if_fail (hsv != NULL);
|
|
||||||
|
|
||||||
priv = GET_PRIVATE (scale);
|
priv = GET_PRIVATE (scale);
|
||||||
|
|
||||||
priv->rgb = *rgb;
|
old_color = priv->color;
|
||||||
priv->hsv = *hsv;
|
priv->color = gegl_color_duplicate (color);
|
||||||
|
|
||||||
priv->needs_render = TRUE;
|
if (! gimp_color_is_perceptually_identical (old_color, priv->color))
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (scale));
|
{
|
||||||
|
priv->needs_render = TRUE;
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (scale));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (old_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -646,12 +652,12 @@ gimp_color_scale_render (GimpColorScale *scale)
|
||||||
{
|
{
|
||||||
GimpColorScalePrivate *priv = GET_PRIVATE (scale);
|
GimpColorScalePrivate *priv = GET_PRIVATE (scale);
|
||||||
GtkRange *range = GTK_RANGE (scale);
|
GtkRange *range = GTK_RANGE (scale);
|
||||||
GimpRGB rgb;
|
gdouble rgb[4];
|
||||||
GimpHSV hsv;
|
gdouble hsv[3];
|
||||||
GimpLCH lch;
|
gdouble lch[3];
|
||||||
gint multiplier = 1;
|
gint multiplier = 1;
|
||||||
guint x, y;
|
guint x, y;
|
||||||
gdouble *channel_value = NULL; /* shut up compiler */
|
gdouble *channel_value = NULL;
|
||||||
gboolean from_hsv = FALSE;
|
gboolean from_hsv = FALSE;
|
||||||
gboolean from_lch = FALSE;
|
gboolean from_lch = FALSE;
|
||||||
gboolean invert;
|
gboolean invert;
|
||||||
|
@ -667,24 +673,24 @@ gimp_color_scale_render (GimpColorScale *scale)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rgb = priv->rgb;
|
gegl_color_get_pixel (priv->color, babl_format ("R'G'B'A double"), rgb);
|
||||||
hsv = priv->hsv;
|
gegl_color_get_pixel (priv->color, babl_format ("HSV double"), hsv);
|
||||||
babl_process (fish_rgb_to_lch, &rgb, &lch, 1);
|
gegl_color_get_pixel (priv->color, babl_format ("CIE LCH(ab) double"), lch);
|
||||||
|
|
||||||
switch (priv->channel)
|
switch (priv->channel)
|
||||||
{
|
{
|
||||||
case GIMP_COLOR_SELECTOR_HUE: channel_value = &hsv.h; break;
|
case GIMP_COLOR_SELECTOR_HUE: channel_value = &hsv[0]; break;
|
||||||
case GIMP_COLOR_SELECTOR_SATURATION: channel_value = &hsv.s; break;
|
case GIMP_COLOR_SELECTOR_SATURATION: channel_value = &hsv[1]; break;
|
||||||
case GIMP_COLOR_SELECTOR_VALUE: channel_value = &hsv.v; break;
|
case GIMP_COLOR_SELECTOR_VALUE: channel_value = &hsv[2]; break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_RED: channel_value = &rgb.r; break;
|
case GIMP_COLOR_SELECTOR_RED: channel_value = &rgb[0]; break;
|
||||||
case GIMP_COLOR_SELECTOR_GREEN: channel_value = &rgb.g; break;
|
case GIMP_COLOR_SELECTOR_GREEN: channel_value = &rgb[1]; break;
|
||||||
case GIMP_COLOR_SELECTOR_BLUE: channel_value = &rgb.b; break;
|
case GIMP_COLOR_SELECTOR_BLUE: channel_value = &rgb[2]; break;
|
||||||
case GIMP_COLOR_SELECTOR_ALPHA: channel_value = &rgb.a; break;
|
case GIMP_COLOR_SELECTOR_ALPHA: channel_value = &rgb[3]; break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS: channel_value = &lch.l; break;
|
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS: channel_value = &lch[0]; break;
|
||||||
case GIMP_COLOR_SELECTOR_LCH_CHROMA: channel_value = &lch.c; break;
|
case GIMP_COLOR_SELECTOR_LCH_CHROMA: channel_value = &lch[1]; break;
|
||||||
case GIMP_COLOR_SELECTOR_LCH_HUE: channel_value = &lch.h; break;
|
case GIMP_COLOR_SELECTOR_LCH_HUE: channel_value = &lch[2]; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (priv->channel)
|
switch (priv->channel)
|
||||||
|
@ -720,7 +726,7 @@ gimp_color_scale_render (GimpColorScale *scale)
|
||||||
for (x = 0, d = buf; x < priv->width; x++, d += 4)
|
for (x = 0, d = buf; x < priv->width; x++, d += 4)
|
||||||
{
|
{
|
||||||
gdouble value = (gdouble) x * multiplier / (gdouble) (priv->width - 1);
|
gdouble value = (gdouble) x * multiplier / (gdouble) (priv->width - 1);
|
||||||
guchar r, g, b;
|
guchar u8rgb[3];
|
||||||
|
|
||||||
if (invert)
|
if (invert)
|
||||||
value = multiplier - value;
|
value = multiplier - value;
|
||||||
|
@ -728,24 +734,31 @@ gimp_color_scale_render (GimpColorScale *scale)
|
||||||
*channel_value = value;
|
*channel_value = value;
|
||||||
|
|
||||||
if (from_hsv)
|
if (from_hsv)
|
||||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
babl_process (fish_hsv_to_rgb, &hsv, &rgb, 1);
|
||||||
else if (from_lch)
|
else if (from_lch)
|
||||||
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
||||||
|
|
||||||
if (rgb.r < 0.0 || rgb.r > 1.0 ||
|
/* This is only checking if a color is within the sRGB gamut. I want
|
||||||
rgb.g < 0.0 || rgb.g > 1.0 ||
|
* to check compared to the image's space (anySpace) or softproof
|
||||||
rgb.b < 0.0 || rgb.b > 1.0)
|
* space. TODO.
|
||||||
|
*/
|
||||||
|
if (rgb[0] < 0.0 || rgb[0] > 1.0 ||
|
||||||
|
rgb[1] < 0.0 || rgb[1] > 1.0 ||
|
||||||
|
rgb[2] < 0.0 || rgb[2] > 1.0)
|
||||||
{
|
{
|
||||||
r = priv->oog_color[0];
|
u8rgb[0] = priv->oog_color[0];
|
||||||
g = priv->oog_color[1];
|
u8rgb[1] = priv->oog_color[1];
|
||||||
b = priv->oog_color[2];
|
u8rgb[2] = priv->oog_color[2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_rgb_get_uchar (&rgb, &r, &g, &b);
|
u8rgb[0] = rgb[0] * 255;
|
||||||
|
u8rgb[1] = rgb[1] * 255;
|
||||||
|
u8rgb[2] = rgb[2] * 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
GIMP_CAIRO_RGB24_SET_PIXEL (d, r, g, b);
|
/* TODO: we should move to CAIRO_FORMAT_RGBA128F. */
|
||||||
|
GIMP_CAIRO_RGB24_SET_PIXEL (d, u8rgb[0], u8rgb[1], u8rgb[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
d = buf + priv->rowstride;
|
d = buf + priv->rowstride;
|
||||||
|
@ -760,7 +773,7 @@ gimp_color_scale_render (GimpColorScale *scale)
|
||||||
for (y = 0; y < priv->height; y++)
|
for (y = 0; y < priv->height; y++)
|
||||||
{
|
{
|
||||||
gdouble value = (gdouble) y * multiplier / (gdouble) (priv->height - 1);
|
gdouble value = (gdouble) y * multiplier / (gdouble) (priv->height - 1);
|
||||||
guchar r, g, b;
|
guchar u8rgb[3];
|
||||||
|
|
||||||
if (invert)
|
if (invert)
|
||||||
value = multiplier - value;
|
value = multiplier - value;
|
||||||
|
@ -768,27 +781,27 @@ gimp_color_scale_render (GimpColorScale *scale)
|
||||||
*channel_value = value;
|
*channel_value = value;
|
||||||
|
|
||||||
if (from_hsv)
|
if (from_hsv)
|
||||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
babl_process (fish_hsv_to_rgb, &hsv, &rgb, 1);
|
||||||
else if (from_lch)
|
else if (from_lch)
|
||||||
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
||||||
|
|
||||||
if (rgb.r < 0.0 || rgb.r > 1.0 ||
|
if (rgb[0] < 0.0 || rgb[0] > 1.0 ||
|
||||||
rgb.g < 0.0 || rgb.g > 1.0 ||
|
rgb[1] < 0.0 || rgb[1] > 1.0 ||
|
||||||
rgb.b < 0.0 || rgb.b > 1.0)
|
rgb[2] < 0.0 || rgb[2] > 1.0)
|
||||||
{
|
{
|
||||||
r = priv->oog_color[0];
|
u8rgb[0] = priv->oog_color[0];
|
||||||
g = priv->oog_color[1];
|
u8rgb[1] = priv->oog_color[1];
|
||||||
b = priv->oog_color[2];
|
u8rgb[2] = priv->oog_color[2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_rgb_get_uchar (&rgb, &r, &g, &b);
|
u8rgb[0] = rgb[0] * 255;
|
||||||
|
u8rgb[1] = rgb[1] * 255;
|
||||||
|
u8rgb[2] = rgb[2] * 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (x = 0, d = buf; x < priv->width; x++, d += 4)
|
for (x = 0, d = buf; x < priv->width; x++, d += 4)
|
||||||
{
|
GIMP_CAIRO_RGB24_SET_PIXEL (d, u8rgb[0], u8rgb[1], u8rgb[2]);
|
||||||
GIMP_CAIRO_RGB24_SET_PIXEL (d, r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
buf += priv->rowstride;
|
buf += priv->rowstride;
|
||||||
}
|
}
|
||||||
|
@ -801,7 +814,7 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
|
||||||
{
|
{
|
||||||
GimpColorScalePrivate *priv = GET_PRIVATE (scale);
|
GimpColorScalePrivate *priv = GET_PRIVATE (scale);
|
||||||
GtkRange *range = GTK_RANGE (scale);
|
GtkRange *range = GTK_RANGE (scale);
|
||||||
GimpRGB rgb;
|
gdouble rgb[4];
|
||||||
gboolean invert;
|
gboolean invert;
|
||||||
gdouble a;
|
gdouble a;
|
||||||
guint x, y;
|
guint x, y;
|
||||||
|
@ -811,7 +824,7 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
|
||||||
invert = should_invert (range);
|
invert = should_invert (range);
|
||||||
|
|
||||||
buf = priv->buf;
|
buf = priv->buf;
|
||||||
rgb = priv->rgb;
|
gegl_color_get_pixel (priv->color, babl_format ("R'G'B'A double"), rgb);
|
||||||
|
|
||||||
switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)))
|
switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)))
|
||||||
{
|
{
|
||||||
|
@ -843,20 +856,20 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
|
||||||
|
|
||||||
GIMP_CAIRO_RGB24_SET_PIXEL (l,
|
GIMP_CAIRO_RGB24_SET_PIXEL (l,
|
||||||
(GIMP_CHECK_LIGHT +
|
(GIMP_CHECK_LIGHT +
|
||||||
(rgb.r - GIMP_CHECK_LIGHT) * a) * 255.999,
|
(rgb[0] - GIMP_CHECK_LIGHT) * a) * 255.999,
|
||||||
(GIMP_CHECK_LIGHT +
|
(GIMP_CHECK_LIGHT +
|
||||||
(rgb.g - GIMP_CHECK_LIGHT) * a) * 255.999,
|
(rgb[1] - GIMP_CHECK_LIGHT) * a) * 255.999,
|
||||||
(GIMP_CHECK_LIGHT +
|
(GIMP_CHECK_LIGHT +
|
||||||
(rgb.b - GIMP_CHECK_LIGHT) * a) * 255.999);
|
(rgb[2] - GIMP_CHECK_LIGHT) * a) * 255.999);
|
||||||
l += 4;
|
l += 4;
|
||||||
|
|
||||||
GIMP_CAIRO_RGB24_SET_PIXEL (d,
|
GIMP_CAIRO_RGB24_SET_PIXEL (d,
|
||||||
(GIMP_CHECK_DARK +
|
(GIMP_CHECK_DARK +
|
||||||
(rgb.r - GIMP_CHECK_DARK) * a) * 255.999,
|
(rgb[0] - GIMP_CHECK_DARK) * a) * 255.999,
|
||||||
(GIMP_CHECK_DARK +
|
(GIMP_CHECK_DARK +
|
||||||
(rgb.g - GIMP_CHECK_DARK) * a) * 255.999,
|
(rgb[1] - GIMP_CHECK_DARK) * a) * 255.999,
|
||||||
(GIMP_CHECK_DARK +
|
(GIMP_CHECK_DARK +
|
||||||
(rgb.b - GIMP_CHECK_DARK) * a) * 255.999);
|
(rgb[2] - GIMP_CHECK_DARK) * a) * 255.999);
|
||||||
d += 4;
|
d += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,19 +900,19 @@ gimp_color_scale_render_alpha (GimpColorScale *scale)
|
||||||
|
|
||||||
GIMP_CAIRO_RGB24_SET_PIXEL (light,
|
GIMP_CAIRO_RGB24_SET_PIXEL (light,
|
||||||
(GIMP_CHECK_LIGHT +
|
(GIMP_CHECK_LIGHT +
|
||||||
(rgb.r - GIMP_CHECK_LIGHT) * a) * 255.999,
|
(rgb[0] - GIMP_CHECK_LIGHT) * a) * 255.999,
|
||||||
(GIMP_CHECK_LIGHT +
|
(GIMP_CHECK_LIGHT +
|
||||||
(rgb.g - GIMP_CHECK_LIGHT) * a) * 255.999,
|
(rgb[1] - GIMP_CHECK_LIGHT) * a) * 255.999,
|
||||||
(GIMP_CHECK_LIGHT +
|
(GIMP_CHECK_LIGHT +
|
||||||
(rgb.b - GIMP_CHECK_LIGHT) * a) * 255.999);
|
(rgb[2] - GIMP_CHECK_LIGHT) * a) * 255.999);
|
||||||
|
|
||||||
GIMP_CAIRO_RGB24_SET_PIXEL (dark,
|
GIMP_CAIRO_RGB24_SET_PIXEL (dark,
|
||||||
(GIMP_CHECK_DARK +
|
(GIMP_CHECK_DARK +
|
||||||
(rgb.r - GIMP_CHECK_DARK) * a) * 255.999,
|
(rgb[0] - GIMP_CHECK_DARK) * a) * 255.999,
|
||||||
(GIMP_CHECK_DARK +
|
(GIMP_CHECK_DARK +
|
||||||
(rgb.g - GIMP_CHECK_DARK) * a) * 255.999,
|
(rgb[1] - GIMP_CHECK_DARK) * a) * 255.999,
|
||||||
(GIMP_CHECK_DARK +
|
(GIMP_CHECK_DARK +
|
||||||
(rgb.b - GIMP_CHECK_DARK) * a) * 255.999);
|
(rgb[2] - GIMP_CHECK_DARK) * a) * 255.999);
|
||||||
|
|
||||||
for (x = 0, l = d; x < priv->width; x++, l += 4)
|
for (x = 0, l = d; x < priv->width; x++, l += 4)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,8 +71,7 @@ GtkWidget * gimp_color_scale_new (GtkOrientation orienta
|
||||||
void gimp_color_scale_set_channel (GimpColorScale *scale,
|
void gimp_color_scale_set_channel (GimpColorScale *scale,
|
||||||
GimpColorSelectorChannel channel);
|
GimpColorSelectorChannel channel);
|
||||||
void gimp_color_scale_set_color (GimpColorScale *scale,
|
void gimp_color_scale_set_color (GimpColorScale *scale,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
|
||||||
|
|
||||||
void gimp_color_scale_set_color_config (GimpColorScale *scale,
|
void gimp_color_scale_set_color_config (GimpColorScale *scale,
|
||||||
GimpColorConfig *config);
|
GimpColorConfig *config);
|
||||||
|
|
|
@ -69,14 +69,6 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpLCH GimpLCH;
|
|
||||||
|
|
||||||
struct _GimpLCH
|
|
||||||
{
|
|
||||||
gdouble l, c, h, a;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _ColorScale ColorScale;
|
typedef struct _ColorScale ColorScale;
|
||||||
|
|
||||||
struct _ColorScale
|
struct _ColorScale
|
||||||
|
@ -143,8 +135,7 @@ static void gimp_color_scales_togg_visible (GimpColorSelector *selector,
|
||||||
static void gimp_color_scales_set_show_alpha (GimpColorSelector *selector,
|
static void gimp_color_scales_set_show_alpha (GimpColorSelector *selector,
|
||||||
gboolean show_alpha);
|
gboolean show_alpha);
|
||||||
static void gimp_color_scales_set_color (GimpColorSelector *selector,
|
static void gimp_color_scales_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
|
||||||
static void gimp_color_scales_set_channel (GimpColorSelector *selector,
|
static void gimp_color_scales_set_channel (GimpColorSelector *selector,
|
||||||
GimpColorSelectorChannel channel);
|
GimpColorSelectorChannel channel);
|
||||||
static void gimp_color_scales_set_model_visible
|
static void gimp_color_scales_set_model_visible
|
||||||
|
@ -380,7 +371,7 @@ gimp_color_scales_init (GimpColorScales *scales)
|
||||||
scales->show_hsv_binding = NULL;
|
scales->show_hsv_binding = NULL;
|
||||||
|
|
||||||
/* don't need the toggles for our own operation */
|
/* don't need the toggles for our own operation */
|
||||||
selector->toggles_visible = FALSE;
|
gimp_color_selector_set_toggles_visible (selector, FALSE);
|
||||||
|
|
||||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
||||||
gtk_box_pack_start (GTK_BOX (scales), hbox, 0, 0, FALSE);
|
gtk_box_pack_start (GTK_BOX (scales), hbox, 0, 0, FALSE);
|
||||||
|
@ -600,8 +591,7 @@ gimp_color_scales_set_show_alpha (GimpColorSelector *selector,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_scales_set_color (GimpColorSelector *selector,
|
gimp_color_scales_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color)
|
||||||
const GimpHSV *hsv)
|
|
||||||
{
|
{
|
||||||
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
||||||
|
|
||||||
|
@ -734,29 +724,31 @@ gimp_color_scales_update_scales (GimpColorScales *scales,
|
||||||
gint skip)
|
gint skip)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
||||||
GimpLCH lch;
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
||||||
|
gdouble pixel[4];
|
||||||
gdouble values[G_N_ELEMENTS (scale_defs)];
|
gdouble values[G_N_ELEMENTS (scale_defs)];
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
babl_process (fish_rgb_to_lch, &selector->rgb, &lch, 1);
|
gegl_color_get_pixel (color, babl_format ("HSV double"), pixel);
|
||||||
|
values[GIMP_COLOR_SELECTOR_HUE] = pixel[0] * 360.0;
|
||||||
|
values[GIMP_COLOR_SELECTOR_SATURATION] = pixel[1] * 100.0;
|
||||||
|
values[GIMP_COLOR_SELECTOR_VALUE] = pixel[2] * 100.0;
|
||||||
|
|
||||||
values[GIMP_COLOR_SELECTOR_HUE] = selector->hsv.h * 360.0;
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), pixel);
|
||||||
values[GIMP_COLOR_SELECTOR_SATURATION] = selector->hsv.s * 100.0;
|
values[GIMP_COLOR_SELECTOR_RED] = pixel[0] * 100.0;
|
||||||
values[GIMP_COLOR_SELECTOR_VALUE] = selector->hsv.v * 100.0;
|
values[GIMP_COLOR_SELECTOR_GREEN] = pixel[1] * 100.0;
|
||||||
|
values[GIMP_COLOR_SELECTOR_BLUE] = pixel[2] * 100.0;
|
||||||
|
values[GIMP_COLOR_SELECTOR_ALPHA] = pixel[3] * 100.0;
|
||||||
|
|
||||||
values[GIMP_COLOR_SELECTOR_RED] = selector->rgb.r * 100.0;
|
values[GIMP_COLOR_SELECTOR_RED_U8] = pixel[0] * 255.0;
|
||||||
values[GIMP_COLOR_SELECTOR_GREEN] = selector->rgb.g * 100.0;
|
values[GIMP_COLOR_SELECTOR_GREEN_U8] = pixel[1] * 255.0;
|
||||||
values[GIMP_COLOR_SELECTOR_BLUE] = selector->rgb.b * 100.0;
|
values[GIMP_COLOR_SELECTOR_BLUE_U8] = pixel[2] * 255.0;
|
||||||
values[GIMP_COLOR_SELECTOR_ALPHA] = selector->rgb.a * 100.0;
|
values[GIMP_COLOR_SELECTOR_ALPHA_U8] = pixel[3] * 255.0;
|
||||||
|
|
||||||
values[GIMP_COLOR_SELECTOR_LCH_LIGHTNESS] = lch.l;
|
gegl_color_get_pixel (color, babl_format ("CIE LCH(ab) double"), pixel);
|
||||||
values[GIMP_COLOR_SELECTOR_LCH_CHROMA] = lch.c;
|
values[GIMP_COLOR_SELECTOR_LCH_LIGHTNESS] = pixel[0];
|
||||||
values[GIMP_COLOR_SELECTOR_LCH_HUE] = lch.h;
|
values[GIMP_COLOR_SELECTOR_LCH_CHROMA] = pixel[1];
|
||||||
|
values[GIMP_COLOR_SELECTOR_LCH_HUE] = pixel[2];
|
||||||
values[GIMP_COLOR_SELECTOR_RED_U8] = selector->rgb.r * 255.0;
|
|
||||||
values[GIMP_COLOR_SELECTOR_GREEN_U8] = selector->rgb.g * 255.0;
|
|
||||||
values[GIMP_COLOR_SELECTOR_BLUE_U8] = selector->rgb.b * 255.0;
|
|
||||||
values[GIMP_COLOR_SELECTOR_ALPHA_U8] = selector->rgb.a * 255.0;
|
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
||||||
{
|
{
|
||||||
|
@ -773,9 +765,10 @@ gimp_color_scales_update_scales (GimpColorScales *scales,
|
||||||
scales);
|
scales);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_color_scale_set_color (GIMP_COLOR_SCALE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scales->scales[i]))),
|
gimp_color_scale_set_color (GIMP_COLOR_SCALE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scales->scales[i]))), color);
|
||||||
&selector->rgb, &selector->hsv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -812,101 +805,102 @@ gimp_color_scales_scale_changed (GtkWidget *scale,
|
||||||
GimpColorScales *scales)
|
GimpColorScales *scales)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
||||||
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
||||||
gdouble value = gimp_label_spin_get_value (GIMP_LABEL_SPIN (scale));
|
gdouble value = gimp_label_spin_get_value (GIMP_LABEL_SPIN (scale));
|
||||||
GimpLCH lch;
|
gdouble lch[4];
|
||||||
|
gdouble hsv[4];
|
||||||
|
gdouble rgb[4];
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
||||||
if (scales->scales[i] == scale)
|
if (scales->scales[i] == scale)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||||
|
gegl_color_get_pixel (color, babl_format ("HSVA double"), hsv);
|
||||||
|
gegl_color_get_pixel (color, babl_format ("CIE LCH(ab) alpha double"), lch);
|
||||||
|
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case GIMP_COLOR_SELECTOR_HUE:
|
case GIMP_COLOR_SELECTOR_HUE:
|
||||||
selector->hsv.h = value / 360.0;
|
hsv[0] = value / 360.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_SATURATION:
|
case GIMP_COLOR_SELECTOR_SATURATION:
|
||||||
selector->hsv.s = value / 100.0;
|
hsv[1] = value / 100.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_VALUE:
|
case GIMP_COLOR_SELECTOR_VALUE:
|
||||||
selector->hsv.v = value / 100.0;
|
hsv[2] = value / 100.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_RED:
|
case GIMP_COLOR_SELECTOR_RED:
|
||||||
selector->rgb.r = value / 100.0;
|
rgb[0] = value / 100.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_GREEN:
|
case GIMP_COLOR_SELECTOR_GREEN:
|
||||||
selector->rgb.g = value / 100.0;
|
rgb[1] = value / 100.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_BLUE:
|
case GIMP_COLOR_SELECTOR_BLUE:
|
||||||
selector->rgb.b = value / 100.0;
|
rgb[2] = value / 100.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_ALPHA:
|
case GIMP_COLOR_SELECTOR_ALPHA:
|
||||||
selector->hsv.a = selector->rgb.a = value / 100.0;
|
gimp_color_set_alpha (color, value / 100.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS:
|
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS:
|
||||||
babl_process (fish_rgb_to_lch, &selector->rgb, &lch, 1);
|
lch[0] = value;
|
||||||
lch.l = value;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_LCH_CHROMA:
|
case GIMP_COLOR_SELECTOR_LCH_CHROMA:
|
||||||
babl_process (fish_rgb_to_lch, &selector->rgb, &lch, 1);
|
lch[1] = value;
|
||||||
lch.c = value;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_LCH_HUE:
|
case GIMP_COLOR_SELECTOR_LCH_HUE:
|
||||||
babl_process (fish_rgb_to_lch, &selector->rgb, &lch, 1);
|
lch[2] = value;
|
||||||
lch.h = value;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_RED_U8:
|
case GIMP_COLOR_SELECTOR_RED_U8:
|
||||||
selector->rgb.r = value / 255.0;
|
rgb[0] = value / 255.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_GREEN_U8:
|
case GIMP_COLOR_SELECTOR_GREEN_U8:
|
||||||
selector->rgb.g = value / 255.0;
|
rgb[1] = value / 255.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_BLUE_U8:
|
case GIMP_COLOR_SELECTOR_BLUE_U8:
|
||||||
selector->rgb.b = value / 255.0;
|
rgb[2] = value / 255.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_COLOR_SELECTOR_ALPHA_U8:
|
case GIMP_COLOR_SELECTOR_ALPHA_U8:
|
||||||
selector->hsv.a = selector->rgb.a = value / 255.0;
|
gimp_color_set_alpha (color, value / 255.0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((i >= GIMP_COLOR_SELECTOR_HUE) &&
|
if ((i >= GIMP_COLOR_SELECTOR_HUE) &&
|
||||||
(i <= GIMP_COLOR_SELECTOR_VALUE))
|
(i <= GIMP_COLOR_SELECTOR_VALUE))
|
||||||
{
|
{
|
||||||
gimp_hsv_to_rgb (&selector->hsv, &selector->rgb);
|
gegl_color_set_pixel (color, babl_format ("HSVA double"), hsv);
|
||||||
}
|
}
|
||||||
else if ((i >= GIMP_COLOR_SELECTOR_LCH_LIGHTNESS) &&
|
else if ((i >= GIMP_COLOR_SELECTOR_LCH_LIGHTNESS) &&
|
||||||
(i <= GIMP_COLOR_SELECTOR_LCH_HUE))
|
(i <= GIMP_COLOR_SELECTOR_LCH_HUE))
|
||||||
{
|
{
|
||||||
babl_process (fish_lch_to_rgb, &lch, &selector->rgb, 1);
|
gegl_color_set_pixel (color, babl_format ("CIE LCH(ab) alpha double"), lch);
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
|
||||||
}
|
}
|
||||||
else if ((i >= GIMP_COLOR_SELECTOR_RED) &&
|
else if (((i >= GIMP_COLOR_SELECTOR_RED) &&
|
||||||
(i <= GIMP_COLOR_SELECTOR_BLUE))
|
(i <= GIMP_COLOR_SELECTOR_BLUE)) ||
|
||||||
|
((i >= GIMP_COLOR_SELECTOR_RED_U8) &&
|
||||||
|
(i <= GIMP_COLOR_SELECTOR_BLUE_U8)))
|
||||||
{
|
{
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
gegl_color_set_pixel (color, babl_format ("R'G'B'A double"), rgb);
|
||||||
}
|
|
||||||
else if ((i >= GIMP_COLOR_SELECTOR_RED_U8) &&
|
|
||||||
(i <= GIMP_COLOR_SELECTOR_BLUE_U8))
|
|
||||||
{
|
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_color_scales_update_scales (scales, i);
|
gimp_color_selector_set_color (selector, color);
|
||||||
|
|
||||||
gimp_color_selector_emit_color_changed (selector);
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -171,9 +171,9 @@ struct _ColorSelectFill
|
||||||
gint y;
|
gint y;
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
GimpRGB rgb;
|
gdouble rgb[4];
|
||||||
GimpHSV hsv;
|
gdouble hsv[4];
|
||||||
GimpLCH lch;
|
gdouble lch[4];
|
||||||
guchar oog_color[3];
|
guchar oog_color[3];
|
||||||
|
|
||||||
ColorSelectRenderFunc render_line;
|
ColorSelectRenderFunc render_line;
|
||||||
|
@ -187,8 +187,7 @@ static void gimp_color_select_togg_visible (GimpColorSelector *selector,
|
||||||
static void gimp_color_select_togg_sensitive (GimpColorSelector *selector,
|
static void gimp_color_select_togg_sensitive (GimpColorSelector *selector,
|
||||||
gboolean sensitive);
|
gboolean sensitive);
|
||||||
static void gimp_color_select_set_color (GimpColorSelector *selector,
|
static void gimp_color_select_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
|
||||||
static void gimp_color_select_set_channel (GimpColorSelector *selector,
|
static void gimp_color_select_set_channel (GimpColorSelector *selector,
|
||||||
GimpColorSelectorChannel channel);
|
GimpColorSelectorChannel channel);
|
||||||
static void gimp_color_select_set_model_visible
|
static void gimp_color_select_set_model_visible
|
||||||
|
@ -239,8 +238,7 @@ static void gimp_color_select_render (GtkWidget *widget,
|
||||||
gint height,
|
gint height,
|
||||||
gint rowstride,
|
gint rowstride,
|
||||||
ColorSelectFillType fill_type,
|
ColorSelectFillType fill_type,
|
||||||
const GimpHSV *hsv,
|
GeglColor *color,
|
||||||
const GimpRGB *rgb,
|
|
||||||
const guchar *oog_color);
|
const guchar *oog_color);
|
||||||
|
|
||||||
static void color_select_render_red (ColorSelectFill *csf);
|
static void color_select_render_red (ColorSelectFill *csf);
|
||||||
|
@ -306,7 +304,6 @@ static const ColorSelectRenderFunc render_funcs[] =
|
||||||
color_select_render_lch_chroma_lightness
|
color_select_render_lch_chroma_lightness
|
||||||
};
|
};
|
||||||
|
|
||||||
static const Babl *fish_rgb_to_lch = NULL;
|
|
||||||
static const Babl *fish_lch_to_rgb = NULL;
|
static const Babl *fish_lch_to_rgb = NULL;
|
||||||
static const Babl *fish_lch_to_rgb_u8 = NULL;
|
static const Babl *fish_lch_to_rgb_u8 = NULL;
|
||||||
|
|
||||||
|
@ -331,8 +328,6 @@ gimp_color_select_class_init (GimpColorSelectClass *klass)
|
||||||
|
|
||||||
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "GimpColorSelect");
|
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "GimpColorSelect");
|
||||||
|
|
||||||
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"),
|
fish_lch_to_rgb = babl_fish (babl_format ("CIE LCH(ab) double"),
|
||||||
babl_format ("R'G'B' double"));
|
babl_format ("R'G'B' double"));
|
||||||
fish_lch_to_rgb_u8 = babl_fish (babl_format ("CIE LCH(ab) double"),
|
fish_lch_to_rgb_u8 = babl_fish (babl_format ("CIE LCH(ab) double"),
|
||||||
|
@ -543,8 +538,7 @@ gimp_color_select_togg_sensitive (GimpColorSelector *selector,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_select_set_color (GimpColorSelector *selector,
|
gimp_color_select_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color)
|
||||||
const GimpHSV *hsv)
|
|
||||||
{
|
{
|
||||||
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
|
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
|
||||||
|
|
||||||
|
@ -690,153 +684,144 @@ gimp_color_select_update (GimpColorSelect *select,
|
||||||
select->z_needs_render = TRUE;
|
select->z_needs_render = TRUE;
|
||||||
gtk_widget_queue_draw (select->z_color);
|
gtk_widget_queue_draw (select->z_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update & UPDATE_CALLER)
|
|
||||||
gimp_color_selector_emit_color_changed (GIMP_COLOR_SELECTOR (select));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_select_update_values (GimpColorSelect *select)
|
gimp_color_select_update_values (GimpColorSelect *select)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
||||||
GimpLCH lch;
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
||||||
|
gdouble values[3];
|
||||||
|
const Babl *rgb_format;
|
||||||
|
|
||||||
|
/* TODO: we want to select colors in the image space! */
|
||||||
|
rgb_format = babl_format_with_space ("R'G'B' double", NULL);
|
||||||
|
|
||||||
switch (select->z_color_fill)
|
switch (select->z_color_fill)
|
||||||
{
|
{
|
||||||
case COLOR_SELECT_RED:
|
case COLOR_SELECT_RED:
|
||||||
selector->rgb.g = select->pos[0];
|
values[0] = select->pos[2];
|
||||||
selector->rgb.b = select->pos[1];
|
values[1] = select->pos[0];
|
||||||
selector->rgb.r = select->pos[2];
|
values[2] = select->pos[1];
|
||||||
|
gegl_color_set_pixel (color, rgb_format, values);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_GREEN:
|
case COLOR_SELECT_GREEN:
|
||||||
selector->rgb.r = select->pos[0];
|
values[0] = select->pos[0];
|
||||||
selector->rgb.b = select->pos[1];
|
values[1] = select->pos[2];
|
||||||
selector->rgb.g = select->pos[2];
|
values[2] = select->pos[1];
|
||||||
|
gegl_color_set_pixel (color, rgb_format, values);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_BLUE:
|
case COLOR_SELECT_BLUE:
|
||||||
selector->rgb.r = select->pos[0];
|
gegl_color_set_pixel (color, rgb_format, select->pos);
|
||||||
selector->rgb.g = select->pos[1];
|
|
||||||
selector->rgb.b = select->pos[2];
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLOR_SELECT_HUE:
|
case COLOR_SELECT_HUE:
|
||||||
selector->hsv.s = select->pos[0];
|
values[0] = select->pos[2];
|
||||||
selector->hsv.v = select->pos[1];
|
values[1] = select->pos[0];
|
||||||
selector->hsv.h = select->pos[2];
|
values[2] = select->pos[1];
|
||||||
|
gegl_color_set_pixel (color, babl_format ("HSV double"), values);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_SATURATION:
|
case COLOR_SELECT_SATURATION:
|
||||||
selector->hsv.h = select->pos[0];
|
values[0] = select->pos[0];
|
||||||
selector->hsv.v = select->pos[1];
|
values[1] = select->pos[2];
|
||||||
selector->hsv.s = select->pos[2];
|
values[2] = select->pos[1];
|
||||||
|
gegl_color_set_pixel (color, babl_format ("HSV double"), values);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_VALUE:
|
case COLOR_SELECT_VALUE:
|
||||||
selector->hsv.h = select->pos[0];
|
gegl_color_set_pixel (color, babl_format ("HSV double"), select->pos);
|
||||||
selector->hsv.s = select->pos[1];
|
|
||||||
selector->hsv.v = select->pos[2];
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLOR_SELECT_LCH_LIGHTNESS:
|
case COLOR_SELECT_LCH_LIGHTNESS:
|
||||||
lch.h = select->pos[0] * 360;
|
values[0] = select->pos[2] * 100.0;
|
||||||
lch.c = select->pos[1] * 200;
|
values[1] = select->pos[1] * 200.0;
|
||||||
lch.l = select->pos[2] * 100;
|
values[2] = select->pos[0] * 360.0;
|
||||||
|
gegl_color_set_pixel (color, babl_format ("CIE LCH(ab) double"), values);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_LCH_CHROMA:
|
case COLOR_SELECT_LCH_CHROMA:
|
||||||
lch.h = select->pos[0] * 360;
|
values[0] = select->pos[1] * 100.0;
|
||||||
lch.l = select->pos[1] * 100;
|
values[1] = select->pos[2] * 200.0;
|
||||||
lch.c = select->pos[2] * 200;
|
values[2] = select->pos[0] * 360.0;
|
||||||
|
gegl_color_set_pixel (color, babl_format ("CIE LCH(ab) double"), values);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_LCH_HUE:
|
case COLOR_SELECT_LCH_HUE:
|
||||||
lch.c = select->pos[0] * 200;
|
values[0] = select->pos[1] * 100.0;
|
||||||
lch.l = select->pos[1] * 100;
|
values[1] = select->pos[0] * 200.0;
|
||||||
lch.h = select->pos[2] * 360;
|
values[2] = select->pos[2] * 360.0;
|
||||||
|
gegl_color_set_pixel (color, babl_format ("CIE LCH(ab) double"), values);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (select->z_color_fill)
|
gimp_color_selector_set_color (selector, color);
|
||||||
{
|
|
||||||
case COLOR_SELECT_RED:
|
|
||||||
case COLOR_SELECT_GREEN:
|
|
||||||
case COLOR_SELECT_BLUE:
|
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case COLOR_SELECT_HUE:
|
g_object_unref (color);
|
||||||
case COLOR_SELECT_SATURATION:
|
|
||||||
case COLOR_SELECT_VALUE:
|
|
||||||
gimp_hsv_to_rgb (&selector->hsv, &selector->rgb);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case COLOR_SELECT_LCH_LIGHTNESS:
|
|
||||||
case COLOR_SELECT_LCH_CHROMA:
|
|
||||||
case COLOR_SELECT_LCH_HUE:
|
|
||||||
babl_process (fish_lch_to_rgb, &lch, &selector->rgb, 1);
|
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_select_update_pos (GimpColorSelect *select)
|
gimp_color_select_update_pos (GimpColorSelect *select)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
||||||
GimpLCH lch;
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
||||||
|
gdouble rgb[3];
|
||||||
|
gdouble lch[3];
|
||||||
|
gdouble hsv[3];
|
||||||
|
|
||||||
babl_process (fish_rgb_to_lch, &selector->rgb, &lch, 1);
|
/* TODO select RGB and HSV within the target RGB space. */
|
||||||
|
gegl_color_get_pixel (color, babl_format ("R'G'B' double"), rgb);
|
||||||
|
gegl_color_get_pixel (color, babl_format ("CIE LCH(ab) double"), lch);
|
||||||
|
gegl_color_get_pixel (color, babl_format ("HSV double"), hsv);
|
||||||
|
g_object_unref (color);
|
||||||
|
|
||||||
switch (select->z_color_fill)
|
switch (select->z_color_fill)
|
||||||
{
|
{
|
||||||
case COLOR_SELECT_RED:
|
case COLOR_SELECT_RED:
|
||||||
select->pos[0] = CLAMP (selector->rgb.g, 0.0, 1.0);
|
select->pos[0] = CLAMP (rgb[1], 0.0, 1.0);
|
||||||
select->pos[1] = CLAMP (selector->rgb.b, 0.0, 1.0);
|
select->pos[1] = CLAMP (rgb[2], 0.0, 1.0);
|
||||||
select->pos[2] = CLAMP (selector->rgb.r, 0.0, 1.0);
|
select->pos[2] = CLAMP (rgb[0], 0.0, 1.0);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_GREEN:
|
case COLOR_SELECT_GREEN:
|
||||||
select->pos[0] = CLAMP (selector->rgb.r, 0.0, 1.0);
|
select->pos[0] = CLAMP (rgb[0], 0.0, 1.0);
|
||||||
select->pos[1] = CLAMP (selector->rgb.b, 0.0, 1.0);
|
select->pos[1] = CLAMP (rgb[2], 0.0, 1.0);
|
||||||
select->pos[2] = CLAMP (selector->rgb.g, 0.0, 1.0);
|
select->pos[2] = CLAMP (rgb[1], 0.0, 1.0);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_BLUE:
|
case COLOR_SELECT_BLUE:
|
||||||
select->pos[0] = CLAMP (selector->rgb.r, 0.0, 1.0);
|
select->pos[0] = CLAMP (rgb[0], 0.0, 1.0);
|
||||||
select->pos[1] = CLAMP (selector->rgb.g, 0.0, 1.0);
|
select->pos[1] = CLAMP (rgb[1], 0.0, 1.0);
|
||||||
select->pos[2] = CLAMP (selector->rgb.b, 0.0, 1.0);
|
select->pos[2] = CLAMP (rgb[2], 0.0, 1.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLOR_SELECT_HUE:
|
case COLOR_SELECT_HUE:
|
||||||
select->pos[0] = CLAMP (selector->hsv.s, 0.0, 1.0);
|
select->pos[0] = CLAMP (hsv[1], 0.0, 1.0);
|
||||||
select->pos[1] = CLAMP (selector->hsv.v, 0.0, 1.0);
|
select->pos[1] = CLAMP (hsv[2], 0.0, 1.0);
|
||||||
select->pos[2] = CLAMP (selector->hsv.h, 0.0, 1.0);
|
select->pos[2] = CLAMP (hsv[0], 0.0, 1.0);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_SATURATION:
|
case COLOR_SELECT_SATURATION:
|
||||||
select->pos[0] = CLAMP (selector->hsv.h, 0.0, 1.0);
|
select->pos[0] = CLAMP (hsv[0], 0.0, 1.0);
|
||||||
select->pos[1] = CLAMP (selector->hsv.v, 0.0, 1.0);
|
select->pos[1] = CLAMP (hsv[2], 0.0, 1.0);
|
||||||
select->pos[2] = CLAMP (selector->hsv.s, 0.0, 1.0);
|
select->pos[2] = CLAMP (hsv[1], 0.0, 1.0);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_VALUE:
|
case COLOR_SELECT_VALUE:
|
||||||
select->pos[0] = CLAMP (selector->hsv.h, 0.0, 1.0);
|
select->pos[0] = CLAMP (hsv[0], 0.0, 1.0);
|
||||||
select->pos[1] = CLAMP (selector->hsv.s, 0.0, 1.0);
|
select->pos[1] = CLAMP (hsv[1], 0.0, 1.0);
|
||||||
select->pos[2] = CLAMP (selector->hsv.v, 0.0, 1.0);
|
select->pos[2] = CLAMP (hsv[2], 0.0, 1.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLOR_SELECT_LCH_LIGHTNESS:
|
case COLOR_SELECT_LCH_LIGHTNESS:
|
||||||
select->pos[0] = CLAMP (lch.h / 360, 0.0, 1.0);
|
select->pos[0] = CLAMP (lch[2] / 360, 0.0, 1.0);
|
||||||
select->pos[1] = CLAMP (lch.c / 200, 0.0, 1.0);
|
select->pos[1] = CLAMP (lch[1] / 200, 0.0, 1.0);
|
||||||
select->pos[2] = CLAMP (lch.l / 100, 0.0, 1.0);
|
select->pos[2] = CLAMP (lch[0] / 100, 0.0, 1.0);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_LCH_CHROMA:
|
case COLOR_SELECT_LCH_CHROMA:
|
||||||
select->pos[0] = CLAMP (lch.h / 360, 0.0, 1.0);
|
select->pos[0] = CLAMP (lch[2] / 360, 0.0, 1.0);
|
||||||
select->pos[1] = CLAMP (lch.l / 100, 0.0, 1.0);
|
select->pos[1] = CLAMP (lch[0] / 100, 0.0, 1.0);
|
||||||
select->pos[2] = CLAMP (lch.c / 200, 0.0, 1.0);
|
select->pos[2] = CLAMP (lch[1] / 200, 0.0, 1.0);
|
||||||
break;
|
break;
|
||||||
case COLOR_SELECT_LCH_HUE:
|
case COLOR_SELECT_LCH_HUE:
|
||||||
select->pos[0] = CLAMP (lch.c / 200, 0.0, 1.0);
|
select->pos[0] = CLAMP (lch[1] / 200, 0.0, 1.0);
|
||||||
select->pos[1] = CLAMP (lch.l / 100, 0.0, 1.0);
|
select->pos[1] = CLAMP (lch[0] / 100, 0.0, 1.0);
|
||||||
select->pos[2] = CLAMP (lch.h / 360, 0.0, 1.0);
|
select->pos[2] = CLAMP (lch[2] / 360, 0.0, 1.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -902,6 +887,7 @@ gimp_color_select_xy_draw (GtkWidget *widget,
|
||||||
if (select->xy_needs_render)
|
if (select->xy_needs_render)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
||||||
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
||||||
|
|
||||||
gimp_color_select_render (select->xy_color,
|
gimp_color_select_render (select->xy_color,
|
||||||
select->xy_buf,
|
select->xy_buf,
|
||||||
|
@ -909,10 +895,11 @@ gimp_color_select_xy_draw (GtkWidget *widget,
|
||||||
select->xy_height,
|
select->xy_height,
|
||||||
select->xy_rowstride,
|
select->xy_rowstride,
|
||||||
select->xy_color_fill,
|
select->xy_color_fill,
|
||||||
&selector->hsv,
|
color,
|
||||||
&selector->rgb,
|
|
||||||
select->oog_color);
|
select->oog_color);
|
||||||
select->xy_needs_render = FALSE;
|
select->xy_needs_render = FALSE;
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! select->transform)
|
if (! select->transform)
|
||||||
|
@ -1099,6 +1086,7 @@ gimp_color_select_z_draw (GtkWidget *widget,
|
||||||
if (select->z_needs_render)
|
if (select->z_needs_render)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (select);
|
||||||
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
||||||
|
|
||||||
gimp_color_select_render (select->z_color,
|
gimp_color_select_render (select->z_color,
|
||||||
select->z_buf,
|
select->z_buf,
|
||||||
|
@ -1106,10 +1094,11 @@ gimp_color_select_z_draw (GtkWidget *widget,
|
||||||
select->z_height,
|
select->z_height,
|
||||||
select->z_rowstride,
|
select->z_rowstride,
|
||||||
select->z_color_fill,
|
select->z_color_fill,
|
||||||
&selector->hsv,
|
color,
|
||||||
&selector->rgb,
|
|
||||||
select->oog_color);
|
select->oog_color);
|
||||||
select->z_needs_render = FALSE;
|
select->z_needs_render = FALSE;
|
||||||
|
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
@ -1256,24 +1245,23 @@ gimp_color_select_render (GtkWidget *preview,
|
||||||
gint height,
|
gint height,
|
||||||
gint rowstride,
|
gint rowstride,
|
||||||
ColorSelectFillType fill_type,
|
ColorSelectFillType fill_type,
|
||||||
const GimpHSV *hsv,
|
GeglColor *color,
|
||||||
const GimpRGB *rgb,
|
|
||||||
const guchar *oog_color)
|
const guchar *oog_color)
|
||||||
{
|
{
|
||||||
ColorSelectFill csf;
|
ColorSelectFill csf;
|
||||||
|
|
||||||
csf.width = width;
|
csf.width = width;
|
||||||
csf.height = height;
|
csf.height = height;
|
||||||
csf.hsv = *hsv;
|
|
||||||
csf.rgb = *rgb;
|
|
||||||
csf.render_line = render_funcs[fill_type];
|
csf.render_line = render_funcs[fill_type];
|
||||||
|
|
||||||
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), csf.rgb);
|
||||||
|
gegl_color_get_pixel (color, babl_format ("HSVA double"), csf.hsv);
|
||||||
|
gegl_color_get_pixel (color, babl_format ("CIE LCH(ab) alpha double"), csf.lch);
|
||||||
|
|
||||||
csf.oog_color[0] = oog_color[0];
|
csf.oog_color[0] = oog_color[0];
|
||||||
csf.oog_color[1] = oog_color[1];
|
csf.oog_color[1] = oog_color[1];
|
||||||
csf.oog_color[2] = oog_color[2];
|
csf.oog_color[2] = oog_color[2];
|
||||||
|
|
||||||
babl_process (fish_rgb_to_lch, rgb, &csf.lch, 1);
|
|
||||||
|
|
||||||
for (csf.y = 0; csf.y < csf.height; csf.y++)
|
for (csf.y = 0; csf.y < csf.height; csf.y++)
|
||||||
{
|
{
|
||||||
csf.buffer = buf;
|
csf.buffer = buf;
|
||||||
|
@ -1437,11 +1425,11 @@ static void
|
||||||
color_select_render_lch_lightness (ColorSelectFill *csf)
|
color_select_render_lch_lightness (ColorSelectFill *csf)
|
||||||
{
|
{
|
||||||
guchar *p = csf->buffer;
|
guchar *p = csf->buffer;
|
||||||
GimpLCH lch = { 0.0, 0.0, 0.0, 1.0 };
|
gdouble lch[4] = { 0.0, 0.0, 0.0, 1.0 };
|
||||||
guchar rgb[3];
|
guchar rgb[3];
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
lch.l = (csf->height - 1 - csf->y) * 100.0 / csf->height;
|
lch[0] = (csf->height - 1 - csf->y) * 100.0 / csf->height;
|
||||||
babl_process (fish_lch_to_rgb_u8, &lch, &rgb, 1);
|
babl_process (fish_lch_to_rgb_u8, &lch, &rgb, 1);
|
||||||
|
|
||||||
for (i = 0; i < csf->width; i++)
|
for (i = 0; i < csf->width; i++)
|
||||||
|
@ -1456,11 +1444,11 @@ static void
|
||||||
color_select_render_lch_chroma (ColorSelectFill *csf)
|
color_select_render_lch_chroma (ColorSelectFill *csf)
|
||||||
{
|
{
|
||||||
guchar *p = csf->buffer;
|
guchar *p = csf->buffer;
|
||||||
GimpLCH lch = { 80.0, 0.0, 0.0, 1.0 };
|
gdouble lch[4] = { 80.0, 0.0, 0.0, 1.0 };
|
||||||
guchar rgb[3];
|
guchar rgb[3];
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
lch.c = (csf->height - 1 - csf->y) * 200.0 / csf->height ;
|
lch[1] = (csf->height - 1 - csf->y) * 200.0 / csf->height ;
|
||||||
babl_process (fish_lch_to_rgb_u8, &lch, &rgb, 1);
|
babl_process (fish_lch_to_rgb_u8, &lch, &rgb, 1);
|
||||||
|
|
||||||
for (i = 0; i < csf->width; i++)
|
for (i = 0; i < csf->width; i++)
|
||||||
|
@ -1474,12 +1462,12 @@ color_select_render_lch_chroma (ColorSelectFill *csf)
|
||||||
static void
|
static void
|
||||||
color_select_render_lch_hue (ColorSelectFill *csf)
|
color_select_render_lch_hue (ColorSelectFill *csf)
|
||||||
{
|
{
|
||||||
guchar *p = csf->buffer;
|
guchar *p = csf->buffer;
|
||||||
GimpLCH lch = { 80.0, 200.0, 0.0, 1.0 };
|
gdouble lch[4] = { 80.0, 200.0, 0.0, 1.0 };
|
||||||
guchar rgb[3];
|
guchar rgb[3];
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
lch.h = (csf->height - 1 - csf->y) * 360.0 / csf->height;
|
lch[2] = (csf->height - 1 - csf->y) * 360.0 / csf->height;
|
||||||
babl_process (fish_lch_to_rgb_u8, &lch, &rgb, 1);
|
babl_process (fish_lch_to_rgb_u8, &lch, &rgb, 1);
|
||||||
|
|
||||||
for (i = 0; i < csf->width; i++)
|
for (i = 0; i < csf->width; i++)
|
||||||
|
@ -1500,7 +1488,7 @@ color_select_render_red_green (ColorSelectFill *csf)
|
||||||
gfloat dr = 0;
|
gfloat dr = 0;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
b = csf->rgb.b * 255.0;
|
b = csf->rgb[2] * 255.0;
|
||||||
|
|
||||||
if (b < 0.0 || b > 255.0)
|
if (b < 0.0 || b > 255.0)
|
||||||
{
|
{
|
||||||
|
@ -1535,7 +1523,7 @@ color_select_render_red_blue (ColorSelectFill *csf)
|
||||||
gfloat dr = 0;
|
gfloat dr = 0;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
g = csf->rgb.g * 255.0;
|
g = csf->rgb[1] * 255.0;
|
||||||
|
|
||||||
if (g < 0.0 || g > 255.0)
|
if (g < 0.0 || g > 255.0)
|
||||||
{
|
{
|
||||||
|
@ -1570,7 +1558,7 @@ color_select_render_green_blue (ColorSelectFill *csf)
|
||||||
gfloat dg = 0;
|
gfloat dg = 0;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
r = csf->rgb.r * 255.0;
|
r = csf->rgb[0] * 255.0;
|
||||||
|
|
||||||
if (r < 0.0 || r > 255.0)
|
if (r < 0.0 || r > 255.0)
|
||||||
{
|
{
|
||||||
|
@ -1603,7 +1591,7 @@ color_select_render_hue_saturation (ColorSelectFill *csf)
|
||||||
gint f;
|
gint f;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
v = csf->hsv.v;
|
v = csf->hsv[2];
|
||||||
|
|
||||||
s = (gfloat) csf->y / csf->height;
|
s = (gfloat) csf->y / csf->height;
|
||||||
s = CLAMP (s, 0.0, 1.0);
|
s = CLAMP (s, 0.0, 1.0);
|
||||||
|
@ -1680,7 +1668,7 @@ color_select_render_hue_value (ColorSelectFill *csf)
|
||||||
gint f;
|
gint f;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
s = csf->hsv.s;
|
s = csf->hsv[1];
|
||||||
|
|
||||||
v = (gfloat) csf->y / csf->height;
|
v = (gfloat) csf->y / csf->height;
|
||||||
v = CLAMP (v, 0.0, 1.0);
|
v = CLAMP (v, 0.0, 1.0);
|
||||||
|
@ -1757,7 +1745,7 @@ color_select_render_saturation_value (ColorSelectFill *csf)
|
||||||
gint f;
|
gint f;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
h = (gfloat) csf->hsv.h * 360.0;
|
h = (gfloat) csf->hsv[0] * 360.0;
|
||||||
if (h >= 360)
|
if (h >= 360)
|
||||||
h -= 360;
|
h -= 360;
|
||||||
h /= 60;
|
h /= 60;
|
||||||
|
@ -1839,23 +1827,23 @@ static void
|
||||||
color_select_render_lch_chroma_lightness (ColorSelectFill *csf)
|
color_select_render_lch_chroma_lightness (ColorSelectFill *csf)
|
||||||
{
|
{
|
||||||
guchar *p = csf->buffer;
|
guchar *p = csf->buffer;
|
||||||
GimpLCH lch;
|
gdouble lch[3];
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
lch.l = (csf->height - 1 - csf->y) * 100.0 / csf->height;
|
lch[0] = (csf->height - 1 - csf->y) * 100.0 / csf->height;
|
||||||
lch.h = csf->lch.h;
|
lch[2] = csf->lch[2];
|
||||||
|
|
||||||
for (i = 0; i < csf->width; i++)
|
for (i = 0; i < csf->width; i++)
|
||||||
{
|
{
|
||||||
GimpRGB rgb;
|
gdouble rgb[3];
|
||||||
|
|
||||||
lch.c = i * 200.0 / csf->width;
|
lch[1] = i * 200.0 / csf->width;
|
||||||
|
|
||||||
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
||||||
|
|
||||||
if (rgb.r < 0.0 || rgb.r > 1.0 ||
|
if (rgb[0] < 0.0 || rgb[0] > 1.0 ||
|
||||||
rgb.g < 0.0 || rgb.g > 1.0 ||
|
rgb[1] < 0.0 || rgb[1] > 1.0 ||
|
||||||
rgb.b < 0.0 || rgb.b > 1.0)
|
rgb[2] < 0.0 || rgb[2] > 1.0)
|
||||||
{
|
{
|
||||||
p[0] = csf->oog_color[0];
|
p[0] = csf->oog_color[0];
|
||||||
p[1] = csf->oog_color[1];
|
p[1] = csf->oog_color[1];
|
||||||
|
@ -1863,7 +1851,9 @@ color_select_render_lch_chroma_lightness (ColorSelectFill *csf)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_rgb_get_uchar (&rgb, p, p + 1, p + 2);
|
p[0] = rgb[0] * 255;
|
||||||
|
p[1] = rgb[1] * 255;
|
||||||
|
p[2] = rgb[2] * 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
p += 3;
|
p += 3;
|
||||||
|
@ -1874,23 +1864,26 @@ static void
|
||||||
color_select_render_lch_hue_lightness (ColorSelectFill *csf)
|
color_select_render_lch_hue_lightness (ColorSelectFill *csf)
|
||||||
{
|
{
|
||||||
guchar *p = csf->buffer;
|
guchar *p = csf->buffer;
|
||||||
GimpLCH lch;
|
gdouble lch[3];
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
lch.l = (csf->height - 1 - csf->y) * 100.0 / csf->height;
|
lch[0] = (csf->height - 1 - csf->y) * 100.0 / csf->height;
|
||||||
lch.c = csf->lch.c;
|
lch[1] = csf->lch[1];
|
||||||
|
|
||||||
for (i = 0; i < csf->width; i++)
|
for (i = 0; i < csf->width; i++)
|
||||||
{
|
{
|
||||||
GimpRGB rgb;
|
gdouble rgb[3];
|
||||||
|
|
||||||
lch.h = i * 360.0 / csf->width;
|
lch[2] = i * 360.0 / csf->width;
|
||||||
|
|
||||||
|
/* TODO: determine if color is out of target space gammut instead of out
|
||||||
|
* of sRGB gamut.
|
||||||
|
*/
|
||||||
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
||||||
|
|
||||||
if (rgb.r < 0.0 || rgb.r > 1.0 ||
|
if (rgb[0] < 0.0 || rgb[0] > 1.0 ||
|
||||||
rgb.g < 0.0 || rgb.g > 1.0 ||
|
rgb[1] < 0.0 || rgb[1] > 1.0 ||
|
||||||
rgb.b < 0.0 || rgb.b > 1.0)
|
rgb[2] < 0.0 || rgb[2] > 1.0)
|
||||||
{
|
{
|
||||||
p[0] = csf->oog_color[0];
|
p[0] = csf->oog_color[0];
|
||||||
p[1] = csf->oog_color[1];
|
p[1] = csf->oog_color[1];
|
||||||
|
@ -1898,7 +1891,9 @@ color_select_render_lch_hue_lightness (ColorSelectFill *csf)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_rgb_get_uchar (&rgb, p, p + 1, p + 2);
|
p[0] = rgb[0] * 255;
|
||||||
|
p[1] = rgb[1] * 255;
|
||||||
|
p[2] = rgb[2] * 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
p += 3;
|
p += 3;
|
||||||
|
@ -1909,23 +1904,23 @@ static void
|
||||||
color_select_render_lch_hue_chroma (ColorSelectFill *csf)
|
color_select_render_lch_hue_chroma (ColorSelectFill *csf)
|
||||||
{
|
{
|
||||||
guchar *p = csf->buffer;
|
guchar *p = csf->buffer;
|
||||||
GimpLCH lch;
|
gdouble lch[3];
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
lch.l = csf->lch.l;
|
lch[0] = csf->lch[0];
|
||||||
lch.c = (csf->height - 1 - csf->y) * 200.0 / csf->height;
|
lch[1] = (csf->height - 1 - csf->y) * 200.0 / csf->height;
|
||||||
|
|
||||||
for (i = 0; i < csf->width; i++)
|
for (i = 0; i < csf->width; i++)
|
||||||
{
|
{
|
||||||
GimpRGB rgb;
|
gdouble rgb[3];
|
||||||
|
|
||||||
lch.h = i * 360.0 / csf->width;
|
lch[2] = i * 360.0 / csf->width;
|
||||||
|
|
||||||
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
babl_process (fish_lch_to_rgb, &lch, &rgb, 1);
|
||||||
|
|
||||||
if (rgb.r < 0.0 || rgb.r > 1.0 ||
|
if (rgb[0] < 0.0 || rgb[0] > 1.0 ||
|
||||||
rgb.g < 0.0 || rgb.g > 1.0 ||
|
rgb[1] < 0.0 || rgb[1] > 1.0 ||
|
||||||
rgb.b < 0.0 || rgb.b > 1.0)
|
rgb[2] < 0.0 || rgb[2] > 1.0)
|
||||||
{
|
{
|
||||||
p[0] = csf->oog_color[0];
|
p[0] = csf->oog_color[0];
|
||||||
p[1] = csf->oog_color[1];
|
p[1] = csf->oog_color[1];
|
||||||
|
@ -1933,7 +1928,9 @@ color_select_render_lch_hue_chroma (ColorSelectFill *csf)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_rgb_get_uchar (&rgb, p, p + 1, p + 2);
|
p[0] = rgb[0] * 255;
|
||||||
|
p[1] = rgb[1] * 255;
|
||||||
|
p[2] = rgb[2] * 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
p += 3;
|
p += 3;
|
||||||
|
|
|
@ -111,12 +111,10 @@ static void gimp_color_selection_switch_page (GtkWidget *widget
|
||||||
guint page_num,
|
guint page_num,
|
||||||
GimpColorSelection *selection);
|
GimpColorSelection *selection);
|
||||||
static void gimp_color_selection_notebook_changed (GimpColorSelector *selector,
|
static void gimp_color_selection_notebook_changed (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
|
||||||
GimpColorSelection *selection);
|
GimpColorSelection *selection);
|
||||||
static void gimp_color_selection_scales_changed (GimpColorSelector *selector,
|
static void gimp_color_selection_scales_changed (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
|
||||||
GimpColorSelection *selection);
|
GimpColorSelection *selection);
|
||||||
static void gimp_color_selection_color_picked (GtkWidget *widget,
|
static void gimp_color_selection_color_picked (GtkWidget *widget,
|
||||||
const GimpRGB *rgb,
|
const GimpRGB *rgb,
|
||||||
|
@ -182,8 +180,6 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
GtkSizeGroup *new_group;
|
GtkSizeGroup *new_group;
|
||||||
GtkSizeGroup *old_group;
|
GtkSizeGroup *old_group;
|
||||||
GimpRGB rgb;
|
|
||||||
GimpHSV hsv;
|
|
||||||
|
|
||||||
selection->priv = gimp_color_selection_get_instance_private (selection);
|
selection->priv = gimp_color_selection_get_instance_private (selection);
|
||||||
|
|
||||||
|
@ -194,11 +190,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (selection),
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (selection),
|
||||||
GTK_ORIENTATION_VERTICAL);
|
GTK_ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
priv->color = gegl_color_new ("black");
|
priv->color = gegl_color_new ("black");
|
||||||
|
|
||||||
gegl_color_get_pixel (priv->color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gegl_color_get_pixel (priv->color, babl_format ("HSVA double"), &hsv);
|
|
||||||
|
|
||||||
priv->channel = GIMP_COLOR_SELECTOR_RED;
|
priv->channel = GIMP_COLOR_SELECTOR_RED;
|
||||||
|
|
||||||
main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
|
@ -217,8 +209,7 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
_gimp_ensure_modules_func ();
|
_gimp_ensure_modules_func ();
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK,
|
priv->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK, priv->color, priv->channel);
|
||||||
&rgb, &hsv, priv->channel);
|
|
||||||
|
|
||||||
if (_gimp_ensure_modules_func)
|
if (_gimp_ensure_modules_func)
|
||||||
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
|
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
|
||||||
|
@ -306,8 +297,8 @@ gimp_color_selection_init (GimpColorSelection *selection)
|
||||||
TRUE, TRUE, 0);
|
TRUE, TRUE, 0);
|
||||||
gtk_widget_show (priv->right_vbox);
|
gtk_widget_show (priv->right_vbox);
|
||||||
|
|
||||||
priv->scales = gimp_color_selector_new (GIMP_TYPE_COLOR_SCALES,
|
priv->scales = gimp_color_selector_new (GIMP_TYPE_COLOR_SCALES, priv->color, priv->channel);
|
||||||
&rgb, &hsv, priv->channel);
|
|
||||||
gimp_color_selector_set_toggles_visible
|
gimp_color_selector_set_toggles_visible
|
||||||
(GIMP_COLOR_SELECTOR (priv->scales), TRUE);
|
(GIMP_COLOR_SELECTOR (priv->scales), TRUE);
|
||||||
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (priv->scales),
|
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (priv->scales),
|
||||||
|
@ -462,18 +453,23 @@ gimp_color_selection_set_color (GimpColorSelection *selection,
|
||||||
GeglColor *color)
|
GeglColor *color)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv;
|
GimpColorSelectionPrivate *priv;
|
||||||
|
GeglColor *old_color;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
||||||
g_return_if_fail (GEGL_IS_COLOR (color));
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
|
|
||||||
priv = GET_PRIVATE (selection);
|
priv = GET_PRIVATE (selection);
|
||||||
|
|
||||||
g_object_unref (priv->color);
|
old_color = priv->color;
|
||||||
priv->color = gegl_color_duplicate (color);
|
priv->color = gegl_color_duplicate (color);
|
||||||
|
|
||||||
gimp_color_selection_update (selection, UPDATE_ALL);
|
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
|
||||||
|
{
|
||||||
|
gimp_color_selection_update (selection, UPDATE_ALL);
|
||||||
|
gimp_color_selection_color_changed (selection);
|
||||||
|
}
|
||||||
|
|
||||||
gimp_color_selection_color_changed (selection);
|
g_object_unref (old_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -681,32 +677,44 @@ gimp_color_selection_switch_page (GtkWidget *widget,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_selection_notebook_changed (GimpColorSelector *selector,
|
gimp_color_selection_notebook_changed (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||||
|
GeglColor *old_color;
|
||||||
|
|
||||||
gegl_color_set_pixel (priv->color, babl_format ("HSVA double"), hsv);
|
old_color = priv->color;
|
||||||
|
priv->color = gegl_color_duplicate (color);
|
||||||
|
|
||||||
gimp_color_selection_update (selection,
|
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
|
||||||
UPDATE_SCALES | UPDATE_ENTRY | UPDATE_COLOR);
|
{
|
||||||
gimp_color_selection_color_changed (selection);
|
gimp_color_selection_update (selection,
|
||||||
|
UPDATE_SCALES | UPDATE_ENTRY | UPDATE_COLOR);
|
||||||
|
gimp_color_selection_color_changed (selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (old_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_selection_scales_changed (GimpColorSelector *selector,
|
gimp_color_selection_scales_changed (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
|
||||||
GimpColorSelection *selection)
|
GimpColorSelection *selection)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||||
|
GeglColor *old_color;
|
||||||
|
|
||||||
gegl_color_set_pixel (priv->color, babl_format ("HSVA double"), hsv);
|
old_color = priv->color;
|
||||||
|
priv->color = gegl_color_duplicate (color);
|
||||||
|
|
||||||
gimp_color_selection_update (selection,
|
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
|
||||||
UPDATE_ENTRY | UPDATE_NOTEBOOK | UPDATE_COLOR);
|
{
|
||||||
gimp_color_selection_color_changed (selection);
|
gimp_color_selection_update (selection,
|
||||||
|
UPDATE_ENTRY | UPDATE_NOTEBOOK | UPDATE_COLOR);
|
||||||
|
gimp_color_selection_color_changed (selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (old_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -768,11 +776,6 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
UpdateType update)
|
UpdateType update)
|
||||||
{
|
{
|
||||||
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
GimpColorSelectionPrivate *priv = GET_PRIVATE (selection);
|
||||||
GimpRGB rgb;
|
|
||||||
GimpHSV hsv;
|
|
||||||
|
|
||||||
gegl_color_get_pixel (priv->color, babl_format ("R'G'B'A double"), &rgb);
|
|
||||||
gegl_color_get_pixel (priv->color, babl_format ("HSVA double"), &hsv);
|
|
||||||
|
|
||||||
if (update & UPDATE_NOTEBOOK)
|
if (update & UPDATE_NOTEBOOK)
|
||||||
{
|
{
|
||||||
|
@ -780,8 +783,7 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
gimp_color_selection_notebook_changed,
|
gimp_color_selection_notebook_changed,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->notebook),
|
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->notebook), priv->color);
|
||||||
&rgb, &hsv);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->notebook,
|
g_signal_handlers_unblock_by_func (priv->notebook,
|
||||||
gimp_color_selection_notebook_changed,
|
gimp_color_selection_notebook_changed,
|
||||||
|
@ -794,8 +796,7 @@ gimp_color_selection_update (GimpColorSelection *selection,
|
||||||
gimp_color_selection_scales_changed,
|
gimp_color_selection_scales_changed,
|
||||||
selection);
|
selection);
|
||||||
|
|
||||||
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->scales),
|
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (priv->scales), priv->color);
|
||||||
&rgb, &hsv);
|
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (priv->scales,
|
g_signal_handlers_unblock_by_func (priv->scales,
|
||||||
gimp_color_selection_scales_changed,
|
gimp_color_selection_scales_changed,
|
||||||
|
|
|
@ -60,13 +60,25 @@ enum
|
||||||
|
|
||||||
struct _GimpColorSelectorPrivate
|
struct _GimpColorSelectorPrivate
|
||||||
{
|
{
|
||||||
gboolean model_visible[3];
|
gboolean toggles_visible;
|
||||||
|
gboolean toggles_sensitive;
|
||||||
|
gboolean show_alpha;
|
||||||
|
gboolean model_visible[3];
|
||||||
|
|
||||||
|
GimpColorSelectorChannel channel;
|
||||||
|
|
||||||
|
GeglColor *color;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GET_PRIVATE(obj) (((GimpColorSelector *) (obj))->priv)
|
#define GET_PRIVATE(obj) (((GimpColorSelector *) (obj))->priv)
|
||||||
|
|
||||||
|
|
||||||
static void gimp_color_selector_dispose (GObject *object);
|
static void gimp_color_selector_dispose (GObject *object);
|
||||||
|
|
||||||
|
static void gimp_color_selector_emit_color_changed (GimpColorSelector *selector);
|
||||||
|
static void gimp_color_selector_emit_channel_changed (GimpColorSelector *selector);
|
||||||
|
static void gimp_color_selector_emit_model_visible_changed (GimpColorSelector *selector,
|
||||||
|
GimpColorSelectorModel model);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorSelector, gimp_color_selector,
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorSelector, gimp_color_selector,
|
||||||
|
@ -89,11 +101,9 @@ gimp_color_selector_class_init (GimpColorSelectorClass *klass)
|
||||||
G_TYPE_FROM_CLASS (klass),
|
G_TYPE_FROM_CLASS (klass),
|
||||||
G_SIGNAL_RUN_FIRST,
|
G_SIGNAL_RUN_FIRST,
|
||||||
G_STRUCT_OFFSET (GimpColorSelectorClass, color_changed),
|
G_STRUCT_OFFSET (GimpColorSelectorClass, color_changed),
|
||||||
NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
_gimp_widgets_marshal_VOID__BOXED_BOXED,
|
G_TYPE_NONE, 1,
|
||||||
G_TYPE_NONE, 2,
|
GEGL_TYPE_COLOR);
|
||||||
GIMP_TYPE_RGB,
|
|
||||||
GIMP_TYPE_RGB);
|
|
||||||
|
|
||||||
selector_signals[CHANNEL_CHANGED] =
|
selector_signals[CHANNEL_CHANGED] =
|
||||||
g_signal_new ("channel-changed",
|
g_signal_new ("channel-changed",
|
||||||
|
@ -140,18 +150,16 @@ gimp_color_selector_init (GimpColorSelector *selector)
|
||||||
|
|
||||||
priv = GET_PRIVATE (selector);
|
priv = GET_PRIVATE (selector);
|
||||||
|
|
||||||
selector->toggles_visible = TRUE;
|
priv->toggles_visible = TRUE;
|
||||||
selector->toggles_sensitive = TRUE;
|
priv->toggles_sensitive = TRUE;
|
||||||
selector->show_alpha = TRUE;
|
priv->show_alpha = TRUE;
|
||||||
|
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (selector),
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (selector),
|
||||||
GTK_ORIENTATION_VERTICAL);
|
GTK_ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
gimp_rgba_set (&selector->rgb, 0.0, 0.0, 0.0, 1.0);
|
priv->channel = GIMP_COLOR_SELECTOR_RED;
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
|
||||||
|
|
||||||
selector->channel = GIMP_COLOR_SELECTOR_RED;
|
|
||||||
|
|
||||||
|
priv->color = gegl_color_new ("black");
|
||||||
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_RGB] = TRUE;
|
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_RGB] = TRUE;
|
||||||
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_LCH] = TRUE;
|
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_LCH] = TRUE;
|
||||||
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_HSV] = FALSE;
|
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_HSV] = FALSE;
|
||||||
|
@ -160,7 +168,10 @@ gimp_color_selector_init (GimpColorSelector *selector)
|
||||||
static void
|
static void
|
||||||
gimp_color_selector_dispose (GObject *object)
|
gimp_color_selector_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (object), NULL);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (object);
|
||||||
|
|
||||||
|
gimp_color_selector_set_config (selector, NULL);
|
||||||
|
g_clear_object (&selector->priv->color);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -171,8 +182,7 @@ gimp_color_selector_dispose (GObject *object)
|
||||||
/**
|
/**
|
||||||
* gimp_color_selector_new:
|
* gimp_color_selector_new:
|
||||||
* @selector_type: The #GType of the selector to create.
|
* @selector_type: The #GType of the selector to create.
|
||||||
* @rgb: The initial color to be edited.
|
* @color: The initial color to be edited.
|
||||||
* @hsv: The same color in HSV.
|
|
||||||
* @channel: The selector's initial channel.
|
* @channel: The selector's initial channel.
|
||||||
*
|
*
|
||||||
* Creates a new #GimpColorSelector widget of type @selector_type.
|
* Creates a new #GimpColorSelector widget of type @selector_type.
|
||||||
|
@ -186,20 +196,17 @@ gimp_color_selector_dispose (GObject *object)
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_color_selector_new (GType selector_type,
|
gimp_color_selector_new (GType selector_type,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
|
||||||
GimpColorSelectorChannel channel)
|
GimpColorSelectorChannel channel)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector;
|
GimpColorSelector *selector;
|
||||||
|
|
||||||
g_return_val_if_fail (g_type_is_a (selector_type, GIMP_TYPE_COLOR_SELECTOR),
|
g_return_val_if_fail (g_type_is_a (selector_type, GIMP_TYPE_COLOR_SELECTOR), NULL);
|
||||||
NULL);
|
g_return_val_if_fail (GEGL_IS_COLOR (color), NULL);
|
||||||
g_return_val_if_fail (rgb != NULL, NULL);
|
|
||||||
g_return_val_if_fail (hsv != NULL, NULL);
|
|
||||||
|
|
||||||
selector = g_object_new (selector_type, NULL);
|
selector = g_object_new (selector_type, NULL);
|
||||||
|
|
||||||
gimp_color_selector_set_color (selector, rgb, hsv);
|
gimp_color_selector_set_color (selector, color);
|
||||||
gimp_color_selector_set_channel (selector, channel);
|
gimp_color_selector_set_channel (selector, channel);
|
||||||
|
|
||||||
return GTK_WIDGET (selector);
|
return GTK_WIDGET (selector);
|
||||||
|
@ -221,11 +228,11 @@ gimp_color_selector_set_toggles_visible (GimpColorSelector *selector,
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||||
|
|
||||||
if (selector->toggles_visible != visible)
|
if (selector->priv->toggles_visible != visible)
|
||||||
{
|
{
|
||||||
GimpColorSelectorClass *selector_class;
|
GimpColorSelectorClass *selector_class;
|
||||||
|
|
||||||
selector->toggles_visible = visible ? TRUE : FALSE;
|
selector->priv->toggles_visible = visible ? TRUE : FALSE;
|
||||||
|
|
||||||
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
||||||
|
|
||||||
|
@ -249,7 +256,7 @@ gimp_color_selector_get_toggles_visible (GimpColorSelector *selector)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
||||||
|
|
||||||
return selector->toggles_visible;
|
return selector->priv->toggles_visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,11 +275,11 @@ gimp_color_selector_set_toggles_sensitive (GimpColorSelector *selector,
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||||
|
|
||||||
if (selector->toggles_sensitive != sensitive)
|
if (selector->priv->toggles_sensitive != sensitive)
|
||||||
{
|
{
|
||||||
GimpColorSelectorClass *selector_class;
|
GimpColorSelectorClass *selector_class;
|
||||||
|
|
||||||
selector->toggles_sensitive = sensitive ? TRUE : FALSE;
|
selector->priv->toggles_sensitive = sensitive ? TRUE : FALSE;
|
||||||
|
|
||||||
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
||||||
|
|
||||||
|
@ -296,7 +303,7 @@ gimp_color_selector_get_toggles_sensitive (GimpColorSelector *selector)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
||||||
|
|
||||||
return selector->toggles_sensitive;
|
return selector->priv->toggles_sensitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,11 +319,11 @@ gimp_color_selector_set_show_alpha (GimpColorSelector *selector,
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||||
|
|
||||||
if (show_alpha != selector->show_alpha)
|
if (show_alpha != selector->priv->show_alpha)
|
||||||
{
|
{
|
||||||
GimpColorSelectorClass *selector_class;
|
GimpColorSelectorClass *selector_class;
|
||||||
|
|
||||||
selector->show_alpha = show_alpha ? TRUE : FALSE;
|
selector->priv->show_alpha = show_alpha ? TRUE : FALSE;
|
||||||
|
|
||||||
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
||||||
|
|
||||||
|
@ -340,61 +347,64 @@ gimp_color_selector_get_show_alpha (GimpColorSelector *selector)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
||||||
|
|
||||||
return selector->show_alpha;
|
return selector->priv->show_alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_color_selector_set_color:
|
* gimp_color_selector_set_color:
|
||||||
* @selector: A #GimpColorSelector widget.
|
* @selector: A #GimpColorSelector widget.
|
||||||
* @rgb: The new color.
|
* @color: The new color.
|
||||||
* @hsv: The same color in HSV.
|
|
||||||
*
|
*
|
||||||
* Sets the color shown in the @selector widget.
|
* Sets the color shown in the @selector widget.
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gimp_color_selector_set_color (GimpColorSelector *selector,
|
gimp_color_selector_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color)
|
||||||
const GimpHSV *hsv)
|
|
||||||
{
|
{
|
||||||
GimpColorSelectorClass *selector_class;
|
GimpColorSelectorClass *selector_class;
|
||||||
|
GimpColorSelectorPrivate *priv;
|
||||||
|
GeglColor *old_color;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||||
g_return_if_fail (rgb != NULL);
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||||
g_return_if_fail (hsv != NULL);
|
|
||||||
|
|
||||||
selector->rgb = *rgb;
|
priv = GET_PRIVATE (selector);
|
||||||
selector->hsv = *hsv;
|
|
||||||
|
old_color = priv->color;
|
||||||
|
priv->color = gegl_color_duplicate (color);
|
||||||
|
|
||||||
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
||||||
|
|
||||||
if (selector_class->set_color)
|
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
|
||||||
selector_class->set_color (selector, rgb, hsv);
|
{
|
||||||
|
if (selector_class->set_color)
|
||||||
|
selector_class->set_color (selector, priv->color);
|
||||||
|
|
||||||
gimp_color_selector_emit_color_changed (selector);
|
gimp_color_selector_emit_color_changed (selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (old_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_color_selector_get_color:
|
* gimp_color_selector_get_color:
|
||||||
* @selector: A #GimpColorSelector widget.
|
* @selector: A #GimpColorSelector widget.
|
||||||
* @rgb: (out caller-allocates): Return location for the color.
|
|
||||||
* @hsv: (out caller-allocates): Return location for the same same
|
|
||||||
* color in HSV.
|
|
||||||
*
|
*
|
||||||
* Retrieves the color shown in the @selector widget.
|
* Retrieves the color shown in the @selector widget.
|
||||||
*
|
*
|
||||||
|
* Returns: (transfer full): a copy of the selected color.
|
||||||
* Since: 2.10
|
* Since: 2.10
|
||||||
**/
|
**/
|
||||||
void
|
GeglColor *
|
||||||
gimp_color_selector_get_color (GimpColorSelector *selector,
|
gimp_color_selector_get_color (GimpColorSelector *selector)
|
||||||
GimpRGB *rgb,
|
|
||||||
GimpHSV *hsv)
|
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
GimpColorSelectorPrivate *priv;
|
||||||
g_return_if_fail (rgb != NULL);
|
|
||||||
g_return_if_fail (hsv != NULL);
|
|
||||||
|
|
||||||
*rgb = selector->rgb;
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), NULL);
|
||||||
*hsv = selector->hsv;
|
|
||||||
|
priv = GET_PRIVATE (selector);
|
||||||
|
|
||||||
|
return gegl_color_duplicate (priv->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -414,12 +424,12 @@ gimp_color_selector_set_channel (GimpColorSelector *selector,
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||||
|
|
||||||
if (channel != selector->channel)
|
if (channel != selector->priv->channel)
|
||||||
{
|
{
|
||||||
GimpColorSelectorClass *selector_class;
|
GimpColorSelectorClass *selector_class;
|
||||||
GimpColorSelectorModel model = -1;
|
GimpColorSelectorModel model = -1;
|
||||||
|
|
||||||
selector->channel = channel;
|
selector->priv->channel = channel;
|
||||||
|
|
||||||
switch (channel)
|
switch (channel)
|
||||||
{
|
{
|
||||||
|
@ -496,7 +506,7 @@ gimp_color_selector_get_channel (GimpColorSelector *selector)
|
||||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector),
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector),
|
||||||
GIMP_COLOR_SELECTOR_RED);
|
GIMP_COLOR_SELECTOR_RED);
|
||||||
|
|
||||||
return selector->channel;
|
return selector->priv->channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -562,59 +572,6 @@ gimp_color_selector_get_model_visible (GimpColorSelector *selector,
|
||||||
return priv->model_visible[model];
|
return priv->model_visible[model];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_color_selector_emit_color_changed:
|
|
||||||
* @selector: A #GimpColorSelector widget.
|
|
||||||
*
|
|
||||||
* Emits the "color-changed" signal.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gimp_color_selector_emit_color_changed (GimpColorSelector *selector)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
||||||
|
|
||||||
g_signal_emit (selector, selector_signals[COLOR_CHANGED], 0,
|
|
||||||
&selector->rgb, &selector->hsv);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_color_selector_emit_channel_changed:
|
|
||||||
* @selector: A #GimpColorSelector widget.
|
|
||||||
*
|
|
||||||
* Emits the "channel-changed" signal.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gimp_color_selector_emit_channel_changed (GimpColorSelector *selector)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
||||||
|
|
||||||
g_signal_emit (selector, selector_signals[CHANNEL_CHANGED], 0,
|
|
||||||
selector->channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_color_selector_emit_model_visible_changed:
|
|
||||||
* @selector: A #GimpColorSelector widget.
|
|
||||||
* @model: The #GimpColorSelectorModel where visibility changed.
|
|
||||||
*
|
|
||||||
* Emits the "model-visible-changed" signal.
|
|
||||||
*
|
|
||||||
* Since: 2.10
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
gimp_color_selector_emit_model_visible_changed (GimpColorSelector *selector,
|
|
||||||
GimpColorSelectorModel model)
|
|
||||||
{
|
|
||||||
GimpColorSelectorPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
||||||
|
|
||||||
priv = GET_PRIVATE (selector);
|
|
||||||
|
|
||||||
g_signal_emit (selector, selector_signals[MODEL_VISIBLE_CHANGED], 0,
|
|
||||||
model, priv->model_visible[model]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_color_selector_set_config:
|
* gimp_color_selector_set_config:
|
||||||
* @selector: a #GimpColorSelector widget.
|
* @selector: a #GimpColorSelector widget.
|
||||||
|
@ -666,3 +623,62 @@ gimp_color_selector_set_simulation (GimpColorSelector *selector,
|
||||||
if (selector_class->set_simulation)
|
if (selector_class->set_simulation)
|
||||||
selector_class->set_simulation (selector, profile, intent, bpc);
|
selector_class->set_simulation (selector, profile, intent, bpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Private functions. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_selector_emit_color_changed:
|
||||||
|
* @selector: A #GimpColorSelector widget.
|
||||||
|
*
|
||||||
|
* Emits the "color-changed" signal.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
gimp_color_selector_emit_color_changed (GimpColorSelector *selector)
|
||||||
|
{
|
||||||
|
GimpColorSelectorPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||||
|
|
||||||
|
priv = GET_PRIVATE (selector);
|
||||||
|
|
||||||
|
g_signal_emit (selector, selector_signals[COLOR_CHANGED], 0, priv->color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_selector_emit_channel_changed:
|
||||||
|
* @selector: A #GimpColorSelector widget.
|
||||||
|
*
|
||||||
|
* Emits the "channel-changed" signal.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
gimp_color_selector_emit_channel_changed (GimpColorSelector *selector)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||||
|
|
||||||
|
g_signal_emit (selector, selector_signals[CHANNEL_CHANGED], 0,
|
||||||
|
selector->priv->channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_selector_emit_model_visible_changed:
|
||||||
|
* @selector: A #GimpColorSelector widget.
|
||||||
|
* @model: The #GimpColorSelectorModel where visibility changed.
|
||||||
|
*
|
||||||
|
* Emits the "model-visible-changed" signal.
|
||||||
|
*
|
||||||
|
* Since: 2.10
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
gimp_color_selector_emit_model_visible_changed (GimpColorSelector *selector,
|
||||||
|
GimpColorSelectorModel model)
|
||||||
|
{
|
||||||
|
GimpColorSelectorPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||||
|
|
||||||
|
priv = GET_PRIVATE (selector);
|
||||||
|
|
||||||
|
g_signal_emit (selector, selector_signals[MODEL_VISIBLE_CHANGED], 0,
|
||||||
|
model, priv->model_visible[model]);
|
||||||
|
}
|
||||||
|
|
|
@ -67,16 +67,6 @@ struct _GimpColorSelector
|
||||||
GtkBox parent_instance;
|
GtkBox parent_instance;
|
||||||
|
|
||||||
GimpColorSelectorPrivate *priv;
|
GimpColorSelectorPrivate *priv;
|
||||||
|
|
||||||
/* FIXME MOVE TO PRIVATE */
|
|
||||||
gboolean toggles_visible;
|
|
||||||
gboolean toggles_sensitive;
|
|
||||||
gboolean show_alpha;
|
|
||||||
|
|
||||||
GimpRGB rgb;
|
|
||||||
GimpHSV hsv;
|
|
||||||
|
|
||||||
GimpColorSelectorChannel channel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpColorSelectorClass
|
struct _GimpColorSelectorClass
|
||||||
|
@ -95,8 +85,7 @@ struct _GimpColorSelectorClass
|
||||||
void (* set_show_alpha) (GimpColorSelector *selector,
|
void (* set_show_alpha) (GimpColorSelector *selector,
|
||||||
gboolean show_alpha);
|
gboolean show_alpha);
|
||||||
void (* set_color) (GimpColorSelector *selector,
|
void (* set_color) (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
|
||||||
void (* set_channel) (GimpColorSelector *selector,
|
void (* set_channel) (GimpColorSelector *selector,
|
||||||
GimpColorSelectorChannel channel);
|
GimpColorSelectorChannel channel);
|
||||||
void (* set_model_visible) (GimpColorSelector *selector,
|
void (* set_model_visible) (GimpColorSelector *selector,
|
||||||
|
@ -112,8 +101,7 @@ struct _GimpColorSelectorClass
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
void (* color_changed) (GimpColorSelector *selector,
|
void (* color_changed) (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
|
||||||
void (* channel_changed) (GimpColorSelector *selector,
|
void (* channel_changed) (GimpColorSelector *selector,
|
||||||
GimpColorSelectorChannel channel);
|
GimpColorSelectorChannel channel);
|
||||||
void (* model_visible_changed) (GimpColorSelector *selector,
|
void (* model_visible_changed) (GimpColorSelector *selector,
|
||||||
|
@ -132,54 +120,45 @@ struct _GimpColorSelectorClass
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GType gimp_color_selector_get_type (void) G_GNUC_CONST;
|
GType gimp_color_selector_get_type (void) G_GNUC_CONST;
|
||||||
GtkWidget * gimp_color_selector_new (GType selector_type,
|
GtkWidget * gimp_color_selector_new (GType selector_type,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color,
|
||||||
const GimpHSV *hsv,
|
GimpColorSelectorChannel channel);
|
||||||
GimpColorSelectorChannel channel);
|
|
||||||
|
|
||||||
void gimp_color_selector_set_toggles_visible (GimpColorSelector *selector,
|
void gimp_color_selector_set_toggles_visible (GimpColorSelector *selector,
|
||||||
gboolean visible);
|
gboolean visible);
|
||||||
gboolean gimp_color_selector_get_toggles_visible (GimpColorSelector *selector);
|
gboolean gimp_color_selector_get_toggles_visible (GimpColorSelector *selector);
|
||||||
|
|
||||||
void gimp_color_selector_set_toggles_sensitive (GimpColorSelector *selector,
|
void gimp_color_selector_set_toggles_sensitive (GimpColorSelector *selector,
|
||||||
gboolean sensitive);
|
gboolean sensitive);
|
||||||
gboolean gimp_color_selector_get_toggles_sensitive (GimpColorSelector *selector);
|
gboolean gimp_color_selector_get_toggles_sensitive (GimpColorSelector *selector);
|
||||||
|
|
||||||
void gimp_color_selector_set_show_alpha (GimpColorSelector *selector,
|
void gimp_color_selector_set_show_alpha (GimpColorSelector *selector,
|
||||||
gboolean show_alpha);
|
gboolean show_alpha);
|
||||||
gboolean gimp_color_selector_get_show_alpha (GimpColorSelector *selector);
|
gboolean gimp_color_selector_get_show_alpha (GimpColorSelector *selector);
|
||||||
|
|
||||||
void gimp_color_selector_set_color (GimpColorSelector *selector,
|
void gimp_color_selector_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
GeglColor * gimp_color_selector_get_color (GimpColorSelector *selector);
|
||||||
void gimp_color_selector_get_color (GimpColorSelector *selector,
|
|
||||||
GimpRGB *rgb,
|
|
||||||
GimpHSV *hsv);
|
|
||||||
|
|
||||||
void gimp_color_selector_set_channel (GimpColorSelector *selector,
|
void gimp_color_selector_set_channel (GimpColorSelector *selector,
|
||||||
GimpColorSelectorChannel channel);
|
GimpColorSelectorChannel channel);
|
||||||
GimpColorSelectorChannel
|
GimpColorSelectorChannel
|
||||||
gimp_color_selector_get_channel (GimpColorSelector *selector);
|
gimp_color_selector_get_channel (GimpColorSelector *selector);
|
||||||
|
|
||||||
void gimp_color_selector_set_model_visible (GimpColorSelector *selector,
|
void gimp_color_selector_set_model_visible (GimpColorSelector *selector,
|
||||||
GimpColorSelectorModel model,
|
GimpColorSelectorModel model,
|
||||||
gboolean visible);
|
gboolean visible);
|
||||||
gboolean gimp_color_selector_get_model_visible (GimpColorSelector *selector,
|
gboolean gimp_color_selector_get_model_visible (GimpColorSelector *selector,
|
||||||
GimpColorSelectorModel model);
|
GimpColorSelectorModel model);
|
||||||
|
|
||||||
void gimp_color_selector_emit_color_changed (GimpColorSelector *selector);
|
void gimp_color_selector_set_config (GimpColorSelector *selector,
|
||||||
void gimp_color_selector_emit_channel_changed (GimpColorSelector *selector);
|
GimpColorConfig *config);
|
||||||
void gimp_color_selector_emit_model_visible_changed (GimpColorSelector *selector,
|
|
||||||
GimpColorSelectorModel model);
|
|
||||||
|
|
||||||
void gimp_color_selector_set_config (GimpColorSelector *selector,
|
void gimp_color_selector_set_simulation (GimpColorSelector *selector,
|
||||||
GimpColorConfig *config);
|
GimpColorProfile *profile,
|
||||||
|
GimpColorRenderingIntent intent,
|
||||||
void gimp_color_selector_set_simulation (GimpColorSelector *selector,
|
gboolean bpc);
|
||||||
GimpColorProfile *profile,
|
|
||||||
GimpColorRenderingIntent intent,
|
|
||||||
gboolean bpc);
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -128,9 +128,6 @@ EXPORTS
|
||||||
gimp_color_selection_set_show_alpha
|
gimp_color_selection_set_show_alpha
|
||||||
gimp_color_selection_set_simulation
|
gimp_color_selection_set_simulation
|
||||||
gimp_color_selector_channel_get_type
|
gimp_color_selector_channel_get_type
|
||||||
gimp_color_selector_emit_channel_changed
|
|
||||||
gimp_color_selector_emit_color_changed
|
|
||||||
gimp_color_selector_emit_model_visible_changed
|
|
||||||
gimp_color_selector_get_channel
|
gimp_color_selector_get_channel
|
||||||
gimp_color_selector_get_color
|
gimp_color_selector_get_color
|
||||||
gimp_color_selector_get_model_visible
|
gimp_color_selector_get_model_visible
|
||||||
|
|
|
@ -67,8 +67,7 @@ GType colorsel_cmyk_get_type (void);
|
||||||
static void colorsel_cmyk_dispose (GObject *object);
|
static void colorsel_cmyk_dispose (GObject *object);
|
||||||
|
|
||||||
static void colorsel_cmyk_set_color (GimpColorSelector *selector,
|
static void colorsel_cmyk_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
|
||||||
static void colorsel_cmyk_set_config (GimpColorSelector *selector,
|
static void colorsel_cmyk_set_config (GimpColorSelector *selector,
|
||||||
GimpColorConfig *config);
|
GimpColorConfig *config);
|
||||||
static void colorsel_cmyk_set_simulation (GimpColorSelector *selector,
|
static void colorsel_cmyk_set_simulation (GimpColorSelector *selector,
|
||||||
|
@ -209,16 +208,13 @@ colorsel_cmyk_dispose (GObject *object)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
colorsel_cmyk_set_color (GimpColorSelector *selector,
|
colorsel_cmyk_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color)
|
||||||
const GimpHSV *hsv)
|
|
||||||
{
|
{
|
||||||
GimpColorProfile *cmyk_profile = NULL;
|
GimpColorProfile *cmyk_profile = NULL;
|
||||||
GimpColorRenderingIntent intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
GimpColorRenderingIntent intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
||||||
const Babl *fish = NULL;
|
const Babl *space = NULL;
|
||||||
const Babl *space = NULL;
|
ColorselCmyk *module = COLORSEL_CMYK (selector);
|
||||||
ColorselCmyk *module = COLORSEL_CMYK (selector);
|
gfloat cmyk[4];
|
||||||
gfloat values[4];
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
/* Try Image Soft-proofing profile first, then default CMYK profile */
|
/* Try Image Soft-proofing profile first, then default CMYK profile */
|
||||||
if (module->simulation_profile)
|
if (module->simulation_profile)
|
||||||
|
@ -236,19 +232,16 @@ colorsel_cmyk_set_color (GimpColorSelector *selector,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
fish = babl_fish (babl_format ("R'G'B'A double"),
|
gegl_color_get_pixel (color, babl_format_with_space ("CMYK float", space), cmyk);
|
||||||
babl_format_with_space ("CMYK float", space));
|
|
||||||
|
|
||||||
babl_process (fish, rgb, values, 1);
|
for (gint i = 0; i < 4; i++)
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
{
|
{
|
||||||
g_signal_handlers_block_by_func (module->scales[i],
|
g_signal_handlers_block_by_func (module->scales[i],
|
||||||
colorsel_cmyk_scale_update,
|
colorsel_cmyk_scale_update,
|
||||||
module);
|
module);
|
||||||
|
|
||||||
values[i] *= 100.0;
|
cmyk[i] *= 100.0;
|
||||||
gimp_label_spin_set_value (GIMP_LABEL_SPIN (module->scales[i]), values[i]);
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (module->scales[i]), cmyk[i]);
|
||||||
|
|
||||||
g_signal_handlers_unblock_by_func (module->scales[i],
|
g_signal_handlers_unblock_by_func (module->scales[i],
|
||||||
colorsel_cmyk_scale_update,
|
colorsel_cmyk_scale_update,
|
||||||
|
@ -320,7 +313,12 @@ colorsel_cmyk_set_simulation (GimpColorSelector *selector,
|
||||||
module->simulation_bpc = bpc;
|
module->simulation_bpc = bpc;
|
||||||
|
|
||||||
if (! module->in_destruction)
|
if (! module->in_destruction)
|
||||||
colorsel_cmyk_set_color (selector, &selector->rgb, &selector->hsv);
|
{
|
||||||
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
||||||
|
|
||||||
|
colorsel_cmyk_set_color (selector, color);
|
||||||
|
g_object_unref (color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -330,13 +328,11 @@ colorsel_cmyk_scale_update (GimpLabelSpin *scale,
|
||||||
GimpColorProfile *cmyk_profile = NULL;
|
GimpColorProfile *cmyk_profile = NULL;
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
|
||||||
GimpColorRenderingIntent intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
GimpColorRenderingIntent intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
||||||
const Babl *fish = NULL;
|
|
||||||
const Babl *space = NULL;
|
const Babl *space = NULL;
|
||||||
|
GeglColor *color = gegl_color_new (NULL);
|
||||||
gfloat cmyk_values[4];
|
gfloat cmyk_values[4];
|
||||||
gfloat rgb_values[3];
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (gint i = 0; i < 4; i++)
|
||||||
cmyk_values[i] = gimp_label_spin_get_value (GIMP_LABEL_SPIN (module->scales[i])) / 100.0;
|
cmyk_values[i] = gimp_label_spin_get_value (GIMP_LABEL_SPIN (module->scales[i])) / 100.0;
|
||||||
|
|
||||||
if (module->simulation_profile)
|
if (module->simulation_profile)
|
||||||
|
@ -349,22 +345,12 @@ colorsel_cmyk_scale_update (GimpLabelSpin *scale,
|
||||||
{
|
{
|
||||||
intent = module->simulation_intent;
|
intent = module->simulation_intent;
|
||||||
|
|
||||||
space = gimp_color_profile_get_space (cmyk_profile, intent,
|
space = gimp_color_profile_get_space (cmyk_profile, intent, NULL);
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fish = babl_fish (babl_format_with_space ("CMYK float", space),
|
gegl_color_set_pixel (color, babl_format_with_space ("CMYK float", space), cmyk_values);
|
||||||
babl_format ("R'G'B'A float"));
|
gimp_color_selector_set_color (selector, color);
|
||||||
|
g_object_unref (color);
|
||||||
babl_process (fish, cmyk_values, rgb_values, 1);
|
|
||||||
|
|
||||||
selector->rgb.r = rgb_values[0];
|
|
||||||
selector->rgb.g = rgb_values[1];
|
|
||||||
selector->rgb.b = rgb_values[2];
|
|
||||||
|
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
|
||||||
|
|
||||||
gimp_color_selector_emit_color_changed (selector);
|
|
||||||
|
|
||||||
if (cmyk_profile && ! module->simulation_profile)
|
if (cmyk_profile && ! module->simulation_profile)
|
||||||
g_object_unref (cmyk_profile);
|
g_object_unref (cmyk_profile);
|
||||||
|
@ -415,5 +401,10 @@ colorsel_cmyk_config_changed (ColorselCmyk *module)
|
||||||
g_object_unref (cmyk_profile);
|
g_object_unref (cmyk_profile);
|
||||||
|
|
||||||
if (! module->in_destruction)
|
if (! module->in_destruction)
|
||||||
colorsel_cmyk_set_color (selector, &selector->rgb, &selector->hsv);
|
{
|
||||||
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
||||||
|
|
||||||
|
colorsel_cmyk_set_color (selector, color);
|
||||||
|
g_object_unref (color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,14 +383,20 @@ add_pigment (ColorselWater *water,
|
||||||
gdouble much)
|
gdouble much)
|
||||||
{
|
{
|
||||||
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (water);
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (water);
|
||||||
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
||||||
|
gdouble rgb[3];
|
||||||
|
|
||||||
much *= (gdouble) water->pressure_adjust;
|
much *= (gdouble) water->pressure_adjust;
|
||||||
|
|
||||||
|
/* TODO: both render (draw() function) and selecting colors should navigate
|
||||||
|
* the target color space, not sRGB.
|
||||||
|
*/
|
||||||
|
gegl_color_get_pixel (color, babl_format ("R'G'B' double"), rgb);
|
||||||
if (erase)
|
if (erase)
|
||||||
{
|
{
|
||||||
selector->rgb.r = 1.0 - (1.0 - selector->rgb.r) * (1.0 - much);
|
rgb[0] = 1.0 - (1.0 - rgb[0]) * (1.0 - much);
|
||||||
selector->rgb.g = 1.0 - (1.0 - selector->rgb.g) * (1.0 - much);
|
rgb[1] = 1.0 - (1.0 - rgb[1]) * (1.0 - much);
|
||||||
selector->rgb.b = 1.0 - (1.0 - selector->rgb.b) * (1.0 - much);
|
rgb[2] = 1.0 - (1.0 - rgb[2]) * (1.0 - much);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -398,16 +404,19 @@ add_pigment (ColorselWater *water,
|
||||||
gdouble g = calc (x, y, 120) / 256.0;
|
gdouble g = calc (x, y, 120) / 256.0;
|
||||||
gdouble b = calc (x, y, 240) / 256.0;
|
gdouble b = calc (x, y, 240) / 256.0;
|
||||||
|
|
||||||
selector->rgb.r *= (1.0 - (1.0 - r) * much);
|
rgb[0] *= (1.0 - (1.0 - r) * much);
|
||||||
selector->rgb.g *= (1.0 - (1.0 - g) * much);
|
rgb[1] *= (1.0 - (1.0 - g) * much);
|
||||||
selector->rgb.b *= (1.0 - (1.0 - b) * much);
|
rgb[2] *= (1.0 - (1.0 - b) * much);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_rgb_clamp (&selector->rgb);
|
rgb[0] = CLAMP (rgb[0], 0.0, 1.0);
|
||||||
|
rgb[1] = CLAMP (rgb[1], 0.0, 1.0);
|
||||||
|
rgb[2] = CLAMP (rgb[2], 0.0, 1.0);
|
||||||
|
gegl_color_set_pixel (color, babl_format ("R'G'B' double"), rgb);
|
||||||
|
|
||||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
gimp_color_selector_set_color (selector, color);
|
||||||
|
|
||||||
gimp_color_selector_emit_color_changed (selector);
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -59,8 +59,7 @@ struct _ColorselWheelClass
|
||||||
GType colorsel_wheel_get_type (void);
|
GType colorsel_wheel_get_type (void);
|
||||||
|
|
||||||
static void colorsel_wheel_set_color (GimpColorSelector *selector,
|
static void colorsel_wheel_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color);
|
||||||
const GimpHSV *hsv);
|
|
||||||
static void colorsel_wheel_set_config (GimpColorSelector *selector,
|
static void colorsel_wheel_set_config (GimpColorSelector *selector,
|
||||||
GimpColorConfig *config);
|
GimpColorConfig *config);
|
||||||
static void colorsel_wheel_changed (GimpColorWheel *hsv,
|
static void colorsel_wheel_changed (GimpColorWheel *hsv,
|
||||||
|
@ -131,13 +130,19 @@ colorsel_wheel_init (ColorselWheel *wheel)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
colorsel_wheel_set_color (GimpColorSelector *selector,
|
colorsel_wheel_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
GeglColor *color)
|
||||||
const GimpHSV *hsv)
|
|
||||||
{
|
{
|
||||||
ColorselWheel *wheel = COLORSEL_WHEEL (selector);
|
ColorselWheel *wheel = COLORSEL_WHEEL (selector);
|
||||||
|
gdouble hsv[3];
|
||||||
|
|
||||||
gimp_color_wheel_set_color (GIMP_COLOR_WHEEL (wheel->hsv),
|
gegl_color_get_pixel (color, babl_format ("HSV double"), hsv);
|
||||||
hsv->h, hsv->s, hsv->v);
|
g_signal_handlers_block_by_func (wheel->hsv,
|
||||||
|
G_CALLBACK (colorsel_wheel_changed),
|
||||||
|
wheel);
|
||||||
|
gimp_color_wheel_set_color (GIMP_COLOR_WHEEL (wheel->hsv), hsv[0], hsv[1], hsv[2]);
|
||||||
|
g_signal_handlers_unblock_by_func (wheel->hsv,
|
||||||
|
G_CALLBACK (colorsel_wheel_changed),
|
||||||
|
wheel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -151,14 +156,14 @@ colorsel_wheel_set_config (GimpColorSelector *selector,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
colorsel_wheel_changed (GimpColorWheel *hsv,
|
colorsel_wheel_changed (GimpColorWheel *wheel,
|
||||||
GimpColorSelector *selector)
|
GimpColorSelector *selector)
|
||||||
{
|
{
|
||||||
gimp_color_wheel_get_color (hsv,
|
GeglColor *color = gegl_color_new (NULL);
|
||||||
&selector->hsv.h,
|
gdouble hsv[3];
|
||||||
&selector->hsv.s,
|
|
||||||
&selector->hsv.v);
|
|
||||||
gimp_hsv_to_rgb (&selector->hsv, &selector->rgb);
|
|
||||||
|
|
||||||
gimp_color_selector_emit_color_changed (selector);
|
gimp_color_wheel_get_color (wheel, &hsv[0], &hsv[1], &hsv[2]);
|
||||||
|
gegl_color_set_pixel (color, babl_format ("HSV double"), hsv);
|
||||||
|
gimp_color_selector_set_color (selector, color);
|
||||||
|
g_object_unref (color);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue