2003-11-19 07:44:35 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
2002-10-29 04:13:17 +08:00
|
|
|
*
|
|
|
|
* gimpcolorscales.c
|
|
|
|
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
|
|
|
* based on color_notebook module
|
|
|
|
* Copyright (C) 1998 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
|
2002-10-29 04:13:17 +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.
|
2003-11-19 07:44:35 +08:00
|
|
|
*
|
|
|
|
* This library 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
|
2002-10-29 04:13:17 +08:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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-29 04:13:17 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-11-25 08:04:26 +08:00
|
|
|
#include <string.h>
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2012-05-03 09:36:22 +08:00
|
|
|
#include <gegl.h>
|
2002-10-29 04:13:17 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-05-23 04:57:23 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2002-10-29 04:13:17 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2003-06-14 00:44:21 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2002-10-29 04:13:17 +08:00
|
|
|
|
|
|
|
#include "gimpwidgetstypes.h"
|
|
|
|
|
2002-10-30 10:02:18 +08:00
|
|
|
#include "gimpcolorscale.h"
|
2002-10-29 04:13:17 +08:00
|
|
|
#include "gimpcolorscales.h"
|
|
|
|
#include "gimpwidgets.h"
|
|
|
|
|
2002-10-29 20:09:46 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
2002-10-29 04:13:17 +08:00
|
|
|
|
|
|
|
|
2010-07-06 00:01:28 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpcolorscales
|
|
|
|
* @title: GimpColorScales
|
|
|
|
* @short_description: A #GimpColorSelector implementation.
|
|
|
|
*
|
|
|
|
* The #GimpColorScales widget is an implementation of a
|
|
|
|
* #GimpColorSelector. It shows a group of #GimpColorScale widgets
|
2017-05-18 01:28:40 +08:00
|
|
|
* that allow to adjust the HSV, LCH, and RGB color channels.
|
2010-07-06 00:01:28 +08:00
|
|
|
**/
|
|
|
|
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2022-11-16 01:45:39 +08:00
|
|
|
PROP_SHOW_RGB_U8,
|
|
|
|
PROP_SHOW_HSV
|
2018-01-01 00:53:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
GIMP_COLOR_SELECTOR_RED_U8 = GIMP_COLOR_SELECTOR_LCH_HUE + 1,
|
|
|
|
GIMP_COLOR_SELECTOR_GREEN_U8,
|
|
|
|
GIMP_COLOR_SELECTOR_BLUE_U8,
|
|
|
|
GIMP_COLOR_SELECTOR_ALPHA_U8
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _ColorScale ColorScale;
|
|
|
|
|
|
|
|
struct _ColorScale
|
|
|
|
{
|
|
|
|
GimpColorSelectorChannel channel;
|
|
|
|
|
|
|
|
gdouble default_value;
|
|
|
|
gdouble scale_min_value;
|
|
|
|
gdouble scale_max_value;
|
|
|
|
gdouble scale_inc;
|
|
|
|
gdouble spin_min_value;
|
|
|
|
gdouble spin_max_value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
#define GIMP_COLOR_SCALES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_SCALES, GimpColorScalesClass))
|
|
|
|
#define GIMP_IS_COLOR_SCALES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_SCALES))
|
|
|
|
#define GIMP_COLOR_SCALES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_SCALES, GimpColorScalesClass))
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _GimpColorScalesClass GimpColorScalesClass;
|
|
|
|
|
|
|
|
struct _GimpColorScales
|
|
|
|
{
|
|
|
|
GimpColorSelector parent_instance;
|
|
|
|
|
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
|
|
|
const Babl *format;
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
gboolean show_rgb_u8;
|
2023-02-17 05:16:27 +08:00
|
|
|
GBinding *show_rgb_u8_binding;
|
|
|
|
GBinding *show_hsv_binding;
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
GtkWidget *lch_group;
|
|
|
|
GtkWidget *hsv_group;
|
2018-01-01 00:53:13 +08:00
|
|
|
GtkWidget *rgb_percent_group;
|
|
|
|
GtkWidget *rgb_u8_group;
|
|
|
|
GtkWidget *alpha_percent_group;
|
|
|
|
GtkWidget *alpha_u8_group;
|
|
|
|
|
|
|
|
GtkWidget *dummy_u8_toggle;
|
|
|
|
GtkWidget *toggles[14];
|
|
|
|
GtkWidget *scales[14];
|
2023-12-17 22:22:18 +08:00
|
|
|
|
|
|
|
GList *profile_labels;
|
2002-10-29 04:13:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GimpColorScalesClass
|
|
|
|
{
|
|
|
|
GimpColorSelectorClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
static void gimp_color_scales_dispose (GObject *object);
|
|
|
|
static void gimp_color_scales_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_color_scales_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
static void gimp_color_scales_togg_sensitive (GimpColorSelector *selector,
|
|
|
|
gboolean sensitive);
|
|
|
|
static void gimp_color_scales_togg_visible (GimpColorSelector *selector,
|
|
|
|
gboolean visible);
|
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
static void gimp_color_scales_set_show_alpha (GimpColorSelector *selector,
|
|
|
|
gboolean show_alpha);
|
|
|
|
static void gimp_color_scales_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-29 04:13:17 +08:00
|
|
|
static void gimp_color_scales_set_channel (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorChannel channel);
|
2018-03-20 05:58:03 +08:00
|
|
|
static void gimp_color_scales_set_model_visible
|
|
|
|
(GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorModel model,
|
|
|
|
gboolean visible);
|
2016-05-27 06:51:32 +08:00
|
|
|
static void gimp_color_scales_set_config (GimpColorSelector *selector,
|
|
|
|
GimpColorConfig *config);
|
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
|
|
|
static void gimp_color_scales_set_format (GimpColorSelector *selector,
|
|
|
|
const Babl *format);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
static void gimp_color_scales_update_visible (GimpColorScales *scales);
|
2002-10-29 04:13:17 +08:00
|
|
|
static void gimp_color_scales_update_scales (GimpColorScales *scales,
|
|
|
|
gint skip);
|
2017-05-18 01:28:40 +08:00
|
|
|
static void gimp_color_scales_toggle_changed (GtkWidget *widget,
|
2002-10-29 04:13:17 +08:00
|
|
|
GimpColorScales *scales);
|
2020-11-01 09:23:03 +08:00
|
|
|
static void gimp_color_scales_scale_changed (GtkWidget *scale,
|
2002-10-29 04:13:17 +08:00
|
|
|
GimpColorScales *scales);
|
2018-03-20 05:58:03 +08:00
|
|
|
static void gimp_color_scales_toggle_lch_hsv (GtkToggleButton *toggle,
|
2018-01-21 07:35:32 +08:00
|
|
|
GimpColorScales *scales);
|
2004-07-26 23:20:18 +08:00
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpColorScales, gimp_color_scales, GIMP_TYPE_COLOR_SELECTOR)
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_color_scales_parent_class
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2017-05-18 01:28:40 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
static const ColorScale scale_defs[] =
|
|
|
|
{
|
|
|
|
{ GIMP_COLOR_SELECTOR_HUE, 0, 0, 360, 30, 0, 360 },
|
|
|
|
{ GIMP_COLOR_SELECTOR_SATURATION, 0, 0, 100, 10, 0, 500 },
|
|
|
|
{ GIMP_COLOR_SELECTOR_VALUE, 0, 0, 100, 10, 0, 500 },
|
|
|
|
|
|
|
|
{ GIMP_COLOR_SELECTOR_RED, 0, 0, 100, 10, -500, 500 },
|
|
|
|
{ GIMP_COLOR_SELECTOR_GREEN, 0, 0, 100, 10, -500, 500 },
|
|
|
|
{ GIMP_COLOR_SELECTOR_BLUE, 0, 0, 100, 10, -500, 500 },
|
|
|
|
{ GIMP_COLOR_SELECTOR_ALPHA, 0, 0, 100, 10, 0, 100 },
|
|
|
|
|
|
|
|
{ GIMP_COLOR_SELECTOR_LCH_LIGHTNESS, 0, 0, 100, 10, 0, 300 },
|
|
|
|
{ GIMP_COLOR_SELECTOR_LCH_CHROMA, 0, 0, 200, 10, 0, 300 },
|
|
|
|
{ GIMP_COLOR_SELECTOR_LCH_HUE, 0, 0, 360, 30, 0, 360 },
|
|
|
|
|
2022-11-16 01:45:39 +08:00
|
|
|
{ (GimpColorSelectorChannel) GIMP_COLOR_SELECTOR_RED_U8,
|
|
|
|
0, 0, 255, 16, -1275, 1275 },
|
|
|
|
{ (GimpColorSelectorChannel) GIMP_COLOR_SELECTOR_GREEN_U8,
|
|
|
|
0, 0, 255, 16, -1275, 1275 },
|
|
|
|
{ (GimpColorSelectorChannel) GIMP_COLOR_SELECTOR_BLUE_U8,
|
|
|
|
0, 0, 255, 16, -1275, 1275 },
|
|
|
|
{ (GimpColorSelectorChannel) GIMP_COLOR_SELECTOR_ALPHA_U8,
|
|
|
|
0, 0, 255, 16, 0, 255 }
|
2018-01-01 00:53:13 +08:00
|
|
|
};
|
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_scales_class_init (GimpColorScalesClass *klass)
|
|
|
|
{
|
2018-01-01 00:53:13 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2018-05-01 06:17:27 +08:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
object_class->dispose = gimp_color_scales_dispose;
|
|
|
|
object_class->get_property = gimp_color_scales_get_property;
|
|
|
|
object_class->set_property = gimp_color_scales_set_property;
|
|
|
|
|
2002-12-20 01:46:45 +08:00
|
|
|
selector_class->name = _("Scales");
|
2003-11-19 07:44:35 +08:00
|
|
|
selector_class->help_id = "gimp-colorselector-scales";
|
2017-03-05 23:01:59 +08:00
|
|
|
selector_class->icon_name = GIMP_ICON_DIALOG_TOOL_OPTIONS;
|
2002-11-05 08:02:56 +08:00
|
|
|
selector_class->set_toggles_visible = gimp_color_scales_togg_visible;
|
|
|
|
selector_class->set_toggles_sensitive = gimp_color_scales_togg_sensitive;
|
|
|
|
selector_class->set_show_alpha = gimp_color_scales_set_show_alpha;
|
|
|
|
selector_class->set_color = gimp_color_scales_set_color;
|
|
|
|
selector_class->set_channel = gimp_color_scales_set_channel;
|
2018-03-20 05:58:03 +08:00
|
|
|
selector_class->set_model_visible = gimp_color_scales_set_model_visible;
|
2016-05-27 06:51:32 +08:00
|
|
|
selector_class->set_config = gimp_color_scales_set_config;
|
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
|
|
|
selector_class->set_format = gimp_color_scales_set_format;
|
2017-05-18 01:28:40 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_SHOW_RGB_U8,
|
|
|
|
g_param_spec_boolean ("show-rgb-u8",
|
|
|
|
"Show RGB 0..255",
|
|
|
|
"Show RGB 0..255 scales",
|
|
|
|
FALSE,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
2022-11-16 01:45:39 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_SHOW_HSV,
|
|
|
|
g_param_spec_boolean ("show-hsv",
|
|
|
|
"Show HSV",
|
|
|
|
"Show HSV instead of LCH",
|
|
|
|
FALSE,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2018-05-01 06:17:27 +08:00
|
|
|
gtk_widget_class_set_css_name (widget_class, "GimpColorScales");
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
static GtkWidget *
|
|
|
|
create_group (GimpColorScales *scales,
|
|
|
|
GSList **radio_group,
|
|
|
|
GtkSizeGroup *size_group0,
|
|
|
|
GtkSizeGroup *size_group1,
|
|
|
|
GtkSizeGroup *size_group2,
|
|
|
|
GimpColorSelectorChannel first_channel,
|
|
|
|
GimpColorSelectorChannel last_channel)
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
2018-04-29 06:48:25 +08:00
|
|
|
GtkWidget *grid;
|
2005-05-23 04:57:23 +08:00
|
|
|
GEnumClass *enum_class;
|
2023-12-17 22:22:18 +08:00
|
|
|
GtkWidget *label = NULL;
|
|
|
|
gboolean add_label = FALSE;
|
2018-01-01 00:53:13 +08:00
|
|
|
gint row;
|
2002-11-05 08:02:56 +08:00
|
|
|
gint i;
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2018-04-29 06:48:25 +08:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 1);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 1);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2005-05-23 04:57:23 +08:00
|
|
|
enum_class = g_type_class_ref (GIMP_TYPE_COLOR_SELECTOR_CHANNEL);
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
for (i = first_channel, row = 0; i <= last_channel; i++, row++)
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
2019-08-09 19:29:34 +08:00
|
|
|
const GimpEnumDesc *enum_desc;
|
|
|
|
gint enum_value = i;
|
|
|
|
gboolean is_u8 = FALSE;
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2023-12-17 22:22:18 +08:00
|
|
|
if ((enum_value >= GIMP_COLOR_SELECTOR_RED_U8 &&
|
|
|
|
enum_value <= GIMP_COLOR_SELECTOR_BLUE_U8) ||
|
|
|
|
(enum_value >= GIMP_COLOR_SELECTOR_HUE &&
|
|
|
|
enum_value <= GIMP_COLOR_SELECTOR_BLUE))
|
|
|
|
add_label = TRUE;
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
if (enum_value >= GIMP_COLOR_SELECTOR_RED_U8 &&
|
|
|
|
enum_value <= GIMP_COLOR_SELECTOR_ALPHA_U8)
|
|
|
|
{
|
|
|
|
enum_value -= 7;
|
|
|
|
is_u8 = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum_desc = gimp_enum_get_desc (enum_class, enum_value);
|
2005-05-23 04:57:23 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
if (i == GIMP_COLOR_SELECTOR_ALPHA ||
|
|
|
|
i == GIMP_COLOR_SELECTOR_ALPHA_U8)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
2018-01-01 00:53:13 +08:00
|
|
|
/* just to allocate the space via the size group */
|
|
|
|
scales->toggles[i] = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2006-04-12 18:53:28 +08:00
|
|
|
}
|
2002-10-29 04:13:17 +08:00
|
|
|
else
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
2018-01-01 00:53:13 +08:00
|
|
|
scales->toggles[i] = gtk_radio_button_new (*radio_group);
|
|
|
|
*radio_group =
|
|
|
|
gtk_radio_button_get_group (GTK_RADIO_BUTTON (scales->toggles[i]));
|
|
|
|
|
2018-01-01 02:04:17 +08:00
|
|
|
if (enum_value == gimp_color_selector_get_channel (selector))
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scales->toggles[i]),
|
|
|
|
TRUE);
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
if (is_u8)
|
|
|
|
{
|
|
|
|
/* bind the RGB U8 toggles to the RGB percent toggles */
|
|
|
|
g_object_bind_property (scales->toggles[i - 7], "active",
|
|
|
|
scales->toggles[i], "active",
|
|
|
|
G_BINDING_SYNC_CREATE |
|
|
|
|
G_BINDING_BIDIRECTIONAL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_signal_connect (scales->toggles[i], "toggled",
|
|
|
|
G_CALLBACK (gimp_color_scales_toggle_changed),
|
|
|
|
scales);
|
|
|
|
}
|
|
|
|
}
|
2002-11-05 08:02:56 +08:00
|
|
|
|
2018-04-29 06:48:25 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), scales->toggles[i], 0, row, 1, 1);
|
2002-11-05 08:02:56 +08:00
|
|
|
|
2018-01-01 02:04:17 +08:00
|
|
|
if (gimp_color_selector_get_toggles_visible (selector))
|
2018-01-01 00:53:13 +08:00
|
|
|
gtk_widget_show (scales->toggles[i]);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
gimp_help_set_help_data (scales->toggles[i],
|
|
|
|
gettext (enum_desc->value_help), NULL);
|
|
|
|
|
|
|
|
gtk_size_group_add_widget (size_group0, scales->toggles[i]);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2020-11-01 09:23:03 +08:00
|
|
|
scales->scales[i] =
|
|
|
|
gimp_color_scale_entry_new (gettext (enum_desc->value_desc),
|
2018-05-11 19:52:33 +08:00
|
|
|
scale_defs[i].default_value,
|
2020-11-01 09:23:03 +08:00
|
|
|
scale_defs[i].spin_min_value,
|
|
|
|
scale_defs[i].spin_max_value,
|
|
|
|
1);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), scales->scales[i], 1, row, 3, 1);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (scales->scales[i]),
|
|
|
|
1.0, scale_defs[i].scale_inc);
|
2020-11-01 09:23:03 +08:00
|
|
|
gimp_help_set_help_data (scales->scales[i],
|
|
|
|
gettext (enum_desc->value_help),
|
|
|
|
NULL);
|
|
|
|
gtk_widget_show (scales->scales[i]);
|
|
|
|
|
2020-11-01 09:54:02 +08:00
|
|
|
gimp_scale_entry_set_bounds (GIMP_SCALE_ENTRY (scales->scales[i]),
|
|
|
|
scale_defs[i].scale_min_value,
|
|
|
|
scale_defs[i].scale_max_value,
|
|
|
|
TRUE);
|
2020-11-01 09:23:03 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (scales->scales[i]),
|
|
|
|
(gpointer) &scales->scales[i]);
|
|
|
|
|
2020-11-01 09:23:03 +08:00
|
|
|
gimp_color_scale_set_channel (GIMP_COLOR_SCALE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scales->scales[i]))),
|
2018-01-01 00:53:13 +08:00
|
|
|
enum_value);
|
|
|
|
gtk_size_group_add_widget (size_group1, scales->scales[i]);
|
2002-10-31 00:10:18 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
gtk_size_group_add_widget (size_group2,
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_get_spin_button (GIMP_LABEL_SPIN (scales->scales[i])));
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2020-11-01 09:23:03 +08:00
|
|
|
g_signal_connect (scales->scales[i], "value-changed",
|
2017-05-18 01:28:40 +08:00
|
|
|
G_CALLBACK (gimp_color_scales_scale_changed),
|
2006-04-12 18:53:28 +08:00
|
|
|
scales);
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
2005-05-23 04:57:23 +08:00
|
|
|
|
2023-12-17 22:22:18 +08:00
|
|
|
if (add_label)
|
|
|
|
{
|
2024-07-23 00:32:47 +08:00
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_POLICY_EXTERNAL, GTK_POLICY_NEVER);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), scrolled_window, 1, row, 3, 1);
|
|
|
|
gtk_widget_set_visible (scrolled_window, TRUE);
|
|
|
|
|
2023-12-17 22:22:18 +08:00
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
2024-07-23 00:32:47 +08:00
|
|
|
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
|
2023-12-17 22:22:18 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (label), _("Profile: sRGB"));
|
2024-07-23 00:32:47 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), label);
|
|
|
|
gtk_widget_set_visible (label, TRUE);
|
2023-12-17 22:22:18 +08:00
|
|
|
|
|
|
|
scales->profile_labels = g_list_prepend (scales->profile_labels, label);
|
|
|
|
}
|
|
|
|
|
2005-05-23 04:57:23 +08:00
|
|
|
g_type_class_unref (enum_class);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2018-04-29 06:48:25 +08:00
|
|
|
return grid;
|
2018-01-01 00:53:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_scales_init (GimpColorScales *scales)
|
|
|
|
{
|
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
|
|
|
GtkSizeGroup *size_group0;
|
|
|
|
GtkSizeGroup *size_group1;
|
|
|
|
GtkSizeGroup *size_group2;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *radio1;
|
|
|
|
GtkWidget *radio2;
|
2018-04-29 06:48:25 +08:00
|
|
|
GtkWidget *grid;
|
2018-01-21 07:35:32 +08:00
|
|
|
GSList *main_group;
|
2018-01-01 00:53:13 +08:00
|
|
|
GSList *u8_group;
|
|
|
|
|
|
|
|
gtk_box_set_spacing (GTK_BOX (scales), 5);
|
|
|
|
|
2023-02-17 05:16:27 +08:00
|
|
|
scales->show_rgb_u8_binding = NULL;
|
|
|
|
scales->show_hsv_binding = NULL;
|
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
/* don't need the toggles for our own operation */
|
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_toggles_visible (selector, FALSE);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2022-11-16 01:45:39 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
|
2018-03-20 05:58:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (scales), hbox, 0, 0, FALSE);
|
|
|
|
gtk_widget_show (hbox);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2018-01-21 07:35:32 +08:00
|
|
|
main_group = NULL;
|
|
|
|
u8_group = NULL;
|
|
|
|
|
2023-12-17 22:22:18 +08:00
|
|
|
scales->profile_labels = NULL;
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
scales->dummy_u8_toggle = gtk_radio_button_new (NULL);
|
|
|
|
g_object_ref_sink (scales->dummy_u8_toggle);
|
|
|
|
u8_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (scales->dummy_u8_toggle));
|
|
|
|
|
|
|
|
size_group0 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
size_group1 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
size_group2 = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
|
|
|
|
scales->rgb_percent_group =
|
2018-04-29 06:48:25 +08:00
|
|
|
grid = create_group (scales, &main_group,
|
|
|
|
size_group0, size_group1, size_group2,
|
|
|
|
GIMP_COLOR_SELECTOR_RED,
|
|
|
|
GIMP_COLOR_SELECTOR_BLUE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (scales), grid, FALSE, FALSE, 0);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
scales->rgb_u8_group =
|
2018-04-29 06:48:25 +08:00
|
|
|
grid = create_group (scales, &u8_group,
|
|
|
|
size_group0, size_group1, size_group2,
|
2022-11-16 01:45:39 +08:00
|
|
|
(GimpColorSelectorChannel) GIMP_COLOR_SELECTOR_RED_U8,
|
|
|
|
(GimpColorSelectorChannel) GIMP_COLOR_SELECTOR_BLUE_U8);
|
2018-04-29 06:48:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (scales), grid, FALSE, FALSE, 0);
|
2018-01-01 02:04:17 +08:00
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
scales->lch_group =
|
2018-04-29 06:48:25 +08:00
|
|
|
grid = create_group (scales, &main_group,
|
|
|
|
size_group0, size_group1, size_group2,
|
|
|
|
GIMP_COLOR_SELECTOR_LCH_LIGHTNESS,
|
|
|
|
GIMP_COLOR_SELECTOR_LCH_HUE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (scales), grid, FALSE, FALSE, 0);
|
2018-03-20 05:58:03 +08:00
|
|
|
|
2022-11-16 01:45:39 +08:00
|
|
|
scales->hsv_group =
|
2018-04-29 06:48:25 +08:00
|
|
|
grid = create_group (scales, &main_group,
|
|
|
|
size_group0, size_group1, size_group2,
|
|
|
|
GIMP_COLOR_SELECTOR_HUE,
|
|
|
|
GIMP_COLOR_SELECTOR_VALUE);
|
2022-11-16 01:45:39 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (scales), grid, FALSE, FALSE, 0);
|
2018-03-20 05:58:03 +08:00
|
|
|
|
|
|
|
scales->alpha_percent_group =
|
2018-04-29 06:48:25 +08:00
|
|
|
grid = create_group (scales, &main_group,
|
|
|
|
size_group0, size_group1, size_group2,
|
|
|
|
GIMP_COLOR_SELECTOR_ALPHA,
|
|
|
|
GIMP_COLOR_SELECTOR_ALPHA);
|
|
|
|
gtk_box_pack_start (GTK_BOX (scales), grid, FALSE, FALSE, 0);
|
2018-03-20 05:58:03 +08:00
|
|
|
|
|
|
|
scales->alpha_u8_group =
|
2018-04-29 06:48:25 +08:00
|
|
|
grid = create_group (scales, &u8_group,
|
|
|
|
size_group0, size_group1, size_group2,
|
2022-11-16 01:45:39 +08:00
|
|
|
(GimpColorSelectorChannel) GIMP_COLOR_SELECTOR_ALPHA_U8,
|
|
|
|
(GimpColorSelectorChannel) GIMP_COLOR_SELECTOR_ALPHA_U8);
|
2018-04-29 06:48:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (scales), grid, FALSE, FALSE, 0);
|
2018-03-20 05:58:03 +08:00
|
|
|
|
|
|
|
g_object_unref (size_group0);
|
|
|
|
g_object_unref (size_group1);
|
|
|
|
g_object_unref (size_group2);
|
|
|
|
|
2022-11-16 01:45:39 +08:00
|
|
|
radio1 = gtk_radio_button_new_with_label (NULL, _("0..100"));
|
|
|
|
radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1),
|
|
|
|
_("0..255"));
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio1), FALSE);
|
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio2), FALSE);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), radio1, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), radio2, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
gtk_widget_show (radio1);
|
|
|
|
gtk_widget_show (radio2);
|
|
|
|
|
2018-01-01 02:04:17 +08:00
|
|
|
if (scales->show_rgb_u8)
|
2018-01-01 00:53:13 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio2), TRUE);
|
2022-11-16 01:45:39 +08:00
|
|
|
else
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio1), TRUE);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
g_object_bind_property (G_OBJECT (radio2), "active",
|
2018-01-01 02:04:17 +08:00
|
|
|
G_OBJECT (scales), "show-rgb-u8",
|
2018-01-01 00:53:13 +08:00
|
|
|
G_BINDING_SYNC_CREATE |
|
|
|
|
G_BINDING_BIDIRECTIONAL);
|
|
|
|
|
2022-11-16 01:45:39 +08:00
|
|
|
radio1 = gtk_radio_button_new_with_label (NULL, _("LCh"));
|
|
|
|
radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1),
|
|
|
|
_("HSV"));
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio1), FALSE);
|
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radio2), FALSE);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), radio2, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), radio1, FALSE, FALSE, 0);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
gtk_widget_show (radio1);
|
|
|
|
gtk_widget_show (radio2);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
if (gimp_color_selector_get_model_visible (selector,
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_HSV))
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio2), TRUE);
|
2022-11-16 01:45:39 +08:00
|
|
|
else
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio1), TRUE);
|
|
|
|
|
|
|
|
g_object_bind_property (G_OBJECT (radio2), "active",
|
|
|
|
G_OBJECT (scales), "show-hsv",
|
|
|
|
G_BINDING_SYNC_CREATE |
|
|
|
|
G_BINDING_BIDIRECTIONAL);
|
2018-03-20 05:58:03 +08:00
|
|
|
|
|
|
|
g_signal_connect (radio1, "toggled",
|
|
|
|
G_CALLBACK (gimp_color_scales_toggle_lch_hsv),
|
|
|
|
scales);
|
2022-11-16 01:45:39 +08:00
|
|
|
|
|
|
|
gimp_color_scales_update_visible (scales);
|
2018-01-01 00:53:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_scales_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpColorScales *scales = GIMP_COLOR_SCALES (object);
|
|
|
|
|
|
|
|
g_clear_object (&scales->dummy_u8_toggle);
|
|
|
|
|
2023-02-17 05:16:27 +08:00
|
|
|
g_clear_pointer (&scales->show_rgb_u8_binding, g_binding_unbind);
|
|
|
|
g_clear_pointer (&scales->show_hsv_binding, g_binding_unbind);
|
2023-12-17 22:22:18 +08:00
|
|
|
g_clear_pointer (&scales->profile_labels, g_list_free);
|
2023-02-17 05:16:27 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_scales_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpColorScales *scales = GIMP_COLOR_SCALES (object);
|
2022-11-16 01:45:39 +08:00
|
|
|
gboolean hsv;
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_SHOW_RGB_U8:
|
|
|
|
g_value_set_boolean (value, scales->show_rgb_u8);
|
|
|
|
break;
|
2022-11-16 01:45:39 +08:00
|
|
|
case PROP_SHOW_HSV:
|
|
|
|
hsv = gimp_color_selector_get_model_visible (GIMP_COLOR_SELECTOR (object),
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_HSV);
|
|
|
|
g_value_set_boolean (value, hsv);
|
|
|
|
break;
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_scales_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpColorScales *scales = GIMP_COLOR_SCALES (object);
|
2022-11-16 01:45:39 +08:00
|
|
|
gboolean show_hsv;
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_SHOW_RGB_U8:
|
|
|
|
gimp_color_scales_set_show_rgb_u8 (scales, g_value_get_boolean (value));
|
|
|
|
break;
|
2022-11-16 01:45:39 +08:00
|
|
|
case PROP_SHOW_HSV:
|
|
|
|
show_hsv = g_value_get_boolean (value);
|
|
|
|
|
|
|
|
gimp_color_selector_set_model_visible (GIMP_COLOR_SELECTOR (object),
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_LCH,
|
|
|
|
! show_hsv);
|
|
|
|
gimp_color_selector_set_model_visible (GIMP_COLOR_SELECTOR (object),
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_HSV,
|
|
|
|
show_hsv);
|
|
|
|
break;
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
|
|
|
|
2002-11-05 08:02:56 +08:00
|
|
|
static void
|
|
|
|
gimp_color_scales_togg_sensitive (GimpColorSelector *selector,
|
|
|
|
gboolean sensitive)
|
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
2002-11-05 08:02:56 +08:00
|
|
|
gint i;
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
2017-05-18 01:28:40 +08:00
|
|
|
if (scales->toggles[i])
|
|
|
|
gtk_widget_set_sensitive (scales->toggles[i], sensitive);
|
2002-11-05 08:02:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_scales_togg_visible (GimpColorSelector *selector,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
2002-11-05 08:02:56 +08:00
|
|
|
gint i;
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
2017-05-18 01:28:40 +08:00
|
|
|
if (scales->toggles[i])
|
|
|
|
gtk_widget_set_visible (scales->toggles[i], visible);
|
2002-11-05 08:02:56 +08:00
|
|
|
}
|
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
static void
|
|
|
|
gimp_color_scales_set_show_alpha (GimpColorSelector *selector,
|
|
|
|
gboolean show_alpha)
|
|
|
|
{
|
2018-01-01 00:53:13 +08:00
|
|
|
gimp_color_scales_update_visible (GIMP_COLOR_SCALES (selector));
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_scales_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-29 04:13:17 +08:00
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
|
|
|
gimp_color_scales_update_scales (scales, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_scales_set_channel (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorChannel channel)
|
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
if (GTK_IS_RADIO_BUTTON (scales->toggles[channel]))
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_block_by_func (scales->toggles[channel],
|
2017-05-18 01:28:40 +08:00
|
|
|
gimp_color_scales_toggle_changed,
|
2002-10-29 04:13:17 +08:00
|
|
|
scales);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scales->toggles[channel]),
|
|
|
|
TRUE);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_unblock_by_func (scales->toggles[channel],
|
2017-05-18 01:28:40 +08:00
|
|
|
gimp_color_scales_toggle_changed,
|
2002-10-29 04:13:17 +08:00
|
|
|
scales);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
static void
|
|
|
|
gimp_color_scales_set_model_visible (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorModel model,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
gimp_color_scales_update_visible (GIMP_COLOR_SCALES (selector));
|
|
|
|
}
|
|
|
|
|
2016-05-27 06:51:32 +08:00
|
|
|
static void
|
|
|
|
gimp_color_scales_set_config (GimpColorSelector *selector,
|
|
|
|
GimpColorConfig *config)
|
|
|
|
{
|
|
|
|
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
|
|
|
gint i;
|
|
|
|
|
2023-02-17 05:16:27 +08:00
|
|
|
g_clear_pointer (&scales->show_rgb_u8_binding, g_binding_unbind);
|
|
|
|
g_clear_pointer (&scales->show_hsv_binding, g_binding_unbind);
|
|
|
|
|
2022-11-16 01:45:39 +08:00
|
|
|
if (config)
|
|
|
|
{
|
2023-02-17 05:16:27 +08:00
|
|
|
scales->show_rgb_u8_binding = g_object_bind_property (config, "show-rgb-u8",
|
|
|
|
scales, "show-rgb-u8",
|
|
|
|
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
|
|
|
scales->show_hsv_binding = g_object_bind_property (config, "show-hsv",
|
|
|
|
scales, "show-hsv",
|
|
|
|
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
|
2022-11-16 01:45:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
2016-05-27 06:51:32 +08:00
|
|
|
{
|
2018-01-01 00:53:13 +08:00
|
|
|
if (scales->scales[i])
|
2020-11-01 09:23:03 +08:00
|
|
|
gimp_color_scale_set_color_config (GIMP_COLOR_SCALE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scales->scales[i]))),
|
2016-05-27 06:51:32 +08:00
|
|
|
config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static void
|
|
|
|
gimp_color_scales_set_format (GimpColorSelector *selector,
|
|
|
|
const Babl *format)
|
|
|
|
{
|
|
|
|
GimpColorScales *scales = GIMP_COLOR_SCALES (selector);
|
|
|
|
|
|
|
|
scales->format = format;
|
|
|
|
|
2023-12-17 22:22:18 +08:00
|
|
|
if (format == NULL || babl_format_get_space (format) == babl_space ("sRGB"))
|
|
|
|
{
|
|
|
|
for (GList *iter = scales->profile_labels; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
gtk_label_set_text (GTK_LABEL (iter->data), _("Profile: sRGB"));
|
|
|
|
gimp_help_set_help_data (iter->data, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpColorProfile *profile = NULL;
|
|
|
|
const gchar *icc;
|
|
|
|
gint icc_len;
|
|
|
|
|
|
|
|
icc = babl_space_get_icc (babl_format_get_space (format), &icc_len);
|
|
|
|
profile = gimp_color_profile_new_from_icc_profile ((const guint8 *) icc, icc_len, NULL);
|
|
|
|
|
|
|
|
if (profile != NULL)
|
|
|
|
{
|
|
|
|
gchar *text;
|
|
|
|
|
|
|
|
text = g_strdup_printf (_("Profile: %s"), gimp_color_profile_get_label (profile));
|
|
|
|
for (GList *iter = scales->profile_labels; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
gtk_label_set_text (GTK_LABEL (iter->data), text);
|
|
|
|
gimp_help_set_help_data (iter->data,
|
|
|
|
gimp_color_profile_get_summary (profile),
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (GList *iter = scales->profile_labels; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
gtk_label_set_markup (GTK_LABEL (iter->data), _("Profile: <i>unknown</i>"));
|
|
|
|
gimp_help_set_help_data (iter->data, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_clear_object (&profile);
|
|
|
|
}
|
|
|
|
|
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_scales_update_scales (scales, -1);
|
|
|
|
}
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_color_scales_set_show_rgb_u8 (GimpColorScales *scales,
|
|
|
|
gboolean show_rgb_u8)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SCALES (scales));
|
|
|
|
|
|
|
|
show_rgb_u8 = show_rgb_u8 ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (show_rgb_u8 != scales->show_rgb_u8)
|
|
|
|
{
|
|
|
|
scales->show_rgb_u8 = show_rgb_u8;
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (scales), "show-rgb-u8");
|
|
|
|
|
|
|
|
gimp_color_scales_update_visible (scales);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_color_scales_get_show_rgb_u8 (GimpColorScales *scales)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SCALES (scales), FALSE);
|
|
|
|
|
|
|
|
return scales->show_rgb_u8;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_scales_update_visible (GimpColorScales *scales)
|
|
|
|
{
|
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
2018-01-01 02:04:17 +08:00
|
|
|
gboolean show_alpha;
|
2018-03-20 05:58:03 +08:00
|
|
|
gboolean rgb_visible;
|
|
|
|
gboolean lch_visible;
|
|
|
|
gboolean hsv_visible;
|
|
|
|
|
|
|
|
show_alpha = gimp_color_selector_get_show_alpha (selector);
|
|
|
|
rgb_visible = gimp_color_selector_get_model_visible (selector,
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_RGB);
|
|
|
|
lch_visible = gimp_color_selector_get_model_visible (selector,
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_LCH);
|
|
|
|
hsv_visible = gimp_color_selector_get_model_visible (selector,
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_HSV);
|
|
|
|
|
|
|
|
gtk_widget_set_visible (scales->rgb_u8_group,
|
|
|
|
rgb_visible && scales->show_rgb_u8);
|
2022-11-16 01:45:39 +08:00
|
|
|
gtk_widget_set_visible (scales->rgb_percent_group,
|
|
|
|
rgb_visible && ! scales->show_rgb_u8);
|
2018-03-20 05:58:03 +08:00
|
|
|
|
|
|
|
gtk_widget_set_visible (scales->lch_group, lch_visible);
|
|
|
|
gtk_widget_set_visible (scales->hsv_group, hsv_visible);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
gtk_widget_set_visible (scales->alpha_percent_group,
|
2018-01-01 02:04:17 +08:00
|
|
|
show_alpha && ! scales->show_rgb_u8);
|
2018-01-01 00:53:13 +08:00
|
|
|
gtk_widget_set_visible (scales->alpha_u8_group,
|
2018-01-01 02:04:17 +08:00
|
|
|
show_alpha && scales->show_rgb_u8);
|
2018-01-01 00:53:13 +08:00
|
|
|
}
|
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
static void
|
|
|
|
gimp_color_scales_update_scales (GimpColorScales *scales,
|
|
|
|
gint skip)
|
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
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);
|
|
|
|
gdouble pixel[4];
|
2024-04-21 11:42:27 +08:00
|
|
|
gfloat pixel_f[4];
|
2018-01-01 00:53:13 +08:00
|
|
|
gdouble values[G_N_ELEMENTS (scale_defs)];
|
2002-10-29 04:13:17 +08:00
|
|
|
gint i;
|
|
|
|
|
2024-04-21 11:42:27 +08:00
|
|
|
gegl_color_get_pixel (color, babl_format_with_space ("HSV float", scales->format), pixel_f);
|
|
|
|
values[GIMP_COLOR_SELECTOR_HUE] = pixel_f[0] * 360.0;
|
|
|
|
values[GIMP_COLOR_SELECTOR_SATURATION] = pixel_f[1] * 100.0;
|
|
|
|
values[GIMP_COLOR_SELECTOR_VALUE] = pixel_f[2] * 100.0;
|
2017-05-18 01:28:40 +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
|
|
|
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", scales->format), pixel);
|
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
|
|
|
values[GIMP_COLOR_SELECTOR_RED] = pixel[0] * 100.0;
|
|
|
|
values[GIMP_COLOR_SELECTOR_GREEN] = pixel[1] * 100.0;
|
|
|
|
values[GIMP_COLOR_SELECTOR_BLUE] = pixel[2] * 100.0;
|
|
|
|
values[GIMP_COLOR_SELECTOR_ALPHA] = pixel[3] * 100.0;
|
2017-05-18 01:28:40 +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
|
|
|
values[GIMP_COLOR_SELECTOR_RED_U8] = pixel[0] * 255.0;
|
|
|
|
values[GIMP_COLOR_SELECTOR_GREEN_U8] = pixel[1] * 255.0;
|
|
|
|
values[GIMP_COLOR_SELECTOR_BLUE_U8] = pixel[2] * 255.0;
|
|
|
|
values[GIMP_COLOR_SELECTOR_ALPHA_U8] = pixel[3] * 255.0;
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2024-08-09 03:25:07 +08:00
|
|
|
gegl_color_get_pixel (color, babl_format ("CIE LCH(ab) float"), pixel_f);
|
|
|
|
values[GIMP_COLOR_SELECTOR_LCH_LIGHTNESS] = pixel_f[0];
|
|
|
|
values[GIMP_COLOR_SELECTOR_LCH_CHROMA] = pixel_f[1];
|
|
|
|
values[GIMP_COLOR_SELECTOR_LCH_HUE] = pixel_f[2];
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
|
|
|
if (i != skip)
|
|
|
|
{
|
2020-11-01 09:23:03 +08:00
|
|
|
g_signal_handlers_block_by_func (scales->scales[i],
|
2017-05-18 01:28:40 +08:00
|
|
|
gimp_color_scales_scale_changed,
|
2002-10-29 04:13:17 +08:00
|
|
|
scales);
|
|
|
|
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (scales->scales[i]), values[i]);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2020-11-01 09:23:03 +08:00
|
|
|
g_signal_handlers_unblock_by_func (scales->scales[i],
|
2017-05-18 01:28:40 +08:00
|
|
|
gimp_color_scales_scale_changed,
|
2002-10-29 04:13:17 +08:00
|
|
|
scales);
|
|
|
|
}
|
2002-10-31 00:10:18 +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_scale_set_format (GIMP_COLOR_SCALE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scales->scales[i]))),
|
|
|
|
scales->format);
|
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_scale_set_color (GIMP_COLOR_SCALE (gimp_scale_entry_get_range (GIMP_SCALE_ENTRY (scales->scales[i]))), color);
|
2002-10-29 04:13: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
|
|
|
|
|
|
|
g_object_unref (color);
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-05-18 01:28:40 +08:00
|
|
|
gimp_color_scales_toggle_changed (GtkWidget *widget,
|
|
|
|
GimpColorScales *scales)
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
2002-10-29 04:13:17 +08:00
|
|
|
|
2008-06-28 23:09:46 +08:00
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
|
|
|
{
|
|
|
|
if (widget == scales->toggles[i])
|
|
|
|
{
|
2018-01-01 02:04:17 +08:00
|
|
|
gimp_color_selector_set_channel (selector, i);
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
if (i < GIMP_COLOR_SELECTOR_RED ||
|
|
|
|
i > GIMP_COLOR_SELECTOR_BLUE)
|
|
|
|
{
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scales->dummy_u8_toggle),
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-11-01 09:23:03 +08:00
|
|
|
gimp_color_scales_scale_changed (GtkWidget *scale,
|
2017-05-18 01:28:40 +08:00
|
|
|
GimpColorScales *scales)
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
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);
|
2020-11-06 00:37:15 +08:00
|
|
|
gdouble value = gimp_label_spin_get_value (GIMP_LABEL_SPIN (scale));
|
2024-08-09 05:44:53 +08:00
|
|
|
gfloat lch[4];
|
2024-04-21 11:42:27 +08:00
|
|
|
gfloat hsv[4];
|
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
|
|
|
gdouble rgb[4];
|
2002-10-29 04:13:17 +08:00
|
|
|
gint i;
|
|
|
|
|
2018-01-01 00:53:13 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (scale_defs); i++)
|
2020-11-01 09:23:03 +08:00
|
|
|
if (scales->scales[i] == scale)
|
2002-10-29 04:13:17 +08:00
|
|
|
break;
|
|
|
|
|
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
|
|
|
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", scales->format), rgb);
|
2024-04-21 11:42:27 +08:00
|
|
|
gegl_color_get_pixel (color, babl_format_with_space ("HSVA float", scales->format), hsv);
|
2024-08-09 05:44:53 +08:00
|
|
|
gegl_color_get_pixel (color, babl_format ("CIE LCH(ab) alpha float"), lch);
|
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
|
|
|
|
2002-10-29 04:13:17 +08:00
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case GIMP_COLOR_SELECTOR_HUE:
|
2024-04-21 11:42:27 +08:00
|
|
|
hsv[0] = value / 360.0f;
|
2002-10-29 04:13:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_SATURATION:
|
2024-04-21 11:42:27 +08:00
|
|
|
hsv[1] = value / 100.0f;
|
2002-10-29 04:13:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_VALUE:
|
2024-04-21 11:42:27 +08:00
|
|
|
hsv[2] = value / 100.0f;
|
2002-10-29 04:13:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_RED:
|
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
|
|
|
rgb[0] = value / 100.0;
|
2002-10-29 04:13:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_GREEN:
|
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
|
|
|
rgb[1] = value / 100.0;
|
2002-10-29 04:13:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_BLUE:
|
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
|
|
|
rgb[2] = value / 100.0;
|
2002-10-29 04:13:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_ALPHA:
|
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_set_alpha (color, value / 100.0);
|
2002-10-29 04:13:17 +08:00
|
|
|
break;
|
2017-05-18 01:28:40 +08:00
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_LCH_LIGHTNESS:
|
2024-08-09 05:44:53 +08:00
|
|
|
lch[0] = (gfloat) value;
|
2017-05-18 01:28:40 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_LCH_CHROMA:
|
2024-08-09 05:44:53 +08:00
|
|
|
lch[1] = (gfloat) value;
|
2017-05-18 01:28:40 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_LCH_HUE:
|
2024-08-09 05:44:53 +08:00
|
|
|
lch[2] = (gfloat) value;
|
2017-05-18 01:28:40 +08:00
|
|
|
break;
|
2018-01-01 00:53:13 +08:00
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_RED_U8:
|
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
|
|
|
rgb[0] = value / 255.0;
|
2018-01-01 00:53:13 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_GREEN_U8:
|
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
|
|
|
rgb[1] = value / 255.0;
|
2018-01-01 00:53:13 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_BLUE_U8:
|
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
|
|
|
rgb[2] = value / 255.0;
|
2018-01-01 00:53:13 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_SELECTOR_ALPHA_U8:
|
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_set_alpha (color, value / 255.0);
|
2018-01-01 00:53:13 +08:00
|
|
|
break;
|
2002-10-29 04:13: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
|
|
|
|
2017-05-18 01:28:40 +08:00
|
|
|
if ((i >= GIMP_COLOR_SELECTOR_HUE) &&
|
|
|
|
(i <= GIMP_COLOR_SELECTOR_VALUE))
|
2002-10-29 04:13:17 +08:00
|
|
|
{
|
2024-04-21 11:42:27 +08:00
|
|
|
gegl_color_set_pixel (color, babl_format_with_space ("HSVA float", scales->format), hsv);
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
2017-05-18 01:28:40 +08:00
|
|
|
else if ((i >= GIMP_COLOR_SELECTOR_LCH_LIGHTNESS) &&
|
|
|
|
(i <= GIMP_COLOR_SELECTOR_LCH_HUE))
|
|
|
|
{
|
2024-08-09 05:44:53 +08:00
|
|
|
gegl_color_set_pixel (color, babl_format ("CIE LCH(ab) alpha float"), lch);
|
2002-10-29 04:13: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
|
|
|
else if (((i >= GIMP_COLOR_SELECTOR_RED) &&
|
|
|
|
(i <= GIMP_COLOR_SELECTOR_BLUE)) ||
|
|
|
|
((i >= GIMP_COLOR_SELECTOR_RED_U8) &&
|
|
|
|
(i <= GIMP_COLOR_SELECTOR_BLUE_U8)))
|
2018-01-01 00:53:13 +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
|
|
|
gegl_color_set_pixel (color, babl_format_with_space ("R'G'B'A double", scales->format), rgb);
|
2018-01-01 00:53:13 +08:00
|
|
|
}
|
2002-10-29 04:13: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
|
|
|
gimp_color_selector_set_color (selector, color);
|
2002-10-29 04:13: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
|
|
|
g_object_unref (color);
|
2002-10-29 04:13:17 +08:00
|
|
|
}
|
2018-01-21 07:35:32 +08:00
|
|
|
|
|
|
|
static void
|
2018-03-20 05:58:03 +08:00
|
|
|
gimp_color_scales_toggle_lch_hsv (GtkToggleButton *toggle,
|
|
|
|
GimpColorScales *scales)
|
2018-01-21 07:35:32 +08:00
|
|
|
{
|
2018-03-20 05:58:03 +08:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
|
2022-11-16 01:45:39 +08:00
|
|
|
gboolean show_hsv = ! gtk_toggle_button_get_active (toggle);
|
|
|
|
|
|
|
|
gimp_color_selector_set_model_visible (selector,
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_LCH,
|
|
|
|
! show_hsv);
|
|
|
|
gimp_color_selector_set_model_visible (selector,
|
|
|
|
GIMP_COLOR_SELECTOR_MODEL_HSV,
|
|
|
|
show_hsv);
|
|
|
|
g_object_set (scales, "show-hsv", show_hsv, NULL);
|
2018-01-21 07:35:32 +08:00
|
|
|
}
|