diff --git a/clutter/clutter-actor-box.c b/clutter/clutter-actor-box.c index 9c8c79768..0a7f1562c 100644 --- a/clutter/clutter-actor-box.c +++ b/clutter/clutter-actor-box.c @@ -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); } /** diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h index 8b41f633a..f9cda7450 100644 --- a/clutter/clutter-types.h +++ b/clutter/clutter-types.h @@ -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, diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols index 558a2f6f9..3b4f8b13f 100644 --- a/clutter/clutter.symbols +++ b/clutter/clutter.symbols @@ -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 diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 6b5dc668d..09ca289b6 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -522,7 +522,10 @@ clutter_actor_set_shader_param_int 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