diff --git a/ChangeLog b/ChangeLog index 041ebda0f..f8d9a65d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-02-15 Tomas Frydrych + + * clutter/clutter-actor.c: + * clutter/clutter-actor.h: + (clutter_group_query_coords): + Added function to translate vertex array to a bounding box. + + (clutter_actor_is_scaled): + (clutter_actor_is_rotated): + Fixed documentation. + 2008-02-15 Tomas Frydrych * clutter/clutter-group.c: (clutter_group_query_coords): diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 06ca83ec8..6f262af48 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -5520,7 +5520,9 @@ clutter_actor_set_shader_param (ClutterActor *self, * clutter_actor_is_rotated: * @self: a #ClutterActor * - * Returns true if any rotation is applied to the actor. + * Checks whether any rotation is applied to the actor. + * + * Return value: %TRUE if the actor is rotated. * * Since: 0.6 */ @@ -5543,7 +5545,9 @@ clutter_actor_is_rotated (ClutterActor *self) * clutter_actor_is_scaled: * @self: a #ClutterActor * - * Returns true if the actor is scaled in either dimension. + * Checks whether the actor is scaled in either dimension. + * + * Return value: %TRUE if the actor is scaled. * * Since: 0.6 */ @@ -5562,3 +5566,55 @@ clutter_actor_is_scaled (ClutterActor *self) return FALSE; } +/** + * clutter_actor_get_box_from_vertices: + * @vtx: array of four #ClutterVertex + * @box: pointer to #ClutterActorBox where to store the result + * + * Calculates the bounding box represented by the four vertices; for details + * of the vertex array see clutter_actor_get_vertices(). + * + * Since: 0.6 + */ +void +clutter_actor_get_box_from_vertices (ClutterVertex vtx[4], + ClutterActorBox *box) +{ + ClutterUnit x1, x2, y1, y2; + + /* 4-way min/max */ + x1 = vtx[0].x; + y1 = vtx[0].y; + if (vtx[1].x < x1) + x1 = vtx[1].x; + if (vtx[2].x < x1) + x1 = vtx[2].x; + if (vtx[3].x < x1) + x1 = vtx[3].x; + if (vtx[1].y < y1) + y1 = vtx[1].y; + if (vtx[2].y < y1) + y1 = vtx[2].y; + if (vtx[3].y < y1) + y1 = vtx[3].y; + + x2 = vtx[0].x; + y2 = vtx[0].y; + if (vtx[1].x > x2) + x2 = vtx[1].x; + if (vtx[2].x > x2) + x2 = vtx[2].x; + if (vtx[3].x > x2) + x2 = vtx[3].x; + if (vtx[1].y > y2) + y2 = vtx[1].y; + if (vtx[2].y > y2) + y2 = vtx[2].y; + if (vtx[3].y > y2) + y2 = vtx[3].y; + + box->x1 = x1; + box->x2 = x2; + box->y1 = y1; + box->y2 = y2; +} diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 5a855d907..4cf39ccd1 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -461,6 +461,9 @@ gboolean clutter_actor_transform_stage_point (ClutterActor *self, gboolean clutter_actor_is_rotated (ClutterActor *self); gboolean clutter_actor_is_scaled (ClutterActor *self); +void clutter_actor_get_box_from_vertices (ClutterVertex vtx[4], + ClutterActorBox *box); + G_END_DECLS #endif /* _HAVE_CLUTTER_ACTOR_H */ diff --git a/clutter/clutter-group.c b/clutter/clutter-group.c index b49f1cff9..03b428343 100644 --- a/clutter/clutter-group.c +++ b/clutter/clutter-group.c @@ -148,49 +148,6 @@ clutter_group_request_coords (ClutterActor *self, CLUTTER_ACTOR_CLASS (clutter_group_parent_class)->request_coords (self, box); } -static void -clutter_group_get_box_from_vertices (ClutterActorBox *box, - ClutterVertex vtx[4]) -{ - ClutterUnit x1, x2, y1, y2; - - /* 4-way min/max */ - x1 = vtx[0].x; - y1 = vtx[0].y; - if (vtx[1].x < x1) - x1 = vtx[1].x; - if (vtx[2].x < x1) - x1 = vtx[2].x; - if (vtx[3].x < x1) - x1 = vtx[3].x; - if (vtx[1].y < y1) - y1 = vtx[1].y; - if (vtx[2].y < y1) - y1 = vtx[2].y; - if (vtx[3].y < y1) - y1 = vtx[3].y; - - x2 = vtx[0].x; - y2 = vtx[0].y; - if (vtx[1].x > x2) - x2 = vtx[1].x; - if (vtx[2].x > x2) - x2 = vtx[2].x; - if (vtx[3].x > x2) - x2 = vtx[3].x; - if (vtx[1].y > y2) - y2 = vtx[1].y; - if (vtx[2].y > y2) - y2 = vtx[2].y; - if (vtx[3].y > y2) - y2 = vtx[3].y; - - box->x1 = x1; - box->x2 = x2; - box->y1 = y1; - box->y2 = y2; -} - static void clutter_group_query_coords (ClutterActor *self, ClutterActorBox *box) @@ -220,7 +177,7 @@ clutter_group_query_coords (ClutterActor *self, ClutterVertex vtx[4]; clutter_actor_get_relative_vertices (child, self, vtx); - clutter_group_get_box_from_vertices (&cbox, vtx); + clutter_actor_get_box_from_vertices (vtx, &cbox); } else #endif