Bug 467930 - color selectors are not color managed
Color manage the wheel/triangle color selector.
This commit is contained in:
@ -61,6 +61,8 @@ static GType colorsel_wheel_get_type (void);
|
|||||||
static void colorsel_wheel_set_color (GimpColorSelector *selector,
|
static void colorsel_wheel_set_color (GimpColorSelector *selector,
|
||||||
const GimpRGB *rgb,
|
const GimpRGB *rgb,
|
||||||
const GimpHSV *hsv);
|
const GimpHSV *hsv);
|
||||||
|
static void colorsel_wheel_set_config (GimpColorSelector *selector,
|
||||||
|
GimpColorConfig *config);
|
||||||
static void colorsel_wheel_changed (GimpColorWheel *hsv,
|
static void colorsel_wheel_changed (GimpColorWheel *hsv,
|
||||||
GimpColorSelector *selector);
|
GimpColorSelector *selector);
|
||||||
|
|
||||||
@ -103,6 +105,7 @@ colorsel_wheel_class_init (ColorselWheelClass *klass)
|
|||||||
selector_class->help_id = "gimp-colorselector-triangle";
|
selector_class->help_id = "gimp-colorselector-triangle";
|
||||||
selector_class->icon_name = GIMP_STOCK_COLOR_TRIANGLE;
|
selector_class->icon_name = GIMP_STOCK_COLOR_TRIANGLE;
|
||||||
selector_class->set_color = colorsel_wheel_set_color;
|
selector_class->set_color = colorsel_wheel_set_color;
|
||||||
|
selector_class->set_config = colorsel_wheel_set_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -121,6 +124,8 @@ colorsel_wheel_init (ColorselWheel *wheel)
|
|||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
wheel->hsv = gimp_color_wheel_new ();
|
wheel->hsv = gimp_color_wheel_new ();
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (wheel->hsv),
|
||||||
|
(gpointer) &wheel->hsv);
|
||||||
gtk_container_add (GTK_CONTAINER (frame), wheel->hsv);
|
gtk_container_add (GTK_CONTAINER (frame), wheel->hsv);
|
||||||
gtk_widget_show (wheel->hsv);
|
gtk_widget_show (wheel->hsv);
|
||||||
|
|
||||||
@ -140,6 +145,16 @@ colorsel_wheel_set_color (GimpColorSelector *selector,
|
|||||||
hsv->h, hsv->s, hsv->v);
|
hsv->h, hsv->s, hsv->v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
colorsel_wheel_set_config (GimpColorSelector *selector,
|
||||||
|
GimpColorConfig *config)
|
||||||
|
{
|
||||||
|
ColorselWheel *wheel = COLORSEL_WHEEL (selector);
|
||||||
|
|
||||||
|
if (wheel->hsv)
|
||||||
|
gimp_color_wheel_set_color_config (GIMP_COLOR_WHEEL (wheel->hsv), config);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
colorsel_wheel_changed (GimpColorWheel *hsv,
|
colorsel_wheel_changed (GimpColorWheel *hsv,
|
||||||
GimpColorSelector *selector)
|
GimpColorSelector *selector)
|
||||||
|
@ -35,8 +35,10 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
|
||||||
|
#include <libgimpconfig/gimpconfig.h>
|
||||||
#include <libgimpcolor/gimpcolor.h>
|
#include <libgimpcolor/gimpcolor.h>
|
||||||
#include <libgimpmath/gimpmath.h>
|
#include <libgimpmath/gimpmath.h>
|
||||||
|
#include <libgimpwidgets/gimpwidgets.h>
|
||||||
|
|
||||||
#include "gimpcolorwheel.h"
|
#include "gimpcolorwheel.h"
|
||||||
|
|
||||||
@ -81,6 +83,9 @@ typedef struct
|
|||||||
DragMode mode;
|
DragMode mode;
|
||||||
|
|
||||||
guint focus_on_ring : 1;
|
guint focus_on_ring : 1;
|
||||||
|
|
||||||
|
GimpColorConfig *config;
|
||||||
|
GimpColorTransform *transform;
|
||||||
} GimpColorWheelPrivate;
|
} GimpColorWheelPrivate;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -90,6 +95,8 @@ enum
|
|||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void gimp_color_wheel_dispose (GObject *object);
|
||||||
|
|
||||||
static void gimp_color_wheel_map (GtkWidget *widget);
|
static void gimp_color_wheel_map (GtkWidget *widget);
|
||||||
static void gimp_color_wheel_unmap (GtkWidget *widget);
|
static void gimp_color_wheel_unmap (GtkWidget *widget);
|
||||||
static void gimp_color_wheel_realize (GtkWidget *widget);
|
static void gimp_color_wheel_realize (GtkWidget *widget);
|
||||||
@ -113,6 +120,11 @@ static gboolean gimp_color_wheel_focus (GtkWidget *widget,
|
|||||||
static void gimp_color_wheel_move (GimpColorWheel *wheel,
|
static void gimp_color_wheel_move (GimpColorWheel *wheel,
|
||||||
GtkDirectionType dir);
|
GtkDirectionType dir);
|
||||||
|
|
||||||
|
static void gimp_color_wheel_config_notify (GimpColorConfig *config,
|
||||||
|
const GParamSpec *pspec,
|
||||||
|
GimpColorWheel *wheel);
|
||||||
|
static void gimp_color_wheel_create_transform (GimpColorWheel *wheel);
|
||||||
|
|
||||||
|
|
||||||
static guint wheel_signals[LAST_SIGNAL];
|
static guint wheel_signals[LAST_SIGNAL];
|
||||||
|
|
||||||
@ -135,6 +147,8 @@ gimp_color_wheel_class_init (GimpColorWheelClass *class)
|
|||||||
GimpColorWheelClass *wheel_class = GIMP_COLOR_WHEEL_CLASS (class);
|
GimpColorWheelClass *wheel_class = GIMP_COLOR_WHEEL_CLASS (class);
|
||||||
GtkBindingSet *binding_set;
|
GtkBindingSet *binding_set;
|
||||||
|
|
||||||
|
object_class->dispose = gimp_color_wheel_dispose;
|
||||||
|
|
||||||
widget_class->map = gimp_color_wheel_map;
|
widget_class->map = gimp_color_wheel_map;
|
||||||
widget_class->unmap = gimp_color_wheel_unmap;
|
widget_class->unmap = gimp_color_wheel_unmap;
|
||||||
widget_class->realize = gimp_color_wheel_realize;
|
widget_class->realize = gimp_color_wheel_realize;
|
||||||
@ -226,6 +240,16 @@ gimp_color_wheel_init (GimpColorWheel *wheel)
|
|||||||
priv->ring_width = DEFAULT_RING_WIDTH;
|
priv->ring_width = DEFAULT_RING_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_wheel_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GimpColorWheel *wheel = GIMP_COLOR_WHEEL (object);
|
||||||
|
|
||||||
|
gimp_color_wheel_set_color_config (wheel, NULL);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_color_wheel_map (GtkWidget *widget)
|
gimp_color_wheel_map (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
@ -862,7 +886,24 @@ paint_ring (GimpColorWheel *wheel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
source = cairo_image_surface_create_for_data ((unsigned char *)buf,
|
if (priv->transform)
|
||||||
|
{
|
||||||
|
const Babl *format = babl_format ("cairo-RGB24");
|
||||||
|
guchar *b = (guchar *) buf;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for (i = 0; i < height; i++)
|
||||||
|
{
|
||||||
|
gimp_color_transform_process_pixels (priv->transform,
|
||||||
|
format, b,
|
||||||
|
format, b,
|
||||||
|
width);
|
||||||
|
|
||||||
|
b += stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source = cairo_image_surface_create_for_data ((guchar *) buf,
|
||||||
CAIRO_FORMAT_RGB24,
|
CAIRO_FORMAT_RGB24,
|
||||||
width, height, stride);
|
width, height, stride);
|
||||||
|
|
||||||
@ -1073,7 +1114,24 @@ paint_triangle (GimpColorWheel *wheel,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
source = cairo_image_surface_create_for_data ((unsigned char *)buf,
|
if (priv->transform)
|
||||||
|
{
|
||||||
|
const Babl *format = babl_format ("cairo-RGB24");
|
||||||
|
guchar *b = (guchar *) buf;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
for (i = 0; i < height; i++)
|
||||||
|
{
|
||||||
|
gimp_color_transform_process_pixels (priv->transform,
|
||||||
|
format, b,
|
||||||
|
format, b,
|
||||||
|
width);
|
||||||
|
|
||||||
|
b += stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source = cairo_image_surface_create_for_data ((guchar *) buf,
|
||||||
CAIRO_FORMAT_RGB24,
|
CAIRO_FORMAT_RGB24,
|
||||||
width, height, stride);
|
width, height, stride);
|
||||||
|
|
||||||
@ -1154,6 +1212,11 @@ paint (GimpColorWheel *hsv,
|
|||||||
gint width,
|
gint width,
|
||||||
gint height)
|
gint height)
|
||||||
{
|
{
|
||||||
|
GimpColorWheelPrivate *priv = hsv->priv;
|
||||||
|
|
||||||
|
if (! priv->transform)
|
||||||
|
gimp_color_wheel_create_transform (hsv);
|
||||||
|
|
||||||
paint_ring (hsv, cr, x, y, width, height);
|
paint_ring (hsv, cr, x, y, width, height);
|
||||||
paint_triangle (hsv, cr, x, y, width, height);
|
paint_triangle (hsv, cr, x, y, width, height);
|
||||||
}
|
}
|
||||||
@ -1379,6 +1442,52 @@ gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel)
|
|||||||
return priv->ring_fraction;
|
return priv->ring_fraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_color_wheel_set_color_config:
|
||||||
|
* @wheel: a #GimpColorWheel widget.
|
||||||
|
* @config: a #GimpColorConfig object.
|
||||||
|
*
|
||||||
|
* Sets the color management configuration to use with this color wheel.
|
||||||
|
*
|
||||||
|
* Since: 2.10
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gimp_color_wheel_set_color_config (GimpColorWheel *wheel,
|
||||||
|
GimpColorConfig *config)
|
||||||
|
{
|
||||||
|
GimpColorWheelPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_COLOR_WHEEL (wheel));
|
||||||
|
g_return_if_fail (config == NULL || GIMP_IS_COLOR_CONFIG (config));
|
||||||
|
|
||||||
|
priv = wheel->priv;
|
||||||
|
|
||||||
|
if (priv->config)
|
||||||
|
{
|
||||||
|
g_signal_handlers_disconnect_by_func (priv->config,
|
||||||
|
gimp_color_wheel_config_notify,
|
||||||
|
wheel);
|
||||||
|
g_object_unref (priv->config);
|
||||||
|
|
||||||
|
if (priv->transform)
|
||||||
|
{
|
||||||
|
g_object_unref (priv->transform);
|
||||||
|
priv->transform = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->config = config;
|
||||||
|
|
||||||
|
if (priv->config)
|
||||||
|
{
|
||||||
|
g_object_ref (priv->config);
|
||||||
|
|
||||||
|
g_signal_connect (priv->config, "notify",
|
||||||
|
G_CALLBACK (gimp_color_wheel_config_notify),
|
||||||
|
wheel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_color_wheel_is_adjusting:
|
* gimp_color_wheel_is_adjusting:
|
||||||
* @hsv: A #GimpColorWheel
|
* @hsv: A #GimpColorWheel
|
||||||
@ -1481,3 +1590,41 @@ gimp_color_wheel_move (GimpColorWheel *wheel,
|
|||||||
|
|
||||||
gimp_color_wheel_set_color (wheel, hue, sat, val);
|
gimp_color_wheel_set_color (wheel, hue, sat, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_wheel_config_notify (GimpColorConfig *config,
|
||||||
|
const GParamSpec *pspec,
|
||||||
|
GimpColorWheel *wheel)
|
||||||
|
{
|
||||||
|
GimpColorWheelPrivate *priv = wheel->priv;
|
||||||
|
|
||||||
|
if (priv->transform)
|
||||||
|
{
|
||||||
|
g_object_unref (priv->transform);
|
||||||
|
priv->transform = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_queue_draw (GTK_WIDGET (wheel));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_color_wheel_create_transform (GimpColorWheel *wheel)
|
||||||
|
{
|
||||||
|
GimpColorWheelPrivate *priv = wheel->priv;
|
||||||
|
|
||||||
|
if (priv->config)
|
||||||
|
{
|
||||||
|
static GimpColorProfile *profile = NULL;
|
||||||
|
|
||||||
|
const Babl *format = babl_format ("cairo-RGB24");
|
||||||
|
|
||||||
|
if (G_UNLIKELY (! profile))
|
||||||
|
profile = gimp_color_profile_new_rgb_srgb ();
|
||||||
|
|
||||||
|
priv->transform = gimp_widget_get_color_transform (GTK_WIDGET (wheel),
|
||||||
|
priv->config,
|
||||||
|
profile,
|
||||||
|
format,
|
||||||
|
format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -88,6 +88,9 @@ void gimp_color_wheel_set_ring_fraction (GimpColorWheel *wheel,
|
|||||||
gdouble fraction);
|
gdouble fraction);
|
||||||
gdouble gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel);
|
gdouble gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel);
|
||||||
|
|
||||||
|
void gimp_color_wheel_set_color_config (GimpColorWheel *wheel,
|
||||||
|
GimpColorConfig *config);
|
||||||
|
|
||||||
gboolean gimp_color_wheel_is_adjusting (GimpColorWheel *wheel);
|
gboolean gimp_color_wheel_is_adjusting (GimpColorWheel *wheel);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
Reference in New Issue
Block a user