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,
|
||||
const GimpRGB *rgb,
|
||||
const GimpHSV *hsv);
|
||||
static void colorsel_wheel_set_config (GimpColorSelector *selector,
|
||||
GimpColorConfig *config);
|
||||
static void colorsel_wheel_changed (GimpColorWheel *hsv,
|
||||
GimpColorSelector *selector);
|
||||
|
||||
@ -99,10 +101,11 @@ colorsel_wheel_class_init (ColorselWheelClass *klass)
|
||||
{
|
||||
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
|
||||
|
||||
selector_class->name = _("Wheel");
|
||||
selector_class->help_id = "gimp-colorselector-triangle";
|
||||
selector_class->icon_name = GIMP_STOCK_COLOR_TRIANGLE;
|
||||
selector_class->set_color = colorsel_wheel_set_color;
|
||||
selector_class->name = _("Wheel");
|
||||
selector_class->help_id = "gimp-colorselector-triangle";
|
||||
selector_class->icon_name = GIMP_STOCK_COLOR_TRIANGLE;
|
||||
selector_class->set_color = colorsel_wheel_set_color;
|
||||
selector_class->set_config = colorsel_wheel_set_config;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -121,6 +124,8 @@ colorsel_wheel_init (ColorselWheel *wheel)
|
||||
gtk_widget_show (frame);
|
||||
|
||||
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_widget_show (wheel->hsv);
|
||||
|
||||
@ -140,6 +145,16 @@ colorsel_wheel_set_color (GimpColorSelector *selector,
|
||||
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
|
||||
colorsel_wheel_changed (GimpColorWheel *hsv,
|
||||
GimpColorSelector *selector)
|
||||
|
@ -35,8 +35,10 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include <libgimpconfig/gimpconfig.h>
|
||||
#include <libgimpcolor/gimpcolor.h>
|
||||
#include <libgimpmath/gimpmath.h>
|
||||
#include <libgimpwidgets/gimpwidgets.h>
|
||||
|
||||
#include "gimpcolorwheel.h"
|
||||
|
||||
@ -81,6 +83,9 @@ typedef struct
|
||||
DragMode mode;
|
||||
|
||||
guint focus_on_ring : 1;
|
||||
|
||||
GimpColorConfig *config;
|
||||
GimpColorTransform *transform;
|
||||
} GimpColorWheelPrivate;
|
||||
|
||||
enum
|
||||
@ -90,28 +95,35 @@ enum
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static void gimp_color_wheel_map (GtkWidget *widget);
|
||||
static void gimp_color_wheel_unmap (GtkWidget *widget);
|
||||
static void gimp_color_wheel_realize (GtkWidget *widget);
|
||||
static void gimp_color_wheel_unrealize (GtkWidget *widget);
|
||||
static void gimp_color_wheel_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gimp_color_wheel_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static gboolean gimp_color_wheel_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event);
|
||||
static gboolean gimp_color_wheel_button_release (GtkWidget *widget,
|
||||
GdkEventButton *event);
|
||||
static gboolean gimp_color_wheel_motion (GtkWidget *widget,
|
||||
GdkEventMotion *event);
|
||||
static gboolean gimp_color_wheel_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event);
|
||||
static gboolean gimp_color_wheel_grab_broken (GtkWidget *widget,
|
||||
GdkEventGrabBroken *event);
|
||||
static gboolean gimp_color_wheel_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction);
|
||||
static void gimp_color_wheel_move (GimpColorWheel *wheel,
|
||||
GtkDirectionType dir);
|
||||
static void gimp_color_wheel_dispose (GObject *object);
|
||||
|
||||
static void gimp_color_wheel_map (GtkWidget *widget);
|
||||
static void gimp_color_wheel_unmap (GtkWidget *widget);
|
||||
static void gimp_color_wheel_realize (GtkWidget *widget);
|
||||
static void gimp_color_wheel_unrealize (GtkWidget *widget);
|
||||
static void gimp_color_wheel_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
static void gimp_color_wheel_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static gboolean gimp_color_wheel_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event);
|
||||
static gboolean gimp_color_wheel_button_release (GtkWidget *widget,
|
||||
GdkEventButton *event);
|
||||
static gboolean gimp_color_wheel_motion (GtkWidget *widget,
|
||||
GdkEventMotion *event);
|
||||
static gboolean gimp_color_wheel_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event);
|
||||
static gboolean gimp_color_wheel_grab_broken (GtkWidget *widget,
|
||||
GdkEventGrabBroken *event);
|
||||
static gboolean gimp_color_wheel_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction);
|
||||
static void gimp_color_wheel_move (GimpColorWheel *wheel,
|
||||
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];
|
||||
@ -135,6 +147,8 @@ gimp_color_wheel_class_init (GimpColorWheelClass *class)
|
||||
GimpColorWheelClass *wheel_class = GIMP_COLOR_WHEEL_CLASS (class);
|
||||
GtkBindingSet *binding_set;
|
||||
|
||||
object_class->dispose = gimp_color_wheel_dispose;
|
||||
|
||||
widget_class->map = gimp_color_wheel_map;
|
||||
widget_class->unmap = gimp_color_wheel_unmap;
|
||||
widget_class->realize = gimp_color_wheel_realize;
|
||||
@ -226,6 +240,16 @@ gimp_color_wheel_init (GimpColorWheel *wheel)
|
||||
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
|
||||
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,
|
||||
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,
|
||||
width, height, stride);
|
||||
|
||||
@ -1154,6 +1212,11 @@ paint (GimpColorWheel *hsv,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
GimpColorWheelPrivate *priv = hsv->priv;
|
||||
|
||||
if (! priv->transform)
|
||||
gimp_color_wheel_create_transform (hsv);
|
||||
|
||||
paint_ring (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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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:
|
||||
* @hsv: A #GimpColorWheel
|
||||
@ -1481,3 +1590,41 @@ gimp_color_wheel_move (GimpColorWheel *wheel,
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -70,25 +70,28 @@ struct _GimpColorWheelClass
|
||||
};
|
||||
|
||||
|
||||
void color_wheel_register_type (GTypeModule *module);
|
||||
void color_wheel_register_type (GTypeModule *module);
|
||||
|
||||
GType gimp_color_wheel_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gimp_color_wheel_new (void);
|
||||
|
||||
void gimp_color_wheel_set_color (GimpColorWheel *wheel,
|
||||
double h,
|
||||
double s,
|
||||
double v);
|
||||
void gimp_color_wheel_get_color (GimpColorWheel *wheel,
|
||||
gdouble *h,
|
||||
gdouble *s,
|
||||
gdouble *v);
|
||||
void gimp_color_wheel_set_color (GimpColorWheel *wheel,
|
||||
double h,
|
||||
double s,
|
||||
double v);
|
||||
void gimp_color_wheel_get_color (GimpColorWheel *wheel,
|
||||
gdouble *h,
|
||||
gdouble *s,
|
||||
gdouble *v);
|
||||
|
||||
void gimp_color_wheel_set_ring_fraction (GimpColorWheel *wheel,
|
||||
gdouble fraction);
|
||||
gdouble gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel);
|
||||
void gimp_color_wheel_set_ring_fraction (GimpColorWheel *wheel,
|
||||
gdouble fraction);
|
||||
gdouble gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel);
|
||||
|
||||
gboolean gimp_color_wheel_is_adjusting (GimpColorWheel *wheel);
|
||||
void gimp_color_wheel_set_color_config (GimpColorWheel *wheel,
|
||||
GimpColorConfig *config);
|
||||
|
||||
gboolean gimp_color_wheel_is_adjusting (GimpColorWheel *wheel);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Reference in New Issue
Block a user