mirror of https://github.com/GNOME/gimp.git
app, libgimp, pdb, plug-ins: gimp_context_[gs]et_foreground() now using GeglColor.
Also the color is internally stored as GeglColor, though there are still get APIs and signals using GimpRGB. The equivalent PDB functions are also changed to use GeglColor, same as app/ functions.
This commit is contained in:
parent
9602926012
commit
f18266cb04
|
@ -110,16 +110,19 @@ context_##name##_##fgbg##ground_cmd_callback (GimpAction *action, \
|
|||
gpointer data) \
|
||||
{ \
|
||||
GimpContext *context; \
|
||||
GimpRGB color; \
|
||||
GimpRGB rgb; \
|
||||
GeglColor *color = gegl_color_new ("black"); \
|
||||
GimpActionSelectType select_type; \
|
||||
return_if_no_context (context, data); \
|
||||
\
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value); \
|
||||
\
|
||||
gimp_context_get_##fgbg##ground (context, &color); \
|
||||
context_select_color (select_type, &color, \
|
||||
gimp_context_get_##fgbg##ground (context, &rgb); \
|
||||
context_select_color (select_type, &rgb, \
|
||||
use_colormap, use_palette); \
|
||||
gimp_context_set_##fgbg##ground (context, &color); \
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL); \
|
||||
gimp_context_set_##fgbg##ground (context, color); \
|
||||
g_object_unref (color); \
|
||||
}
|
||||
|
||||
SELECT_COLOR_CMD_CALLBACK (palette, fore, FALSE, TRUE)
|
||||
|
@ -135,18 +138,21 @@ context_foreground_red_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_foreground (context, &color);
|
||||
color.r = action_select_value (select_type,
|
||||
color.r,
|
||||
gimp_context_get_foreground (context, &rgb);
|
||||
rgb.r = action_select_value (select_type,
|
||||
rgb.r,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_context_set_foreground (context, &color);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_foreground (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -155,18 +161,21 @@ context_foreground_green_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_foreground (context, &color);
|
||||
color.g = action_select_value (select_type,
|
||||
color.g,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_context_set_foreground (context, &color);
|
||||
gimp_context_get_foreground (context, &rgb);
|
||||
rgb.g = action_select_value (select_type,
|
||||
rgb.g,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_foreground (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -175,18 +184,21 @@ context_foreground_blue_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_foreground (context, &color);
|
||||
color.b = action_select_value (select_type,
|
||||
color.b,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_context_set_foreground (context, &color);
|
||||
gimp_context_get_foreground (context, &rgb);
|
||||
rgb.b = action_select_value (select_type,
|
||||
rgb.b,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_foreground (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -195,18 +207,21 @@ context_background_red_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_background (context, &color);
|
||||
color.r = action_select_value (select_type,
|
||||
color.r,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_context_set_background (context, &color);
|
||||
gimp_context_get_background (context, &rgb);
|
||||
rgb.r = action_select_value (select_type,
|
||||
rgb.r,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_background (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -215,18 +230,21 @@ context_background_green_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_background (context, &color);
|
||||
color.g = action_select_value (select_type,
|
||||
color.g,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_context_set_background (context, &color);
|
||||
gimp_context_get_background (context, &rgb);
|
||||
rgb.g = action_select_value (select_type,
|
||||
rgb.g,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_background (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -235,18 +253,21 @@ context_background_blue_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_background (context, &color);
|
||||
color.b = action_select_value (select_type,
|
||||
color.b,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_context_set_background (context, &color);
|
||||
gimp_context_get_background (context, &rgb);
|
||||
rgb.b = action_select_value (select_type,
|
||||
rgb.b,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_background (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -255,21 +276,24 @@ context_foreground_hue_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_foreground (context, &color);
|
||||
gimp_rgb_to_hsv (&color, &hsv);
|
||||
gimp_context_get_foreground (context, &rgb);
|
||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
||||
hsv.h = action_select_value (select_type,
|
||||
hsv.h,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 360.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_hsv_to_rgb (&hsv, &color);
|
||||
gimp_context_set_foreground (context, &color);
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_foreground (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -278,21 +302,24 @@ context_foreground_saturation_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_foreground (context, &color);
|
||||
gimp_rgb_to_hsv (&color, &hsv);
|
||||
gimp_context_get_foreground (context, &rgb);
|
||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
||||
hsv.s = action_select_value (select_type,
|
||||
hsv.s,
|
||||
0.0, 1.0, 1.0,
|
||||
0.01, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_hsv_to_rgb (&hsv, &color);
|
||||
gimp_context_set_foreground (context, &color);
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_foreground (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -301,21 +328,24 @@ context_foreground_value_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_foreground (context, &color);
|
||||
gimp_rgb_to_hsv (&color, &hsv);
|
||||
gimp_context_get_foreground (context, &rgb);
|
||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
||||
hsv.v = action_select_value (select_type,
|
||||
hsv.v,
|
||||
0.0, 1.0, 1.0,
|
||||
0.01, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_hsv_to_rgb (&hsv, &color);
|
||||
gimp_context_set_foreground (context, &color);
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_foreground (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -324,21 +354,24 @@ context_background_hue_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_background (context, &color);
|
||||
gimp_rgb_to_hsv (&color, &hsv);
|
||||
gimp_context_get_background (context, &rgb);
|
||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
||||
hsv.h = action_select_value (select_type,
|
||||
hsv.h,
|
||||
0.0, 1.0, 1.0,
|
||||
1.0 / 360.0, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_hsv_to_rgb (&hsv, &color);
|
||||
gimp_context_set_background (context, &color);
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_background (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -347,21 +380,24 @@ context_background_saturation_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_background (context, &color);
|
||||
gimp_rgb_to_hsv (&color, &hsv);
|
||||
gimp_context_get_background (context, &rgb);
|
||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
||||
hsv.s = action_select_value (select_type,
|
||||
hsv.s,
|
||||
0.0, 1.0, 1.0,
|
||||
0.01, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_hsv_to_rgb (&hsv, &color);
|
||||
gimp_context_set_background (context, &color);
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_background (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -370,21 +406,24 @@ context_background_value_cmd_callback (GimpAction *action,
|
|||
gpointer data)
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpRGB color;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
GimpHSV hsv;
|
||||
GimpActionSelectType select_type;
|
||||
return_if_no_context (context, data);
|
||||
|
||||
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
||||
|
||||
gimp_context_get_background (context, &color);
|
||||
gimp_rgb_to_hsv (&color, &hsv);
|
||||
gimp_context_get_background (context, &rgb);
|
||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
||||
hsv.v = action_select_value (select_type,
|
||||
hsv.v,
|
||||
0.0, 1.0, 1.0,
|
||||
0.01, 0.01, 0.1, 0.0, FALSE);
|
||||
gimp_hsv_to_rgb (&hsv, &color);
|
||||
gimp_context_set_background (context, &color);
|
||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_background (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -153,11 +153,11 @@ static void gimp_context_real_set_paint_info (GimpContext *context,
|
|||
|
||||
/* foreground */
|
||||
static void gimp_context_real_set_foreground (GimpContext *context,
|
||||
const GimpRGB *color);
|
||||
GeglColor *color);
|
||||
|
||||
/* background */
|
||||
static void gimp_context_real_set_background (GimpContext *context,
|
||||
const GimpRGB *color);
|
||||
GeglColor *color);
|
||||
|
||||
/* opacity */
|
||||
static void gimp_context_real_set_opacity (GimpContext *context,
|
||||
|
@ -826,6 +826,9 @@ gimp_context_init (GimpContext *context)
|
|||
|
||||
context->line_art = NULL;
|
||||
context->line_art_timeout_id = 0;
|
||||
|
||||
context->foreground = NULL;
|
||||
context->background = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1023,6 +1026,8 @@ gimp_context_finalize (GObject *object)
|
|||
g_clear_pointer (&context->template_name, g_free);
|
||||
|
||||
g_clear_object (&context->line_art);
|
||||
g_clear_object (&context->foreground);
|
||||
g_clear_object (&context->background);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -1053,10 +1058,24 @@ gimp_context_set_property (GObject *object,
|
|||
gimp_context_set_paint_info (context, g_value_get_object (value));
|
||||
break;
|
||||
case GIMP_CONTEXT_PROP_FOREGROUND:
|
||||
gimp_context_set_foreground (context, g_value_get_boxed (value));
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB *rgb = g_value_get_boxed (value);
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
gimp_context_set_foreground (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
break;
|
||||
case GIMP_CONTEXT_PROP_BACKGROUND:
|
||||
gimp_context_set_background (context, g_value_get_boxed (value));
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB *rgb = g_value_get_boxed (value);
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
gimp_context_set_background (context, color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
break;
|
||||
case GIMP_CONTEXT_PROP_OPACITY:
|
||||
gimp_context_set_opacity (context, g_value_get_double (value));
|
||||
|
@ -1664,11 +1683,11 @@ gimp_context_copy_property (GimpContext *src,
|
|||
break;
|
||||
|
||||
case GIMP_CONTEXT_PROP_FOREGROUND:
|
||||
gimp_context_real_set_foreground (dest, &src->foreground);
|
||||
gimp_context_real_set_foreground (dest, src->foreground);
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_PROP_BACKGROUND:
|
||||
gimp_context_real_set_background (dest, &src->background);
|
||||
gimp_context_real_set_background (dest, src->background);
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_PROP_OPACITY:
|
||||
|
@ -2290,17 +2309,17 @@ gimp_context_real_set_paint_info (GimpContext *context,
|
|||
|
||||
void
|
||||
gimp_context_get_foreground (GimpContext *context,
|
||||
GimpRGB *color)
|
||||
GimpRGB *rgb)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
*color = context->foreground;
|
||||
gegl_color_get_rgba_with_space (context->foreground, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_foreground (GimpContext *context,
|
||||
const GimpRGB *color)
|
||||
gimp_context_set_foreground (GimpContext *context,
|
||||
GeglColor *color)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
@ -2321,14 +2340,16 @@ gimp_context_foreground_changed (GimpContext *context)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_context_real_set_foreground (GimpContext *context,
|
||||
const GimpRGB *color)
|
||||
gimp_context_real_set_foreground (GimpContext *context,
|
||||
GeglColor *color)
|
||||
{
|
||||
if (gimp_rgba_distance (&context->foreground, color) < RGBA_EPSILON)
|
||||
if (context->foreground != NULL &&
|
||||
gimp_color_is_perceptually_identical (context->foreground, color))
|
||||
return;
|
||||
|
||||
context->foreground = *color;
|
||||
gimp_rgb_set_alpha (&context->foreground, GIMP_OPACITY_OPAQUE);
|
||||
g_clear_object (&context->foreground);
|
||||
context->foreground = gegl_color_duplicate (color);
|
||||
gimp_color_set_alpha (context->foreground, GIMP_OPACITY_OPAQUE);
|
||||
|
||||
g_object_notify (G_OBJECT (context), "foreground");
|
||||
gimp_context_foreground_changed (context);
|
||||
|
@ -2340,18 +2361,18 @@ gimp_context_real_set_foreground (GimpContext *context,
|
|||
|
||||
void
|
||||
gimp_context_get_background (GimpContext *context,
|
||||
GimpRGB *color)
|
||||
GimpRGB *rgb)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
|
||||
g_return_if_fail (color != NULL);
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
*color = context->background;
|
||||
gegl_color_get_rgba_with_space (context->background, &rgb->r, &rgb->g, &rgb->b, &rgb->a, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_background (GimpContext *context,
|
||||
const GimpRGB *color)
|
||||
gimp_context_set_background (GimpContext *context,
|
||||
GeglColor *color)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
@ -2372,14 +2393,16 @@ gimp_context_background_changed (GimpContext *context)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_context_real_set_background (GimpContext *context,
|
||||
const GimpRGB *color)
|
||||
gimp_context_real_set_background (GimpContext *context,
|
||||
GeglColor *color)
|
||||
{
|
||||
if (gimp_rgba_distance (&context->background, color) < RGBA_EPSILON)
|
||||
if (context->background != NULL &&
|
||||
gimp_color_is_perceptually_identical (context->background, color))
|
||||
return;
|
||||
|
||||
context->background = *color;
|
||||
gimp_rgb_set_alpha (&context->background, GIMP_OPACITY_OPAQUE);
|
||||
g_clear_object (&context->background);
|
||||
context->background = gegl_color_duplicate (color);
|
||||
gimp_color_set_alpha (context->background, GIMP_OPACITY_OPAQUE);
|
||||
|
||||
g_object_notify (G_OBJECT (context), "background");
|
||||
gimp_context_background_changed (context);
|
||||
|
@ -2393,8 +2416,8 @@ void
|
|||
gimp_context_set_default_colors (GimpContext *context)
|
||||
{
|
||||
GimpContext *bg_context;
|
||||
GimpRGB fg;
|
||||
GimpRGB bg;
|
||||
GeglColor *fg;
|
||||
GeglColor *bg;
|
||||
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
|
||||
|
@ -2403,19 +2426,22 @@ gimp_context_set_default_colors (GimpContext *context)
|
|||
context_find_defined (context, GIMP_CONTEXT_PROP_FOREGROUND);
|
||||
context_find_defined (bg_context, GIMP_CONTEXT_PROP_BACKGROUND);
|
||||
|
||||
gimp_rgba_set (&fg, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
||||
gimp_rgba_set (&bg, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
|
||||
fg = gegl_color_new ("black");
|
||||
bg = gegl_color_new ("white");
|
||||
|
||||
gimp_context_real_set_foreground (context, &fg);
|
||||
gimp_context_real_set_background (bg_context, &bg);
|
||||
gimp_context_real_set_foreground (context, fg);
|
||||
gimp_context_real_set_background (bg_context, bg);
|
||||
|
||||
g_object_unref (fg);
|
||||
g_object_unref (bg);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_swap_colors (GimpContext *context)
|
||||
{
|
||||
GimpContext *bg_context;
|
||||
GimpRGB fg;
|
||||
GimpRGB bg;
|
||||
GeglColor *fg;
|
||||
GeglColor *bg;
|
||||
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
|
||||
|
@ -2424,11 +2450,14 @@ gimp_context_swap_colors (GimpContext *context)
|
|||
context_find_defined (context, GIMP_CONTEXT_PROP_FOREGROUND);
|
||||
context_find_defined (bg_context, GIMP_CONTEXT_PROP_BACKGROUND);
|
||||
|
||||
gimp_context_get_foreground (context, &fg);
|
||||
gimp_context_get_background (bg_context, &bg);
|
||||
fg = g_object_ref (context->foreground);
|
||||
bg = g_object_ref (context->background);
|
||||
|
||||
gimp_context_real_set_foreground (context, &bg);
|
||||
gimp_context_real_set_background (bg_context, &fg);
|
||||
gimp_context_real_set_foreground (context, bg);
|
||||
gimp_context_real_set_background (bg_context, fg);
|
||||
|
||||
g_object_unref (fg);
|
||||
g_object_unref (bg);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -64,8 +64,8 @@ struct _GimpContext
|
|||
GimpPaintInfo *paint_info;
|
||||
gchar *paint_name;
|
||||
|
||||
GimpRGB foreground;
|
||||
GimpRGB background;
|
||||
GeglColor *foreground;
|
||||
GeglColor *background;
|
||||
|
||||
gdouble opacity;
|
||||
GimpLayerMode paint_mode;
|
||||
|
@ -249,7 +249,7 @@ void gimp_context_paint_info_changed (GimpContext *context);
|
|||
void gimp_context_get_foreground (GimpContext *context,
|
||||
GimpRGB *color);
|
||||
void gimp_context_set_foreground (GimpContext *context,
|
||||
const GimpRGB *color);
|
||||
GeglColor *color);
|
||||
void gimp_context_foreground_changed (GimpContext *context);
|
||||
|
||||
|
||||
|
@ -257,7 +257,7 @@ void gimp_context_foreground_changed (GimpContext *context);
|
|||
void gimp_context_get_background (GimpContext *context,
|
||||
GimpRGB *color);
|
||||
void gimp_context_set_background (GimpContext *context,
|
||||
const GimpRGB *color);
|
||||
GeglColor *color);
|
||||
void gimp_context_background_changed (GimpContext *context);
|
||||
|
||||
|
||||
|
|
|
@ -468,12 +468,12 @@ gimp_drawable_get_line_art_fill_buffer (GimpDrawable *drawable,
|
|||
GList *drawables;
|
||||
GimpContext *context = gimp_get_user_context (image->gimp);
|
||||
GError *error = NULL;
|
||||
const GimpRGB white = {1.0, 1.0, 1.0, 1.0};
|
||||
GeglColor *white = gegl_color_new ("white");
|
||||
|
||||
context = gimp_config_duplicate (GIMP_CONFIG (context));
|
||||
/* As we are stroking a mask, we need to set color to white. */
|
||||
gimp_context_set_foreground (GIMP_CONTEXT (context),
|
||||
&white);
|
||||
gimp_context_set_foreground (GIMP_CONTEXT (context), white);
|
||||
g_object_unref (white);
|
||||
|
||||
channel = gimp_channel_new_from_buffer (image, new_mask, NULL, NULL);
|
||||
stroked = gimp_channel_new_from_buffer (image, rendered_mask, NULL, NULL);
|
||||
|
|
|
@ -375,7 +375,8 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
|
|||
GError **error)
|
||||
{
|
||||
GimpFillOptionsPrivate *private;
|
||||
GimpRGB color;
|
||||
GeglColor *color;
|
||||
GimpRGB rgb;
|
||||
const gchar *undo_desc;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), FALSE);
|
||||
|
@ -389,12 +390,12 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
|
|||
switch (fill_type)
|
||||
{
|
||||
case GIMP_FILL_FOREGROUND:
|
||||
gimp_context_get_foreground (context, &color);
|
||||
gimp_context_get_foreground (context, &rgb);
|
||||
undo_desc = C_("undo-type", "Fill with Foreground Color");
|
||||
break;
|
||||
|
||||
case GIMP_FILL_BACKGROUND:
|
||||
gimp_context_get_background (context, &color);
|
||||
gimp_context_get_background (context, &rgb);
|
||||
undo_desc = C_("undo-type", "Fill with Background Color");
|
||||
break;
|
||||
|
||||
|
@ -417,18 +418,18 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
|
|||
babl_process (babl_fish (babl_format ("CIE Lab float"), format),
|
||||
cielab_pixel, pixel, 1);
|
||||
|
||||
gimp_rgba_set (&color, pixel[0], pixel[1], pixel[2], GIMP_OPACITY_OPAQUE);
|
||||
gimp_rgba_set (&rgb, pixel[0], pixel[1], pixel[2], GIMP_OPACITY_OPAQUE);
|
||||
undo_desc = C_("undo-type", "Fill with Middle Gray (CIELAB) Color");
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_FILL_WHITE:
|
||||
gimp_rgba_set (&color, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
|
||||
gimp_rgba_set (&rgb, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
|
||||
undo_desc = C_("undo-type", "Fill with White");
|
||||
break;
|
||||
|
||||
case GIMP_FILL_TRANSPARENT:
|
||||
gimp_context_get_background (context, &color);
|
||||
gimp_context_get_background (context, &rgb);
|
||||
gimp_context_set_paint_mode (GIMP_CONTEXT (options),
|
||||
GIMP_LAYER_MODE_ERASE);
|
||||
undo_desc = C_("undo-type", "Fill with Transparency");
|
||||
|
@ -459,9 +460,13 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
|
|||
}
|
||||
|
||||
gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
|
||||
gimp_context_set_foreground (GIMP_CONTEXT (options), &color);
|
||||
color = gegl_color_new ("black");
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
gimp_context_set_foreground (GIMP_CONTEXT (options), color);
|
||||
private->undo_desc = undo_desc;
|
||||
|
||||
g_object_unref (color);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -436,22 +436,25 @@ static void
|
|||
gimp_display_shell_drop_color (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
const GimpRGB *color,
|
||||
const GimpRGB *rgb,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
|
||||
GimpFillOptions *options = gimp_fill_options_new (shell->display->gimp,
|
||||
NULL, FALSE);
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
GIMP_LOG (DND, NULL);
|
||||
|
||||
gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
gimp_context_set_foreground (GIMP_CONTEXT (options), color);
|
||||
|
||||
gimp_display_shell_dnd_fill (shell, options,
|
||||
C_("undo-type", "Drop color to layer"));
|
||||
|
||||
g_object_unref (options);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -269,14 +269,14 @@ context_set_foreground_invoker (GimpProcedure *procedure,
|
|||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpRGB foreground;
|
||||
GeglColor *foreground;
|
||||
|
||||
gimp_value_get_rgb (gimp_value_array_index (args, 0), &foreground);
|
||||
foreground = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimp_rgb_set_alpha (&foreground, 1.0);
|
||||
gimp_context_set_foreground (context, &foreground);
|
||||
gimp_color_set_alpha (foreground, 1.0);
|
||||
gimp_context_set_foreground (context, foreground);
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
|
@ -312,14 +312,14 @@ context_set_background_invoker (GimpProcedure *procedure,
|
|||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpRGB background;
|
||||
GeglColor *background;
|
||||
|
||||
gimp_value_get_rgb (gimp_value_array_index (args, 0), &background);
|
||||
background = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimp_rgb_set_alpha (&background, 1.0);
|
||||
gimp_context_set_background (context, &background);
|
||||
gimp_color_set_alpha (background, 1.0);
|
||||
gimp_context_set_background (context, background);
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
|
@ -3282,12 +3282,11 @@ register_context_procs (GimpPDB *pdb)
|
|||
"Michael Natterer & Sven Neumann",
|
||||
"2004");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_rgb ("foreground",
|
||||
"foreground",
|
||||
"The foreground color",
|
||||
FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gegl_param_spec_color ("foreground",
|
||||
"foreground",
|
||||
"The foreground color",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
|
@ -3330,12 +3329,11 @@ register_context_procs (GimpPDB *pdb)
|
|||
"Michael Natterer & Sven Neumann",
|
||||
"2004");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_rgb ("background",
|
||||
"background",
|
||||
"The background color",
|
||||
FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gegl_param_spec_color ("background",
|
||||
"background",
|
||||
"The background color",
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
|
|
|
@ -492,7 +492,6 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
|
|||
GimpImageWindow *image_window;
|
||||
GimpDialogFactory *dialog_factory;
|
||||
GimpContext *context;
|
||||
GimpRGB rgb = { 0 };
|
||||
|
||||
g_return_if_fail (GEGL_IS_COLOR (color));
|
||||
|
||||
|
@ -557,19 +556,17 @@ gimp_color_tool_real_picked (GimpColorTool *color_tool,
|
|||
}
|
||||
}
|
||||
|
||||
gegl_color_get_rgba_with_space (color, &rgb.r, &rgb.g, &rgb.b, &rgb.a, sample_format);
|
||||
switch (color_tool->pick_target)
|
||||
{
|
||||
case GIMP_COLOR_PICK_TARGET_NONE:
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_PICK_TARGET_FOREGROUND:
|
||||
/* TODO: FG/BG colors should be stored as GeglColor. */
|
||||
gimp_context_set_foreground (context, &rgb);
|
||||
gimp_context_set_foreground (context, color);
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_PICK_TARGET_BACKGROUND:
|
||||
gimp_context_set_background (context, &rgb);
|
||||
gimp_context_set_background (context, color);
|
||||
break;
|
||||
|
||||
case GIMP_COLOR_PICK_TARGET_PALETTE:
|
||||
|
|
|
@ -703,13 +703,18 @@ gimp_text_options_notify_text_color (GimpText *text,
|
|||
GParamSpec *pspec,
|
||||
GimpContext *context)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
g_signal_handlers_block_by_func (context,
|
||||
gimp_text_options_notify_color, text);
|
||||
|
||||
gimp_context_set_foreground (context, &text->color);
|
||||
gegl_color_set_rgba_with_space (color, text->color.r, text->color.g, text->color.b, text->color.a, NULL);
|
||||
gimp_context_set_foreground (context, color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (context,
|
||||
gimp_text_options_notify_color, text);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
/* This function could live in gimptexttool.c also.
|
||||
|
|
|
@ -591,13 +591,16 @@ gimp_color_editor_color_changed (GimpColorSelector *selector,
|
|||
{
|
||||
if (editor->context)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
if (editor->edit_bg)
|
||||
{
|
||||
g_signal_handlers_block_by_func (editor->context,
|
||||
gimp_color_editor_bg_changed,
|
||||
editor);
|
||||
|
||||
gimp_context_set_background (editor->context, rgb);
|
||||
gimp_context_set_background (editor->context, color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (editor->context,
|
||||
gimp_color_editor_bg_changed,
|
||||
|
@ -609,12 +612,14 @@ gimp_color_editor_color_changed (GimpColorSelector *selector,
|
|||
gimp_color_editor_fg_changed,
|
||||
editor);
|
||||
|
||||
gimp_context_set_foreground (editor->context, rgb);
|
||||
gimp_context_set_foreground (editor->context, color);
|
||||
|
||||
g_signal_handlers_unblock_by_func (editor->context,
|
||||
gimp_color_editor_fg_changed,
|
||||
editor);
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
g_signal_handlers_block_by_func (editor->hex_entry,
|
||||
|
@ -693,10 +698,16 @@ gimp_color_editor_color_picked (GtkWidget *widget,
|
|||
{
|
||||
if (editor->context)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
|
||||
if (editor->edit_bg)
|
||||
gimp_context_set_background (editor->context, rgb);
|
||||
gimp_context_set_background (editor->context, color);
|
||||
else
|
||||
gimp_context_set_foreground (editor->context, rgb);
|
||||
gimp_context_set_foreground (editor->context, color);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -704,17 +715,21 @@ static void
|
|||
gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
|
||||
GimpColorEditor *editor)
|
||||
{
|
||||
GimpRGB rgb;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
GimpRGB rgb;
|
||||
|
||||
gimp_color_hex_entry_get_color (entry, &rgb);
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
|
||||
if (editor->context)
|
||||
{
|
||||
if (editor->edit_bg)
|
||||
gimp_context_set_background (editor->context, &rgb);
|
||||
gimp_context_set_background (editor->context, color);
|
||||
else
|
||||
gimp_context_set_foreground (editor->context, &rgb);
|
||||
gimp_context_set_foreground (editor->context, color);
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -724,9 +739,15 @@ gimp_color_editor_history_selected (GimpColorHistory *history,
|
|||
{
|
||||
if (editor->context)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
|
||||
if (editor->edit_bg)
|
||||
gimp_context_set_background (editor->context, rgb);
|
||||
gimp_context_set_background (editor->context, color);
|
||||
else
|
||||
gimp_context_set_foreground (editor->context, rgb);
|
||||
gimp_context_set_foreground (editor->context, color);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ gimp_colormap_editor_max_index (GimpColormapEditor *editor)
|
|||
|
||||
static void
|
||||
gimp_colormap_editor_color_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
const GimpRGB *rgb,
|
||||
GimpColorDialogState state,
|
||||
GimpColormapEditor *editor)
|
||||
{
|
||||
|
@ -364,12 +364,20 @@ gimp_colormap_editor_color_update (GimpColorDialog *dialog,
|
|||
switch (state)
|
||||
{
|
||||
case GIMP_COLOR_DIALOG_OK:
|
||||
push_undo = TRUE;
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
if (state & gimp_get_toggle_behavior_mask ())
|
||||
gimp_context_set_background (image_editor->context, color);
|
||||
else
|
||||
gimp_context_set_foreground (image_editor->context, color);
|
||||
push_undo = TRUE;
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
|
||||
if (state & gimp_get_toggle_behavior_mask ())
|
||||
gimp_context_set_background (image_editor->context, color);
|
||||
else
|
||||
gimp_context_set_foreground (image_editor->context, color);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
/* Fall through */
|
||||
|
||||
case GIMP_COLOR_DIALOG_CANCEL:
|
||||
|
@ -398,8 +406,7 @@ gimp_colormap_editor_color_update (GimpColorDialog *dialog,
|
|||
FALSE);
|
||||
}
|
||||
|
||||
gimp_image_set_colormap_entry (image, col_index, color,
|
||||
push_undo);
|
||||
gimp_image_set_colormap_entry (image, col_index, rgb, push_undo);
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_flush (image);
|
||||
|
@ -448,11 +455,16 @@ gimp_colormap_editor_color_clicked (GimpColormapEditor *editor,
|
|||
GdkModifierType state)
|
||||
{
|
||||
GimpImageEditor *image_editor = GIMP_IMAGE_EDITOR (editor);
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, entry->color.r, entry->color.g, entry->color.b, entry->color.a, NULL);
|
||||
|
||||
if (state & gimp_get_toggle_behavior_mask ())
|
||||
gimp_context_set_background (image_editor->context, &entry->color);
|
||||
gimp_context_set_background (image_editor->context, color);
|
||||
else
|
||||
gimp_context_set_foreground (image_editor->context, &entry->color);
|
||||
gimp_context_set_foreground (image_editor->context, color);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -281,7 +281,7 @@ gimp_drawable_tree_view_drop_viewables (GimpContainerTreeView *view,
|
|||
|
||||
static void
|
||||
gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
|
||||
const GimpRGB *color,
|
||||
const GimpRGB *rgb,
|
||||
GimpViewable *dest_viewable,
|
||||
GtkTreeViewDropPosition drop_pos)
|
||||
{
|
||||
|
@ -289,6 +289,9 @@ gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
|
|||
{
|
||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (dest_viewable));
|
||||
GimpFillOptions *options = gimp_fill_options_new (image->gimp, NULL, FALSE);
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
|
||||
gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
|
||||
gimp_context_set_foreground (GIMP_CONTEXT (options), color);
|
||||
|
@ -298,6 +301,7 @@ gimp_drawable_tree_view_drop_color (GimpContainerTreeView *view,
|
|||
C_("undo-type", "Drop color to layer"));
|
||||
|
||||
g_object_unref (options);
|
||||
g_object_unref (color);
|
||||
|
||||
gimp_image_flush (image);
|
||||
}
|
||||
|
@ -387,12 +391,15 @@ static void
|
|||
gimp_drawable_tree_view_new_color_dropped (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
const GimpRGB *color,
|
||||
const GimpRGB *rgb,
|
||||
gpointer data)
|
||||
{
|
||||
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (data);
|
||||
GimpImage *image = gimp_item_tree_view_get_image (view);
|
||||
GimpFillOptions *options = gimp_fill_options_new (image->gimp, NULL, FALSE);
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
|
||||
gimp_fill_options_set_style (options, GIMP_FILL_STYLE_FG_COLOR);
|
||||
gimp_context_set_foreground (GIMP_CONTEXT (options), color);
|
||||
|
@ -401,4 +408,5 @@ gimp_drawable_tree_view_new_color_dropped (GtkWidget *widget,
|
|||
C_("undo-type", "Drop color to layer"));
|
||||
|
||||
g_object_unref (options);
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
|
|
@ -766,10 +766,13 @@ static void
|
|||
gimp_fg_bg_editor_drop_color (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
const GimpRGB *color,
|
||||
const GimpRGB *rgb,
|
||||
gpointer data)
|
||||
{
|
||||
GimpFgBgEditor *editor = GIMP_FG_BG_EDITOR (widget);
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
|
||||
if (editor->context)
|
||||
{
|
||||
|
@ -791,6 +794,8 @@ gimp_fg_bg_editor_drop_color (GtkWidget *widget,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1325,41 +1325,44 @@ view_pick_color (GimpGradientEditor *editor,
|
|||
gint x)
|
||||
{
|
||||
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
|
||||
GimpRGB color;
|
||||
GimpRGB rgb;
|
||||
gdouble xpos;
|
||||
gchar *str2;
|
||||
gchar *str3;
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
xpos = control_calc_g_pos (editor, x);
|
||||
|
||||
gimp_gradient_get_color_at (GIMP_GRADIENT (data_editor->data),
|
||||
data_editor->context, NULL,
|
||||
xpos, FALSE, FALSE, &color);
|
||||
xpos, FALSE, FALSE, &rgb);
|
||||
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (editor->current_color), &color);
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (editor->current_color), &rgb);
|
||||
|
||||
str2 = g_strdup_printf (_("RGB (%d, %d, %d)"),
|
||||
(gint) (color.r * 255.0),
|
||||
(gint) (color.g * 255.0),
|
||||
(gint) (color.b * 255.0));
|
||||
(gint) (rgb.r * 255.0),
|
||||
(gint) (rgb.g * 255.0),
|
||||
(gint) (rgb.b * 255.0));
|
||||
|
||||
str3 = g_strdup_printf ("(%0.3f, %0.3f, %0.3f)", color.r, color.g, color.b);
|
||||
str3 = g_strdup_printf ("(%0.3f, %0.3f, %0.3f)", rgb.r, rgb.g, rgb.b);
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb.r, rgb.g, rgb.b, rgb.a, NULL);
|
||||
if (pick_target == GIMP_COLOR_PICK_TARGET_FOREGROUND)
|
||||
{
|
||||
gimp_context_set_foreground (data_editor->context, &color);
|
||||
gimp_context_set_foreground (data_editor->context, color);
|
||||
|
||||
gradient_editor_set_hint (editor, _("Foreground color set to:"),
|
||||
str2, str3, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_context_set_background (data_editor->context, &color);
|
||||
gimp_context_set_background (data_editor->context, color);
|
||||
|
||||
gradient_editor_set_hint (editor, _("Background color set to:"),
|
||||
str2, str3, NULL);
|
||||
}
|
||||
|
||||
g_object_unref (color);
|
||||
g_free (str2);
|
||||
g_free (str3);
|
||||
}
|
||||
|
|
|
@ -774,11 +774,15 @@ palette_editor_entry_clicked (GimpPaletteView *view,
|
|||
if (entry)
|
||||
{
|
||||
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, entry->color.r, entry->color.g, entry->color.b, entry->color.a, NULL);
|
||||
if (state & gimp_get_toggle_behavior_mask ())
|
||||
gimp_context_set_background (data_editor->context, &entry->color);
|
||||
gimp_context_set_background (data_editor->context, color);
|
||||
else
|
||||
gimp_context_set_foreground (data_editor->context, &entry->color);
|
||||
gimp_context_set_foreground (data_editor->context, color);
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -164,10 +164,14 @@ color_area_background_changed (GimpContext *context,
|
|||
|
||||
static void
|
||||
color_area_dialog_update (GimpColorDialog *dialog,
|
||||
const GimpRGB *color,
|
||||
const GimpRGB *rgb,
|
||||
GimpColorDialogState state,
|
||||
GimpContext *context)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case GIMP_COLOR_DIALOG_OK:
|
||||
|
@ -205,13 +209,17 @@ color_area_dialog_update (GimpColorDialog *dialog,
|
|||
case GIMP_COLOR_DIALOG_CANCEL:
|
||||
gtk_widget_hide (color_dialog);
|
||||
color_dialog_active = FALSE;
|
||||
gimp_context_set_foreground (context, &revert_fg);
|
||||
gimp_context_set_background (context, &revert_bg);
|
||||
gegl_color_set_rgba_with_space (color, revert_fg.r, revert_fg.g, revert_fg.b, revert_fg.a, NULL);
|
||||
gimp_context_set_foreground (context, color);
|
||||
gegl_color_set_rgba_with_space (color, revert_bg.r, revert_bg.g, revert_bg.b, revert_bg.a, NULL);
|
||||
gimp_context_set_background (context, color);
|
||||
break;
|
||||
}
|
||||
|
||||
if (gimp_context_get_display (context))
|
||||
gimp_display_grab_focus (gimp_context_get_display (context));
|
||||
|
||||
g_object_unref (color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -380,14 +380,14 @@ gimp_context_get_foreground (GimpRGB *foreground)
|
|||
* Since: 2.2
|
||||
**/
|
||||
gboolean
|
||||
gimp_context_set_foreground (const GimpRGB *foreground)
|
||||
gimp_context_set_foreground (GeglColor *foreground)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
args = gimp_value_array_new_from_types (NULL,
|
||||
GIMP_TYPE_RGB, foreground,
|
||||
GEGL_TYPE_COLOR, foreground,
|
||||
G_TYPE_NONE);
|
||||
|
||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||
|
@ -456,14 +456,14 @@ gimp_context_get_background (GimpRGB *background)
|
|||
* Since: 2.2
|
||||
**/
|
||||
gboolean
|
||||
gimp_context_set_background (const GimpRGB *background)
|
||||
gimp_context_set_background (GeglColor *background)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
args = gimp_value_array_new_from_types (NULL,
|
||||
GIMP_TYPE_RGB, background,
|
||||
GEGL_TYPE_COLOR, background,
|
||||
G_TYPE_NONE);
|
||||
|
||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||
|
|
|
@ -41,9 +41,9 @@ gboolean gimp_context_set_paint_method (const
|
|||
GimpStrokeMethod gimp_context_get_stroke_method (void);
|
||||
gboolean gimp_context_set_stroke_method (GimpStrokeMethod stroke_method);
|
||||
gboolean gimp_context_get_foreground (GimpRGB *foreground);
|
||||
gboolean gimp_context_set_foreground (const GimpRGB *foreground);
|
||||
gboolean gimp_context_set_foreground (GeglColor *foreground);
|
||||
gboolean gimp_context_get_background (GimpRGB *background);
|
||||
gboolean gimp_context_set_background (const GimpRGB *background);
|
||||
gboolean gimp_context_set_background (GeglColor *background);
|
||||
gboolean gimp_context_set_default_colors (void);
|
||||
gboolean gimp_context_swap_colors (void);
|
||||
gdouble gimp_context_get_opacity (void);
|
||||
|
|
|
@ -275,15 +275,15 @@ HELP
|
|||
&pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
{ name => 'foreground', type => 'color', void_ret => 1,
|
||||
{ name => 'foreground', type => 'geglcolor', void_ret => 1,
|
||||
desc => 'The foreground color' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimp_rgb_set_alpha (&foreground, 1.0);
|
||||
gimp_context_set_foreground (context, &foreground);
|
||||
gimp_color_set_alpha (foreground, 1.0);
|
||||
gimp_context_set_foreground (context, foreground);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
@ -327,15 +327,15 @@ HELP
|
|||
&pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
{ name => 'background', type => 'color', void_ret => 1,
|
||||
{ name => 'background', type => 'geglcolor', void_ret => 1,
|
||||
desc => 'The background color' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimp_rgb_set_alpha (&background, 1.0);
|
||||
gimp_context_set_background (context, &background);
|
||||
gimp_color_set_alpha (background, 1.0);
|
||||
gimp_context_set_background (context, background);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
|
|
@ -209,7 +209,13 @@ border_average_run (GimpProcedure *procedure,
|
|||
borderaverage (G_OBJECT (config), buffer, drawable, &result_color);
|
||||
|
||||
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
||||
gimp_context_set_foreground (&result_color);
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
gegl_color_set_rgba_with_space (color, result_color.r, result_color.g, result_color.b, result_color.a, NULL);
|
||||
gimp_context_set_foreground (color);
|
||||
g_object_unref (color);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -418,6 +418,7 @@ film (GimpProcedureConfig *config)
|
|||
gint picture_count;
|
||||
GimpRGB *number_color;
|
||||
GimpRGB *film_color;
|
||||
GeglColor *color;
|
||||
gboolean keep_height;
|
||||
gdouble f;
|
||||
GimpImage *image_dst;
|
||||
|
@ -456,8 +457,12 @@ film (GimpProcedureConfig *config)
|
|||
return NULL;
|
||||
|
||||
gimp_context_push ();
|
||||
gimp_context_set_foreground (number_color);
|
||||
gimp_context_set_background (film_color);
|
||||
color = gegl_color_new ("black");
|
||||
gegl_color_set_rgba_with_space (color, number_color->r, number_color->g, number_color->b, number_color->a, NULL);
|
||||
gimp_context_set_foreground (color);
|
||||
gegl_color_set_rgba_with_space (color, film_color->r, film_color->g, film_color->b, film_color->a, NULL);
|
||||
gimp_context_set_background (color);
|
||||
g_object_unref (color);
|
||||
|
||||
if (keep_height) /* Search maximum picture height */
|
||||
{
|
||||
|
|
|
@ -610,12 +610,17 @@ gfig_style_copy (Style *style1,
|
|||
void
|
||||
gfig_style_apply (Style *style)
|
||||
{
|
||||
GeglColor *color = gegl_color_new ("black");
|
||||
|
||||
if (gfig_context->debug_styles)
|
||||
g_printerr ("Applying style '%s' -- ", style->name);
|
||||
|
||||
gimp_context_set_foreground (&style->foreground);
|
||||
gegl_color_set_rgba_with_space (color, style->foreground.r, style->foreground.g, style->foreground.b, style->foreground.a, NULL);
|
||||
gimp_context_set_foreground (color);
|
||||
|
||||
gimp_context_set_background (&style->background);
|
||||
gegl_color_set_rgba_with_space (color, style->background.r, style->background.g, style->background.b, style->background.a, NULL);
|
||||
gimp_context_set_background (color);
|
||||
g_object_unref (color);
|
||||
|
||||
if (! gimp_context_set_brush (style->brush))
|
||||
g_message ("Style apply: Failed to set brush to '%s' in style '%s'",
|
||||
|
|
Loading…
Reference in New Issue