Add some utility initializers to ClutterActorBox

This commit is contained in:
Emmanuele Bassi 2012-03-17 15:27:26 +00:00
parent e1a31bb587
commit 5e9d6f7257
4 changed files with 86 additions and 5 deletions

View File

@ -32,12 +32,63 @@ clutter_actor_box_new (gfloat x_1,
ClutterActorBox *box;
box = g_slice_new (ClutterActorBox);
clutter_actor_box_init (box, x_1, y_1, x_2, y_2);
return box;
}
/**
* clutter_actor_box_init:
* @box: a #ClutterActorBox
* @x_1: X coordinate of the top left point
* @y_1: Y coordinate of the top left point
* @x_2: X coordinate of the bottom right point
* @y_2: Y coordinate of the bottom right point
*
* Initializes @box with the given coordinates.
*
* Since: 1.10
*/
void
clutter_actor_box_init (ClutterActorBox *box,
gfloat x_1,
gfloat y_1,
gfloat x_2,
gfloat y_2)
{
g_return_if_fail (box != NULL);
box->x1 = x_1;
box->y1 = y_1;
box->x2 = x_2;
box->y2 = y_2;
}
return box;
/**
* clutter_actor_box_init_rect:
* @box: a #ClutterActorBox
* @x: X coordinate of the origin
* @y: Y coordinate of the origin
* @width: width of the box
* @height: height of the box
*
* Initializes @box with the given origin and size.
*
* Since: 1.10
*/
void
clutter_actor_box_init_rect (ClutterActorBox *box,
gfloat x,
gfloat y,
gfloat width,
gfloat height)
{
g_return_if_fail (box != NULL);
box->x1 = x;
box->y1 = y;
box->x2 = box->x1 + width;
box->y2 = box->y1 + height;
}
/**
@ -444,10 +495,7 @@ clutter_actor_box_set_origin (ClutterActorBox *box,
width = box->x2 - box->x1;
height = box->y2 - box->y1;
box->x1 = x;
box->y1 = y;
box->x2 = box->x1 + width;
box->y2 = box->y1 + height;
clutter_actor_box_init_rect (box, x, y, width, height);
}
/**

View File

@ -151,11 +151,39 @@ struct _ClutterActorBox
gfloat y2;
};
/**
* CLUTTER_ACTOR_BOX_INIT:
* @x_1: the X coordinate of the top left corner
* @y_1: the Y coordinate of the top left corner
* @x_2: the X coordinate of the bottom right corner
* @y_2: the Y coordinate of the bottom right corner
*
* A simple macro for initializing a #ClutterActorBox when declaring
* it, e.g.:
*
* |[
* ClutterActorBox box = CLUTTER_ACTOR_BOX_INIT (0, 0, 400, 600);
* ]|
*
* Since: 1.10
*/
#define CLUTTER_ACTOR_BOX_INIT(x_1,y_1,x_2,y_2) { (x_1), (y_1), (x_2), (y_2) }
GType clutter_actor_box_get_type (void) G_GNUC_CONST;
ClutterActorBox *clutter_actor_box_new (gfloat x_1,
gfloat y_1,
gfloat x_2,
gfloat y_2);
void clutter_actor_box_init (ClutterActorBox *box,
gfloat x_1,
gfloat y_1,
gfloat x_2,
gfloat y_2);
void clutter_actor_box_init_rect (ClutterActorBox *box,
gfloat x,
gfloat y,
gfloat width,
gfloat height);
ClutterActorBox *clutter_actor_box_copy (const ClutterActorBox *box);
void clutter_actor_box_free (ClutterActorBox *box);
gboolean clutter_actor_box_equal (const ClutterActorBox *box_a,

View File

@ -58,6 +58,8 @@ clutter_actor_box_get_type
clutter_actor_box_get_width
clutter_actor_box_get_x
clutter_actor_box_get_y
clutter_actor_box_init_rect
clutter_actor_box_init
clutter_actor_box_interpolate
clutter_actor_box_new
clutter_actor_box_set_origin

View File

@ -522,7 +522,10 @@ clutter_actor_set_shader_param_int
<SUBSECTION>
ClutterActorBox
CLUTTER_ACTOR_BOX_INIT
clutter_actor_box_new
clutter_actor_box_init
clutter_actor_box_init_rect
clutter_actor_box_copy
clutter_actor_box_free
clutter_actor_box_equal