2003-11-19 07:44:35 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2002-10-20 18:14:17 +08:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpcolorselector.c
|
|
|
|
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
|
|
|
* based on:
|
|
|
|
* Colour selector module
|
|
|
|
* Copyright (C) 1999 Austin Donnelly <austin@greenend.org.uk>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2003-11-23 21:28:15 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2002-10-20 18:14:17 +08:00
|
|
|
*
|
2003-11-23 21:28:15 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2002-10-20 18:14:17 +08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-11-23 21:28:15 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2002-10-20 18:14:17 +08:00
|
|
|
*
|
2003-11-23 21:28:15 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2002-10-20 18:14:17 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-05-03 09:36:22 +08:00
|
|
|
#include <gegl.h>
|
2002-10-20 18:14:17 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2006-09-26 16:55:41 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
#include "gimpwidgetstypes.h"
|
|
|
|
|
|
|
|
#include "gimpcolorselector.h"
|
2017-03-05 23:01:59 +08:00
|
|
|
#include "gimpicons.h"
|
2002-10-20 18:14:17 +08:00
|
|
|
#include "gimpwidgetsmarshal.h"
|
|
|
|
|
|
|
|
|
2010-07-06 00:01:28 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpcolorselector
|
|
|
|
* @title: GimpColorSelector
|
|
|
|
* @short_description: Pluggable GIMP color selector modules.
|
|
|
|
* @see_also: #GModule, #GTypeModule, #GimpModule
|
|
|
|
*
|
|
|
|
* Functions and definitions for creating pluggable GIMP color
|
|
|
|
* selector modules.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLOR_CHANGED,
|
2002-10-29 04:13:17 +08:00
|
|
|
CHANNEL_CHANGED,
|
2018-03-20 05:58:03 +08:00
|
|
|
MODEL_VISIBLE_CHANGED,
|
2023-12-20 19:09:25 +08:00
|
|
|
SIMULATION,
|
2002-10-20 18:14:17 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
typedef struct _GimpColorSelectorPrivate
|
2018-03-20 05:58:03 +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
|
|
|
gboolean toggles_visible;
|
|
|
|
gboolean toggles_sensitive;
|
|
|
|
gboolean show_alpha;
|
|
|
|
gboolean model_visible[3];
|
|
|
|
|
|
|
|
GimpColorSelectorChannel channel;
|
|
|
|
|
|
|
|
GeglColor *color;
|
2023-12-20 19:09:25 +08:00
|
|
|
|
|
|
|
gboolean simulation;
|
|
|
|
GimpColorProfile *simulation_profile;
|
|
|
|
GimpColorRenderingIntent simulation_intent;
|
|
|
|
gboolean simulation_bpc;
|
2024-08-01 11:55:31 +08:00
|
|
|
} GimpColorSelectorPrivate;
|
2018-03-20 05:58:03 +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
|
|
|
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);
|
2011-12-11 09:43:14 +08:00
|
|
|
|
|
|
|
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-19 00:09:39 +08:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorSelector, gimp_color_selector,
|
|
|
|
GTK_TYPE_BOX)
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_color_selector_parent_class
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static guint selector_signals[LAST_SIGNAL] = { 0 };
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selector_class_init (GimpColorSelectorClass *klass)
|
|
|
|
{
|
2011-12-11 09:43:14 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->dispose = gimp_color_selector_dispose;
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
selector_signals[COLOR_CHANGED] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("color-changed",
|
2002-10-20 18:14:17 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpColorSelectorClass, color_changed),
|
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
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GEGL_TYPE_COLOR);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
selector_signals[CHANNEL_CHANGED] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("channel-changed",
|
2002-10-29 04:13:17 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpColorSelectorClass, channel_changed),
|
2021-08-06 14:34:30 +08:00
|
|
|
NULL, NULL, NULL,
|
2002-10-29 04:13:17 +08:00
|
|
|
G_TYPE_NONE, 1,
|
2018-03-20 05:58:03 +08:00
|
|
|
GIMP_TYPE_COLOR_SELECTOR_CHANNEL);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
selector_signals[MODEL_VISIBLE_CHANGED] =
|
|
|
|
g_signal_new ("model-visible-changed",
|
2018-01-21 07:35:32 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2018-03-20 05:58:03 +08:00
|
|
|
G_STRUCT_OFFSET (GimpColorSelectorClass, model_visible_changed),
|
2018-01-21 07:35:32 +08:00
|
|
|
NULL, NULL,
|
2018-03-20 05:58:03 +08:00
|
|
|
_gimp_widgets_marshal_VOID__ENUM_BOOLEAN,
|
|
|
|
G_TYPE_NONE, 2,
|
|
|
|
GIMP_TYPE_COLOR_SELECTOR_MODEL,
|
|
|
|
G_TYPE_BOOLEAN);
|
2018-01-21 07:35:32 +08:00
|
|
|
|
2023-12-20 19:09:25 +08:00
|
|
|
selector_signals[SIMULATION] =
|
|
|
|
g_signal_new ("simulation",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpColorSelectorClass, simulation),
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_BOOLEAN);
|
|
|
|
|
2003-11-19 07:44:35 +08:00
|
|
|
klass->name = "Unnamed";
|
|
|
|
klass->help_id = NULL;
|
2017-03-05 23:01:59 +08:00
|
|
|
klass->icon_name = GIMP_ICON_PALETTE;
|
2002-11-05 08:02:56 +08:00
|
|
|
|
|
|
|
klass->set_toggles_visible = NULL;
|
|
|
|
klass->set_toggles_sensitive = NULL;
|
|
|
|
klass->set_show_alpha = NULL;
|
|
|
|
klass->set_color = NULL;
|
|
|
|
klass->set_channel = NULL;
|
2018-03-20 05:58:03 +08:00
|
|
|
klass->set_model_visible = NULL;
|
2002-11-05 08:02:56 +08:00
|
|
|
klass->color_changed = NULL;
|
|
|
|
klass->channel_changed = NULL;
|
2018-03-20 05:58:03 +08:00
|
|
|
klass->model_visible_changed = NULL;
|
2006-09-26 16:55:41 +08:00
|
|
|
klass->set_config = NULL;
|
2002-10-20 18:14:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selector_init (GimpColorSelector *selector)
|
|
|
|
{
|
2018-05-03 18:51:36 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
2018-03-20 05:58:03 +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
|
|
|
priv->toggles_visible = TRUE;
|
|
|
|
priv->toggles_sensitive = TRUE;
|
|
|
|
priv->show_alpha = TRUE;
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2011-07-28 01:53:34 +08:00
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (selector),
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
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
|
|
|
priv->channel = GIMP_COLOR_SELECTOR_RED;
|
2018-03-20 05:58:03 +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
|
|
|
priv->color = gegl_color_new ("black");
|
2018-03-20 05:58:03 +08:00
|
|
|
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_HSV] = FALSE;
|
2023-12-20 19:09:25 +08:00
|
|
|
|
|
|
|
priv->simulation = FALSE;
|
|
|
|
priv->simulation_profile = NULL;
|
|
|
|
priv->simulation_intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
|
|
|
priv->simulation_bpc = FALSE;
|
2002-10-20 18:14:17 +08:00
|
|
|
}
|
|
|
|
|
2011-12-11 09:43:14 +08:00
|
|
|
static void
|
|
|
|
gimp_color_selector_dispose (GObject *object)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (object);
|
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_color_selector_get_instance_private (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
|
|
|
|
|
|
|
gimp_color_selector_set_config (selector, NULL);
|
2024-08-01 11:55:31 +08:00
|
|
|
g_clear_object (&priv->color);
|
|
|
|
g_clear_object (&priv->simulation_profile);
|
2011-12-11 09:43:14 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_color_selector_new:
|
|
|
|
* @selector_type: The #GType of the selector to create.
|
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
|
|
|
* @color: The initial color to be edited.
|
2017-12-31 23:02:21 +08:00
|
|
|
* @channel: The selector's initial channel.
|
|
|
|
*
|
|
|
|
* Creates a new #GimpColorSelector widget of type @selector_type.
|
|
|
|
*
|
|
|
|
* Note that this is mostly internal API to be used by other widgets.
|
|
|
|
*
|
|
|
|
* Please use gimp_color_selection_new() for the "GIMP-typical" color
|
|
|
|
* selection widget. Also see gimp_color_button_new().
|
|
|
|
*
|
|
|
|
* Retunn value: the new #GimpColorSelector widget.
|
|
|
|
**/
|
2002-10-20 18:14:17 +08:00
|
|
|
GtkWidget *
|
2002-10-29 04:13:17 +08:00
|
|
|
gimp_color_selector_new (GType selector_type,
|
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,
|
2002-10-29 04:13:17 +08:00
|
|
|
GimpColorSelectorChannel channel)
|
2002-10-20 18:14:17 +08:00
|
|
|
{
|
|
|
|
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
|
|
|
g_return_val_if_fail (g_type_is_a (selector_type, GIMP_TYPE_COLOR_SELECTOR), NULL);
|
|
|
|
g_return_val_if_fail (GEGL_IS_COLOR (color), NULL);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
selector = g_object_new (selector_type, 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
|
|
|
gimp_color_selector_set_color (selector, color);
|
2002-10-29 04:13:17 +08:00
|
|
|
gimp_color_selector_set_channel (selector, channel);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
|
|
|
return GTK_WIDGET (selector);
|
|
|
|
}
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selector_set_toggles_visible:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
|
|
|
* @visible: The new @visible setting.
|
|
|
|
*
|
|
|
|
* Sets the @visible property of the @selector's toggles.
|
|
|
|
*
|
|
|
|
* This function has no effect if this @selector instance has no
|
|
|
|
* toggles to switch channels.
|
|
|
|
**/
|
2002-11-05 08:02:56 +08:00
|
|
|
void
|
|
|
|
gimp_color_selector_set_toggles_visible (GimpColorSelector *selector,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
|
|
|
|
|
|
|
if (priv->toggles_visible != visible)
|
2002-11-05 08:02:56 +08:00
|
|
|
{
|
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv->toggles_visible = visible ? TRUE : FALSE;
|
2002-11-05 08:02:56 +08:00
|
|
|
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
|
|
|
|
|
|
|
if (selector_class->set_toggles_visible)
|
|
|
|
selector_class->set_toggles_visible (selector, visible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selector_get_toggles_visible:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
|
|
|
*
|
|
|
|
* Returns the @visible property of the @selector's toggles.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: %TRUE if the #GimpColorSelector's toggles are visible.
|
2017-12-31 23:02:21 +08:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_color_selector_get_toggles_visible (GimpColorSelector *selector)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
|
|
|
|
|
|
|
return priv->toggles_visible;
|
2017-12-31 23:02:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_color_selector_set_toggles_sensitive:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
|
|
|
* @sensitive: The new @sensitive setting.
|
|
|
|
*
|
|
|
|
* Sets the @sensitive property of the @selector's toggles.
|
|
|
|
*
|
|
|
|
* This function has no effect if this @selector instance has no
|
|
|
|
* toggles to switch channels.
|
|
|
|
**/
|
2002-11-05 08:02:56 +08:00
|
|
|
void
|
|
|
|
gimp_color_selector_set_toggles_sensitive (GimpColorSelector *selector,
|
|
|
|
gboolean sensitive)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
|
|
|
|
|
|
|
if (priv->toggles_sensitive != sensitive)
|
2002-11-05 08:02:56 +08:00
|
|
|
{
|
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv->toggles_sensitive = sensitive ? TRUE : FALSE;
|
2002-11-05 08:02:56 +08:00
|
|
|
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
|
|
|
|
|
|
|
if (selector_class->set_toggles_sensitive)
|
|
|
|
selector_class->set_toggles_sensitive (selector, sensitive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selector_get_toggles_sensitive:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
|
|
|
*
|
|
|
|
* Returns the @sensitive property of the @selector's toggles.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: %TRUE if the #GimpColorSelector's toggles are sensitive.
|
2017-12-31 23:02:21 +08:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_color_selector_get_toggles_sensitive (GimpColorSelector *selector)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
|
|
|
|
|
|
|
return priv->toggles_sensitive;
|
2017-12-31 23:02:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_color_selector_set_show_alpha:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
|
|
|
* @show_alpha: The new @show_alpha setting.
|
|
|
|
*
|
|
|
|
* Sets the @show_alpha property of the @selector widget.
|
|
|
|
**/
|
2002-10-29 04:13:17 +08:00
|
|
|
void
|
|
|
|
gimp_color_selector_set_show_alpha (GimpColorSelector *selector,
|
|
|
|
gboolean show_alpha)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
|
|
|
|
|
|
|
if (show_alpha != priv->show_alpha)
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
2002-11-05 08:02:56 +08:00
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv->show_alpha = show_alpha ? TRUE : FALSE;
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
|
|
|
|
|
|
|
if (selector_class->set_show_alpha)
|
|
|
|
selector_class->set_show_alpha (selector, show_alpha);
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selector_get_show_alpha:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
|
|
|
*
|
|
|
|
* Returns the @selector's @show_alpha property.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: %TRUE if the #GimpColorSelector has alpha controls.
|
2017-12-31 23:02:21 +08:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_color_selector_get_show_alpha (GimpColorSelector *selector)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
|
|
|
|
|
|
|
return priv->show_alpha;
|
2017-12-31 23:02:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_color_selector_set_color:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
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
|
|
|
* @color: The new color.
|
2017-12-31 23:02:21 +08:00
|
|
|
*
|
|
|
|
* Sets the color shown in the @selector widget.
|
2024-06-07 20:16:34 +08:00
|
|
|
*
|
|
|
|
* Unlike most setters, this does NOT change the model (or update views)
|
|
|
|
* when the change is not perceivable to the eye.
|
|
|
|
*
|
|
|
|
* A control cannot depend on this actually changing the model.
|
|
|
|
* A control, e.g. a chroma slider, may show a small difference from the model.
|
|
|
|
*/
|
2002-10-20 18:14:17 +08:00
|
|
|
void
|
|
|
|
gimp_color_selector_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)
|
2002-10-20 18:14:17 +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
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
GimpColorSelectorPrivate *priv;
|
2002-11-05 08:02:56 +08:00
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (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
|
|
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
2002-10-20 18:14:17 +08:00
|
|
|
|
2024-06-07 20:16:34 +08:00
|
|
|
if (! gimp_color_is_perceptually_identical (priv->color, color))
|
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
|
|
|
{
|
2024-06-07 20:16:34 +08:00
|
|
|
g_object_unref (priv->color);
|
|
|
|
priv->color = gegl_color_duplicate (color);
|
|
|
|
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (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
|
|
|
if (selector_class->set_color)
|
|
|
|
selector_class->set_color (selector, priv->color);
|
|
|
|
|
|
|
|
gimp_color_selector_emit_color_changed (selector);
|
|
|
|
}
|
2024-06-07 20:16:34 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* This happens often, more than you might expect.
|
|
|
|
* A single user event may yield many calls to the setter,
|
|
|
|
* some but not all of which are perceptually identical.
|
|
|
|
*/
|
|
|
|
g_debug ("%s new color perceptually identical", G_STRFUNC);
|
|
|
|
}
|
2002-10-20 18:14:17 +08:00
|
|
|
}
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selector_get_color:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
|
|
|
*
|
|
|
|
* Retrieves the color shown in the @selector widget.
|
|
|
|
*
|
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
|
|
|
* Returns: (transfer full): a copy of the selected color.
|
2017-12-31 23:02:21 +08:00
|
|
|
* Since: 2.10
|
|
|
|
**/
|
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 *
|
|
|
|
gimp_color_selector_get_color (GimpColorSelector *selector)
|
2017-12-31 23:02:21 +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
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), NULL);
|
2017-12-31 23:02:21 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (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
|
|
|
|
|
|
|
return gegl_color_duplicate (priv->color);
|
2017-12-31 23:02:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_color_selector_set_channel:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
|
|
|
* @channel: The new @channel setting.
|
|
|
|
*
|
|
|
|
* Sets the @channel property of the @selector widget.
|
|
|
|
*
|
|
|
|
* Changes between displayed channels if this @selector instance has
|
|
|
|
* the ability to show different channels.
|
2018-01-21 07:35:32 +08:00
|
|
|
* This will also update the color model if needed.
|
2017-12-31 23:02:21 +08:00
|
|
|
**/
|
2002-10-20 18:14:17 +08:00
|
|
|
void
|
|
|
|
gimp_color_selector_set_channel (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorChannel channel)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2002-10-20 18:14:17 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
|
|
|
|
|
|
|
if (channel != priv->channel)
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
2002-11-05 08:02:56 +08:00
|
|
|
GimpColorSelectorClass *selector_class;
|
2018-03-20 05:58:03 +08:00
|
|
|
GimpColorSelectorModel model = -1;
|
2002-11-05 08:02:56 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv->channel = channel;
|
2002-11-05 08:02:56 +08:00
|
|
|
|
2018-01-21 07:35:32 +08:00
|
|
|
switch (channel)
|
|
|
|
{
|
|
|
|
case GIMP_COLOR_SELECTOR_RED:
|
|
|
|
case GIMP_COLOR_SELECTOR_GREEN:
|
|
|
|
case GIMP_COLOR_SELECTOR_BLUE:
|
2018-03-20 05:58:03 +08:00
|
|
|
model = GIMP_COLOR_SELECTOR_MODEL_RGB;
|
2018-01-21 07:35:32 +08:00
|
|
|
break;
|
2018-03-20 05:58:03 +08:00
|
|
|
|
2018-01-21 07:35:32 +08:00
|
|
|
case GIMP_COLOR_SELECTOR_HUE:
|
|
|
|
case GIMP_COLOR_SELECTOR_SATURATION:
|
|
|
|
case GIMP_COLOR_SELECTOR_VALUE:
|
2018-03-20 05:58:03 +08:00
|
|
|
model = GIMP_COLOR_SELECTOR_MODEL_HSV;
|
2018-01-21 07:35:32 +08:00
|
|
|
break;
|
2018-03-20 05:58:03 +08:00
|
|
|
|
2018-01-21 07:35:32 +08:00
|
|
|
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS:
|
|
|
|
case GIMP_COLOR_SELECTOR_LCH_CHROMA:
|
|
|
|
case GIMP_COLOR_SELECTOR_LCH_HUE:
|
2018-03-20 05:58:03 +08:00
|
|
|
model = GIMP_COLOR_SELECTOR_MODEL_LCH;
|
2018-01-21 07:35:32 +08:00
|
|
|
break;
|
2018-03-20 05:58:03 +08:00
|
|
|
|
2018-01-21 07:35:32 +08:00
|
|
|
case GIMP_COLOR_SELECTOR_ALPHA:
|
|
|
|
/* Alpha channel does not change the color model. */
|
2018-01-22 18:23:49 +08:00
|
|
|
break;
|
2018-03-20 05:58:03 +08:00
|
|
|
|
2018-01-21 07:35:32 +08:00
|
|
|
default:
|
|
|
|
/* Should not happen. */
|
2018-01-22 18:23:49 +08:00
|
|
|
g_return_if_reached ();
|
2018-01-21 07:35:32 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
if (selector_class->set_channel)
|
|
|
|
selector_class->set_channel (selector, channel);
|
|
|
|
|
2020-05-04 05:17:57 +08:00
|
|
|
gimp_color_selector_emit_channel_changed (selector);
|
2018-01-21 07:35:32 +08:00
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
if (model != -1)
|
2018-01-21 07:35:32 +08:00
|
|
|
{
|
2018-03-20 05:58:03 +08:00
|
|
|
/* make visibility of LCH and HSV mutuallky exclusive */
|
|
|
|
if (model == GIMP_COLOR_SELECTOR_MODEL_HSV)
|
|
|
|
{
|
|
|
|
gimp_color_selector_set_model_visible (selector,
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_LCH,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
else if (model == GIMP_COLOR_SELECTOR_MODEL_LCH)
|
|
|
|
{
|
|
|
|
gimp_color_selector_set_model_visible (selector,
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_HSV,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_color_selector_set_model_visible (selector, model, TRUE);
|
2018-01-21 07:35:32 +08:00
|
|
|
}
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
2002-10-20 18:14:17 +08:00
|
|
|
}
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selector_get_channel:
|
|
|
|
* @selector: A #GimpColorSelector widget.
|
|
|
|
*
|
|
|
|
* Returns the @selector's current channel.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: The #GimpColorSelectorChannel currently shown by the
|
2017-12-31 23:02:21 +08:00
|
|
|
* @selector.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
|
|
|
GimpColorSelectorChannel
|
|
|
|
gimp_color_selector_get_channel (GimpColorSelector *selector)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2017-12-31 23:02:21 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector),
|
2018-01-01 02:04:17 +08:00
|
|
|
GIMP_COLOR_SELECTOR_RED);
|
2017-12-31 23:02:21 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
|
|
|
|
|
|
|
return priv->channel;
|
2017-12-31 23:02:21 +08:00
|
|
|
}
|
|
|
|
|
2018-01-21 07:35:32 +08:00
|
|
|
/**
|
2018-03-20 05:58:03 +08:00
|
|
|
* gimp_color_selector_set_model_visible:
|
2018-01-21 07:35:32 +08:00
|
|
|
* @selector: A #GimpColorSelector widget.
|
2018-03-20 05:58:03 +08:00
|
|
|
* @model: The affected #GimpColorSelectorModel.
|
|
|
|
* @visible: The new visible setting.
|
2018-01-21 07:35:32 +08:00
|
|
|
*
|
2018-03-20 05:58:03 +08:00
|
|
|
* Sets the @model visible/invisible on the @selector widget.
|
2018-01-21 07:35:32 +08:00
|
|
|
*
|
2018-03-20 05:58:03 +08:00
|
|
|
* Toggles visibility of displayed models if this @selector instance
|
|
|
|
* has the ability to show different color models.
|
2018-01-21 07:35:32 +08:00
|
|
|
*
|
2018-03-20 05:58:03 +08:00
|
|
|
* Since: 2.10
|
2018-01-21 07:35:32 +08:00
|
|
|
**/
|
|
|
|
void
|
2018-03-20 05:58:03 +08:00
|
|
|
gimp_color_selector_set_model_visible (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorModel model,
|
|
|
|
gboolean visible)
|
2018-01-21 07:35:32 +08:00
|
|
|
{
|
2018-03-20 05:58:03 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
2018-01-21 07:35:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
2018-03-20 05:58:03 +08:00
|
|
|
|
|
|
|
visible = visible ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (visible != priv->model_visible[model])
|
2018-01-21 07:35:32 +08:00
|
|
|
{
|
2018-03-20 05:58:03 +08:00
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
|
|
|
|
priv->model_visible[model] = visible;
|
|
|
|
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
|
|
|
|
|
|
|
if (selector_class->set_model_visible)
|
|
|
|
selector_class->set_model_visible (selector, model, visible);
|
|
|
|
|
2020-05-04 05:17:57 +08:00
|
|
|
gimp_color_selector_emit_model_visible_changed (selector, model);
|
2018-01-21 07:35:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-03-20 05:58:03 +08:00
|
|
|
* gimp_color_selector_get_model_visible:
|
2018-01-21 07:35:32 +08:00
|
|
|
* @selector: A #GimpColorSelector widget.
|
2018-03-20 05:58:03 +08:00
|
|
|
* @model: The #GimpColorSelectorModel.
|
2018-01-21 07:35:32 +08:00
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: whether @model is visible in @selector.
|
2018-01-21 07:35:32 +08:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
**/
|
2018-03-20 05:58:03 +08:00
|
|
|
gboolean
|
|
|
|
gimp_color_selector_get_model_visible (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorModel model)
|
2018-01-21 07:35:32 +08:00
|
|
|
{
|
2018-03-20 05:58:03 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
2018-01-21 07:35:32 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
2018-03-20 05:58:03 +08:00
|
|
|
|
|
|
|
return priv->model_visible[model];
|
2018-01-21 07:35:32 +08:00
|
|
|
}
|
|
|
|
|
2006-09-26 16:55:41 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selector_set_config:
|
2010-07-06 01:04:15 +08:00
|
|
|
* @selector: a #GimpColorSelector widget.
|
|
|
|
* @config: a #GimpColorConfig object.
|
2006-09-26 16:55:41 +08:00
|
|
|
*
|
|
|
|
* Sets the color management configuration to use with this color selector.
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.4
|
2006-09-26 16:55:41 +08:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_color_selector_set_config (GimpColorSelector *selector,
|
|
|
|
GimpColorConfig *config)
|
|
|
|
{
|
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
|
|
g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config));
|
|
|
|
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
|
|
|
|
|
|
|
if (selector_class->set_config)
|
|
|
|
selector_class->set_config (selector, config);
|
|
|
|
}
|
2022-04-30 09:51:20 +08:00
|
|
|
|
app, libgimpwidgets: "Scales" color selection now space-aware.
This commit adds gimp_color_selector_set_format() which is meant to give
awareness of the target color format for which we are selecting colors.
Right now, I am only using this information on the Scales selection
method, which means that now colors you read and select are in the
target space. Even better, the out-of-gamut shown happens in the with
LCH scales is for the target space too. As tested, it already makes
quite a difference for an image in sRGB vs. say adobeRGB.
Note that right now, I only use the format information as a space, but
in fact, I made the API to be about a format because the actual format
can be used wisely too. First we may want to do different thing
depending on the color model itself (which the space may give away or
not, especially when using default spaces or when we'll have images
using models with no space in the future, such as CIE Lab). But also
whether the image is following the space TRC or is linear (or
perceptual) would change how we represent the data. If we were to show
non-linear values in the Colors dockable but when painting, the color
picker shows linear values for instance, it might be puzzling to people.
2023-12-17 09:32:48 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selector_set_format
|
|
|
|
* @selector: a #GimpColorSelector widget.
|
|
|
|
* @format: a Babl format, with space.
|
|
|
|
*
|
|
|
|
* Sets the babl format representing the color model and the space this
|
|
|
|
* @selector is supposed to display values for. Depending on the type of color
|
|
|
|
* selector, it may trigger various UX changes, or none at all.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_color_selector_set_format (GimpColorSelector *selector,
|
|
|
|
const Babl *format)
|
|
|
|
{
|
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
|
|
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
|
|
|
|
|
|
|
if (selector_class->set_format)
|
|
|
|
selector_class->set_format (selector, format);
|
|
|
|
}
|
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selector_set_simulation
|
|
|
|
* @selector: a #GimpColorSelector widget.
|
|
|
|
* @profile: a #GimpColorProfile object.
|
|
|
|
* @intent: a #GimpColorRenderingIntent enum.
|
|
|
|
* @bpc: a gboolean.
|
|
|
|
*
|
|
|
|
* Sets the simulation options to use with this color selector.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
app, libgimpwidgets: "Scales" color selection now space-aware.
This commit adds gimp_color_selector_set_format() which is meant to give
awareness of the target color format for which we are selecting colors.
Right now, I am only using this information on the Scales selection
method, which means that now colors you read and select are in the
target space. Even better, the out-of-gamut shown happens in the with
LCH scales is for the target space too. As tested, it already makes
quite a difference for an image in sRGB vs. say adobeRGB.
Note that right now, I only use the format information as a space, but
in fact, I made the API to be about a format because the actual format
can be used wisely too. First we may want to do different thing
depending on the color model itself (which the space may give away or
not, especially when using default spaces or when we'll have images
using models with no space in the future, such as CIE Lab). But also
whether the image is following the space TRC or is linear (or
perceptual) would change how we represent the data. If we were to show
non-linear values in the Colors dockable but when painting, the color
picker shows linear values for instance, it might be puzzling to people.
2023-12-17 09:32:48 +08:00
|
|
|
gimp_color_selector_set_simulation (GimpColorSelector *selector,
|
|
|
|
GimpColorProfile *profile,
|
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
gboolean bpc)
|
2022-04-30 09:51:20 +08:00
|
|
|
{
|
2023-12-20 19:09:25 +08:00
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
GimpColorSelectorPrivate *priv;
|
2022-04-30 09:51:20 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
|
|
g_return_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile));
|
|
|
|
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
2023-12-20 19:09:25 +08:00
|
|
|
|
|
|
|
if ((profile && ! priv->simulation_profile) ||
|
|
|
|
(! profile && priv->simulation_profile) ||
|
|
|
|
(profile && ! gimp_color_profile_is_equal (profile, priv->simulation_profile)) ||
|
|
|
|
intent != priv->simulation_intent ||
|
|
|
|
bpc != priv->simulation_bpc)
|
|
|
|
{
|
|
|
|
g_set_object (&priv->simulation_profile, profile);
|
|
|
|
priv->simulation_intent = intent;
|
|
|
|
priv->simulation_bpc = bpc;
|
|
|
|
|
|
|
|
if (selector_class->set_simulation)
|
|
|
|
selector_class->set_simulation (selector, profile, intent, bpc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_color_selector_get_simulation (GimpColorSelector *selector,
|
|
|
|
GimpColorProfile **profile,
|
|
|
|
GimpColorRenderingIntent *intent,
|
|
|
|
gboolean *bpc)
|
|
|
|
{
|
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
2023-12-20 19:09:25 +08:00
|
|
|
|
|
|
|
if (profile)
|
|
|
|
*profile = priv->simulation_profile;
|
|
|
|
if (intent)
|
|
|
|
*intent = priv->simulation_intent;
|
|
|
|
if (bpc)
|
|
|
|
*bpc = priv->simulation_bpc;
|
|
|
|
|
|
|
|
return priv->simulation;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_color_selector_enable_simulation (GimpColorSelector *selector,
|
|
|
|
gboolean enabled)
|
|
|
|
{
|
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (selector);
|
2023-12-20 19:09:25 +08:00
|
|
|
if (priv->simulation != enabled)
|
|
|
|
{
|
|
|
|
if (! enabled || priv->simulation_profile)
|
|
|
|
{
|
|
|
|
priv->simulation = enabled;
|
|
|
|
g_signal_emit (selector, selector_signals[SIMULATION], 0, enabled);
|
|
|
|
}
|
|
|
|
}
|
2022-04-30 09:51:20 +08:00
|
|
|
|
2023-12-20 19:09:25 +08:00
|
|
|
return priv->simulation;
|
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
|
|
|
|
|
|
|
|
|
|
|
/* 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));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (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
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectorPrivate *priv;
|
|
|
|
|
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
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (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
|
|
|
g_signal_emit (selector, selector_signals[CHANNEL_CHANGED], 0,
|
2024-08-01 11:55:31 +08:00
|
|
|
priv->channel);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selector_get_instance_private (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
|
|
|
|
|
|
|
g_signal_emit (selector, selector_signals[MODEL_VISIBLE_CHANGED], 0,
|
|
|
|
model, priv->model_visible[model]);
|
|
|
|
}
|