2013-11-04 05:06:51 +08:00
|
|
|
/* GIMP CMYK ColorSelector using littleCMS
|
|
|
|
* Copyright (C) 2006 Sven Neumann <sven@gimp.org>
|
2003-07-15 08:29:34 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-07-15 08:29:34 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-07-15 08:29:34 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2003-07-15 08:29:34 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-05-03 09:36:22 +08:00
|
|
|
#include <gegl.h>
|
2003-07-15 08:29:34 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2013-11-04 05:06:51 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2003-07-15 08:29:34 +08:00
|
|
|
#include "libgimpmodule/gimpmodule.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "libgimp/libgimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* definitions and variables */
|
|
|
|
|
2008-01-10 06:22:10 +08:00
|
|
|
#define COLORSEL_TYPE_CMYK (colorsel_cmyk_get_type ())
|
2003-07-15 08:29:34 +08:00
|
|
|
#define COLORSEL_CMYK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COLORSEL_TYPE_CMYK, ColorselCmyk))
|
|
|
|
#define COLORSEL_CMYK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), COLORSEL_TYPE_CMYK, ColorselCmykClass))
|
|
|
|
#define COLORSEL_IS_CMYK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COLORSEL_TYPE_CMYK))
|
|
|
|
#define COLORSEL_IS_CMYK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), COLORSEL_TYPE_CMYK))
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _ColorselCmyk ColorselCmyk;
|
|
|
|
typedef struct _ColorselCmykClass ColorselCmykClass;
|
|
|
|
|
|
|
|
struct _ColorselCmyk
|
|
|
|
{
|
2016-05-27 04:18:50 +08:00
|
|
|
GimpColorSelector parent_instance;
|
2003-07-15 08:29:34 +08:00
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
GimpColorConfig *config;
|
|
|
|
GimpColorProfile *simulation_profile;
|
|
|
|
GimpColorRenderingIntent simulation_intent;
|
|
|
|
gboolean simulation_bpc;
|
2013-11-04 05:06:51 +08:00
|
|
|
|
2024-06-21 20:44:08 +08:00
|
|
|
GtkWidget *scales[4];
|
|
|
|
GtkWidget *name_label;
|
2013-11-04 05:06:51 +08:00
|
|
|
|
2024-06-21 20:44:08 +08:00
|
|
|
gboolean in_destruction;
|
2003-07-15 08:29:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _ColorselCmykClass
|
|
|
|
{
|
|
|
|
GimpColorSelectorClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-05-22 09:51:36 +08:00
|
|
|
GType colorsel_cmyk_get_type (void);
|
2013-11-04 05:06:51 +08:00
|
|
|
|
|
|
|
static void colorsel_cmyk_dispose (GObject *object);
|
2003-07-15 08:29:34 +08:00
|
|
|
|
2003-09-03 06:52:25 +08:00
|
|
|
static void colorsel_cmyk_set_color (GimpColorSelector *selector,
|
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.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *color);
|
2013-11-04 05:06:51 +08:00
|
|
|
static void colorsel_cmyk_set_config (GimpColorSelector *selector,
|
|
|
|
GimpColorConfig *config);
|
2022-04-30 09:51:20 +08:00
|
|
|
static void colorsel_cmyk_set_simulation (GimpColorSelector *selector,
|
|
|
|
GimpColorProfile *profile,
|
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
gboolean bpc);
|
2013-11-04 05:06:51 +08:00
|
|
|
|
2020-11-06 00:37:15 +08:00
|
|
|
static void colorsel_cmyk_scale_update (GimpLabelSpin *scale,
|
2003-09-03 06:52:25 +08:00
|
|
|
ColorselCmyk *module);
|
2013-11-04 05:06:51 +08:00
|
|
|
static void colorsel_cmyk_config_changed (ColorselCmyk *module);
|
2003-07-15 08:29:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
static const GimpModuleInfo colorsel_cmyk_info =
|
|
|
|
{
|
|
|
|
GIMP_MODULE_ABI_VERSION,
|
2013-11-04 05:06:51 +08:00
|
|
|
N_("CMYK color selector (using color profile)"),
|
2003-07-15 08:29:34 +08:00
|
|
|
"Sven Neumann <sven@gimp.org>",
|
2013-11-04 05:06:51 +08:00
|
|
|
"v0.1",
|
|
|
|
"(c) 2006, released under the GPL",
|
|
|
|
"September 2006"
|
2003-07-15 08:29:34 +08:00
|
|
|
};
|
|
|
|
|
2008-01-10 06:22:10 +08:00
|
|
|
|
|
|
|
G_DEFINE_DYNAMIC_TYPE (ColorselCmyk, colorsel_cmyk,
|
|
|
|
GIMP_TYPE_COLOR_SELECTOR)
|
2003-07-15 08:29:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
G_MODULE_EXPORT const GimpModuleInfo *
|
|
|
|
gimp_module_query (GTypeModule *module)
|
|
|
|
{
|
|
|
|
return &colorsel_cmyk_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_MODULE_EXPORT gboolean
|
|
|
|
gimp_module_register (GTypeModule *module)
|
|
|
|
{
|
2008-01-10 06:22:10 +08:00
|
|
|
colorsel_cmyk_register_type (module);
|
2003-07-15 08:29:34 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
colorsel_cmyk_class_init (ColorselCmykClass *klass)
|
|
|
|
{
|
2013-11-04 05:06:51 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2004-08-17 23:07:27 +08:00
|
|
|
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
|
2003-07-15 08:29:34 +08:00
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
object_class->dispose = colorsel_cmyk_dispose;
|
2013-11-04 05:06:51 +08:00
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
selector_class->name = _("CMYK");
|
|
|
|
selector_class->help_id = "gimp-colorselector-cmyk";
|
|
|
|
selector_class->icon_name = GIMP_ICON_COLOR_SELECTOR_CMYK;
|
|
|
|
selector_class->set_color = colorsel_cmyk_set_color;
|
|
|
|
selector_class->set_config = colorsel_cmyk_set_config;
|
|
|
|
selector_class->set_simulation = colorsel_cmyk_set_simulation;
|
2018-06-24 21:36:00 +08:00
|
|
|
|
|
|
|
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "ColorselCmyk");
|
2003-07-15 08:29:34 +08:00
|
|
|
}
|
|
|
|
|
2008-01-10 06:22:10 +08:00
|
|
|
static void
|
|
|
|
colorsel_cmyk_class_finalize (ColorselCmykClass *klass)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-07-15 08:29:34 +08:00
|
|
|
static void
|
|
|
|
colorsel_cmyk_init (ColorselCmyk *module)
|
|
|
|
{
|
2018-06-25 00:15:16 +08:00
|
|
|
GtkWidget *grid;
|
|
|
|
gint i;
|
2003-07-15 08:29:34 +08:00
|
|
|
|
2006-04-20 15:15:15 +08:00
|
|
|
static const gchar * const cmyk_labels[] =
|
2003-07-15 18:54:03 +08:00
|
|
|
{
|
2005-09-14 00:06:06 +08:00
|
|
|
/* Cyan */
|
2003-07-15 08:29:34 +08:00
|
|
|
N_("_C"),
|
2005-09-14 00:06:06 +08:00
|
|
|
/* Magenta */
|
2003-07-15 08:29:34 +08:00
|
|
|
N_("_M"),
|
2005-09-14 00:06:06 +08:00
|
|
|
/* Yellow */
|
2003-07-15 08:29:34 +08:00
|
|
|
N_("_Y"),
|
2005-09-14 00:06:06 +08:00
|
|
|
/* Key (Black) */
|
2003-07-15 08:29:34 +08:00
|
|
|
N_("_K")
|
|
|
|
};
|
2006-04-20 15:15:15 +08:00
|
|
|
static const gchar * const cmyk_tips[] =
|
2003-07-15 08:29:34 +08:00
|
|
|
{
|
|
|
|
N_("Cyan"),
|
|
|
|
N_("Magenta"),
|
|
|
|
N_("Yellow"),
|
|
|
|
N_("Black")
|
|
|
|
};
|
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
module->config = NULL;
|
2003-09-03 06:52:25 +08:00
|
|
|
|
2013-11-04 05:06:51 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (module), 6);
|
|
|
|
|
2018-05-11 18:47:07 +08:00
|
|
|
grid = gtk_grid_new ();
|
2003-07-15 08:29:34 +08:00
|
|
|
|
2018-05-11 18:47:07 +08:00
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 1);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
|
2003-09-03 06:52:25 +08:00
|
|
|
|
2018-05-11 18:47:07 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (module), grid, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (grid);
|
2003-07-15 08:29:34 +08:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2020-11-01 09:35:03 +08:00
|
|
|
module->scales[i] = gimp_scale_entry_new (gettext (cmyk_labels[i]),
|
|
|
|
0.0, 0.0, 100.0, 0);
|
2020-10-31 07:53:26 +08:00
|
|
|
gimp_help_set_help_data (module->scales[i], gettext (cmyk_tips[i]), NULL);
|
|
|
|
|
|
|
|
g_signal_connect (module->scales[i], "value-changed",
|
|
|
|
G_CALLBACK (colorsel_cmyk_scale_update),
|
2006-11-25 00:15:50 +08:00
|
|
|
module);
|
2020-10-31 07:53:26 +08:00
|
|
|
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), module->scales[i], 1, i, 3, 1);
|
|
|
|
gtk_widget_show (module->scales[i]);
|
2003-07-15 08:29:34 +08:00
|
|
|
}
|
|
|
|
|
2013-11-04 05:06:51 +08:00
|
|
|
module->name_label = gtk_label_new (NULL);
|
2016-09-09 01:11:20 +08:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (module->name_label), 0.0);
|
2013-11-04 05:06:51 +08:00
|
|
|
gtk_label_set_ellipsize (GTK_LABEL (module->name_label), PANGO_ELLIPSIZE_END);
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (module->name_label),
|
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
|
|
|
|
-1);
|
|
|
|
gtk_box_pack_start (GTK_BOX (module), module->name_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (module->name_label);
|
|
|
|
}
|
2003-09-03 06:52:25 +08:00
|
|
|
|
2013-11-04 05:06:51 +08:00
|
|
|
static void
|
|
|
|
colorsel_cmyk_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
ColorselCmyk *module = COLORSEL_CMYK (object);
|
2003-09-03 06:52:25 +08:00
|
|
|
|
2013-11-04 05:06:51 +08:00
|
|
|
module->in_destruction = TRUE;
|
2003-09-03 06:52:25 +08:00
|
|
|
|
2013-11-04 05:06:51 +08:00
|
|
|
colorsel_cmyk_set_config (GIMP_COLOR_SELECTOR (object), NULL);
|
2022-04-30 09:51:20 +08:00
|
|
|
g_clear_object (&module->simulation_profile);
|
2003-09-03 06:52:25 +08:00
|
|
|
|
2013-11-04 05:06:51 +08:00
|
|
|
G_OBJECT_CLASS (colorsel_cmyk_parent_class)->dispose (object);
|
2003-07-15 08:29:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
colorsel_cmyk_set_color (GimpColorSelector *selector,
|
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.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *color)
|
2003-07-15 08:29:34 +08: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.
2023-12-12 16:01:17 +08:00
|
|
|
GimpColorProfile *cmyk_profile = NULL;
|
|
|
|
GimpColorRenderingIntent intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
|
|
|
const Babl *space = NULL;
|
|
|
|
ColorselCmyk *module = COLORSEL_CMYK (selector);
|
|
|
|
gfloat cmyk[4];
|
2022-04-30 09:51:20 +08:00
|
|
|
|
|
|
|
/* Try Image Soft-proofing profile first, then default CMYK profile */
|
|
|
|
if (module->simulation_profile)
|
|
|
|
cmyk_profile = module->simulation_profile;
|
|
|
|
|
|
|
|
if (! cmyk_profile && GIMP_IS_COLOR_CONFIG (module->config))
|
|
|
|
cmyk_profile = gimp_color_config_get_cmyk_color_profile (GIMP_COLOR_CONFIG (module->config),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (cmyk_profile && gimp_color_profile_is_cmyk (cmyk_profile))
|
2013-11-04 05:06:51 +08:00
|
|
|
{
|
2022-04-30 09:51:20 +08:00
|
|
|
intent = module->simulation_intent;
|
|
|
|
|
|
|
|
space = gimp_color_profile_get_space (cmyk_profile, intent,
|
|
|
|
NULL);
|
2013-11-04 05:06:51 +08: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.
2023-12-12 16:01:17 +08:00
|
|
|
gegl_color_get_pixel (color, babl_format_with_space ("CMYK float", space), cmyk);
|
2022-04-30 09:51:20 +08: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.
2023-12-12 16:01:17 +08:00
|
|
|
for (gint i = 0; i < 4; i++)
|
2013-11-04 05:06:51 +08:00
|
|
|
{
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_handlers_block_by_func (module->scales[i],
|
|
|
|
colorsel_cmyk_scale_update,
|
2013-11-04 05:06:51 +08:00
|
|
|
module);
|
|
|
|
|
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.
2023-12-12 16:01:17 +08:00
|
|
|
cmyk[i] *= 100.0;
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (module->scales[i]), cmyk[i]);
|
2013-11-04 05:06:51 +08:00
|
|
|
|
2020-10-31 07:53:26 +08:00
|
|
|
g_signal_handlers_unblock_by_func (module->scales[i],
|
|
|
|
colorsel_cmyk_scale_update,
|
2013-11-04 05:06:51 +08:00
|
|
|
module);
|
|
|
|
}
|
2022-04-30 09:51:20 +08:00
|
|
|
|
|
|
|
if (cmyk_profile && ! module->simulation_profile)
|
|
|
|
g_object_unref (cmyk_profile);
|
2013-11-04 05:06:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
colorsel_cmyk_set_config (GimpColorSelector *selector,
|
|
|
|
GimpColorConfig *config)
|
|
|
|
{
|
|
|
|
ColorselCmyk *module = COLORSEL_CMYK (selector);
|
|
|
|
|
2016-05-31 18:24:58 +08:00
|
|
|
if (config != module->config)
|
2013-11-04 05:06:51 +08:00
|
|
|
{
|
2016-05-31 18:24:58 +08:00
|
|
|
if (module->config)
|
2018-06-01 18:59:52 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (module->config,
|
|
|
|
colorsel_cmyk_config_changed,
|
|
|
|
module);
|
2016-05-31 18:24:58 +08:00
|
|
|
|
2018-06-01 18:59:52 +08:00
|
|
|
g_set_object (&module->config, config);
|
2016-05-31 18:24:58 +08:00
|
|
|
|
|
|
|
if (module->config)
|
2018-06-01 18:59:52 +08:00
|
|
|
g_signal_connect_swapped (module->config, "notify",
|
|
|
|
G_CALLBACK (colorsel_cmyk_config_changed),
|
|
|
|
module);
|
2016-05-31 18:24:58 +08:00
|
|
|
|
|
|
|
colorsel_cmyk_config_changed (module);
|
2013-11-04 05:06:51 +08:00
|
|
|
}
|
2003-07-15 08:29:34 +08:00
|
|
|
}
|
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
static void
|
|
|
|
colorsel_cmyk_set_simulation (GimpColorSelector *selector,
|
|
|
|
GimpColorProfile *profile,
|
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
gboolean bpc)
|
|
|
|
{
|
|
|
|
ColorselCmyk *module = COLORSEL_CMYK (selector);
|
|
|
|
GimpColorProfile *cmyk_profile = NULL;
|
|
|
|
gchar *text;
|
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (module->name_label), _("Profile: (none)"));
|
|
|
|
gimp_help_set_help_data (module->name_label, NULL, NULL);
|
|
|
|
|
|
|
|
g_set_object (&module->simulation_profile, profile);
|
|
|
|
|
|
|
|
cmyk_profile = module->simulation_profile;
|
|
|
|
|
|
|
|
if (! cmyk_profile && GIMP_IS_COLOR_CONFIG (module->config))
|
|
|
|
cmyk_profile = gimp_color_config_get_cmyk_color_profile (GIMP_COLOR_CONFIG (module->config),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (cmyk_profile && gimp_color_profile_is_cmyk (cmyk_profile))
|
|
|
|
{
|
|
|
|
text = g_strdup_printf (_("Profile: %s"),
|
|
|
|
gimp_color_profile_get_label (cmyk_profile));
|
|
|
|
gtk_label_set_text (GTK_LABEL (module->name_label), text);
|
|
|
|
g_free (text);
|
|
|
|
|
|
|
|
gimp_help_set_help_data (module->name_label,
|
|
|
|
gimp_color_profile_get_summary (cmyk_profile),
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
module->simulation_intent = intent;
|
|
|
|
module->simulation_bpc = bpc;
|
|
|
|
|
|
|
|
if (! module->in_destruction)
|
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.
2023-12-12 16:01:17 +08:00
|
|
|
{
|
|
|
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
|
|
|
|
|
|
|
colorsel_cmyk_set_color (selector, color);
|
|
|
|
g_object_unref (color);
|
|
|
|
}
|
2022-04-30 09:51:20 +08:00
|
|
|
}
|
|
|
|
|
2003-07-15 08:29:34 +08:00
|
|
|
static void
|
2020-11-06 00:37:15 +08:00
|
|
|
colorsel_cmyk_scale_update (GimpLabelSpin *scale,
|
|
|
|
ColorselCmyk *module)
|
2003-07-15 08:29:34 +08:00
|
|
|
{
|
2022-04-30 09:51:20 +08:00
|
|
|
GimpColorProfile *cmyk_profile = NULL;
|
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
|
|
|
|
GimpColorRenderingIntent intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
|
|
|
const Babl *space = NULL;
|
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.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *color = gegl_color_new (NULL);
|
2022-04-30 09:51:20 +08:00
|
|
|
gfloat cmyk_values[4];
|
2003-07-15 08:29:34 +08: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.
2023-12-12 16:01:17 +08:00
|
|
|
for (gint i = 0; i < 4; i++)
|
2022-04-30 09:51:20 +08:00
|
|
|
cmyk_values[i] = gimp_label_spin_get_value (GIMP_LABEL_SPIN (module->scales[i])) / 100.0;
|
2003-07-15 08:29:34 +08:00
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
if (module->simulation_profile)
|
|
|
|
cmyk_profile = module->simulation_profile;
|
2010-02-10 05:42:20 +08:00
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
if (! cmyk_profile && GIMP_IS_COLOR_CONFIG (module->config))
|
|
|
|
cmyk_profile = gimp_color_config_get_cmyk_color_profile (GIMP_COLOR_CONFIG (module->config),
|
|
|
|
NULL);
|
|
|
|
if (cmyk_profile)
|
2003-07-15 08:29:34 +08:00
|
|
|
{
|
2022-04-30 09:51:20 +08:00
|
|
|
intent = module->simulation_intent;
|
2003-07-15 08:29:34 +08: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.
2023-12-12 16:01:17 +08:00
|
|
|
space = gimp_color_profile_get_space (cmyk_profile, intent, NULL);
|
2013-11-04 05:06:51 +08: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.
2023-12-12 16:01:17 +08:00
|
|
|
gegl_color_set_pixel (color, babl_format_with_space ("CMYK float", space), cmyk_values);
|
|
|
|
gimp_color_selector_set_color (selector, color);
|
|
|
|
g_object_unref (color);
|
2022-04-30 09:51:20 +08:00
|
|
|
|
|
|
|
if (cmyk_profile && ! module->simulation_profile)
|
|
|
|
g_object_unref (cmyk_profile);
|
2003-07-15 08:29:34 +08:00
|
|
|
}
|
2003-09-03 06:52:25 +08:00
|
|
|
|
|
|
|
static void
|
2013-11-04 05:06:51 +08:00
|
|
|
colorsel_cmyk_config_changed (ColorselCmyk *module)
|
2003-09-03 06:52:25 +08:00
|
|
|
{
|
2016-05-27 04:18:50 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (module);
|
|
|
|
GimpColorConfig *config = module->config;
|
|
|
|
GimpColorProfile *rgb_profile = NULL;
|
|
|
|
GimpColorProfile *cmyk_profile = NULL;
|
|
|
|
gchar *text;
|
2013-11-04 05:06:51 +08:00
|
|
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (module->name_label), _("Profile: (none)"));
|
|
|
|
gimp_help_set_help_data (module->name_label, NULL, NULL);
|
|
|
|
|
|
|
|
if (! config)
|
|
|
|
goto out;
|
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
if (module->simulation_profile)
|
|
|
|
cmyk_profile = module->simulation_profile;
|
|
|
|
|
|
|
|
if (! cmyk_profile && GIMP_IS_COLOR_CONFIG (module->config))
|
|
|
|
cmyk_profile = gimp_color_config_get_cmyk_color_profile (GIMP_COLOR_CONFIG (module->config),
|
|
|
|
NULL);
|
|
|
|
|
2014-03-16 06:56:03 +08:00
|
|
|
if (! cmyk_profile)
|
2013-11-04 05:06:51 +08:00
|
|
|
goto out;
|
|
|
|
|
2015-12-16 07:22:39 +08:00
|
|
|
rgb_profile = gimp_color_profile_new_rgb_srgb ();
|
2015-08-19 23:57:48 +08:00
|
|
|
|
2015-07-12 20:08:42 +08:00
|
|
|
text = g_strdup_printf (_("Profile: %s"),
|
|
|
|
gimp_color_profile_get_label (cmyk_profile));
|
2013-11-04 05:06:51 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (module->name_label), text);
|
2014-03-16 06:56:03 +08:00
|
|
|
g_free (text);
|
2015-07-12 20:08:42 +08:00
|
|
|
|
|
|
|
gimp_help_set_help_data (module->name_label,
|
|
|
|
gimp_color_profile_get_summary (cmyk_profile),
|
|
|
|
NULL);
|
2013-11-04 05:06:51 +08:00
|
|
|
|
|
|
|
out:
|
2014-10-07 02:29:58 +08:00
|
|
|
|
|
|
|
if (rgb_profile)
|
2015-07-11 04:43:53 +08:00
|
|
|
g_object_unref (rgb_profile);
|
2014-10-07 02:29:58 +08:00
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
if (cmyk_profile && ! module->simulation_profile)
|
2015-07-11 04:43:53 +08:00
|
|
|
g_object_unref (cmyk_profile);
|
2014-10-07 02:29:58 +08:00
|
|
|
|
2013-11-04 05:06:51 +08:00
|
|
|
if (! module->in_destruction)
|
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.
2023-12-12 16:01:17 +08:00
|
|
|
{
|
|
|
|
GeglColor *color = gimp_color_selector_get_color (selector);
|
|
|
|
|
|
|
|
colorsel_cmyk_set_color (selector, color);
|
|
|
|
g_object_unref (color);
|
|
|
|
}
|
2003-09-03 06:52:25 +08:00
|
|
|
}
|