2003-07-19 11:30:10 +00:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
2002-10-28 13:19:02 +00:00
|
|
|
*
|
|
|
|
* gimpcolornotebook.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-17 22:28:01 +00:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2002-10-28 13:19:02 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-17 22:28:01 +00:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2003-07-19 11:30:10 +00: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-28 13:19:02 +00:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-17 22:28:01 +00:00
|
|
|
* License along with this library. If not, see
|
2018-07-11 23:27:07 +02:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2002-10-28 13:19:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-05-03 03:36:22 +02:00
|
|
|
#include <gegl.h>
|
2002-10-28 13:19:02 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
|
|
|
#include "gimpwidgetstypes.h"
|
|
|
|
|
|
|
|
#include "gimpcolornotebook.h"
|
2002-10-28 20:13:17 +00:00
|
|
|
#include "gimpcolorscales.h"
|
2018-06-08 19:44:29 +02:00
|
|
|
#include "gimphelpui.h"
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2003-07-19 11:30:10 +00:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
|
|
|
|
|
|
|
|
2010-07-05 18:01:28 +02:00
|
|
|
/**
|
|
|
|
* SECTION: gimpcolornotebook
|
|
|
|
* @title: GimpColorNotebook
|
|
|
|
* @short_description: A #GimpColorSelector implementation.
|
|
|
|
*
|
|
|
|
* The #GimpColorNotebook widget is an implementation of a
|
|
|
|
* #GimpColorSelector. It serves as a container for
|
|
|
|
* #GimpColorSelectors.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2003-07-19 11:30:10 +00:00
|
|
|
#define DEFAULT_TAB_ICON_SIZE GTK_ICON_SIZE_BUTTON
|
|
|
|
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
struct _GimpColorNotebook
|
2011-01-02 02:20:09 +01:00
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorSelector parent_instance;
|
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
GtkWidget *notebook;
|
|
|
|
|
|
|
|
GList *selectors;
|
|
|
|
GimpColorSelector *cur_page;
|
2024-10-16 21:56:26 +02:00
|
|
|
};
|
2011-01-02 02:20:09 +01:00
|
|
|
|
|
|
|
|
2010-12-21 09:32:10 +01:00
|
|
|
static void gimp_color_notebook_style_updated (GtkWidget *widget);
|
2011-12-11 02:41:01 +01:00
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
static void gimp_color_notebook_togg_visible (GimpColorSelector *selector,
|
|
|
|
gboolean visible);
|
|
|
|
static void gimp_color_notebook_togg_sensitive (GimpColorSelector *selector,
|
|
|
|
gboolean sensitive);
|
2002-10-29 12:49:02 +00:00
|
|
|
static void gimp_color_notebook_set_show_alpha (GimpColorSelector *selector,
|
|
|
|
gboolean show_alpha);
|
|
|
|
static void gimp_color_notebook_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 17:01:17 +09:00
|
|
|
GeglColor *color);
|
2002-10-29 12:49:02 +00:00
|
|
|
static void gimp_color_notebook_set_channel (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorChannel channel);
|
2018-03-19 22:58:03 +01:00
|
|
|
static void gimp_color_notebook_set_model_visible
|
|
|
|
(GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorModel model,
|
|
|
|
gboolean gboolean);
|
2006-09-26 08:55:41 +00:00
|
|
|
static void gimp_color_notebook_set_config (GimpColorSelector *selector,
|
|
|
|
GimpColorConfig *config);
|
|
|
|
|
2002-10-29 12:49:02 +00:00
|
|
|
|
2002-10-28 13:19:02 +00:00
|
|
|
static void gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
|
2010-07-16 15:24:25 +02:00
|
|
|
gpointer page,
|
2002-10-29 12:49:02 +00:00
|
|
|
guint page_num,
|
|
|
|
GimpColorNotebook *notebook);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2002-10-29 12:49:02 +00:00
|
|
|
static void gimp_color_notebook_color_changed (GimpColorSelector *page,
|
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 17:01:17 +09:00
|
|
|
GeglColor *color,
|
2002-10-28 13:19:02 +00:00
|
|
|
GimpColorNotebook *notebook);
|
2002-10-29 12:49:02 +00:00
|
|
|
static void gimp_color_notebook_channel_changed (GimpColorSelector *page,
|
|
|
|
GimpColorSelectorChannel channel,
|
|
|
|
GimpColorNotebook *notebook);
|
2018-03-19 22:58:03 +01:00
|
|
|
static void gimp_color_notebook_model_visible_changed
|
|
|
|
(GimpColorSelector *page,
|
|
|
|
GimpColorSelectorModel model,
|
|
|
|
gboolean visible,
|
|
|
|
GimpColorNotebook *notebook);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2003-07-19 11:30:10 +00:00
|
|
|
static GtkWidget * gimp_color_notebook_add_page (GimpColorNotebook *notebook,
|
|
|
|
GType page_type);
|
2011-12-11 02:41:01 +01:00
|
|
|
static void gimp_color_notebook_remove_selector (GtkContainer *container,
|
|
|
|
GtkWidget *widget,
|
|
|
|
GimpColorNotebook *notebook);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
G_DEFINE_TYPE (GimpColorNotebook, gimp_color_notebook, GIMP_TYPE_COLOR_SELECTOR)
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2005-12-20 20:35:23 +00:00
|
|
|
#define parent_class gimp_color_notebook_parent_class
|
2002-10-28 13:19:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_notebook_class_init (GimpColorNotebookClass *klass)
|
|
|
|
{
|
2004-07-13 14:55:16 +00:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2010-12-21 09:32:10 +01:00
|
|
|
widget_class->style_updated = gimp_color_notebook_style_updated;
|
2003-07-19 11:30:10 +00:00
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
selector_class->name = "Notebook";
|
2003-11-18 23:44:35 +00:00
|
|
|
selector_class->help_id = "gimp-colorselector-notebook";
|
2002-11-05 00:02:56 +00:00
|
|
|
selector_class->set_toggles_visible = gimp_color_notebook_togg_visible;
|
|
|
|
selector_class->set_toggles_sensitive = gimp_color_notebook_togg_sensitive;
|
|
|
|
selector_class->set_show_alpha = gimp_color_notebook_set_show_alpha;
|
|
|
|
selector_class->set_color = gimp_color_notebook_set_color;
|
|
|
|
selector_class->set_channel = gimp_color_notebook_set_channel;
|
2018-03-19 22:58:03 +01:00
|
|
|
selector_class->set_model_visible = gimp_color_notebook_set_model_visible;
|
2006-09-26 08:55:41 +00:00
|
|
|
selector_class->set_config = gimp_color_notebook_set_config;
|
2003-07-19 11:30:10 +00:00
|
|
|
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
2006-09-20 20:37:15 +00:00
|
|
|
g_param_spec_enum ("tab-icon-size",
|
2003-07-25 12:48:06 +00:00
|
|
|
NULL,
|
|
|
|
"Size for icons displayed in the tab",
|
2003-07-19 11:30:10 +00:00
|
|
|
GTK_TYPE_ICON_SIZE,
|
|
|
|
DEFAULT_TAB_ICON_SIZE,
|
|
|
|
G_PARAM_READABLE));
|
2011-01-02 02:20:09 +01:00
|
|
|
|
2018-06-24 15:36:00 +02:00
|
|
|
gtk_widget_class_set_css_name (widget_class, "GimpColorNotebook");
|
2002-10-28 13:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_notebook_init (GimpColorNotebook *notebook)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GType *selector_types;
|
|
|
|
guint n_selector_types;
|
|
|
|
guint i;
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
notebook->notebook = gtk_notebook_new ();
|
|
|
|
gtk_notebook_popup_enable (GTK_NOTEBOOK (notebook->notebook));
|
|
|
|
gtk_box_pack_start (GTK_BOX (notebook), notebook->notebook, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (notebook->notebook);
|
2011-01-02 02:20:09 +01:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_connect (notebook->notebook, "switch-page",
|
2002-10-29 12:49:02 +00:00
|
|
|
G_CALLBACK (gimp_color_notebook_switch_page),
|
|
|
|
notebook);
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_connect (notebook->notebook, "remove",
|
2011-12-11 02:41:01 +01:00
|
|
|
G_CALLBACK (gimp_color_notebook_remove_selector),
|
|
|
|
notebook);
|
2002-10-28 20:13:17 +00:00
|
|
|
|
2003-07-19 01:43:51 +00:00
|
|
|
selector_types = g_type_children (GIMP_TYPE_COLOR_SELECTOR,
|
2006-04-12 10:53:28 +00:00
|
|
|
&n_selector_types);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2002-10-29 12:49:02 +00:00
|
|
|
if (n_selector_types == 2)
|
2002-10-28 13:19:02 +00:00
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook->notebook), FALSE);
|
|
|
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook->notebook), FALSE);
|
2002-10-28 13:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n_selector_types; i++)
|
|
|
|
{
|
2002-10-29 12:49:02 +00:00
|
|
|
/* skip ourselves */
|
|
|
|
if (g_type_is_a (selector_types[i], GIMP_TYPE_COLOR_NOTEBOOK))
|
|
|
|
continue;
|
|
|
|
|
2002-10-28 20:13:17 +00:00
|
|
|
/* skip the "Scales" color selector */
|
|
|
|
if (g_type_is_a (selector_types[i], GIMP_TYPE_COLOR_SCALES))
|
|
|
|
continue;
|
|
|
|
|
2003-07-19 11:30:10 +00:00
|
|
|
gimp_color_notebook_add_page (notebook, selector_types[i]);
|
2002-10-28 13:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (selector_types);
|
|
|
|
}
|
|
|
|
|
2003-07-19 11:30:10 +00:00
|
|
|
static void
|
2010-12-21 09:32:10 +01:00
|
|
|
gimp_color_notebook_style_updated (GtkWidget *widget)
|
2003-07-19 11:30:10 +00:00
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (widget);
|
|
|
|
GList *list;
|
|
|
|
GtkIconSize icon_size;
|
2003-07-19 11:30:10 +00:00
|
|
|
|
2010-12-21 09:32:10 +01:00
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
2012-02-01 20:32:22 +01:00
|
|
|
"tab-icon-size", &icon_size,
|
2003-07-19 11:30:10 +00:00
|
|
|
NULL);
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
for (list = notebook->selectors; list; list = g_list_next (list))
|
2003-07-19 11:30:10 +00:00
|
|
|
{
|
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (list->data);
|
|
|
|
|
2014-05-10 08:33:29 +02:00
|
|
|
image = gtk_image_new_from_icon_name (selector_class->icon_name,
|
|
|
|
icon_size);
|
2018-06-08 19:44:29 +02:00
|
|
|
gimp_help_set_help_data (image, gettext (selector_class->name), NULL);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook->notebook),
|
2003-07-19 11:30:10 +00:00
|
|
|
GTK_WIDGET (list->data),
|
|
|
|
image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_togg_visible (GimpColorSelector *selector,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
|
|
|
|
GList *list;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
for (list = notebook->selectors; list; list = g_list_next (list))
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2003-11-11 19:36:40 +00:00
|
|
|
GimpColorSelector *child = list->data;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
gimp_color_selector_set_toggles_visible (child, visible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_notebook_togg_sensitive (GimpColorSelector *selector,
|
|
|
|
gboolean sensitive)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
|
|
|
|
GList *list;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
for (list = notebook->selectors; list; list = g_list_next (list))
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2003-11-11 19:36:40 +00:00
|
|
|
GimpColorSelector *child = list->data;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
gimp_color_selector_set_toggles_sensitive (child, sensitive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-28 13:19:02 +00:00
|
|
|
static void
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_notebook_set_show_alpha (GimpColorSelector *selector,
|
|
|
|
gboolean show_alpha)
|
2002-10-28 13:19:02 +00:00
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
|
|
|
|
GList *list;
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
for (list = notebook->selectors; list; list = g_list_next (list))
|
2002-10-29 12:49:02 +00:00
|
|
|
{
|
2003-11-11 19:36:40 +00:00
|
|
|
GimpColorSelector *child = list->data;
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_selector_set_show_alpha (child, show_alpha);
|
|
|
|
}
|
|
|
|
}
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2002-10-29 12:49:02 +00:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_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 17:01:17 +09:00
|
|
|
GeglColor *color)
|
2002-10-29 12:49:02 +00:00
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_block_by_func (notebook->cur_page,
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_notebook_color_changed,
|
2011-01-02 02:20:09 +01:00
|
|
|
selector);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
gimp_color_selector_set_color (notebook->cur_page, color);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_unblock_by_func (notebook->cur_page,
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_notebook_color_changed,
|
2011-01-02 02:20:09 +01:00
|
|
|
selector);
|
2002-10-28 13:19:02 +00:00
|
|
|
}
|
|
|
|
|
2002-10-29 12:49:02 +00:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_set_channel (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorChannel channel)
|
2002-10-28 13:19:02 +00:00
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_block_by_func (notebook->cur_page,
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_notebook_channel_changed,
|
2011-01-02 02:20:09 +01:00
|
|
|
selector);
|
2002-10-29 12:49:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
gimp_color_selector_set_channel (notebook->cur_page, channel);
|
2002-10-29 12:49:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_unblock_by_func (notebook->cur_page,
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_notebook_channel_changed,
|
2011-01-02 02:20:09 +01:00
|
|
|
selector);
|
2002-10-28 13:19:02 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 22:58:03 +01:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_set_model_visible (GimpColorSelector *selector,
|
|
|
|
GimpColorSelectorModel model,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
|
2018-03-19 22:58:03 +01:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_block_by_func (notebook->cur_page,
|
2018-03-19 22:58:03 +01:00
|
|
|
gimp_color_notebook_model_visible_changed,
|
2011-01-02 02:20:09 +01:00
|
|
|
selector);
|
2018-03-19 22:58:03 +01:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
gimp_color_selector_set_model_visible (notebook->cur_page, model, visible);
|
2018-03-19 22:58:03 +01:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_unblock_by_func (notebook->cur_page,
|
2018-03-19 22:58:03 +01:00
|
|
|
gimp_color_notebook_model_visible_changed,
|
2011-01-02 02:20:09 +01:00
|
|
|
selector);
|
2018-03-19 22:58:03 +01:00
|
|
|
}
|
|
|
|
|
2006-09-26 08:55:41 +00:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_set_config (GimpColorSelector *selector,
|
|
|
|
GimpColorConfig *config)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (selector);
|
|
|
|
GList *list;
|
2006-09-26 08:55:41 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
for (list = notebook->selectors; list; list = g_list_next (list))
|
2006-09-26 08:55:41 +00:00
|
|
|
{
|
|
|
|
GimpColorSelector *child = list->data;
|
|
|
|
|
|
|
|
gimp_color_selector_set_config (child, config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-29 12:49:02 +00:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_switch_page (GtkNotebook *gtk_notebook,
|
2010-07-16 15:24:25 +02:00
|
|
|
gpointer page,
|
2002-10-29 12:49:02 +00:00
|
|
|
guint page_num,
|
|
|
|
GimpColorNotebook *notebook)
|
2002-10-28 13:19:02 +00:00
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
|
|
|
|
GtkWidget *page_widget;
|
|
|
|
GeglColor *color;
|
|
|
|
GimpColorSelectorModel model;
|
2002-10-29 12:49:02 +00:00
|
|
|
|
|
|
|
page_widget = gtk_notebook_get_nth_page (gtk_notebook, page_num);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
notebook->cur_page = GIMP_COLOR_SELECTOR (page_widget);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_block_by_func (notebook->cur_page,
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_notebook_color_changed,
|
|
|
|
notebook);
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_block_by_func (notebook->cur_page,
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_notebook_channel_changed,
|
2002-10-28 13:19:02 +00:00
|
|
|
notebook);
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_block_by_func (notebook->cur_page,
|
2018-03-19 22:58:03 +01:00
|
|
|
gimp_color_notebook_model_visible_changed,
|
|
|
|
notebook);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 17:01:17 +09:00
|
|
|
color = gimp_color_selector_get_color (selector);
|
2024-10-16 21:56:26 +02:00
|
|
|
gimp_color_selector_set_color (notebook->cur_page, color);
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 17:01:17 +09:00
|
|
|
g_object_unref (color);
|
2024-10-16 21:56:26 +02:00
|
|
|
gimp_color_selector_set_channel (notebook->cur_page,
|
2017-12-31 19:04:17 +01:00
|
|
|
gimp_color_selector_get_channel (selector));
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2018-03-19 22:58:03 +01:00
|
|
|
for (model = GIMP_COLOR_SELECTOR_MODEL_RGB;
|
|
|
|
model <= GIMP_COLOR_SELECTOR_MODEL_HSV;
|
|
|
|
model++)
|
|
|
|
{
|
|
|
|
gboolean visible = gimp_color_selector_get_model_visible (selector, model);
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
gimp_color_selector_set_model_visible (notebook->cur_page, model,
|
2018-03-19 22:58:03 +01:00
|
|
|
visible);
|
|
|
|
}
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_unblock_by_func (notebook->cur_page,
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_notebook_color_changed,
|
|
|
|
notebook);
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_unblock_by_func (notebook->cur_page,
|
2002-10-29 12:49:02 +00:00
|
|
|
gimp_color_notebook_channel_changed,
|
2002-10-28 13:19:02 +00:00
|
|
|
notebook);
|
2024-10-16 21:56:26 +02:00
|
|
|
g_signal_handlers_unblock_by_func (notebook->cur_page,
|
2018-03-19 22:58:03 +01:00
|
|
|
gimp_color_notebook_model_visible_changed,
|
|
|
|
notebook);
|
2002-10-28 13:19:02 +00:00
|
|
|
}
|
|
|
|
|
2002-10-29 12:49:02 +00:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_color_changed (GimpColorSelector *page,
|
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 17:01:17 +09:00
|
|
|
GeglColor *color,
|
2002-10-29 12:49:02 +00:00
|
|
|
GimpColorNotebook *notebook)
|
2002-10-28 13:19:02 +00:00
|
|
|
{
|
2003-11-11 19:36:40 +00:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 17:01:17 +09:00
|
|
|
gimp_color_selector_set_color (selector, color);
|
2002-10-28 13:19:02 +00:00
|
|
|
}
|
|
|
|
|
2002-10-29 12:49:02 +00:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_channel_changed (GimpColorSelector *page,
|
|
|
|
GimpColorSelectorChannel channel,
|
|
|
|
GimpColorNotebook *notebook)
|
2002-10-28 13:19:02 +00:00
|
|
|
{
|
2003-11-11 19:36:40 +00:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
|
2002-10-28 13:19:02 +00:00
|
|
|
|
2017-12-31 19:04:17 +01:00
|
|
|
gimp_color_selector_set_channel (selector, channel);
|
2002-10-28 13:19:02 +00:00
|
|
|
}
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2018-03-19 22:58:03 +01:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_model_visible_changed (GimpColorSelector *page,
|
|
|
|
GimpColorSelectorModel model,
|
|
|
|
gboolean visible,
|
|
|
|
GimpColorNotebook *notebook)
|
|
|
|
{
|
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
|
|
|
|
|
|
|
|
gimp_color_selector_set_model_visible (selector, model, visible);
|
|
|
|
}
|
|
|
|
|
2003-07-19 11:30:10 +00:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_color_notebook_add_page (GimpColorNotebook *notebook,
|
|
|
|
GType page_type)
|
|
|
|
{
|
2011-01-02 02:20:09 +01:00
|
|
|
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (notebook);
|
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
GtkWidget *page;
|
|
|
|
GtkWidget *menu_widget;
|
|
|
|
GtkWidget *image;
|
|
|
|
GtkWidget *label;
|
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 17:01:17 +09:00
|
|
|
GeglColor *color;
|
2011-01-02 02:20:09 +01:00
|
|
|
gboolean show_alpha;
|
2003-07-19 11:30:10 +00:00
|
|
|
|
app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:
1. Take into account the image space, and this is what we must navigate
through, in particular for various representations of RGB or HSV.
I.e. that if the active image is in anyRGB, the RGB values shown must
be within anyRGB. Right now, everything is still shown/used as sRGB
(even though it's properly retrieved and transformed to the target
space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
label somewhere.
3. Allow to switch between image and softproof spaces, regarding
out-of-gamut display. I.e. that while RGB/HSV must be shown within
the image space (assuming it's anyRGB), we may want to show
out-of-gamut area (pink areas) within the softproof space. This may
mean adding a checkbox. Or maybe simply taking into account whether
we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
gimp_widget_get_render_space() for display drawing. We don't need any
soft-proofing or black point compensation for any of these widgets so
pure babl is fine. Indeed we want to show any in-gamut color
correctly (and not transformed according to specific intents or
through soft-proofing). We will take care of the proofing case with
out-of-gamut area showing only.
5. In the various drawing functions, we should move to
CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
that it makes sense to be more accurate, especially as we are
essentially showing color gradients in 1 or 2 directions in these
various widgets.
2023-12-12 17:01:17 +09:00
|
|
|
color = gimp_color_selector_get_color (selector);
|
|
|
|
page = gimp_color_selector_new (page_type, color,
|
2017-12-31 19:04:17 +01:00
|
|
|
gimp_color_selector_get_channel (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 17:01:17 +09:00
|
|
|
g_object_unref (color);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
|
|
|
if (! page)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (page);
|
|
|
|
|
2017-12-31 16:02:21 +01:00
|
|
|
show_alpha = gimp_color_selector_get_show_alpha (GIMP_COLOR_SELECTOR (notebook));
|
|
|
|
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (page), show_alpha);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
2011-09-30 10:50:50 +02:00
|
|
|
menu_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
2014-05-10 08:33:29 +02:00
|
|
|
image = gtk_image_new_from_icon_name (selector_class->icon_name,
|
2014-05-07 21:27:57 +02:00
|
|
|
GTK_ICON_SIZE_MENU);
|
2003-07-19 11:30:10 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (menu_widget), image, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
|
|
|
label = gtk_label_new (gettext (selector_class->name));
|
|
|
|
gtk_box_pack_start (GTK_BOX (menu_widget), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2014-05-10 08:33:29 +02:00
|
|
|
image = gtk_image_new_from_icon_name (selector_class->icon_name,
|
2014-05-07 21:27:57 +02:00
|
|
|
DEFAULT_TAB_ICON_SIZE);
|
2018-06-08 19:44:29 +02:00
|
|
|
gimp_help_set_help_data (image, gettext (selector_class->name), NULL);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
gtk_notebook_append_page_menu (GTK_NOTEBOOK (notebook->notebook),
|
2003-07-19 11:30:10 +00:00
|
|
|
page, image, menu_widget);
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
if (! notebook->cur_page)
|
|
|
|
notebook->cur_page = GIMP_COLOR_SELECTOR (page);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
notebook->selectors = g_list_append (notebook->selectors, page);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
|
|
|
gtk_widget_show (page);
|
|
|
|
|
2005-05-27 13:05:26 +00:00
|
|
|
g_signal_connect (page, "color-changed",
|
2003-07-19 11:30:10 +00:00
|
|
|
G_CALLBACK (gimp_color_notebook_color_changed),
|
|
|
|
notebook);
|
2005-05-27 13:05:26 +00:00
|
|
|
g_signal_connect (page, "channel-changed",
|
2003-07-19 11:30:10 +00:00
|
|
|
G_CALLBACK (gimp_color_notebook_channel_changed),
|
|
|
|
notebook);
|
2018-03-19 22:58:03 +01:00
|
|
|
g_signal_connect (page, "model-visible-changed",
|
|
|
|
G_CALLBACK (gimp_color_notebook_model_visible_changed),
|
|
|
|
notebook);
|
2003-07-19 11:30:10 +00:00
|
|
|
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
|
2011-12-11 02:41:01 +01:00
|
|
|
static void
|
|
|
|
gimp_color_notebook_remove_selector (GtkContainer *container,
|
|
|
|
GtkWidget *widget,
|
|
|
|
GimpColorNotebook *notebook)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
notebook->selectors = g_list_remove (notebook->selectors, widget);
|
2011-12-11 02:41:01 +01:00
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
if (! notebook->selectors)
|
|
|
|
notebook->cur_page = NULL;
|
2011-12-11 02:41:01 +01:00
|
|
|
}
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-11-11 19:36:40 +00:00
|
|
|
/**
|
|
|
|
* gimp_color_notebook_set_has_page:
|
|
|
|
* @notebook: A #GimpColorNotebook widget.
|
|
|
|
* @page_type: The #GType of the notebook page to add or remove.
|
|
|
|
* @has_page: Whether the page should be added or removed.
|
|
|
|
*
|
|
|
|
* This function adds and removed pages to / from a #GimpColorNotebook.
|
|
|
|
* The @page_type passed must be a #GimpColorSelector subtype.
|
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: (transfer none): The new page widget, if @has_page was
|
2019-08-03 00:04:28 +02:00
|
|
|
* %TRUE, or %NULL if @has_page was %FALSE.
|
2003-11-11 19:36:40 +00:00
|
|
|
**/
|
2002-11-05 00:02:56 +00:00
|
|
|
GtkWidget *
|
|
|
|
gimp_color_notebook_set_has_page (GimpColorNotebook *notebook,
|
|
|
|
GType page_type,
|
|
|
|
gboolean has_page)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GList *list;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook), NULL);
|
|
|
|
g_return_val_if_fail (g_type_is_a (page_type, GIMP_TYPE_COLOR_SELECTOR),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (! g_type_is_a (page_type, GIMP_TYPE_COLOR_NOTEBOOK),
|
|
|
|
NULL);
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
for (list = notebook->selectors; list; list = g_list_next (list))
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2003-11-11 19:36:40 +00:00
|
|
|
GimpColorSelector *page = list->data;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
if (G_TYPE_FROM_INSTANCE (page) == page_type)
|
|
|
|
{
|
|
|
|
if (has_page)
|
|
|
|
return GTK_WIDGET (page);
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
gtk_container_remove (GTK_CONTAINER (notebook->notebook),
|
2002-11-05 00:02:56 +00:00
|
|
|
GTK_WIDGET (page));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! has_page)
|
|
|
|
return NULL;
|
|
|
|
|
2003-07-19 11:30:10 +00:00
|
|
|
return gimp_color_notebook_add_page (notebook, page_type);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
2011-01-02 02:20:09 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_color_notebook_get_notebook:
|
|
|
|
* @notebook: A #GimpColorNotebook 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 15:05:16 +01:00
|
|
|
* Returns: (transfer none) (type GtkNotebook): The #GtkNotebook inside.
|
2011-01-02 02:20:09 +01:00
|
|
|
*
|
2019-07-24 01:18:30 +02:00
|
|
|
* Since: 3.0
|
2011-01-02 02:20:09 +01:00
|
|
|
**/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_color_notebook_get_notebook (GimpColorNotebook *notebook)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook), NULL);
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
return notebook->notebook;
|
2011-01-02 02:20:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_color_notebook_get_selectors:
|
|
|
|
* @notebook: A #GimpColorNotebook widget.
|
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: (element-type GimpColorSelector) (transfer none): The
|
2019-08-01 14:02:21 +02:00
|
|
|
* notebook's list of #GimpColorSelector's.
|
2011-01-02 02:20:09 +01:00
|
|
|
*
|
2019-07-24 01:18:30 +02:00
|
|
|
* Since: 3.0
|
2011-01-02 02:20:09 +01:00
|
|
|
**/
|
|
|
|
GList *
|
|
|
|
gimp_color_notebook_get_selectors (GimpColorNotebook *notebook)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook), NULL);
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
return notebook->selectors;
|
2011-01-02 02:20:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_color_notebook_get_current_selector:
|
|
|
|
* @notebook: A #GimpColorNotebook widget.
|
|
|
|
*
|
2019-08-03 00:10:14 +02:00
|
|
|
* Returns: (transfer none): The active page's #GimpColorSelector.
|
2011-01-02 02:20:09 +01:00
|
|
|
*
|
2019-07-24 01:18:30 +02:00
|
|
|
* Since: 3.0
|
2011-01-02 02:20:09 +01:00
|
|
|
**/
|
|
|
|
GimpColorSelector *
|
|
|
|
gimp_color_notebook_get_current_selector (GimpColorNotebook *notebook)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook), NULL);
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
return notebook->cur_page;
|
2011-01-02 02:20:09 +01:00
|
|
|
}
|
2022-04-30 01:51:20 +00: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 10:32:48 +09:00
|
|
|
/**
|
|
|
|
* gimp_color_notebook_set_format:
|
|
|
|
* @notebook: A #GimpColorNotebook widget.
|
|
|
|
* @format: A Babl format, with space.
|
|
|
|
*
|
|
|
|
* Updates all selectors with the current format.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_color_notebook_set_format (GimpColorNotebook *notebook,
|
|
|
|
const Babl *format)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GList *list;
|
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 10:32:48 +09:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook));
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
for (list = notebook->selectors; list; list = g_list_next (list))
|
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 10:32:48 +09:00
|
|
|
{
|
|
|
|
GimpColorSelector *selector = list->data;
|
|
|
|
|
|
|
|
if (selector)
|
|
|
|
gimp_color_selector_set_format (selector, format);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-30 01:51:20 +00:00
|
|
|
/**
|
|
|
|
* gimp_color_notebook_set_simulation:
|
|
|
|
* @notebook: A #GimpColorNotebook widget.
|
|
|
|
* @profile: A #GimpColorProfile object.
|
|
|
|
* @intent: A #GimpColorRenderingIntent enum.
|
|
|
|
* @bpc: A gboolean.
|
|
|
|
*
|
|
|
|
* Updates all selectors with the current simulation settings.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_color_notebook_set_simulation (GimpColorNotebook *notebook,
|
|
|
|
GimpColorProfile *profile,
|
|
|
|
GimpColorRenderingIntent intent,
|
|
|
|
gboolean bpc)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GList *list;
|
2022-04-30 01:51:20 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook));
|
|
|
|
g_return_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile));
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
for (list = notebook->selectors; list; list = g_list_next (list))
|
2022-04-30 01:51:20 +00:00
|
|
|
{
|
|
|
|
GimpColorSelector *selector = list->data;
|
|
|
|
|
|
|
|
if (selector)
|
|
|
|
gimp_color_selector_set_simulation (selector, profile, intent, bpc);
|
|
|
|
}
|
|
|
|
}
|
2023-12-20 20:09:25 +09:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_color_notebook_enable_simulation (GimpColorNotebook *notebook,
|
|
|
|
gboolean enabled)
|
|
|
|
{
|
2024-10-16 21:56:26 +02:00
|
|
|
GList *list;
|
2023-12-20 20:09:25 +09:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook));
|
|
|
|
|
2024-10-16 21:56:26 +02:00
|
|
|
for (list = notebook->selectors; list; list = g_list_next (list))
|
2023-12-20 20:09:25 +09:00
|
|
|
{
|
|
|
|
GimpColorSelector *selector = list->data;
|
|
|
|
|
|
|
|
if (selector)
|
|
|
|
gimp_color_selector_enable_simulation (selector, enabled);
|
|
|
|
}
|
|
|
|
}
|