From 999359d64ccfbdbcc952662c14fa47441d6a5225 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 11 Dec 2009 23:48:58 +0000 Subject: [PATCH] Add ActorBox animation methods ClutterActorBox should have an interpolate() method that allows to compute the intermediate values between two states, given a progress value, e.g.: clutter_actor_box_interpolate (start, end, alpha, &result); Another utility method, useful for layout managers, is a modifier that clamps the members of the actor box to the nearest integer value. --- clutter/clutter-actor.c | 47 ++++++++++++++++++++++ clutter/clutter-types.h | 5 +++ doc/reference/clutter/clutter-sections.txt | 2 + 3 files changed, 54 insertions(+) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index f676d5e3b..c439437d0 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -8317,6 +8317,53 @@ clutter_actor_box_from_vertices (ClutterActorBox *box, box->y2 = y_2; } +/** + * clutter_actor_box_interpolate: + * @initial: the initial #ClutterActorBox + * @final: the final #ClutterActorBox + * @progress: the interpolation progress + * @result: (out): return location for the interpolation + * + * Interpolates between @initial and @final #ClutterActorBoxes + * using @progress + * + * Since: 1.2 + */ +void +clutter_actor_box_interpolate (const ClutterActorBox *initial, + const ClutterActorBox *final, + gdouble progress, + ClutterActorBox *result) +{ + g_return_if_fail (initial != NULL); + g_return_if_fail (final != NULL); + g_return_if_fail (result != NULL); + + result->x1 = initial->x1 + (final->x1 - initial->x1) * progress; + result->y1 = initial->y1 + (final->y1 - initial->y1) * progress; + result->x2 = initial->x2 + (final->x2 - initial->x2) * progress; + result->y2 = initial->y2 + (final->y2 - initial->y2) * progress; +} + +/** + * clutter_actor_box_clamp_to_pixel: + * @box: (inout): the #ClutterActorBox to clamp + * + * Clamps the components of @box to the nearest integer + * + * Since: 1.2 + */ +void +clutter_actor_box_clamp_to_pixel (ClutterActorBox *box) +{ + g_return_if_fail (box != NULL); + + box->x1 = floorf (box->x1 + 0.5); + box->y1 = floorf (box->y1 + 0.5); + box->x2 = floorf (box->x2 + 0.5); + box->y2 = floorf (box->y2 + 0.5); +} + /******************************************************************************/ struct _ShaderData diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h index ec7502310..b13a4dfed 100644 --- a/clutter/clutter-types.h +++ b/clutter/clutter-types.h @@ -153,6 +153,11 @@ gboolean clutter_actor_box_contains (const ClutterActorBox *box, gfloat y); void clutter_actor_box_from_vertices (ClutterActorBox *box, const ClutterVertex verts[]); +void clutter_actor_box_interpolate (const ClutterActorBox *initial, + const ClutterActorBox *final, + gdouble progress, + ClutterActorBox *result); +void clutter_actor_box_clamp_to_pixel (ClutterActorBox *box); /** * ClutterGeometry: diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index e7dafd772..d90358739 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -414,6 +414,8 @@ clutter_actor_box_get_size clutter_actor_box_get_area clutter_actor_box_contains clutter_actor_box_from_vertices +clutter_actor_box_clamp_to_pixel +clutter_actor_box_interpolate ClutterVertex