2003-11-11 00:38:37 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpcolorselection.c
|
|
|
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2003-11-23 21:28:15 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2003-11-11 00:38:37 +08:00
|
|
|
*
|
2003-11-23 21:28:15 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2003-11-11 00:38:37 +08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-11-23 21:28:15 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-11-11 00:38:37 +08:00
|
|
|
*
|
2003-11-23 21:28:15 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2003-11-11 00:38:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-05-03 09:36:22 +08:00
|
|
|
#include <gegl.h>
|
2003-11-11 00:38:37 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2006-09-26 16:55:41 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2003-11-11 00:38:37 +08:00
|
|
|
|
|
|
|
#include "gimpwidgetstypes.h"
|
|
|
|
|
|
|
|
#include "gimpcolorarea.h"
|
|
|
|
#include "gimpcolornotebook.h"
|
|
|
|
#include "gimpcolorscales.h"
|
2003-11-12 01:55:45 +08:00
|
|
|
#include "gimpcolorselect.h"
|
2003-11-11 00:38:37 +08:00
|
|
|
#include "gimpcolorselection.h"
|
|
|
|
#include "gimphelpui.h"
|
2015-12-13 03:44:46 +08:00
|
|
|
#include "gimpicons.h"
|
2003-11-11 00:38:37 +08:00
|
|
|
#include "gimpwidgets.h"
|
2003-11-12 01:55:45 +08:00
|
|
|
#include "gimpwidgets-private.h"
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
|
|
|
|
|
|
|
|
2010-07-06 00:01:28 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpcolorselection
|
|
|
|
* @title: GimpColorSelection
|
|
|
|
* @short_description: Widget for doing a color selection.
|
|
|
|
*
|
|
|
|
* Widget for doing a color selection.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
#define COLOR_AREA_SIZE 20
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
UPDATE_NOTEBOOK = 1 << 0,
|
|
|
|
UPDATE_SCALES = 1 << 1,
|
2005-05-20 01:08:03 +08:00
|
|
|
UPDATE_ENTRY = 1 << 2,
|
|
|
|
UPDATE_COLOR = 1 << 3
|
2003-11-11 00:38:37 +08:00
|
|
|
} UpdateType;
|
|
|
|
|
2005-05-20 01:08:03 +08:00
|
|
|
#define UPDATE_ALL (UPDATE_NOTEBOOK | \
|
|
|
|
UPDATE_SCALES | \
|
|
|
|
UPDATE_ENTRY | \
|
|
|
|
UPDATE_COLOR)
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLOR_CHANGED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2006-09-26 16:55:41 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_CONFIG
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
typedef struct _GimpColorSelectionPrivate
|
2011-01-03 20:00:37 +08:00
|
|
|
{
|
|
|
|
gboolean show_alpha;
|
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
GeglColor *color;
|
2011-01-03 20:00:37 +08:00
|
|
|
GimpColorSelectorChannel channel;
|
|
|
|
|
|
|
|
GtkWidget *left_vbox;
|
|
|
|
GtkWidget *right_vbox;
|
|
|
|
|
|
|
|
GtkWidget *notebook;
|
|
|
|
GtkWidget *scales;
|
|
|
|
|
|
|
|
GtkWidget *new_color;
|
|
|
|
GtkWidget *old_color;
|
2024-08-01 11:55:31 +08:00
|
|
|
} GimpColorSelectionPrivate;
|
2011-01-03 20:00:37 +08:00
|
|
|
|
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
static void gimp_color_selection_finalize (GObject *object);
|
2006-09-26 16:55:41 +08:00
|
|
|
static void gimp_color_selection_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
|
|
|
static void gimp_color_selection_switch_page (GtkWidget *widget,
|
2010-07-16 21:24:25 +08:00
|
|
|
gpointer page,
|
2003-11-11 00:38:37 +08:00
|
|
|
guint page_num,
|
|
|
|
GimpColorSelection *selection);
|
|
|
|
static void gimp_color_selection_notebook_changed (GimpColorSelector *selector,
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *color,
|
2003-11-11 00:38:37 +08:00
|
|
|
GimpColorSelection *selection);
|
|
|
|
static void gimp_color_selection_scales_changed (GimpColorSelector *selector,
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *color,
|
2003-11-11 00:38:37 +08:00
|
|
|
GimpColorSelection *selection);
|
2005-10-10 07:26:49 +08:00
|
|
|
static void gimp_color_selection_color_picked (GtkWidget *widget,
|
2024-03-26 09:25:08 +08:00
|
|
|
const GeglColor *rgb,
|
2005-10-10 07:26:49 +08:00
|
|
|
GimpColorSelection *selection);
|
2005-05-20 01:08:03 +08:00
|
|
|
static void gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
|
|
|
|
GimpColorSelection *selection);
|
2003-11-11 00:38:37 +08:00
|
|
|
static void gimp_color_selection_channel_changed (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorChannel channel,
|
|
|
|
GimpColorSelection *selection);
|
|
|
|
static void gimp_color_selection_new_color_changed (GtkWidget *widget,
|
|
|
|
GimpColorSelection *selection);
|
|
|
|
|
|
|
|
static void gimp_color_selection_update (GimpColorSelection *selection,
|
|
|
|
UpdateType update);
|
|
|
|
|
|
|
|
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-19 00:09:39 +08:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpColorSelection, gimp_color_selection,
|
|
|
|
GTK_TYPE_BOX)
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_color_selection_parent_class
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2018-03-20 05:58:03 +08:00
|
|
|
static guint selection_signals[LAST_SIGNAL] = { 0, };
|
2003-11-11 00:38:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selection_class_init (GimpColorSelectionClass *klass)
|
|
|
|
{
|
2006-09-26 16:55:41 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
object_class->finalize = gimp_color_selection_finalize;
|
2006-09-26 16:55:41 +08:00
|
|
|
object_class->set_property = gimp_color_selection_set_property;
|
|
|
|
|
|
|
|
klass->color_changed = NULL;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_CONFIG,
|
|
|
|
g_param_spec_object ("config",
|
2017-06-07 03:19:17 +08:00
|
|
|
"Config",
|
|
|
|
"The color config used by this color selection",
|
2006-09-26 16:55:41 +08:00
|
|
|
GIMP_TYPE_COLOR_CONFIG,
|
|
|
|
G_PARAM_WRITABLE));
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
selection_signals[COLOR_CHANGED] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("color-changed",
|
2003-11-11 00:38:37 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpColorSelectionClass, color_changed),
|
2020-01-12 18:06:05 +08:00
|
|
|
NULL, NULL, NULL,
|
2003-11-11 00:38:37 +08:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2018-06-24 21:36:00 +08:00
|
|
|
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "GimpColorSelection");
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selection_init (GimpColorSelection *selection)
|
|
|
|
{
|
2018-05-03 18:51:36 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
2011-01-03 20:00:37 +08:00
|
|
|
GtkWidget *main_hbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkSizeGroup *new_group;
|
|
|
|
GtkSizeGroup *old_group;
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2018-05-03 18:51:36 +08:00
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
priv->show_alpha = TRUE;
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-07-28 01:53:34 +08:00
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (selection),
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
priv->color = gegl_color_new ("black");
|
2011-01-03 20:00:37 +08:00
|
|
|
priv->channel = GIMP_COLOR_SELECTOR_RED;
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-09-30 16:50:50 +08:00
|
|
|
main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2014-11-29 19:52:26 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (selection), main_hbox, TRUE, TRUE, 0);
|
2003-11-11 00:38:37 +08:00
|
|
|
gtk_widget_show (main_hbox);
|
|
|
|
|
|
|
|
/* The left vbox with the notebook */
|
2011-01-03 20:00:37 +08:00
|
|
|
priv->left_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_hbox), priv->left_vbox,
|
2003-11-11 00:38:37 +08:00
|
|
|
TRUE, TRUE, 0);
|
2011-01-03 20:00:37 +08:00
|
|
|
gtk_widget_show (priv->left_vbox);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2003-11-12 01:55:45 +08:00
|
|
|
if (_gimp_ensure_modules_func)
|
|
|
|
{
|
|
|
|
g_type_class_ref (GIMP_TYPE_COLOR_SELECT);
|
|
|
|
_gimp_ensure_modules_func ();
|
|
|
|
}
|
|
|
|
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
priv->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK, priv->color, priv->channel);
|
2003-11-12 01:55:45 +08:00
|
|
|
|
|
|
|
if (_gimp_ensure_modules_func)
|
|
|
|
g_type_class_unref (g_type_class_peek (GIMP_TYPE_COLOR_SELECT));
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selector_set_toggles_visible
|
2011-01-03 20:00:37 +08:00
|
|
|
(GIMP_COLOR_SELECTOR (priv->notebook), FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->left_vbox), priv->notebook,
|
2003-11-11 00:38:37 +08:00
|
|
|
TRUE, TRUE, 0);
|
2011-01-03 20:00:37 +08:00
|
|
|
gtk_widget_show (priv->notebook);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_connect (priv->notebook, "color-changed",
|
2003-11-11 00:38:37 +08:00
|
|
|
G_CALLBACK (gimp_color_selection_notebook_changed),
|
|
|
|
selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_connect (gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (priv->notebook)),
|
2005-05-27 21:05:26 +08:00
|
|
|
"switch-page",
|
2003-11-11 00:38:37 +08:00
|
|
|
G_CALLBACK (gimp_color_selection_switch_page),
|
|
|
|
selection);
|
|
|
|
|
2010-01-25 06:55:36 +08:00
|
|
|
/* The hbox for the color_areas */
|
2011-09-30 16:50:50 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2011-01-03 20:00:37 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (priv->left_vbox), hbox, FALSE, FALSE, 0);
|
2010-01-25 06:55:36 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* The labels */
|
2011-09-30 16:50:50 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2010-01-25 06:55:36 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Current:"));
|
2016-09-09 01:11:20 +08:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
|
2010-01-25 06:55:36 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
new_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
|
|
|
|
gtk_size_group_add_widget (new_group, label);
|
|
|
|
g_object_unref (new_group);
|
|
|
|
|
|
|
|
label = gtk_label_new (_("Old:"));
|
2016-09-09 01:11:20 +08:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
|
2010-01-25 06:55:36 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
old_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
|
|
|
|
gtk_size_group_add_widget (old_group, label);
|
|
|
|
g_object_unref (old_group);
|
|
|
|
|
|
|
|
/* The color areas */
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2011-09-30 16:50:50 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2010-01-25 06:55:36 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
priv->new_color = gimp_color_area_new (priv->color,
|
2011-01-03 20:00:37 +08:00
|
|
|
priv->show_alpha ?
|
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
|
|
|
GIMP_COLOR_AREA_FLAT,
|
|
|
|
GDK_BUTTON1_MASK |
|
|
|
|
GDK_BUTTON2_MASK);
|
|
|
|
gtk_size_group_add_widget (new_group, priv->new_color);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), priv->new_color, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (priv->new_color);
|
|
|
|
|
|
|
|
g_signal_connect (priv->new_color, "color-changed",
|
2006-04-12 18:53:28 +08:00
|
|
|
G_CALLBACK (gimp_color_selection_new_color_changed),
|
|
|
|
selection);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
priv->old_color = gimp_color_area_new (priv->color,
|
2011-01-03 20:00:37 +08:00
|
|
|
priv->show_alpha ?
|
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
|
|
|
GIMP_COLOR_AREA_FLAT,
|
|
|
|
GDK_BUTTON1_MASK |
|
|
|
|
GDK_BUTTON2_MASK);
|
|
|
|
gtk_drag_dest_unset (priv->old_color);
|
|
|
|
gtk_size_group_add_widget (old_group, priv->old_color);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), priv->old_color, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (priv->old_color);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
|
|
|
/* The right vbox with color scales */
|
2011-01-03 20:00:37 +08:00
|
|
|
priv->right_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_hbox), priv->right_vbox,
|
2003-11-11 00:38:37 +08:00
|
|
|
TRUE, TRUE, 0);
|
2011-01-03 20:00:37 +08:00
|
|
|
gtk_widget_show (priv->right_vbox);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
priv->scales = gimp_color_selector_new (GIMP_TYPE_COLOR_SCALES, priv->color, priv->channel);
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selector_set_toggles_visible
|
2011-01-03 20:00:37 +08:00
|
|
|
(GIMP_COLOR_SELECTOR (priv->scales), TRUE);
|
|
|
|
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (priv->scales),
|
|
|
|
priv->show_alpha);
|
|
|
|
gtk_box_pack_start (GTK_BOX (priv->right_vbox), priv->scales,
|
2003-11-11 00:38:37 +08:00
|
|
|
TRUE, TRUE, 0);
|
2011-01-03 20:00:37 +08:00
|
|
|
gtk_widget_show (priv->scales);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_connect (priv->scales, "channel-changed",
|
2003-11-11 00:38:37 +08:00
|
|
|
G_CALLBACK (gimp_color_selection_channel_changed),
|
|
|
|
selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_connect (priv->scales, "color-changed",
|
2003-11-11 00:38:37 +08:00
|
|
|
G_CALLBACK (gimp_color_selection_scales_changed),
|
|
|
|
selection);
|
2005-05-20 01:08:03 +08:00
|
|
|
|
2011-09-30 16:50:50 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2011-01-03 20:00:37 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (priv->right_vbox), hbox, FALSE, FALSE, 0);
|
2005-05-20 01:08:03 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2005-10-10 07:26:49 +08:00
|
|
|
/* The color picker */
|
|
|
|
button = gimp_pick_button_new ();
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
g_signal_connect (button, "color-picked",
|
|
|
|
G_CALLBACK (gimp_color_selection_color_picked),
|
|
|
|
selection);
|
|
|
|
|
|
|
|
/* The hex triplet entry */
|
2005-05-20 01:08:03 +08:00
|
|
|
entry = gimp_color_hex_entry_new ();
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (entry);
|
|
|
|
|
2005-08-23 07:39:12 +08:00
|
|
|
label = gtk_label_new_with_mnemonic (_("HTML _notation:"));
|
2005-05-20 01:08:03 +08:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (selection), "color-hex-entry", entry);
|
|
|
|
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect (entry, "color-changed",
|
2005-05-20 01:08:03 +08:00
|
|
|
G_CALLBACK (gimp_color_selection_entry_changed),
|
|
|
|
selection);
|
2023-12-09 19:53:39 +08:00
|
|
|
}
|
2023-11-24 05:08:09 +08:00
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
static void
|
|
|
|
gimp_color_selection_finalize (GObject *object)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelection *selection = GIMP_COLOR_SELECTION (object);
|
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2023-12-09 19:53:39 +08:00
|
|
|
|
|
|
|
g_object_unref (priv->color);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
2006-09-26 16:55:41 +08:00
|
|
|
static void
|
|
|
|
gimp_color_selection_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpColorSelection *selection = GIMP_COLOR_SELECTION (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CONFIG:
|
|
|
|
gimp_color_selection_set_config (selection, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-11 00:53:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_new:
|
|
|
|
*
|
|
|
|
* Creates a new #GimpColorSelection widget.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: The new #GimpColorSelection widget.
|
2003-11-11 00:53:09 +08:00
|
|
|
**/
|
2003-11-11 00:38:37 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_color_selection_new (void)
|
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
return g_object_new (GIMP_TYPE_COLOR_SELECTION, NULL);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
2003-11-11 00:53:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_set_show_alpha:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
* @show_alpha: The new @show_alpha setting.
|
|
|
|
*
|
|
|
|
* Sets the @show_alpha property of the @selection widget.
|
|
|
|
**/
|
2003-11-11 00:38:37 +08:00
|
|
|
void
|
|
|
|
gimp_color_selection_set_show_alpha (GimpColorSelection *selection,
|
|
|
|
gboolean show_alpha)
|
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
|
|
|
|
if (show_alpha != priv->show_alpha)
|
2003-11-11 00:38:37 +08:00
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
priv->show_alpha = show_alpha ? TRUE : FALSE;
|
2003-11-11 00:38:37 +08:00
|
|
|
|
|
|
|
gimp_color_selector_set_show_alpha
|
2011-01-03 20:00:37 +08:00
|
|
|
(GIMP_COLOR_SELECTOR (priv->notebook), priv->show_alpha);
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selector_set_show_alpha
|
2011-01-03 20:00:37 +08:00
|
|
|
(GIMP_COLOR_SELECTOR (priv->scales), priv->show_alpha);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
gimp_color_area_set_type (GIMP_COLOR_AREA (priv->new_color),
|
|
|
|
priv->show_alpha ?
|
2003-11-11 00:38:37 +08:00
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
|
|
|
GIMP_COLOR_AREA_FLAT);
|
2011-01-03 20:00:37 +08:00
|
|
|
gimp_color_area_set_type (GIMP_COLOR_AREA (priv->old_color),
|
|
|
|
priv->show_alpha ?
|
2003-11-11 00:38:37 +08:00
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS :
|
|
|
|
GIMP_COLOR_AREA_FLAT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-11 00:53:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_get_show_alpha:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
*
|
|
|
|
* Returns the @selection's @show_alpha property.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: %TRUE if the #GimpColorSelection has alpha controls.
|
2003-11-11 00:53:09 +08:00
|
|
|
**/
|
2003-11-11 00:38:37 +08:00
|
|
|
gboolean
|
|
|
|
gimp_color_selection_get_show_alpha (GimpColorSelection *selection)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), FALSE);
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
|
|
|
|
|
|
|
return priv->show_alpha;
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
2003-11-11 00:53:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_set_color:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
* @color: The @color to set as current color.
|
|
|
|
*
|
|
|
|
* Sets the #GimpColorSelection's current color to the new @color.
|
|
|
|
**/
|
2003-11-11 00:38:37 +08:00
|
|
|
void
|
|
|
|
gimp_color_selection_set_color (GimpColorSelection *selection,
|
2023-12-09 19:53:39 +08:00
|
|
|
GeglColor *color)
|
2003-11-11 00:38:37 +08:00
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *old_color;
|
2011-01-03 20:00:37 +08:00
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
2023-12-09 19:53:39 +08:00
|
|
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2011-01-03 20:00:37 +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
|
|
|
old_color = priv->color;
|
2023-12-09 19:53:39 +08:00
|
|
|
priv->color = gegl_color_duplicate (color);
|
2003-11-11 00:38:37 +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
|
|
|
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
|
|
|
|
{
|
|
|
|
gimp_color_selection_update (selection, UPDATE_ALL);
|
|
|
|
gimp_color_selection_color_changed (selection);
|
|
|
|
}
|
2003-11-11 00:38:37 +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 (old_color);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
2003-11-11 00:53:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_get_color:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
*
|
2003-11-12 03:36:40 +08:00
|
|
|
* This function returns the #GimpColorSelection's current color.
|
2023-12-09 19:53:39 +08:00
|
|
|
*
|
|
|
|
* Returns: (transfer full): the currently selected color.
|
2003-11-11 00:53:09 +08:00
|
|
|
**/
|
2023-12-09 19:53:39 +08:00
|
|
|
GeglColor *
|
|
|
|
gimp_color_selection_get_color (GimpColorSelection *selection)
|
2003-11-11 00:38:37 +08:00
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
|
|
|
|
|
|
|
return gegl_color_duplicate (priv->color);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
2003-11-11 00:53:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_set_old_color:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
* @color: The @color to set as old color.
|
|
|
|
*
|
|
|
|
* Sets the #GimpColorSelection's old color.
|
|
|
|
**/
|
2003-11-11 00:38:37 +08:00
|
|
|
void
|
|
|
|
gimp_color_selection_set_old_color (GimpColorSelection *selection,
|
2023-12-09 19:53:39 +08:00
|
|
|
GeglColor *color)
|
2003-11-11 00:38:37 +08:00
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
2023-12-09 19:53:39 +08:00
|
|
|
g_return_if_fail (GEGL_IS_COLOR (color));
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
|
|
|
|
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->old_color), color);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
2003-11-11 00:53:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_get_old_color:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
*
|
2023-12-09 19:53:39 +08:00
|
|
|
* Returns: (transfer full): the old color.
|
2003-11-11 00:53:09 +08:00
|
|
|
**/
|
2023-12-09 19:53:39 +08:00
|
|
|
GeglColor *
|
|
|
|
gimp_color_selection_get_old_color (GimpColorSelection *selection)
|
2003-11-11 00:38:37 +08:00
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
return gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
2003-11-11 00:53:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_reset:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
*
|
|
|
|
* Sets the #GimpColorSelection's current color to its old color.
|
|
|
|
**/
|
2003-11-11 00:38:37 +08:00
|
|
|
void
|
|
|
|
gimp_color_selection_reset (GimpColorSelection *selection)
|
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
2023-11-24 05:08:09 +08:00
|
|
|
GeglColor *color;
|
2003-11-11 00:38:37 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
|
2023-11-24 05:08:09 +08:00
|
|
|
color = gimp_color_area_get_color (GIMP_COLOR_AREA (priv->old_color));
|
2023-12-09 19:53:39 +08:00
|
|
|
gimp_color_selection_set_color (selection, color);
|
2023-11-24 05:08:09 +08:00
|
|
|
|
|
|
|
g_object_unref (color);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
2003-11-11 00:53:09 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_color_changed:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
*
|
2005-05-27 21:05:26 +08:00
|
|
|
* Emits the "color-changed" signal.
|
2003-11-11 00:53:09 +08:00
|
|
|
**/
|
2003-11-11 00:38:37 +08:00
|
|
|
void
|
|
|
|
gimp_color_selection_color_changed (GimpColorSelection *selection)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
|
|
|
|
|
|
|
g_signal_emit (selection, selection_signals[COLOR_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
2024-02-17 18:17:49 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_set_format:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
* @format: A Babl format, with space.
|
|
|
|
*
|
|
|
|
* Updates all selectors with the current format.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_color_selection_set_format (GimpColorSelection *selection,
|
2024-08-01 11:55:31 +08:00
|
|
|
const Babl *format)
|
2024-02-17 18:17:49 +08:00
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2024-02-17 18:17:49 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
|
|
|
|
|
|
|
gimp_color_notebook_set_format (GIMP_COLOR_NOTEBOOK (priv->notebook),
|
2024-02-17 18:17:49 +08:00
|
|
|
format);
|
2024-08-01 11:55:31 +08:00
|
|
|
gimp_color_selector_set_format (GIMP_COLOR_SELECTOR (priv->scales),
|
2024-02-17 18:17:49 +08:00
|
|
|
format);
|
|
|
|
|
|
|
|
g_signal_emit (selection, selection_signals[COLOR_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_set_simulation:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
* @profile: A #GimpColorProfile object.
|
|
|
|
* @intent: A #GimpColorRenderingIntent enum.
|
|
|
|
* @bpc: A gboolean.
|
|
|
|
*
|
|
|
|
* Sets the simulation options to use with this color selection.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_color_selection_set_simulation (GimpColorSelection *selection,
|
|
|
|
GimpColorProfile *profile,
|
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
gboolean bpc)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2022-04-30 09:51:20 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
|
|
|
|
|
|
|
gimp_color_notebook_set_simulation (GIMP_COLOR_NOTEBOOK (priv->notebook),
|
2022-04-30 09:51:20 +08:00
|
|
|
profile,
|
|
|
|
intent,
|
|
|
|
bpc);
|
|
|
|
|
|
|
|
g_signal_emit (selection, selection_signals[COLOR_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
2006-09-26 16:55:41 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_set_config:
|
2010-07-06 01:04:15 +08:00
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
* @config: A #GimpColorConfig object.
|
2006-09-26 16:55:41 +08:00
|
|
|
*
|
|
|
|
* Sets the color management configuration to use with this color selection.
|
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.4
|
2006-09-26 16:55:41 +08:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gimp_color_selection_set_config (GimpColorSelection *selection,
|
|
|
|
GimpColorConfig *config)
|
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2006-09-26 16:55:41 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_SELECTION (selection));
|
|
|
|
g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config));
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
|
|
|
|
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (priv->notebook),
|
2006-09-26 16:55:41 +08:00
|
|
|
config);
|
2011-01-03 20:00:37 +08:00
|
|
|
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (priv->scales),
|
2006-09-26 16:55:41 +08:00
|
|
|
config);
|
2011-01-03 20:00:37 +08:00
|
|
|
gimp_color_area_set_color_config (GIMP_COLOR_AREA (priv->old_color),
|
2016-05-27 04:22:50 +08:00
|
|
|
config);
|
2011-01-03 20:00:37 +08:00
|
|
|
gimp_color_area_set_color_config (GIMP_COLOR_AREA (priv->new_color),
|
2016-05-27 04:22:50 +08:00
|
|
|
config);
|
2006-09-26 16:55:41 +08:00
|
|
|
}
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
/**
|
|
|
|
* gimp_color_selection_get_notebook:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
*
|
2019-08-01 19:06:35 +08:00
|
|
|
* Returns: (transfer none): The selection's #GimpColorNotebook.
|
2011-01-03 20:00:37 +08:00
|
|
|
*
|
2019-07-24 07:18:30 +08:00
|
|
|
* Since: 3.0
|
2011-01-03 20:00:37 +08:00
|
|
|
*/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_color_selection_get_notebook (GimpColorSelection *selection)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
|
|
|
|
|
|
|
return priv->notebook;
|
2011-01-03 20:00:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_color_selection_get_right_vbox:
|
|
|
|
* @selection: A #GimpColorSelection widget.
|
|
|
|
*
|
GIR: Try to return more specific GtkWidget subclass
In GTK, a common scheme is to let a function creating a specific widget
to return a `GtkWidget *`, rather than the specific subtype, since you
often need to call API of GtkWidget, avoiding some useless casts.
For bindings however (and especially bindings to compiled languages),
this is a bit annoying, as you have to explicitly change the type of the
return value (downcast), which is not trivial (or at least desirable) in
each language.
Luckily, we can use `(type ...)` annotation for this use case, leaving
the C API unchanged, while improving the experience for bindings.
2020-12-25 22:05:16 +08:00
|
|
|
* Returns: (transfer none) (type GtkBox): The selection's right #GtkBox which
|
2019-08-01 20:02:21 +08:00
|
|
|
* contains the color scales.
|
2011-01-03 20:00:37 +08:00
|
|
|
*
|
2019-07-24 07:18:30 +08:00
|
|
|
* Since: 3.0
|
2011-01-03 20:00:37 +08:00
|
|
|
*/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_color_selection_get_right_vbox (GimpColorSelection *selection)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_SELECTION (selection), NULL);
|
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
|
|
|
|
|
|
|
return priv->right_vbox;
|
2011-01-03 20:00:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selection_switch_page (GtkWidget *widget,
|
2010-07-16 21:24:25 +08:00
|
|
|
gpointer page,
|
2003-11-11 00:38:37 +08:00
|
|
|
guint page_num,
|
|
|
|
GimpColorSelection *selection)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
GimpColorNotebook *notebook;
|
2011-01-03 20:00:37 +08:00
|
|
|
GimpColorSelector *current;
|
|
|
|
gboolean sensitive;
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
|
|
|
notebook = GIMP_COLOR_NOTEBOOK (priv->notebook);
|
|
|
|
|
2011-01-02 09:20:09 +08:00
|
|
|
current = gimp_color_notebook_get_current_selector (notebook);
|
|
|
|
|
|
|
|
sensitive = (GIMP_COLOR_SELECTOR_GET_CLASS (current)->set_channel != NULL);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
|
|
|
gimp_color_selector_set_toggles_sensitive
|
2011-01-03 20:00:37 +08:00
|
|
|
(GIMP_COLOR_SELECTOR (priv->scales), sensitive);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selection_notebook_changed (GimpColorSelector *selector,
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *color,
|
2003-11-11 00:38:37 +08:00
|
|
|
GimpColorSelection *selection)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *old_color;
|
2011-01-03 20:00:37 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
|
|
|
|
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
|
|
|
old_color = priv->color;
|
|
|
|
priv->color = gegl_color_duplicate (color);
|
2003-11-11 00:38:37 +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
|
|
|
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
|
|
|
|
{
|
|
|
|
gimp_color_selection_update (selection,
|
|
|
|
UPDATE_SCALES | UPDATE_ENTRY | UPDATE_COLOR);
|
|
|
|
gimp_color_selection_color_changed (selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (old_color);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selection_scales_changed (GimpColorSelector *selector,
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *color,
|
2003-11-11 00:38:37 +08:00
|
|
|
GimpColorSelection *selection)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 16:01:17 +08:00
|
|
|
GeglColor *old_color;
|
2011-01-03 20:00:37 +08:00
|
|
|
|
2024-08-01 11:55:31 +08:00
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
|
|
|
|
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
|
|
|
old_color = priv->color;
|
|
|
|
priv->color = gegl_color_duplicate (color);
|
2003-11-11 00:38:37 +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
|
|
|
if (! gimp_color_is_perceptually_identical (priv->color, old_color))
|
|
|
|
{
|
|
|
|
gimp_color_selection_update (selection,
|
|
|
|
UPDATE_ENTRY | UPDATE_NOTEBOOK | UPDATE_COLOR);
|
|
|
|
gimp_color_selection_color_changed (selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_unref (old_color);
|
2005-05-20 01:08:03 +08:00
|
|
|
}
|
|
|
|
|
2005-10-10 07:26:49 +08:00
|
|
|
static void
|
|
|
|
gimp_color_selection_color_picked (GtkWidget *widget,
|
2024-03-26 09:25:08 +08:00
|
|
|
const GeglColor *rgb,
|
2005-10-10 07:26:49 +08:00
|
|
|
GimpColorSelection *selection)
|
|
|
|
{
|
2024-03-26 09:25:08 +08:00
|
|
|
if (rgb)
|
|
|
|
gimp_color_selection_set_color (selection, (GeglColor *) rgb);
|
2005-10-10 07:26:49 +08:00
|
|
|
}
|
|
|
|
|
2005-05-20 01:08:03 +08:00
|
|
|
static void
|
|
|
|
gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
|
|
|
|
GimpColorSelection *selection)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
g_object_unref (priv->color);
|
|
|
|
priv->color = gimp_color_hex_entry_get_color (entry);
|
2005-05-20 01:08:03 +08:00
|
|
|
|
|
|
|
gimp_color_selection_update (selection,
|
|
|
|
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_COLOR);
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selection_color_changed (selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selection_channel_changed (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorChannel channel,
|
|
|
|
GimpColorSelection *selection)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
priv->channel = channel;
|
|
|
|
|
|
|
|
gimp_color_selector_set_channel (GIMP_COLOR_SELECTOR (priv->notebook),
|
|
|
|
priv->channel);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selection_new_color_changed (GtkWidget *widget,
|
|
|
|
GimpColorSelection *selection)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
g_object_unref (priv->color);
|
|
|
|
priv->color = gimp_color_area_get_color (GIMP_COLOR_AREA (widget));
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2005-05-20 01:08:03 +08:00
|
|
|
gimp_color_selection_update (selection,
|
|
|
|
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_ENTRY);
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selection_color_changed (selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_selection_update (GimpColorSelection *selection,
|
|
|
|
UpdateType update)
|
|
|
|
{
|
2024-08-01 11:55:31 +08:00
|
|
|
GimpColorSelectionPrivate *priv;
|
|
|
|
|
|
|
|
priv = gimp_color_selection_get_instance_private (selection);
|
2011-01-03 20:00:37 +08:00
|
|
|
|
2003-11-11 00:38:37 +08:00
|
|
|
if (update & UPDATE_NOTEBOOK)
|
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_handlers_block_by_func (priv->notebook,
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selection_notebook_changed,
|
|
|
|
selection);
|
|
|
|
|
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 (GIMP_COLOR_SELECTOR (priv->notebook), priv->color);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_handlers_unblock_by_func (priv->notebook,
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selection_notebook_changed,
|
|
|
|
selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update & UPDATE_SCALES)
|
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_handlers_block_by_func (priv->scales,
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selection_scales_changed,
|
|
|
|
selection);
|
|
|
|
|
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 (GIMP_COLOR_SELECTOR (priv->scales), priv->color);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_handlers_unblock_by_func (priv->scales,
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selection_scales_changed,
|
|
|
|
selection);
|
|
|
|
}
|
|
|
|
|
2005-05-20 01:08:03 +08:00
|
|
|
if (update & UPDATE_ENTRY)
|
|
|
|
{
|
|
|
|
GimpColorHexEntry *entry;
|
|
|
|
|
|
|
|
entry = g_object_get_data (G_OBJECT (selection), "color-hex-entry");
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (entry,
|
|
|
|
gimp_color_selection_entry_changed,
|
|
|
|
selection);
|
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
gimp_color_hex_entry_set_color (entry, priv->color);
|
2005-05-20 01:08:03 +08:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (entry,
|
|
|
|
gimp_color_selection_entry_changed,
|
|
|
|
selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update & UPDATE_COLOR)
|
2003-11-11 00:38:37 +08:00
|
|
|
{
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_handlers_block_by_func (priv->new_color,
|
2003-11-11 00:38:37 +08:00
|
|
|
gimp_color_selection_new_color_changed,
|
2006-04-12 18:53:28 +08:00
|
|
|
selection);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2023-12-09 19:53:39 +08:00
|
|
|
gimp_color_area_set_color (GIMP_COLOR_AREA (priv->new_color), priv->color);
|
2003-11-11 00:38:37 +08:00
|
|
|
|
2011-01-03 20:00:37 +08:00
|
|
|
g_signal_handlers_unblock_by_func (priv->new_color,
|
2006-04-12 18:53:28 +08:00
|
|
|
gimp_color_selection_new_color_changed,
|
|
|
|
selection);
|
2003-11-11 00:38:37 +08:00
|
|
|
}
|
|
|
|
}
|