From 60cfa5edb241a4115e36d4d67374f3e87a4bb688 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 8 Jan 2009 12:59:16 +0000 Subject: [PATCH] [animation] Use ClutterAnimatable inside Animation ClutterAnimation should check if the object is implementing the Animatable interface, and if so delegate to it the computation of the value along the interval initial and final value, depending on the progress. --- clutter/clutter-animation.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-animation.c b/clutter/clutter-animation.c index f27d9da3e..9cff31d07 100644 --- a/clutter/clutter-animation.c +++ b/clutter/clutter-animation.c @@ -50,6 +50,7 @@ #include #include "clutter-alpha.h" +#include "clutter-animatable.h" #include "clutter-animation.h" #include "clutter-debug.h" #include "clutter-enum-types.h" @@ -664,9 +665,17 @@ on_alpha_notify (GObject *gobject, ClutterAnimationPrivate *priv = animation->priv; GList *properties, *p; guint32 alpha_value; + gboolean is_animatable = FALSE; + ClutterAnimatable *animatable = NULL; alpha_value = clutter_alpha_get_alpha (CLUTTER_ALPHA (gobject)); + if (CLUTTER_IS_ANIMATABLE (priv->actor)) + { + animatable = CLUTTER_ANIMATABLE (priv->actor); + is_animatable = TRUE; + } + g_object_freeze_notify (G_OBJECT (priv->actor)); properties = g_hash_table_get_keys (priv->properties); @@ -684,8 +693,29 @@ on_alpha_notify (GObject *gobject, factor = (gdouble) alpha_value / CLUTTER_ALPHA_MAX_ALPHA; - if (clutter_interval_compute_value (interval, factor, &value)) - g_object_set_property (G_OBJECT (priv->actor), p_name, &value); + if (is_animatable) + { + const GValue *initial, *final; + + initial = clutter_interval_peek_initial_value (interval); + final = clutter_interval_peek_final_value (interval); + + CLUTTER_NOTE (ANIMATION, "Animatable property `%s'", p_name); + clutter_animatable_animate_property (animatable, animation, + p_name, + initial, final, + factor, + &value); + + g_object_set_property (G_OBJECT (priv->actor), p_name, &value); + } + else + { + CLUTTER_NOTE (ANIMATION, "Standard property `%s'", p_name); + + if (clutter_interval_compute_value (interval, factor, &value)) + g_object_set_property (G_OBJECT (priv->actor), p_name, &value); + } g_value_unset (&value); }