mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
color: Add initializers for ClutterColor
Similar to the ones we have for the other boxed types in Clutter.
This commit is contained in:
parent
2276f24ffd
commit
0fc4053613
@ -968,6 +968,12 @@ clutter_color_free (ClutterColor *color)
|
|||||||
*
|
*
|
||||||
* Creates a new #ClutterColor with the given values.
|
* Creates a new #ClutterColor with the given values.
|
||||||
*
|
*
|
||||||
|
* This function is the equivalent of:
|
||||||
|
*
|
||||||
|
* |[
|
||||||
|
* clutter_color_init (clutter_color_alloc (), red, green, blue, alpha);
|
||||||
|
* ]|
|
||||||
|
*
|
||||||
* Return value: (transfer full): the newly allocated color.
|
* Return value: (transfer full): the newly allocated color.
|
||||||
* Use clutter_color_free() when done
|
* Use clutter_color_free() when done
|
||||||
*
|
*
|
||||||
@ -979,13 +985,55 @@ clutter_color_new (guint8 red,
|
|||||||
guint8 blue,
|
guint8 blue,
|
||||||
guint8 alpha)
|
guint8 alpha)
|
||||||
{
|
{
|
||||||
ClutterColor *color;
|
return clutter_color_init (clutter_color_alloc (),
|
||||||
|
red,
|
||||||
|
green,
|
||||||
|
blue,
|
||||||
|
alpha);
|
||||||
|
}
|
||||||
|
|
||||||
color = g_slice_new (ClutterColor);
|
/**
|
||||||
|
* clutter_color_alloc:
|
||||||
|
*
|
||||||
|
* Allocates a new, transparent black #ClutterColor.
|
||||||
|
*
|
||||||
|
* Return value: (transfer full): the newly allocated #ClutterColor; use
|
||||||
|
* clutter_color_free() to free its resources
|
||||||
|
*
|
||||||
|
* Since: 1.12
|
||||||
|
*/
|
||||||
|
ClutterColor *
|
||||||
|
clutter_color_alloc (void)
|
||||||
|
{
|
||||||
|
return g_slice_new0 (ClutterColor);
|
||||||
|
}
|
||||||
|
|
||||||
color->red = red;
|
/**
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* Since: 1.12
|
||||||
|
*/
|
||||||
|
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->green = green;
|
||||||
color->blue = blue;
|
color->blue = blue;
|
||||||
color->alpha = alpha;
|
color->alpha = alpha;
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
|
@ -55,12 +55,31 @@ struct _ClutterColor
|
|||||||
guint8 alpha;
|
guint8 alpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CLUTTER_COLOR_INIT:
|
||||||
|
* @r: value for the red channel, between 0 and 255
|
||||||
|
* @g: value for the green channel, between 0 and 255
|
||||||
|
* @b: value for the blue channel, between 0 and 255
|
||||||
|
* @a: value for the alpha channel, between 0 and 255
|
||||||
|
*
|
||||||
|
* A macro that initializes a #ClutterColor, to be used when declaring it.
|
||||||
|
*
|
||||||
|
* Since: 1.12
|
||||||
|
*/
|
||||||
|
#define CLUTTER_COLOR_INIT(r,g,b,a) { (r), (g), (b), (a) }
|
||||||
|
|
||||||
GType clutter_color_get_type (void) G_GNUC_CONST;
|
GType clutter_color_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
ClutterColor *clutter_color_new (guint8 red,
|
ClutterColor *clutter_color_new (guint8 red,
|
||||||
guint8 green,
|
guint8 green,
|
||||||
guint8 blue,
|
guint8 blue,
|
||||||
guint8 alpha);
|
guint8 alpha);
|
||||||
|
ClutterColor *clutter_color_alloc (void);
|
||||||
|
ClutterColor *clutter_color_init (ClutterColor *color,
|
||||||
|
guint8 red,
|
||||||
|
guint8 green,
|
||||||
|
guint8 blue,
|
||||||
|
guint8 alpha);
|
||||||
ClutterColor *clutter_color_copy (const ClutterColor *color);
|
ClutterColor *clutter_color_copy (const ClutterColor *color);
|
||||||
void clutter_color_free (ClutterColor *color);
|
void clutter_color_free (ClutterColor *color);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user