mirror of https://github.com/GNOME/gimp.git
app, libgimpwidgets: make GimpColorSelector sync with soft-proofing.
Until now we only had the case of the CMYK color selector using the soft-proofing profile. Yet this is also interesting for other color selectors, in particular to show out-of-gamut colors. Indeed if we enable soft-proofing on the active image, it is interesting to show the intersection of the current RGB/Grayscale space gamut with the soft-proofing gamut. Right now, this is only used in GimpColorSelect when showing colors in LCh color space.
This commit is contained in:
parent
12b2abce7c
commit
de83bca814
|
@ -28,6 +28,7 @@
|
|||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
|
@ -38,6 +39,10 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-color-profile.h"
|
||||
|
||||
#include "display/display-types.h"
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "gimpcoloreditor.h"
|
||||
#include "gimpcolorhistory.h"
|
||||
#include "gimpdocked.h"
|
||||
|
@ -103,11 +108,18 @@ static void gimp_color_editor_history_selected (GimpColorHistory *history,
|
|||
GeglColor *color,
|
||||
GimpColorEditor *editor);
|
||||
|
||||
static void gimp_color_editor_image_changed (GimpContext *context,
|
||||
GimpImage *image,
|
||||
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,
|
||||
GimpColorEditor *editor);
|
||||
static void gimp_color_editor_update_simulation (GimpImage *image,
|
||||
GimpColorEditor *editor);
|
||||
static void gimp_color_editor_enable_simulation (GimpColorEditor *editor);
|
||||
static void gimp_color_editor_update_format (GimpColorEditor *editor);
|
||||
|
||||
|
||||
|
@ -284,7 +296,7 @@ gimp_color_editor_constructed (GObject *object)
|
|||
{
|
||||
GimpColorEditor *editor = GIMP_COLOR_EDITOR (object);
|
||||
GimpContext *user_context = editor->context->gimp->user_context;
|
||||
GimpImage *image = gimp_context_get_image (user_context);
|
||||
GimpDisplay *display = gimp_context_get_display (user_context);
|
||||
GtkWidget *history;
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->constructed (object);
|
||||
|
@ -298,11 +310,11 @@ gimp_color_editor_constructed (GObject *object)
|
|||
G_CALLBACK (gimp_color_editor_history_selected),
|
||||
editor);
|
||||
|
||||
g_signal_connect (user_context, "image-changed",
|
||||
G_CALLBACK (gimp_color_editor_image_changed),
|
||||
g_signal_connect (user_context, "display-changed",
|
||||
G_CALLBACK (gimp_color_editor_display_changed),
|
||||
editor);
|
||||
|
||||
gimp_color_editor_image_changed (user_context, image, editor);
|
||||
gimp_color_editor_display_changed (user_context, display, editor);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -746,10 +758,46 @@ gimp_color_editor_history_selected (GimpColorHistory *history,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_color_editor_image_changed (GimpContext *context,
|
||||
GimpImage *image,
|
||||
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)
|
||||
{
|
||||
g_signal_connect (display, "notify::image",
|
||||
G_CALLBACK (gimp_color_editor_image_changed),
|
||||
editor);
|
||||
g_signal_connect (display, "notify::shell",
|
||||
G_CALLBACK (gimp_color_editor_shell_changed),
|
||||
editor);
|
||||
}
|
||||
|
||||
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,
|
||||
GimpColorEditor *editor)
|
||||
{
|
||||
GimpImage *image = display ? gimp_display_get_image (display) : NULL;
|
||||
|
||||
if (editor->active_image != image)
|
||||
{
|
||||
if (editor->active_image)
|
||||
|
@ -792,6 +840,41 @@ gimp_color_editor_image_changed (GimpContext *context,
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
g_signal_connect_swapped (config, "notify::mode",
|
||||
G_CALLBACK (gimp_color_editor_enable_simulation),
|
||||
editor);
|
||||
}
|
||||
|
||||
gimp_color_editor_enable_simulation (editor);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_editor_update_simulation (GimpImage *image,
|
||||
GimpColorEditor *editor)
|
||||
|
@ -810,6 +893,27 @@ gimp_color_editor_update_simulation (GimpImage *image,
|
|||
FALSE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_editor_update_format (GimpColorEditor *editor)
|
||||
{
|
||||
|
|
|
@ -37,16 +37,18 @@ typedef struct _GimpColorEditorClass GimpColorEditorClass;
|
|||
|
||||
struct _GimpColorEditor
|
||||
{
|
||||
GimpEditor parent_instance;
|
||||
GimpEditor parent_instance;
|
||||
|
||||
GimpContext *context;
|
||||
GimpImage *active_image;
|
||||
gboolean edit_bg;
|
||||
GimpContext *context;
|
||||
GimpDisplay *active_display;
|
||||
GimpDisplayShell *active_shell;
|
||||
GimpImage *active_image;
|
||||
gboolean edit_bg;
|
||||
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *notebook;
|
||||
GtkWidget *fg_bg;
|
||||
GtkWidget *hex_entry;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *notebook;
|
||||
GtkWidget *fg_bg;
|
||||
GtkWidget *hex_entry;
|
||||
};
|
||||
|
||||
struct _GimpColorEditorClass
|
||||
|
|
|
@ -647,3 +647,20 @@ gimp_color_notebook_set_simulation (GimpColorNotebook *notebook,
|
|||
gimp_color_selector_set_simulation (selector, profile, intent, bpc);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_color_notebook_enable_simulation (GimpColorNotebook *notebook,
|
||||
gboolean enabled)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_NOTEBOOK (notebook));
|
||||
|
||||
for (list = notebook->priv->selectors; list; list = g_list_next (list))
|
||||
{
|
||||
GimpColorSelector *selector = list->data;
|
||||
|
||||
if (selector)
|
||||
gimp_color_selector_enable_simulation (selector, enabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,8 @@ void gimp_color_notebook_set_simulation (GimpColorNotebook
|
|||
GimpColorProfile *profile,
|
||||
GimpColorRenderingIntent intent,
|
||||
gboolean bpc);
|
||||
void gimp_color_notebook_enable_simulation (GimpColorNotebook *notebook,
|
||||
gboolean enabled);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -130,6 +130,7 @@ struct _GimpColorSelect
|
|||
|
||||
GtkWidget *toggle_box[3];
|
||||
GtkWidget *label;
|
||||
GtkWidget *simulation_label;
|
||||
|
||||
GtkWidget *xy_color;
|
||||
ColorSelectFillType xy_color_fill;
|
||||
|
@ -181,32 +182,38 @@ struct _ColorSelectFill
|
|||
};
|
||||
|
||||
|
||||
static void gimp_color_select_finalize (GObject *object);
|
||||
static void gimp_color_select_finalize (GObject *object);
|
||||
|
||||
static void gimp_color_select_togg_visible (GimpColorSelector *selector,
|
||||
gboolean visible);
|
||||
static void gimp_color_select_togg_sensitive (GimpColorSelector *selector,
|
||||
gboolean sensitive);
|
||||
static void gimp_color_select_set_color (GimpColorSelector *selector,
|
||||
GeglColor *color);
|
||||
static void gimp_color_select_set_channel (GimpColorSelector *selector,
|
||||
static void gimp_color_select_togg_visible (GimpColorSelector *selector,
|
||||
gboolean visible);
|
||||
static void gimp_color_select_togg_sensitive (GimpColorSelector *selector,
|
||||
gboolean sensitive);
|
||||
static void gimp_color_select_set_color (GimpColorSelector *selector,
|
||||
GeglColor *color);
|
||||
static void gimp_color_select_set_channel (GimpColorSelector *selector,
|
||||
GimpColorSelectorChannel channel);
|
||||
static void gimp_color_select_set_model_visible
|
||||
(GimpColorSelector *selector,
|
||||
GimpColorSelectorModel model,
|
||||
gboolean visible);
|
||||
static void gimp_color_select_set_format (GimpColorSelector *selector,
|
||||
const Babl *format);
|
||||
static void gimp_color_select_set_config (GimpColorSelector *selector,
|
||||
GimpColorConfig *config);
|
||||
(GimpColorSelector *selector,
|
||||
GimpColorSelectorModel model,
|
||||
gboolean visible);
|
||||
static void gimp_color_select_set_format (GimpColorSelector *selector,
|
||||
const Babl *format);
|
||||
static void gimp_color_select_set_simulation (GimpColorSelector *selector,
|
||||
GimpColorProfile *profile,
|
||||
GimpColorRenderingIntent intent,
|
||||
gboolean bpc);
|
||||
static void gimp_color_select_set_config (GimpColorSelector *selector,
|
||||
GimpColorConfig *config);
|
||||
static void gimp_color_select_simulation (GimpColorSelector *selector,
|
||||
gboolean enabled);
|
||||
|
||||
static void gimp_color_select_channel_toggled (GtkWidget *widget,
|
||||
GimpColorSelect *select);
|
||||
static void gimp_color_select_channel_toggled (GtkWidget *widget,
|
||||
GimpColorSelect *select);
|
||||
|
||||
static void gimp_color_select_update (GimpColorSelect *select,
|
||||
ColorSelectUpdateType type);
|
||||
static void gimp_color_select_update_values (GimpColorSelect *select);
|
||||
static void gimp_color_select_update_pos (GimpColorSelect *select);
|
||||
static void gimp_color_select_update (GimpColorSelect *select,
|
||||
ColorSelectUpdateType type);
|
||||
static void gimp_color_select_update_values (GimpColorSelect *select);
|
||||
static void gimp_color_select_update_pos (GimpColorSelect *select);
|
||||
|
||||
#if 0
|
||||
static void gimp_color_select_drop_color (GtkWidget *widget,
|
||||
|
@ -305,8 +312,10 @@ static const ColorSelectRenderFunc render_funcs[] =
|
|||
color_select_render_lch_chroma_lightness
|
||||
};
|
||||
|
||||
static const Babl *fish_lch_to_rgb = NULL;
|
||||
static const Babl *fish_lch_to_rgb_u8 = NULL;
|
||||
static const Babl *fish_lch_to_rgb = NULL;
|
||||
static const Babl *fish_lch_to_rgb_u8 = NULL;
|
||||
static const Babl *fish_lch_to_softproof = NULL;
|
||||
static const Babl *softproof_format = NULL;
|
||||
|
||||
|
||||
static void
|
||||
|
@ -325,8 +334,10 @@ gimp_color_select_class_init (GimpColorSelectClass *klass)
|
|||
selector_class->set_color = gimp_color_select_set_color;
|
||||
selector_class->set_channel = gimp_color_select_set_channel;
|
||||
selector_class->set_model_visible = gimp_color_select_set_model_visible;
|
||||
selector_class->set_simulation = gimp_color_select_set_simulation;
|
||||
selector_class->set_format = gimp_color_select_set_format;
|
||||
selector_class->set_config = gimp_color_select_set_config;
|
||||
selector_class->simulation = gimp_color_select_simulation;
|
||||
|
||||
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "GimpColorSelect");
|
||||
|
||||
|
@ -498,6 +509,13 @@ gimp_color_select_init (GimpColorSelect *select)
|
|||
gtk_box_pack_start (GTK_BOX (select), select->label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (select->label);
|
||||
|
||||
select->simulation_label = gtk_label_new (NULL);
|
||||
gtk_widget_set_halign (select->simulation_label, GTK_ALIGN_START);
|
||||
gtk_widget_set_vexpand (select->simulation_label, FALSE);
|
||||
gtk_label_set_justify (GTK_LABEL (select->simulation_label), GTK_JUSTIFY_LEFT);
|
||||
gtk_label_set_markup (GTK_LABEL (select->simulation_label), _("Soft-Proof Profile: <i>unknown</i>"));
|
||||
gtk_box_pack_start (GTK_BOX (select), select->simulation_label, FALSE, FALSE, 0);
|
||||
|
||||
g_type_class_unref (model_class);
|
||||
g_type_class_unref (channel_class);
|
||||
}
|
||||
|
@ -684,6 +702,17 @@ gimp_color_select_set_format (GimpColorSelector *selector,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_select_set_simulation (GimpColorSelector *selector,
|
||||
GimpColorProfile *profile,
|
||||
GimpColorRenderingIntent intent,
|
||||
gboolean bpc)
|
||||
{
|
||||
gimp_color_select_simulation (selector,
|
||||
gimp_color_selector_get_simulation (selector,
|
||||
NULL, NULL, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_select_set_config (GimpColorSelector *selector,
|
||||
GimpColorConfig *config)
|
||||
|
@ -712,6 +741,85 @@ gimp_color_select_set_config (GimpColorSelector *selector,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_select_simulation (GimpColorSelector *selector,
|
||||
gboolean enabled)
|
||||
{
|
||||
GimpColorSelect *select = GIMP_COLOR_SELECT (selector);
|
||||
const Babl *format = NULL;
|
||||
GimpColorProfile *profile = NULL;
|
||||
|
||||
if (enabled && gimp_color_selector_get_simulation (selector, &profile, NULL, NULL))
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (gimp_color_profile_is_rgb (profile))
|
||||
format = gimp_color_profile_get_format (profile, babl_format ("R'G'B' float"),
|
||||
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
||||
&error);
|
||||
else if (gimp_color_profile_is_cmyk (profile))
|
||||
format = gimp_color_profile_get_format (profile, babl_format ("CMYK float"),
|
||||
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
||||
&error);
|
||||
else if (gimp_color_profile_is_gray (profile))
|
||||
format = gimp_color_profile_get_format (profile, babl_format ("Y' float"),
|
||||
GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
|
||||
&error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_printerr ("Color Selector: invalid color profile: %s\n", error->message);
|
||||
format = NULL;
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
if (format)
|
||||
{
|
||||
softproof_format = format;
|
||||
fish_lch_to_softproof = babl_fish (babl_format ("CIE LCH(ab) double"), format);
|
||||
|
||||
if (babl_format_get_space (format) == babl_space ("sRGB"))
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (select->simulation_label), _("Soft-Proof Profile: sRGB"));
|
||||
gimp_help_set_help_data (select->simulation_label, NULL, NULL);
|
||||
}
|
||||
else if (profile != NULL)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
text = g_strdup_printf (_("Soft-Proof Profile: %s"), gimp_color_profile_get_label (profile));
|
||||
gtk_label_set_text (GTK_LABEL (select->simulation_label), text);
|
||||
gimp_help_set_help_data (select->simulation_label,
|
||||
gimp_color_profile_get_summary (profile),
|
||||
NULL);
|
||||
g_free (text);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_label_set_markup (GTK_LABEL (select->simulation_label), _("Soft-Proof Profile: <i>unknown</i>"));
|
||||
gimp_help_set_help_data (select->simulation_label, NULL, NULL);
|
||||
}
|
||||
|
||||
select->xy_needs_render = TRUE;
|
||||
select->z_needs_render = TRUE;
|
||||
|
||||
gtk_widget_queue_draw (select->xy_color);
|
||||
gtk_widget_queue_draw (select->z_color);
|
||||
|
||||
gtk_widget_show (select->simulation_label);
|
||||
}
|
||||
else
|
||||
{
|
||||
softproof_format = NULL;
|
||||
fish_lch_to_softproof = NULL;
|
||||
|
||||
gtk_label_set_markup (GTK_LABEL (select->simulation_label), _("Soft-Proof Profile: <i>unknown</i>"));
|
||||
gimp_help_set_help_data (select->simulation_label, NULL, NULL);
|
||||
gtk_widget_hide (select->simulation_label);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_select_channel_toggled (GtkWidget *widget,
|
||||
GimpColorSelect *select)
|
||||
|
@ -1884,6 +1992,35 @@ color_select_render_lch_chroma_lightness (ColorSelectFill *csf)
|
|||
p[1] = csf->oog_color[1];
|
||||
p[2] = csf->oog_color[2];
|
||||
}
|
||||
else if (fish_lch_to_softproof)
|
||||
{
|
||||
GeglColor *softcolor;
|
||||
GeglColor *lchcolor;
|
||||
gfloat softdata[4];
|
||||
|
||||
babl_process (fish_lch_to_softproof, &lch, &softdata, 1);
|
||||
softcolor = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (softcolor, softproof_format, softdata);
|
||||
|
||||
lchcolor = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (lchcolor, babl_format ("CIE LCH(ab) double"), lch);
|
||||
|
||||
if (gimp_color_is_perceptually_identical (softcolor, lchcolor))
|
||||
{
|
||||
p[0] = rgb[0] * 255;
|
||||
p[1] = rgb[1] * 255;
|
||||
p[2] = rgb[2] * 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = csf->oog_color[0];
|
||||
p[1] = csf->oog_color[1];
|
||||
p[2] = csf->oog_color[2];
|
||||
}
|
||||
|
||||
g_object_unref (softcolor);
|
||||
g_object_unref (lchcolor);
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = rgb[0] * 255;
|
||||
|
@ -1921,6 +2058,35 @@ color_select_render_lch_hue_lightness (ColorSelectFill *csf)
|
|||
p[1] = csf->oog_color[1];
|
||||
p[2] = csf->oog_color[2];
|
||||
}
|
||||
else if (fish_lch_to_softproof)
|
||||
{
|
||||
GeglColor *softcolor;
|
||||
GeglColor *lchcolor;
|
||||
gfloat softdata[4];
|
||||
|
||||
babl_process (fish_lch_to_softproof, &lch, &softdata, 1);
|
||||
softcolor = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (softcolor, softproof_format, softdata);
|
||||
|
||||
lchcolor = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (lchcolor, babl_format ("CIE LCH(ab) double"), lch);
|
||||
|
||||
if (gimp_color_is_perceptually_identical (softcolor, lchcolor))
|
||||
{
|
||||
p[0] = rgb[0] * 255;
|
||||
p[1] = rgb[1] * 255;
|
||||
p[2] = rgb[2] * 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = csf->oog_color[0];
|
||||
p[1] = csf->oog_color[1];
|
||||
p[2] = csf->oog_color[2];
|
||||
}
|
||||
|
||||
g_object_unref (softcolor);
|
||||
g_object_unref (lchcolor);
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = rgb[0] * 255;
|
||||
|
@ -1958,6 +2124,35 @@ color_select_render_lch_hue_chroma (ColorSelectFill *csf)
|
|||
p[1] = csf->oog_color[1];
|
||||
p[2] = csf->oog_color[2];
|
||||
}
|
||||
else if (fish_lch_to_softproof)
|
||||
{
|
||||
GeglColor *softcolor;
|
||||
GeglColor *lchcolor;
|
||||
gfloat softdata[4];
|
||||
|
||||
babl_process (fish_lch_to_softproof, &lch, &softdata, 1);
|
||||
softcolor = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (softcolor, softproof_format, softdata);
|
||||
|
||||
lchcolor = gegl_color_new (NULL);
|
||||
gegl_color_set_pixel (lchcolor, babl_format ("CIE LCH(ab) double"), lch);
|
||||
|
||||
if (gimp_color_is_perceptually_identical (softcolor, lchcolor))
|
||||
{
|
||||
p[0] = rgb[0] * 255;
|
||||
p[1] = rgb[1] * 255;
|
||||
p[2] = rgb[2] * 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = csf->oog_color[0];
|
||||
p[1] = csf->oog_color[1];
|
||||
p[2] = csf->oog_color[2];
|
||||
}
|
||||
|
||||
g_object_unref (softcolor);
|
||||
g_object_unref (lchcolor);
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = rgb[0] * 255;
|
||||
|
|
|
@ -54,6 +54,7 @@ enum
|
|||
COLOR_CHANGED,
|
||||
CHANNEL_CHANGED,
|
||||
MODEL_VISIBLE_CHANGED,
|
||||
SIMULATION,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
@ -68,6 +69,11 @@ struct _GimpColorSelectorPrivate
|
|||
GimpColorSelectorChannel channel;
|
||||
|
||||
GeglColor *color;
|
||||
|
||||
gboolean simulation;
|
||||
GimpColorProfile *simulation_profile;
|
||||
GimpColorRenderingIntent simulation_intent;
|
||||
gboolean simulation_bpc;
|
||||
};
|
||||
|
||||
#define GET_PRIVATE(obj) (((GimpColorSelector *) (obj))->priv)
|
||||
|
@ -125,6 +131,15 @@ gimp_color_selector_class_init (GimpColorSelectorClass *klass)
|
|||
GIMP_TYPE_COLOR_SELECTOR_MODEL,
|
||||
G_TYPE_BOOLEAN);
|
||||
|
||||
selector_signals[SIMULATION] =
|
||||
g_signal_new ("simulation",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpColorSelectorClass, simulation),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_BOOLEAN);
|
||||
|
||||
klass->name = "Unnamed";
|
||||
klass->help_id = NULL;
|
||||
klass->icon_name = GIMP_ICON_PALETTE;
|
||||
|
@ -163,6 +178,11 @@ gimp_color_selector_init (GimpColorSelector *selector)
|
|||
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_RGB] = TRUE;
|
||||
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_LCH] = TRUE;
|
||||
priv->model_visible[GIMP_COLOR_SELECTOR_MODEL_HSV] = FALSE;
|
||||
|
||||
priv->simulation = FALSE;
|
||||
priv->simulation_profile = NULL;
|
||||
priv->simulation_intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
|
||||
priv->simulation_bpc = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -172,6 +192,7 @@ gimp_color_selector_dispose (GObject *object)
|
|||
|
||||
gimp_color_selector_set_config (selector, NULL);
|
||||
g_clear_object (&selector->priv->color);
|
||||
g_clear_object (&selector->priv->simulation_profile);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -638,15 +659,71 @@ gimp_color_selector_set_simulation (GimpColorSelector *selector,
|
|||
GimpColorRenderingIntent intent,
|
||||
gboolean bpc)
|
||||
{
|
||||
GimpColorSelectorClass *selector_class;
|
||||
GimpColorSelectorClass *selector_class;
|
||||
GimpColorSelectorPrivate *priv;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_SELECTOR (selector));
|
||||
g_return_if_fail (profile == NULL || GIMP_IS_COLOR_PROFILE (profile));
|
||||
|
||||
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
||||
priv = GET_PRIVATE (selector);
|
||||
|
||||
if (selector_class->set_simulation)
|
||||
selector_class->set_simulation (selector, profile, intent, bpc);
|
||||
if ((profile && ! priv->simulation_profile) ||
|
||||
(! profile && priv->simulation_profile) ||
|
||||
(profile && ! gimp_color_profile_is_equal (profile, priv->simulation_profile)) ||
|
||||
intent != priv->simulation_intent ||
|
||||
bpc != priv->simulation_bpc)
|
||||
{
|
||||
g_set_object (&priv->simulation_profile, profile);
|
||||
priv->simulation_intent = intent;
|
||||
priv->simulation_bpc = bpc;
|
||||
|
||||
if (selector_class->set_simulation)
|
||||
selector_class->set_simulation (selector, profile, intent, bpc);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_color_selector_get_simulation (GimpColorSelector *selector,
|
||||
GimpColorProfile **profile,
|
||||
GimpColorRenderingIntent *intent,
|
||||
gboolean *bpc)
|
||||
{
|
||||
GimpColorSelectorPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
||||
|
||||
priv = GET_PRIVATE (selector);
|
||||
|
||||
if (profile)
|
||||
*profile = priv->simulation_profile;
|
||||
if (intent)
|
||||
*intent = priv->simulation_intent;
|
||||
if (bpc)
|
||||
*bpc = priv->simulation_bpc;
|
||||
|
||||
return priv->simulation;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_color_selector_enable_simulation (GimpColorSelector *selector,
|
||||
gboolean enabled)
|
||||
{
|
||||
GimpColorSelectorPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_SELECTOR (selector), FALSE);
|
||||
|
||||
priv = GET_PRIVATE (selector);
|
||||
if (priv->simulation != enabled)
|
||||
{
|
||||
if (! enabled || priv->simulation_profile)
|
||||
{
|
||||
priv->simulation = enabled;
|
||||
g_signal_emit (selector, selector_signals[SIMULATION], 0, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
return priv->simulation;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ struct _GimpColorSelectorClass
|
|||
void (* model_visible_changed) (GimpColorSelector *selector,
|
||||
GimpColorSelectorModel model,
|
||||
gboolean visible);
|
||||
void (* simulation) (GimpColorSelector *selector,
|
||||
gboolean enabled);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (* _gimp_reserved1) (void);
|
||||
|
@ -157,12 +159,18 @@ gboolean gimp_color_selector_get_model_visible (GimpColorSelector *select
|
|||
void gimp_color_selector_set_config (GimpColorSelector *selector,
|
||||
GimpColorConfig *config);
|
||||
|
||||
void gimp_color_selector_set_format (GimpColorSelector *selector,
|
||||
const Babl *format);
|
||||
void gimp_color_selector_set_simulation (GimpColorSelector *selector,
|
||||
GimpColorProfile *profile,
|
||||
GimpColorRenderingIntent intent,
|
||||
gboolean bpc);
|
||||
void gimp_color_selector_set_format (GimpColorSelector *selector,
|
||||
const Babl *format);
|
||||
void gimp_color_selector_set_simulation (GimpColorSelector *selector,
|
||||
GimpColorProfile *profile,
|
||||
GimpColorRenderingIntent intent,
|
||||
gboolean bpc);
|
||||
gboolean gimp_color_selector_get_simulation (GimpColorSelector *selector,
|
||||
GimpColorProfile **profile,
|
||||
GimpColorRenderingIntent *intent,
|
||||
gboolean *bpc);
|
||||
gboolean gimp_color_selector_enable_simulation (GimpColorSelector *selector,
|
||||
gboolean enabled);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -80,6 +80,7 @@ EXPORTS
|
|||
gimp_color_hex_entry_get_type
|
||||
gimp_color_hex_entry_new
|
||||
gimp_color_hex_entry_set_color
|
||||
gimp_color_notebook_enable_simulation
|
||||
gimp_color_notebook_get_current_selector
|
||||
gimp_color_notebook_get_notebook
|
||||
gimp_color_notebook_get_selectors
|
||||
|
@ -130,10 +131,12 @@ EXPORTS
|
|||
gimp_color_selection_set_show_alpha
|
||||
gimp_color_selection_set_simulation
|
||||
gimp_color_selector_channel_get_type
|
||||
gimp_color_selector_enable_simulation
|
||||
gimp_color_selector_get_channel
|
||||
gimp_color_selector_get_color
|
||||
gimp_color_selector_get_model_visible
|
||||
gimp_color_selector_get_show_alpha
|
||||
gimp_color_selector_get_simulation
|
||||
gimp_color_selector_get_toggles_sensitive
|
||||
gimp_color_selector_get_toggles_visible
|
||||
gimp_color_selector_get_type
|
||||
|
|
Loading…
Reference in New Issue