2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2002-11-05 00:02:56 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpcoloreditor.c
|
|
|
|
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2002-11-05 00:02:56 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-11-05 00:02:56 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2002-11-05 00:02:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-10-11 16:50:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-03-29 19:19:01 +02:00
|
|
|
#include <gegl.h>
|
2002-11-05 00:02:56 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2019-07-31 10:16:21 +02:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2023-12-20 20:09:25 +09:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
2006-09-26 08:55:41 +00:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
#include "core/gimpcontext.h"
|
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
|
|
|
#include "core/gimpimage.h"
|
2023-12-16 22:30:02 +09:00
|
|
|
#include "core/gimpimage-color-profile.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2023-12-20 20:09:25 +09:00
|
|
|
#include "display/display-types.h"
|
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
#include "display/gimpdisplayshell.h"
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
#include "gimpcoloreditor.h"
|
2015-12-23 03:32:25 +01:00
|
|
|
#include "gimpcolorhistory.h"
|
2003-10-10 21:24:12 +00:00
|
|
|
#include "gimpdocked.h"
|
2004-05-27 12:41:22 +00:00
|
|
|
#include "gimpfgbgeditor.h"
|
2005-03-31 13:39:18 +00:00
|
|
|
#include "gimpfgbgview.h"
|
2007-05-25 11:42:28 +00:00
|
|
|
#include "gimpsessioninfo-aux.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
|
2005-05-29 13:48:03 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_CONTEXT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
static void gimp_color_editor_docked_iface_init (GimpDockedInterface *iface);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2023-12-16 22:30:02 +09:00
|
|
|
static void gimp_color_editor_constructed (GObject *object);
|
|
|
|
static void gimp_color_editor_dispose (GObject *object);
|
|
|
|
static void gimp_color_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_color_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
static void gimp_color_editor_style_updated (GtkWidget *widget);
|
|
|
|
|
|
|
|
static void gimp_color_editor_set_aux_info (GimpDocked *docked,
|
|
|
|
GList *aux_info);
|
|
|
|
static GList *gimp_color_editor_get_aux_info (GimpDocked *docked);
|
|
|
|
static GtkWidget *gimp_color_editor_get_preview (GimpDocked *docked,
|
|
|
|
GimpContext *context,
|
|
|
|
GtkIconSize size);
|
|
|
|
static void gimp_color_editor_set_context (GimpDocked *docked,
|
|
|
|
GimpContext *context);
|
|
|
|
|
|
|
|
static void gimp_color_editor_fg_changed (GimpContext *context,
|
|
|
|
GeglColor *color,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_bg_changed (GimpContext *context,
|
|
|
|
GeglColor *color,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_color_changed (GimpColorSelector *selector,
|
|
|
|
GeglColor *color,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_tab_toggled (GtkWidget *widget,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_fg_bg_notify (GtkWidget *widget,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_color_picked (GtkWidget *widget,
|
2024-03-26 01:25:08 +00:00
|
|
|
const GeglColor *color,
|
2023-12-16 22:30:02 +09:00
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
|
|
|
|
static void gimp_color_editor_history_selected (GimpColorHistory *history,
|
|
|
|
GeglColor *color,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
|
2023-12-20 20:09:25 +09:00
|
|
|
static void gimp_color_editor_display_changed (GimpContext *context,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_image_changed (GimpDisplay *display,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_shell_changed (GimpDisplay *display,
|
|
|
|
GParamSpec *pspec,
|
2023-12-16 22:30:02 +09:00
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_update_simulation (GimpImage *image,
|
|
|
|
GimpColorEditor *editor);
|
2023-12-20 20:09:25 +09:00
|
|
|
static void gimp_color_editor_enable_simulation (GimpColorEditor *editor);
|
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
|
|
|
static void gimp_color_editor_update_format (GimpColorEditor *editor);
|
2023-12-16 22:30:02 +09:00
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpColorEditor, gimp_color_editor, GIMP_TYPE_EDITOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
|
2006-05-15 09:46:31 +00:00
|
|
|
gimp_color_editor_docked_iface_init))
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
#define parent_class gimp_color_editor_parent_class
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
static GimpDockedInterface *parent_docked_iface = NULL;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_class_init (GimpColorEditorClass* klass)
|
|
|
|
{
|
2010-09-26 22:38:01 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2011-01-09 20:38:01 +01:00
|
|
|
object_class->constructed = gimp_color_editor_constructed;
|
|
|
|
object_class->dispose = gimp_color_editor_dispose;
|
|
|
|
object_class->set_property = gimp_color_editor_set_property;
|
|
|
|
object_class->get_property = gimp_color_editor_get_property;
|
2005-05-29 13:48:03 +00:00
|
|
|
|
2011-01-09 20:38:01 +01:00
|
|
|
widget_class->style_updated = gimp_color_editor_style_updated;
|
2005-05-29 13:48:03 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_CONTEXT,
|
|
|
|
g_param_spec_object ("context",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_CONTEXT,
|
2015-12-23 03:32:25 +01:00
|
|
|
G_PARAM_CONSTRUCT |
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_READWRITE));
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
2006-08-29 21:44:51 +00:00
|
|
|
static void
|
|
|
|
gimp_color_editor_docked_iface_init (GimpDockedInterface *iface)
|
|
|
|
{
|
|
|
|
parent_docked_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
|
|
if (! parent_docked_iface)
|
|
|
|
parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
|
|
|
|
|
|
|
|
iface->get_preview = gimp_color_editor_get_preview;
|
|
|
|
iface->set_aux_info = gimp_color_editor_set_aux_info;
|
|
|
|
iface->get_aux_info = gimp_color_editor_get_aux_info;
|
|
|
|
iface->set_context = gimp_color_editor_set_context;
|
|
|
|
}
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
static void
|
|
|
|
gimp_color_editor_init (GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
GtkWidget *notebook;
|
2005-05-19 17:08:03 +00:00
|
|
|
GtkWidget *hbox;
|
2005-05-20 10:54:44 +00:00
|
|
|
GtkWidget *button;
|
2002-11-05 00:02:56 +00:00
|
|
|
gint content_spacing;
|
|
|
|
gint button_spacing;
|
|
|
|
GtkIconSize button_icon_size;
|
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-11-05 00:02:56 +00:00
|
|
|
GList *list;
|
|
|
|
GSList *group;
|
Issue #7023: icon size selection on GIMP 2.99.
This kinda reverts commit 6aebd30de142286c41e6cd90abedc4082a13fcea ("app: remove
icon sizing preferences"), except that the code base is different enough since
this old commit was mainly for GIMP 2.10.x.
In any case, after initially thinking that GTK+3 handling for high density
display would be enough, we finally decide that adding back a Preferences-wide
setting for overriding the theme-set icon size is a good idea (additionally to
GTK+3 automatic support).
The base idea for removing the feature was that GTK+3 has high density display
support, through the "scale factor". Typically a high density display will
normally be set as using a ×2 scale factor so all icons will be double size.
Unfortunately it turns out it's not enough.
For instance, on very small screen estate, even with a scale factor of 1, if the
theme sets 24px toolbox icons, it may still take too much space.
Oppositely on huge screens, even with ×2 factor scale detected by the OS, the
icons may still feel too small (this is possibly what happens with #7023).
Furthermore there is also a matter of taste. Some people like small icons even
when they have the space. Others may want bigger icons, easy to click on.
Finally you can like a theme for its color scheme for instance, but it may not
have the icon size you want. Right now, we'd need to duplicate every theme in
small or bigger size. Instead of doing so, let's just have this global setting
overriding the theme rules.
Comparison with the 2.10 implementation:
- We still provide 4 sizes: small, medium, large and huge.
- We don't have the "Guess ideal size" setting anymore. Instead this is now a
mix of the GTK+3 scale factor logic and the theme-set or custom size. I.e.
that on a high density display with ×2 scale factor, we could have toolbox
icons up to 96 pixels (48×2)!
- We now try to have less custom code in widgets as we append the CSS rules to
the theme (similar to what we were already doing for dark theme or icon
variants). What happens in widget code is mostly to connect to changes in
themes and redraw the widgets which need to be.
- The custom size will now affect: toolbox icons, the FG/BG editor widget (in
both the toolbox and the color dockable), dockable tab icons, the main
dockable buttons, eye and lock header icons in item tree views, eye and lock
cell icons in the item lists.
There are still a bunch of areas where it is not taken into account, such as
plug-ins, and various dialogs, but even in custom-made interface in dockables.
Ultimately it might be interesting to have a way to sync more buttons and
widgets to a global size settings.
Lastly, I fixed a bunch of existing bugs where we were updating icon sizes with
gtk_image_set_from_icon_name() using the const icon name taken from
gtk_image_get_icon_name(). As this was reusing the same string pointer, we were
ending with freeing the icon name.
2022-09-26 22:56:08 +02:00
|
|
|
gint icon_width = 40;
|
|
|
|
gint icon_height = 38;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
editor->context = NULL;
|
|
|
|
editor->edit_bg = FALSE;
|
|
|
|
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (editor),
|
2005-08-03 09:34:55 +00:00
|
|
|
"content-spacing", &content_spacing,
|
2006-04-12 12:49:29 +00:00
|
|
|
"button-spacing", &button_spacing,
|
2005-08-03 09:34:55 +00:00
|
|
|
"button-icon-size", &button_icon_size,
|
2006-04-12 12:49:29 +00:00
|
|
|
NULL);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
editor->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, button_spacing);
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (editor->hbox), TRUE);
|
2002-11-05 00:02:56 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), editor->hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (editor->hbox);
|
|
|
|
|
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 = gegl_color_new ("black");
|
|
|
|
editor->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK, color,
|
2024-10-13 14:25:24 +02:00
|
|
|
GIMP_COLOR_SELECTOR_HUE);
|
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);
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (editor->notebook),
|
|
|
|
FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), editor->notebook,
|
|
|
|
TRUE, TRUE, content_spacing);
|
|
|
|
gtk_widget_show (editor->notebook);
|
|
|
|
|
2005-05-27 16:51:39 +00:00
|
|
|
g_signal_connect (editor->notebook, "color-changed",
|
2002-11-05 00:02:56 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_color_changed),
|
|
|
|
editor);
|
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
notebook = gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (editor->notebook));
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
|
|
|
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
|
|
|
|
|
|
|
|
gimp_color_notebook_set_has_page (GIMP_COLOR_NOTEBOOK (editor->notebook),
|
|
|
|
GIMP_TYPE_COLOR_SCALES, TRUE);
|
|
|
|
|
|
|
|
group = NULL;
|
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
for (list = gimp_color_notebook_get_selectors (GIMP_COLOR_NOTEBOOK (editor->notebook));
|
2002-11-05 00:02:56 +00:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpColorSelector *selector;
|
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
selector = GIMP_COLOR_SELECTOR (list->data);
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
|
|
|
|
|
|
|
button = gtk_radio_button_new (group);
|
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor->hbox), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2014-05-10 08:33:29 +02:00
|
|
|
image = gtk_image_new_from_icon_name (selector_class->icon_name,
|
2018-05-10 17:55:49 +02:00
|
|
|
GTK_ICON_SIZE_MENU);
|
2002-11-05 00:02:56 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2003-07-19 01:43:51 +00:00
|
|
|
gimp_help_set_help_data (button,
|
2006-04-12 12:49:29 +00:00
|
|
|
selector_class->name, selector_class->help_id);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-10-11 16:50:35 +00:00
|
|
|
g_object_set_data (G_OBJECT (button), "selector", selector);
|
|
|
|
g_object_set_data (G_OBJECT (selector), "button", button);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_connect (button, "toggled",
|
2002-11-05 00:02:56 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_tab_toggled),
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2019-02-12 13:44:01 +01:00
|
|
|
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
2005-05-19 17:08:03 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
/* FG/BG editor */
|
|
|
|
editor->fg_bg = gimp_fg_bg_editor_new (NULL);
|
Issue #7023: icon size selection on GIMP 2.99.
This kinda reverts commit 6aebd30de142286c41e6cd90abedc4082a13fcea ("app: remove
icon sizing preferences"), except that the code base is different enough since
this old commit was mainly for GIMP 2.10.x.
In any case, after initially thinking that GTK+3 handling for high density
display would be enough, we finally decide that adding back a Preferences-wide
setting for overriding the theme-set icon size is a good idea (additionally to
GTK+3 automatic support).
The base idea for removing the feature was that GTK+3 has high density display
support, through the "scale factor". Typically a high density display will
normally be set as using a ×2 scale factor so all icons will be double size.
Unfortunately it turns out it's not enough.
For instance, on very small screen estate, even with a scale factor of 1, if the
theme sets 24px toolbox icons, it may still take too much space.
Oppositely on huge screens, even with ×2 factor scale detected by the OS, the
icons may still feel too small (this is possibly what happens with #7023).
Furthermore there is also a matter of taste. Some people like small icons even
when they have the space. Others may want bigger icons, easy to click on.
Finally you can like a theme for its color scheme for instance, but it may not
have the icon size you want. Right now, we'd need to duplicate every theme in
small or bigger size. Instead of doing so, let's just have this global setting
overriding the theme rules.
Comparison with the 2.10 implementation:
- We still provide 4 sizes: small, medium, large and huge.
- We don't have the "Guess ideal size" setting anymore. Instead this is now a
mix of the GTK+3 scale factor logic and the theme-set or custom size. I.e.
that on a high density display with ×2 scale factor, we could have toolbox
icons up to 96 pixels (48×2)!
- We now try to have less custom code in widgets as we append the CSS rules to
the theme (similar to what we were already doing for dark theme or icon
variants). What happens in widget code is mostly to connect to changes in
themes and redraw the widgets which need to be.
- The custom size will now affect: toolbox icons, the FG/BG editor widget (in
both the toolbox and the color dockable), dockable tab icons, the main
dockable buttons, eye and lock header icons in item tree views, eye and lock
cell icons in the item lists.
There are still a bunch of areas where it is not taken into account, such as
plug-ins, and various dialogs, but even in custom-made interface in dockables.
Ultimately it might be interesting to have a way to sync more buttons and
widgets to a global size settings.
Lastly, I fixed a bunch of existing bugs where we were updating icon sizes with
gtk_image_set_from_icon_name() using the const icon name taken from
gtk_image_get_icon_name(). As this was reusing the same string pointer, we were
ending with freeing the icon name.
2022-09-26 22:56:08 +02:00
|
|
|
gtk_icon_size_lookup (button_icon_size, &icon_width, &icon_height);
|
|
|
|
gtk_widget_set_size_request (editor->fg_bg,
|
|
|
|
(gint) (icon_width * 1.75),
|
|
|
|
(gint) (icon_height * 1.75));
|
2019-02-12 14:32:43 +01:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), editor->fg_bg, FALSE, FALSE, 0);
|
2004-05-27 12:41:22 +00:00
|
|
|
gtk_widget_show (editor->fg_bg);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
g_signal_connect (editor->fg_bg, "notify::active-color",
|
|
|
|
G_CALLBACK (gimp_color_editor_fg_bg_notify),
|
|
|
|
editor);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
2005-05-20 10:54:44 +00:00
|
|
|
/* The color picker */
|
|
|
|
button = gimp_pick_button_new ();
|
2019-02-12 13:44:01 +01:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
2005-05-20 10:54:44 +00:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2005-08-03 09:34:55 +00:00
|
|
|
g_signal_connect (button, "color-picked",
|
2005-05-20 10:54:44 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_color_picked),
|
|
|
|
editor);
|
|
|
|
|
|
|
|
/* The hex triplet entry */
|
2005-05-19 17:08:03 +00:00
|
|
|
editor->hex_entry = gimp_color_hex_entry_new ();
|
2019-02-12 13:44:01 +01:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), editor->hex_entry, TRUE, TRUE, 0);
|
2005-05-19 17:08:03 +00:00
|
|
|
gtk_widget_show (editor->hex_entry);
|
|
|
|
|
2005-05-27 16:51:39 +00:00
|
|
|
g_signal_connect (editor->hex_entry, "color-changed",
|
2005-05-19 17:08:03 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_entry_changed),
|
|
|
|
editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
2015-12-23 03:32:25 +01:00
|
|
|
static void
|
|
|
|
gimp_color_editor_constructed (GObject *object)
|
|
|
|
{
|
2023-12-16 22:30:02 +09:00
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (object);
|
|
|
|
GimpContext *user_context = editor->context->gimp->user_context;
|
2023-12-20 20:09:25 +09:00
|
|
|
GimpDisplay *display = gimp_context_get_display (user_context);
|
2015-12-23 03:32:25 +01:00
|
|
|
GtkWidget *history;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
|
|
|
|
|
|
|
/* The color history */
|
|
|
|
history = gimp_color_history_new (editor->context, 12);
|
|
|
|
gtk_box_pack_end (GTK_BOX (editor), history, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (history);
|
|
|
|
|
|
|
|
g_signal_connect (history, "color-selected",
|
|
|
|
G_CALLBACK (gimp_color_editor_history_selected),
|
|
|
|
editor);
|
2023-12-16 22:30:02 +09:00
|
|
|
|
2024-06-30 04:14:48 +00:00
|
|
|
g_signal_connect_object (user_context, "display-changed",
|
|
|
|
G_CALLBACK (gimp_color_editor_display_changed),
|
|
|
|
editor, 0);
|
2023-12-16 22:30:02 +09:00
|
|
|
|
2023-12-20 20:09:25 +09:00
|
|
|
gimp_color_editor_display_changed (user_context, display, editor);
|
2015-12-23 03:32:25 +01:00
|
|
|
}
|
|
|
|
|
2010-09-26 22:38:01 +02:00
|
|
|
static void
|
|
|
|
gimp_color_editor_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (object);
|
|
|
|
|
2024-08-28 21:25:33 +02:00
|
|
|
g_clear_weak_pointer (&editor->active_display);
|
|
|
|
g_clear_weak_pointer (&editor->active_image);
|
|
|
|
g_clear_weak_pointer (&editor->active_shell);
|
|
|
|
|
2010-09-26 22:38:01 +02:00
|
|
|
if (editor->context)
|
|
|
|
gimp_docked_set_context (GIMP_DOCKED (editor), NULL);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2005-05-29 13:48:03 +00:00
|
|
|
static void
|
|
|
|
gimp_color_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
gimp_docked_set_context (GIMP_DOCKED (object),
|
|
|
|
g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
g_value_set_object (value, editor->context);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-12-19 22:37:49 +00:00
|
|
|
|
2005-03-31 13:39:18 +00:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_color_editor_get_preview (GimpDocked *docked,
|
|
|
|
GimpContext *context,
|
|
|
|
GtkIconSize size)
|
|
|
|
{
|
2018-04-29 02:53:51 +02:00
|
|
|
GtkWidget *preview;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
2005-03-31 13:39:18 +00:00
|
|
|
|
|
|
|
preview = gimp_fg_bg_view_new (context);
|
|
|
|
|
2018-04-29 02:53:51 +02:00
|
|
|
if (gtk_icon_size_lookup (size, &width, &height))
|
2005-03-31 13:39:18 +00:00
|
|
|
gtk_widget_set_size_request (preview, width, height);
|
|
|
|
|
|
|
|
return preview;
|
|
|
|
}
|
|
|
|
|
2003-10-18 17:10:36 +00:00
|
|
|
#define AUX_INFO_CURRENT_PAGE "current-page"
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
static void
|
2003-10-11 16:50:35 +00:00
|
|
|
gimp_color_editor_set_aux_info (GimpDocked *docked,
|
|
|
|
GList *aux_info)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2003-10-11 16:50:35 +00:00
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
|
2011-01-02 02:20:09 +01:00
|
|
|
GtkWidget *notebook;
|
2003-10-11 16:50:35 +00:00
|
|
|
GList *list;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
notebook = gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (editor->notebook));
|
|
|
|
|
2005-06-04 22:49:53 +00:00
|
|
|
parent_docked_iface->set_aux_info (docked, aux_info);
|
|
|
|
|
2003-10-11 16:50:35 +00:00
|
|
|
for (list = aux_info; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpSessionInfoAux *aux = list->data;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-10-18 17:10:36 +00:00
|
|
|
if (! strcmp (aux->name, AUX_INFO_CURRENT_PAGE))
|
2003-10-11 16:50:35 +00:00
|
|
|
{
|
|
|
|
GList *children;
|
|
|
|
GList *child;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-10-11 16:50:35 +00:00
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (notebook));
|
|
|
|
|
|
|
|
for (child = children; child; child = g_list_next (child))
|
|
|
|
{
|
|
|
|
if (! strcmp (G_OBJECT_TYPE_NAME (child->data), aux->value))
|
|
|
|
{
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
button = g_object_get_data (G_OBJECT (child->data), "button");
|
|
|
|
|
|
|
|
if (button)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
gimp_color_editor_get_aux_info (GimpDocked *docked)
|
|
|
|
{
|
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
|
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (editor->notebook);
|
2011-01-02 02:20:09 +01:00
|
|
|
GimpColorSelector *current;
|
2005-06-04 22:49:53 +00:00
|
|
|
GList *aux_info;
|
|
|
|
|
|
|
|
aux_info = parent_docked_iface->get_aux_info (docked);
|
2003-10-11 16:50:35 +00:00
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
current = gimp_color_notebook_get_current_selector (notebook);
|
|
|
|
|
|
|
|
if (current)
|
2003-10-11 16:50:35 +00:00
|
|
|
{
|
|
|
|
GimpSessionInfoAux *aux;
|
|
|
|
|
2003-10-18 17:10:36 +00:00
|
|
|
aux = gimp_session_info_aux_new (AUX_INFO_CURRENT_PAGE,
|
2011-01-02 02:20:09 +01:00
|
|
|
G_OBJECT_TYPE_NAME (current));
|
2003-10-11 16:50:35 +00:00
|
|
|
aux_info = g_list_append (aux_info, aux);
|
|
|
|
}
|
|
|
|
|
|
|
|
return aux_info;
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
2003-10-10 21:24:12 +00:00
|
|
|
static void
|
2004-05-23 10:04:41 +00:00
|
|
|
gimp_color_editor_set_context (GimpDocked *docked,
|
|
|
|
GimpContext *context)
|
2003-10-10 21:24:12 +00:00
|
|
|
{
|
2004-05-23 10:04:41 +00:00
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
if (context == editor->context)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (editor->context)
|
|
|
|
{
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->context,
|
2006-04-12 12:49:29 +00:00
|
|
|
gimp_color_editor_fg_changed,
|
|
|
|
editor);
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->context,
|
2006-04-12 12:49:29 +00:00
|
|
|
gimp_color_editor_bg_changed,
|
|
|
|
editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
Issue #7023: icon size selection on GIMP 2.99.
This kinda reverts commit 6aebd30de142286c41e6cd90abedc4082a13fcea ("app: remove
icon sizing preferences"), except that the code base is different enough since
this old commit was mainly for GIMP 2.10.x.
In any case, after initially thinking that GTK+3 handling for high density
display would be enough, we finally decide that adding back a Preferences-wide
setting for overriding the theme-set icon size is a good idea (additionally to
GTK+3 automatic support).
The base idea for removing the feature was that GTK+3 has high density display
support, through the "scale factor". Typically a high density display will
normally be set as using a ×2 scale factor so all icons will be double size.
Unfortunately it turns out it's not enough.
For instance, on very small screen estate, even with a scale factor of 1, if the
theme sets 24px toolbox icons, it may still take too much space.
Oppositely on huge screens, even with ×2 factor scale detected by the OS, the
icons may still feel too small (this is possibly what happens with #7023).
Furthermore there is also a matter of taste. Some people like small icons even
when they have the space. Others may want bigger icons, easy to click on.
Finally you can like a theme for its color scheme for instance, but it may not
have the icon size you want. Right now, we'd need to duplicate every theme in
small or bigger size. Instead of doing so, let's just have this global setting
overriding the theme rules.
Comparison with the 2.10 implementation:
- We still provide 4 sizes: small, medium, large and huge.
- We don't have the "Guess ideal size" setting anymore. Instead this is now a
mix of the GTK+3 scale factor logic and the theme-set or custom size. I.e.
that on a high density display with ×2 scale factor, we could have toolbox
icons up to 96 pixels (48×2)!
- We now try to have less custom code in widgets as we append the CSS rules to
the theme (similar to what we were already doing for dark theme or icon
variants). What happens in widget code is mostly to connect to changes in
themes and redraw the widgets which need to be.
- The custom size will now affect: toolbox icons, the FG/BG editor widget (in
both the toolbox and the color dockable), dockable tab icons, the main
dockable buttons, eye and lock header icons in item tree views, eye and lock
cell icons in the item lists.
There are still a bunch of areas where it is not taken into account, such as
plug-ins, and various dialogs, but even in custom-made interface in dockables.
Ultimately it might be interesting to have a way to sync more buttons and
widgets to a global size settings.
Lastly, I fixed a bunch of existing bugs where we were updating icon sizes with
gtk_image_set_from_icon_name() using the const icon name taken from
gtk_image_get_icon_name(). As this was reusing the same string pointer, we were
ending with freeing the icon name.
2022-09-26 22:56:08 +02:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->context->gimp->config,
|
|
|
|
G_CALLBACK (gimp_color_editor_style_updated),
|
|
|
|
editor);
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
g_object_unref (editor->context);
|
|
|
|
}
|
|
|
|
|
2006-08-29 21:44:51 +00:00
|
|
|
editor->context = context;
|
|
|
|
|
|
|
|
if (editor->context)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2006-08-29 21:44:51 +00:00
|
|
|
g_object_ref (editor->context);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2024-08-05 15:14:32 +02:00
|
|
|
g_signal_connect_object (editor->context, "foreground-changed",
|
|
|
|
G_CALLBACK (gimp_color_editor_fg_changed),
|
|
|
|
editor, 0);
|
|
|
|
g_signal_connect_object (editor->context, "background-changed",
|
|
|
|
G_CALLBACK (gimp_color_editor_bg_changed),
|
|
|
|
editor, 0);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
Issue #7023: icon size selection on GIMP 2.99.
This kinda reverts commit 6aebd30de142286c41e6cd90abedc4082a13fcea ("app: remove
icon sizing preferences"), except that the code base is different enough since
this old commit was mainly for GIMP 2.10.x.
In any case, after initially thinking that GTK+3 handling for high density
display would be enough, we finally decide that adding back a Preferences-wide
setting for overriding the theme-set icon size is a good idea (additionally to
GTK+3 automatic support).
The base idea for removing the feature was that GTK+3 has high density display
support, through the "scale factor". Typically a high density display will
normally be set as using a ×2 scale factor so all icons will be double size.
Unfortunately it turns out it's not enough.
For instance, on very small screen estate, even with a scale factor of 1, if the
theme sets 24px toolbox icons, it may still take too much space.
Oppositely on huge screens, even with ×2 factor scale detected by the OS, the
icons may still feel too small (this is possibly what happens with #7023).
Furthermore there is also a matter of taste. Some people like small icons even
when they have the space. Others may want bigger icons, easy to click on.
Finally you can like a theme for its color scheme for instance, but it may not
have the icon size you want. Right now, we'd need to duplicate every theme in
small or bigger size. Instead of doing so, let's just have this global setting
overriding the theme rules.
Comparison with the 2.10 implementation:
- We still provide 4 sizes: small, medium, large and huge.
- We don't have the "Guess ideal size" setting anymore. Instead this is now a
mix of the GTK+3 scale factor logic and the theme-set or custom size. I.e.
that on a high density display with ×2 scale factor, we could have toolbox
icons up to 96 pixels (48×2)!
- We now try to have less custom code in widgets as we append the CSS rules to
the theme (similar to what we were already doing for dark theme or icon
variants). What happens in widget code is mostly to connect to changes in
themes and redraw the widgets which need to be.
- The custom size will now affect: toolbox icons, the FG/BG editor widget (in
both the toolbox and the color dockable), dockable tab icons, the main
dockable buttons, eye and lock header icons in item tree views, eye and lock
cell icons in the item lists.
There are still a bunch of areas where it is not taken into account, such as
plug-ins, and various dialogs, but even in custom-made interface in dockables.
Ultimately it might be interesting to have a way to sync more buttons and
widgets to a global size settings.
Lastly, I fixed a bunch of existing bugs where we were updating icon sizes with
gtk_image_set_from_icon_name() using the const icon name taken from
gtk_image_get_icon_name(). As this was reusing the same string pointer, we were
ending with freeing the icon name.
2022-09-26 22:56:08 +02:00
|
|
|
g_signal_connect_object (editor->context->gimp->config,
|
|
|
|
"notify::theme",
|
|
|
|
G_CALLBACK (gimp_color_editor_style_updated),
|
|
|
|
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (context->gimp->config,
|
|
|
|
"notify::override-theme-icon-size",
|
|
|
|
G_CALLBACK (gimp_color_editor_style_updated),
|
|
|
|
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (context->gimp->config,
|
|
|
|
"notify::custom-icon-size",
|
|
|
|
G_CALLBACK (gimp_color_editor_style_updated),
|
|
|
|
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
if (editor->edit_bg)
|
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_background (editor->context);
|
|
|
|
gimp_color_editor_bg_changed (editor->context, color, editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_foreground (editor->context);
|
|
|
|
gimp_color_editor_fg_changed (editor->context, color, editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
2006-09-26 08:55:41 +00:00
|
|
|
|
2006-11-03 21:29:42 +00:00
|
|
|
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
|
|
|
"gimp-context", editor->context);
|
|
|
|
|
2006-09-26 08:55:41 +00:00
|
|
|
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (editor->notebook),
|
|
|
|
context->gimp->config->color_management);
|
2006-11-03 21:29:42 +00:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
|
|
|
"gimp-context", NULL);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
2004-05-27 12:41:22 +00:00
|
|
|
|
|
|
|
gimp_fg_bg_editor_set_context (GIMP_FG_BG_EDITOR (editor->fg_bg), context);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
2004-05-23 10:04:41 +00:00
|
|
|
GtkWidget *
|
|
|
|
gimp_color_editor_new (GimpContext *context)
|
|
|
|
{
|
2005-05-29 13:48:03 +00:00
|
|
|
return g_object_new (GIMP_TYPE_COLOR_EDITOR,
|
|
|
|
"context", context,
|
|
|
|
NULL);
|
2004-05-23 10:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-09 20:38:01 +01:00
|
|
|
gimp_color_editor_style_updated (GtkWidget *widget)
|
2004-05-23 10:04:41 +00:00
|
|
|
{
|
2024-06-25 12:40:04 +00:00
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (widget);
|
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (editor->notebook);
|
|
|
|
GtkIconSize button_icon_size;
|
|
|
|
gint icon_width = 40;
|
|
|
|
gint icon_height = 38;
|
2004-05-23 10:04:41 +00:00
|
|
|
|
2011-01-09 20:38:01 +01:00
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
|
2004-05-23 10:04:41 +00:00
|
|
|
|
|
|
|
if (editor->hbox)
|
|
|
|
gimp_editor_set_box_style (GIMP_EDITOR (editor), GTK_BOX (editor->hbox));
|
Issue #7023: icon size selection on GIMP 2.99.
This kinda reverts commit 6aebd30de142286c41e6cd90abedc4082a13fcea ("app: remove
icon sizing preferences"), except that the code base is different enough since
this old commit was mainly for GIMP 2.10.x.
In any case, after initially thinking that GTK+3 handling for high density
display would be enough, we finally decide that adding back a Preferences-wide
setting for overriding the theme-set icon size is a good idea (additionally to
GTK+3 automatic support).
The base idea for removing the feature was that GTK+3 has high density display
support, through the "scale factor". Typically a high density display will
normally be set as using a ×2 scale factor so all icons will be double size.
Unfortunately it turns out it's not enough.
For instance, on very small screen estate, even with a scale factor of 1, if the
theme sets 24px toolbox icons, it may still take too much space.
Oppositely on huge screens, even with ×2 factor scale detected by the OS, the
icons may still feel too small (this is possibly what happens with #7023).
Furthermore there is also a matter of taste. Some people like small icons even
when they have the space. Others may want bigger icons, easy to click on.
Finally you can like a theme for its color scheme for instance, but it may not
have the icon size you want. Right now, we'd need to duplicate every theme in
small or bigger size. Instead of doing so, let's just have this global setting
overriding the theme rules.
Comparison with the 2.10 implementation:
- We still provide 4 sizes: small, medium, large and huge.
- We don't have the "Guess ideal size" setting anymore. Instead this is now a
mix of the GTK+3 scale factor logic and the theme-set or custom size. I.e.
that on a high density display with ×2 scale factor, we could have toolbox
icons up to 96 pixels (48×2)!
- We now try to have less custom code in widgets as we append the CSS rules to
the theme (similar to what we were already doing for dark theme or icon
variants). What happens in widget code is mostly to connect to changes in
themes and redraw the widgets which need to be.
- The custom size will now affect: toolbox icons, the FG/BG editor widget (in
both the toolbox and the color dockable), dockable tab icons, the main
dockable buttons, eye and lock header icons in item tree views, eye and lock
cell icons in the item lists.
There are still a bunch of areas where it is not taken into account, such as
plug-ins, and various dialogs, but even in custom-made interface in dockables.
Ultimately it might be interesting to have a way to sync more buttons and
widgets to a global size settings.
Lastly, I fixed a bunch of existing bugs where we were updating icon sizes with
gtk_image_set_from_icon_name() using the const icon name taken from
gtk_image_get_icon_name(). As this was reusing the same string pointer, we were
ending with freeing the icon name.
2022-09-26 22:56:08 +02:00
|
|
|
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (editor),
|
|
|
|
"button-icon-size", &button_icon_size,
|
|
|
|
NULL);
|
|
|
|
gtk_icon_size_lookup (button_icon_size, &icon_width, &icon_height);
|
|
|
|
gtk_widget_set_size_request (editor->fg_bg,
|
|
|
|
(gint) (icon_width * 1.75),
|
|
|
|
(gint) (icon_height * 1.75));
|
2024-06-25 12:40:04 +00:00
|
|
|
|
|
|
|
GTK_WIDGET_GET_CLASS (notebook)->style_updated (GTK_WIDGET (notebook));
|
2004-05-23 10:04:41 +00:00
|
|
|
}
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2005-05-19 17:08:03 +00:00
|
|
|
static void
|
|
|
|
gimp_color_editor_set_color (GimpColorEditor *editor,
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color)
|
2005-05-19 17:08:03 +00:00
|
|
|
{
|
|
|
|
g_signal_handlers_block_by_func (editor->notebook,
|
|
|
|
gimp_color_editor_color_changed,
|
|
|
|
editor);
|
|
|
|
|
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 (GIMP_COLOR_SELECTOR (editor->notebook), color);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (editor->notebook,
|
|
|
|
gimp_color_editor_color_changed,
|
|
|
|
editor);
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (editor->hex_entry,
|
|
|
|
gimp_color_editor_entry_changed,
|
|
|
|
editor);
|
|
|
|
|
2023-12-09 20:53:39 +09:00
|
|
|
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry), color);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
|
|
|
gimp_color_editor_entry_changed,
|
|
|
|
editor);
|
|
|
|
}
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_fg_changed (GimpContext *context,
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color,
|
2002-11-05 00:02:56 +00:00
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
if (! editor->edit_bg)
|
2023-11-14 20:04:14 +01:00
|
|
|
gimp_color_editor_set_color (editor, color);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_bg_changed (GimpContext *context,
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color,
|
2002-11-05 00:02:56 +00:00
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
if (editor->edit_bg)
|
2023-11-14 20:04:14 +01:00
|
|
|
gimp_color_editor_set_color (editor, color);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_color_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 17:01:17 +09:00
|
|
|
GeglColor *color,
|
2002-11-05 00:02:56 +00:00
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
if (editor->context)
|
|
|
|
{
|
|
|
|
if (editor->edit_bg)
|
|
|
|
{
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_block_by_func (editor->context,
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_editor_bg_changed,
|
|
|
|
editor);
|
|
|
|
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_background (editor->context, color);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_unblock_by_func (editor->context,
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_editor_bg_changed,
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_block_by_func (editor->context,
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_editor_fg_changed,
|
|
|
|
editor);
|
|
|
|
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_foreground (editor->context, color);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_unblock_by_func (editor->context,
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_editor_fg_changed,
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
}
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (editor->hex_entry,
|
|
|
|
gimp_color_editor_entry_changed,
|
|
|
|
editor);
|
|
|
|
|
2023-12-09 20:53:39 +09:00
|
|
|
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry), color);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
|
|
|
gimp_color_editor_entry_changed,
|
|
|
|
editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_tab_toggled (GtkWidget *widget,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
2008-06-28 15:50:27 +00:00
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
|
|
|
GtkWidget *selector;
|
|
|
|
|
|
|
|
selector = g_object_get_data (G_OBJECT (widget), "selector");
|
|
|
|
|
|
|
|
if (selector)
|
|
|
|
{
|
|
|
|
GtkWidget *notebook;
|
|
|
|
gint page_num;
|
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
notebook = gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (editor->notebook));
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), selector);
|
|
|
|
|
|
|
|
if (page_num >= 0)
|
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-27 12:41:22 +00:00
|
|
|
gimp_color_editor_fg_bg_notify (GtkWidget *widget,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpColorEditor *editor)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2004-05-27 12:41:22 +00:00
|
|
|
gboolean edit_bg;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
edit_bg = (GIMP_FG_BG_EDITOR (widget)->active_color ==
|
|
|
|
GIMP_ACTIVE_COLOR_BACKGROUND);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
if (edit_bg != editor->edit_bg)
|
|
|
|
{
|
|
|
|
editor->edit_bg = edit_bg;
|
|
|
|
|
|
|
|
if (editor->context)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
if (edit_bg)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_background (editor->context);
|
|
|
|
gimp_color_editor_bg_changed (editor->context, color, editor);
|
2004-05-27 12:41:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_foreground (editor->context);
|
|
|
|
gimp_color_editor_fg_changed (editor->context, color, editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_color_picked (GtkWidget *widget,
|
2024-03-26 01:25:08 +00:00
|
|
|
const GeglColor *color,
|
2002-11-05 00:02:56 +00:00
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
2024-03-26 01:25:08 +00:00
|
|
|
if (editor->context && color)
|
2004-05-27 12:41:22 +00:00
|
|
|
{
|
|
|
|
if (editor->edit_bg)
|
2024-04-16 16:40:36 +02:00
|
|
|
gimp_context_set_background (editor->context, GEGL_COLOR (color));
|
2004-05-27 12:41:22 +00:00
|
|
|
else
|
2024-04-16 16:40:36 +02:00
|
|
|
gimp_context_set_foreground (editor->context, GEGL_COLOR (color));
|
2004-05-27 12:41:22 +00:00
|
|
|
}
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
2023-12-09 20:53:39 +09:00
|
|
|
GeglColor *color;
|
2005-05-19 17:08:03 +00:00
|
|
|
|
2023-12-09 20:53:39 +09:00
|
|
|
color = gimp_color_hex_entry_get_color (entry);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
if (editor->context)
|
|
|
|
{
|
|
|
|
if (editor->edit_bg)
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_background (editor->context, color);
|
2005-05-19 17:08:03 +00:00
|
|
|
else
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_foreground (editor->context, color);
|
2005-05-19 17:08:03 +00:00
|
|
|
}
|
2023-11-13 23:29:20 +01:00
|
|
|
|
|
|
|
g_object_unref (color);
|
2005-05-19 17:08:03 +00:00
|
|
|
}
|
2015-12-23 03:32:25 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_history_selected (GimpColorHistory *history,
|
2023-12-12 00:34:24 +09:00
|
|
|
GeglColor *color,
|
2015-12-23 03:32:25 +01:00
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
if (editor->context)
|
|
|
|
{
|
|
|
|
if (editor->edit_bg)
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_background (editor->context, color);
|
2015-12-23 03:32:25 +01:00
|
|
|
else
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_foreground (editor->context, color);
|
2015-12-23 03:32:25 +01:00
|
|
|
}
|
|
|
|
}
|
2023-12-16 22:30:02 +09:00
|
|
|
|
|
|
|
static void
|
2023-12-20 20:09:25 +09:00
|
|
|
gimp_color_editor_display_changed (GimpContext *context,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
if (editor->active_display != display)
|
|
|
|
{
|
|
|
|
if (editor->active_display)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (editor->active_display,
|
|
|
|
gimp_color_editor_image_changed,
|
|
|
|
editor);
|
|
|
|
g_signal_handlers_disconnect_by_func (editor->active_display,
|
|
|
|
gimp_color_editor_shell_changed,
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_set_weak_pointer (&editor->active_display, display);
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
{
|
2024-08-05 15:14:32 +02:00
|
|
|
g_signal_connect_object (display, "notify::image",
|
|
|
|
G_CALLBACK (gimp_color_editor_image_changed),
|
|
|
|
editor, 0);
|
|
|
|
g_signal_connect_object (display, "notify::shell",
|
|
|
|
G_CALLBACK (gimp_color_editor_shell_changed),
|
|
|
|
editor, 0);
|
2023-12-20 20:09:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_color_editor_image_changed (display, NULL, editor);
|
|
|
|
gimp_color_editor_shell_changed (display, NULL, editor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_image_changed (GimpDisplay *display,
|
|
|
|
GParamSpec *pspec,
|
2023-12-16 22:30:02 +09:00
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
2023-12-20 20:09:25 +09:00
|
|
|
GimpImage *image = display ? gimp_display_get_image (display) : NULL;
|
|
|
|
|
2023-12-16 22:30:02 +09:00
|
|
|
if (editor->active_image != image)
|
|
|
|
{
|
|
|
|
if (editor->active_image)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (editor->active_image,
|
|
|
|
gimp_color_editor_update_simulation,
|
|
|
|
editor);
|
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_signal_handlers_disconnect_by_func (editor->active_image,
|
|
|
|
gimp_color_editor_update_format,
|
|
|
|
editor);
|
2023-12-16 22:30:02 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
g_set_weak_pointer (&editor->active_image, image);
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
{
|
2024-08-05 15:14:32 +02:00
|
|
|
g_signal_connect_object (image, "simulation-profile-changed",
|
|
|
|
G_CALLBACK (gimp_color_editor_update_simulation),
|
|
|
|
editor, 0);
|
|
|
|
g_signal_connect_object (image, "simulation-intent-changed",
|
|
|
|
G_CALLBACK (gimp_color_editor_update_simulation),
|
|
|
|
editor, 0);
|
|
|
|
g_signal_connect_object (image, "simulation-bpc-changed",
|
|
|
|
G_CALLBACK (gimp_color_editor_update_simulation),
|
|
|
|
editor, 0);
|
|
|
|
|
|
|
|
g_signal_connect_object (image, "profile-changed",
|
|
|
|
G_CALLBACK (gimp_color_editor_update_format),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (image, "precision-changed",
|
|
|
|
G_CALLBACK (gimp_color_editor_update_format),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (image, "notify::base-type",
|
|
|
|
G_CALLBACK (gimp_color_editor_update_format),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
2023-12-16 22:30:02 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_color_editor_update_simulation (image, editor);
|
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_editor_update_format (editor);
|
2023-12-16 22:30:02 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-20 20:09:25 +09:00
|
|
|
static void
|
|
|
|
gimp_color_editor_shell_changed (GimpDisplay *display,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = display ? gimp_display_get_shell (display) : NULL;
|
|
|
|
|
|
|
|
if (editor->active_shell != shell)
|
|
|
|
{
|
|
|
|
GimpColorConfig *config;
|
|
|
|
|
|
|
|
if (editor->active_shell)
|
|
|
|
{
|
|
|
|
config = gimp_display_shell_get_color_config (editor->active_shell);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (config,
|
|
|
|
gimp_color_editor_enable_simulation,
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_set_weak_pointer (&editor->active_shell, shell);
|
|
|
|
|
|
|
|
if (shell)
|
|
|
|
{
|
|
|
|
config = gimp_display_shell_get_color_config (shell);
|
|
|
|
|
2024-08-05 15:14:32 +02:00
|
|
|
g_signal_connect_object (config, "notify::mode",
|
|
|
|
G_CALLBACK (gimp_color_editor_enable_simulation),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
2023-12-20 20:09:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_color_editor_enable_simulation (editor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-16 22:30:02 +09:00
|
|
|
static void
|
|
|
|
gimp_color_editor_update_simulation (GimpImage *image,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_EDITOR (editor));
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
gimp_color_notebook_set_simulation (GIMP_COLOR_NOTEBOOK (editor->notebook),
|
|
|
|
gimp_image_get_simulation_profile (image),
|
|
|
|
gimp_image_get_simulation_intent (image),
|
|
|
|
gimp_image_get_simulation_bpc (image));
|
|
|
|
else
|
|
|
|
gimp_color_notebook_set_simulation (GIMP_COLOR_NOTEBOOK (editor->notebook),
|
|
|
|
NULL,
|
|
|
|
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
|
|
|
FALSE);
|
|
|
|
}
|
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
|
|
|
|
2023-12-20 20:09:25 +09:00
|
|
|
static void
|
|
|
|
gimp_color_editor_enable_simulation (GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_EDITOR (editor));
|
|
|
|
|
|
|
|
if (editor->active_shell && editor->active_image)
|
|
|
|
{
|
|
|
|
GimpColorConfig *config;
|
|
|
|
GimpColorManagementMode mode;
|
|
|
|
|
|
|
|
config = gimp_display_shell_get_color_config (editor->active_shell);
|
|
|
|
mode = gimp_color_config_get_mode (config);
|
|
|
|
gimp_color_notebook_enable_simulation (GIMP_COLOR_NOTEBOOK (editor->notebook),
|
|
|
|
(mode == GIMP_COLOR_MANAGEMENT_SOFTPROOF));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_color_notebook_enable_simulation (GIMP_COLOR_NOTEBOOK (editor->notebook), FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static void
|
|
|
|
gimp_color_editor_update_format (GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_EDITOR (editor));
|
|
|
|
|
|
|
|
if (editor->active_image)
|
|
|
|
gimp_color_notebook_set_format (GIMP_COLOR_NOTEBOOK (editor->notebook),
|
|
|
|
gimp_image_get_layer_format (editor->active_image, FALSE));
|
|
|
|
else
|
|
|
|
gimp_color_notebook_set_format (GIMP_COLOR_NOTEBOOK (editor->notebook), NULL);
|
|
|
|
}
|