clutter: Drop various Color constructors
The fields are writable, there is no need to provide a custom constructor. This shapes the Color API to be similar to GdkRGBA Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3802>
This commit is contained in:
parent
04842393aa
commit
74ece2ad92
7 changed files with 14 additions and 107 deletions
|
@ -3077,7 +3077,6 @@ _clutter_actor_draw_paint_volume (ClutterActor *self,
|
|||
ClutterPaintNode *node)
|
||||
{
|
||||
ClutterPaintVolume *pv;
|
||||
ClutterColor color;
|
||||
|
||||
pv = _clutter_actor_get_paint_volume_mutable (self);
|
||||
if (!pv)
|
||||
|
@ -3092,18 +3091,16 @@ _clutter_actor_draw_paint_volume (ClutterActor *self,
|
|||
clutter_paint_volume_set_width (&fake_pv, width);
|
||||
clutter_paint_volume_set_height (&fake_pv, height);
|
||||
|
||||
clutter_color_init (&color, 0, 0, 255, 255);
|
||||
_clutter_actor_draw_paint_volume_full (self, &fake_pv,
|
||||
&color,
|
||||
&CLUTTER_COLOR_INIT (0, 0, 255, 255),
|
||||
node);
|
||||
|
||||
clutter_paint_volume_free (&fake_pv);
|
||||
}
|
||||
else
|
||||
{
|
||||
clutter_color_init (&color, 0, 255, 0, 255);
|
||||
_clutter_actor_draw_paint_volume_full (self, pv,
|
||||
&color,
|
||||
&CLUTTER_COLOR_INIT (0, 255, 0, 255),
|
||||
node);
|
||||
}
|
||||
}
|
||||
|
@ -3122,18 +3119,18 @@ _clutter_actor_paint_cull_result (ClutterActor *self,
|
|||
switch (result)
|
||||
{
|
||||
case CLUTTER_CULL_RESULT_IN:
|
||||
clutter_color_init (&color, 0, 255, 0, 255);
|
||||
color = CLUTTER_COLOR_INIT (0, 255, 0, 255);
|
||||
break;
|
||||
case CLUTTER_CULL_RESULT_OUT:
|
||||
clutter_color_init (&color, 0, 0, 255, 255);
|
||||
color = CLUTTER_COLOR_INIT (0, 0, 255, 255);
|
||||
break;
|
||||
default:
|
||||
clutter_color_init (&color, 0, 255, 255, 255);
|
||||
color = CLUTTER_COLOR_INIT (0, 255, 255, 255);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
clutter_color_init (&color, 255, 255, 255, 255);
|
||||
color = CLUTTER_COLOR_INIT (255, 255, 255, 255);
|
||||
|
||||
if (success && (pv = _clutter_actor_get_paint_volume_mutable (self)))
|
||||
_clutter_actor_draw_paint_volume_full (self, pv,
|
||||
|
|
|
@ -668,80 +668,6 @@ clutter_color_free (ClutterColor *color)
|
|||
g_free (color);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_color_new:
|
||||
* @red: red component of the color, between 0 and 255
|
||||
* @green: green component of the color, between 0 and 255
|
||||
* @blue: blue component of the color, between 0 and 255
|
||||
* @alpha: alpha component of the color, between 0 and 255
|
||||
*
|
||||
* Creates a new #ClutterColor with the given values.
|
||||
*
|
||||
* This function is the equivalent of:
|
||||
*
|
||||
* ```c
|
||||
* clutter_color_init (clutter_color_alloc (), red, green, blue, alpha);
|
||||
* ```
|
||||
*
|
||||
* Return value: (transfer full): the newly allocated color.
|
||||
* Use [method@Clutter.Color.free] when done
|
||||
*/
|
||||
ClutterColor *
|
||||
clutter_color_new (guint8 red,
|
||||
guint8 green,
|
||||
guint8 blue,
|
||||
guint8 alpha)
|
||||
{
|
||||
return clutter_color_init (clutter_color_alloc (),
|
||||
red,
|
||||
green,
|
||||
blue,
|
||||
alpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_color_alloc: (constructor)
|
||||
*
|
||||
* Allocates a new, transparent black #ClutterColor.
|
||||
*
|
||||
* Return value: (transfer full): the newly allocated #ClutterColor; use
|
||||
* [method@Clutter.Color.free] to free its resources
|
||||
*/
|
||||
ClutterColor *
|
||||
clutter_color_alloc (void)
|
||||
{
|
||||
return g_new0 (ClutterColor, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_color_init:
|
||||
* @color: a #ClutterColor
|
||||
* @red: red component of the color, between 0 and 255
|
||||
* @green: green component of the color, between 0 and 255
|
||||
* @blue: blue component of the color, between 0 and 255
|
||||
* @alpha: alpha component of the color, between 0 and 255
|
||||
*
|
||||
* Initializes @color with the given values.
|
||||
*
|
||||
* Return value: (transfer none): the initialized #ClutterColor
|
||||
*/
|
||||
ClutterColor *
|
||||
clutter_color_init (ClutterColor *color,
|
||||
guint8 red,
|
||||
guint8 green,
|
||||
guint8 blue,
|
||||
guint8 alpha)
|
||||
{
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
color->red = red;
|
||||
color->green = green;
|
||||
color->blue = blue;
|
||||
color->alpha = alpha;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_value_transform_color_string (const GValue *src,
|
||||
GValue *dest)
|
||||
|
|
|
@ -79,19 +79,6 @@ struct _ClutterColor
|
|||
CLUTTER_EXPORT
|
||||
GType clutter_color_get_type (void) G_GNUC_CONST;
|
||||
|
||||
CLUTTER_EXPORT
|
||||
ClutterColor *clutter_color_new (guint8 red,
|
||||
guint8 green,
|
||||
guint8 blue,
|
||||
guint8 alpha);
|
||||
CLUTTER_EXPORT
|
||||
ClutterColor *clutter_color_alloc (void);
|
||||
CLUTTER_EXPORT
|
||||
ClutterColor *clutter_color_init (ClutterColor *color,
|
||||
guint8 red,
|
||||
guint8 green,
|
||||
guint8 blue,
|
||||
guint8 alpha);
|
||||
CLUTTER_EXPORT
|
||||
ClutterColor *clutter_color_copy (const ClutterColor *color);
|
||||
CLUTTER_EXPORT
|
||||
|
|
|
@ -1254,7 +1254,6 @@ clutter_stage_paint (ClutterActor *actor,
|
|||
g_autoptr (GString) string = NULL;
|
||||
PangoLayout *layout;
|
||||
PangoRectangle logical;
|
||||
ClutterColor color;
|
||||
g_autoptr (ClutterPaintNode) node = NULL;
|
||||
ClutterActorBox box;
|
||||
|
||||
|
@ -1267,8 +1266,8 @@ clutter_stage_paint (ClutterActor *actor,
|
|||
pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
|
||||
pango_layout_get_pixel_extents (layout, NULL, &logical);
|
||||
|
||||
clutter_color_init (&color, 255, 255, 255, 255);
|
||||
node = clutter_text_node_new (layout, &color);
|
||||
node = clutter_text_node_new (layout,
|
||||
&CLUTTER_COLOR_INIT (255, 255, 255, 255));
|
||||
|
||||
box.x1 = view_layout.x;
|
||||
box.y1 = view_layout.y + 30;
|
||||
|
|
|
@ -329,7 +329,6 @@ on_monitors_changed (MetaMonitorManager *monitor_manager,
|
|||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
ClutterColor color;
|
||||
|
||||
meta_display_get_monitor_geometry (display, i, &rect);
|
||||
|
||||
|
@ -348,10 +347,10 @@ on_monitors_changed (MetaMonitorManager *monitor_manager,
|
|||
blue = g_rand_int_range (rand, 0, 255);
|
||||
green = g_rand_int_range (rand, 0, 255);
|
||||
red = g_rand_int_range (rand, 0, 255);
|
||||
clutter_color_init (&color, red, green, blue, 255);
|
||||
|
||||
background = meta_background_new (display);
|
||||
meta_background_set_color (background, &color);
|
||||
meta_background_set_color (background,
|
||||
&CLUTTER_COLOR_INIT (red, green, blue, 255));
|
||||
meta_background_content_set_background (background_content, background);
|
||||
g_object_unref (background);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ on_clicked (ClutterClickAction *action,
|
|||
new_height = old_height + 200;
|
||||
new_angle = 360.0;
|
||||
|
||||
clutter_color_init (&new_color, 164, 0, 0, 255);
|
||||
new_color = CLUTTER_COLOR_INIT (164, 0, 0, 255);
|
||||
new_opacity = 255;
|
||||
}
|
||||
else
|
||||
|
@ -58,7 +58,7 @@ on_clicked (ClutterClickAction *action,
|
|||
new_height = old_height - 200;
|
||||
new_angle = 0.0;
|
||||
|
||||
clutter_color_init (&new_color, 206, 92, 0, 255);
|
||||
new_color = CLUTTER_COLOR_INIT (206, 92, 0, 255);
|
||||
|
||||
new_opacity = 128;
|
||||
}
|
||||
|
|
|
@ -268,7 +268,6 @@ on_monitors_changed (MetaMonitorManager *monitor_manager,
|
|||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
ClutterColor color;
|
||||
|
||||
meta_display_get_monitor_geometry (display, i, &rect);
|
||||
|
||||
|
@ -282,10 +281,10 @@ on_monitors_changed (MetaMonitorManager *monitor_manager,
|
|||
blue = g_rand_int_range (rand, 0, 255);
|
||||
green = g_rand_int_range (rand, 0, 255);
|
||||
red = g_rand_int_range (rand, 0, 255);
|
||||
clutter_color_init (&color, red, green, blue, 255);
|
||||
|
||||
background = meta_background_new (display);
|
||||
meta_background_set_color (background, &color);
|
||||
meta_background_set_color (background,
|
||||
&CLUTTER_COLOR_INIT (red, green, blue, 255));
|
||||
meta_background_content_set_background (background_content, background);
|
||||
g_object_unref (background);
|
||||
|
||||
|
|
Loading…
Reference in a new issue