animatable: Allow passing a NULL animation
authorEmmanuele Bassi <ebassi@linux.intel.com>
Sat, 31 Jul 2010 09:40:21 +0000 (10:40 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Sat, 31 Jul 2010 09:56:09 +0000 (10:56 +0100)
The Animatable interface was created specifically for the Animation
class. It turns out that it might be fairly useful to others - such as
ClutterAnimator and ClutterState.

The newly-added API in this cycle for querying and accessing custom
properties should not require that we pass a ClutterAnimation to the
implementations: the Animatable itself should be enough.

This is necessary to allow language bindings to wrap
clutter_actor_animate() correctly and do type validation and
demarshalling between native values and GValues; an Animation instance
is not available until the animate() call returns, and validation must
be performed before that happens.

There is nothing we can do about the animate_property() virtual
function - but in that case we might want to be able to access the
animation from an Animatable implementation to get the Interval for
the property, just like ClutterActor does in order to animate
ClutterActorMeta objects.

clutter/clutter-actor.c
clutter/clutter-animatable.c
clutter/clutter-animatable.h
clutter/clutter-animation.c

index 863243e..6454422 100644 (file)
@@ -8613,7 +8613,6 @@ get_meta_from_animation_property (ClutterActor  *actor,
 
 static GParamSpec *
 clutter_actor_find_property (ClutterAnimatable *animatable,
-                             ClutterAnimation  *animation,
                              const gchar       *property_name)
 {
   ClutterActorMeta *meta = NULL;
@@ -8645,7 +8644,6 @@ clutter_actor_find_property (ClutterAnimatable *animatable,
 
 static void
 clutter_actor_get_initial_state (ClutterAnimatable *animatable,
-                                 ClutterAnimation  *animation,
                                  const gchar       *property_name,
                                  GValue            *initial)
 {
@@ -8666,7 +8664,6 @@ clutter_actor_get_initial_state (ClutterAnimatable *animatable,
 
 static void
 clutter_actor_set_final_state (ClutterAnimatable *animatable,
-                               ClutterAnimation  *animation,
                                const gchar       *property_name,
                                const GValue      *final)
 {
index 0674abf..be8437d 100644 (file)
@@ -128,7 +128,6 @@ clutter_animatable_animate_property (ClutterAnimatable *animatable,
 /**
  * clutter_animatable_find_property:
  * @animatable: a #ClutterAnimatable
- * @animation: a #ClutterAnimation
  * @property_name: the name of the animatable property to find
  *
  * Finds the #GParamSpec for @property_name
@@ -140,20 +139,18 @@ clutter_animatable_animate_property (ClutterAnimatable *animatable,
  */
 GParamSpec *
 clutter_animatable_find_property (ClutterAnimatable *animatable,
-                                  ClutterAnimation  *animation,
                                   const gchar       *property_name)
 {
   ClutterAnimatableIface *iface;
 
   g_return_val_if_fail (CLUTTER_IS_ANIMATABLE (animatable), NULL);
-  g_return_val_if_fail (CLUTTER_IS_ANIMATION (animation), NULL);
   g_return_val_if_fail (property_name != NULL, NULL);
 
   CLUTTER_NOTE (ANIMATION, "Looking for property '%s'", property_name);
 
   iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
   if (iface->find_property != NULL)
-    return iface->find_property (animatable, animation, property_name);
+    return iface->find_property (animatable, property_name);
 
   return g_object_class_find_property (G_OBJECT_GET_CLASS (animatable),
                                        property_name);
@@ -162,7 +159,6 @@ clutter_animatable_find_property (ClutterAnimatable *animatable,
 /**
  * clutter_animatable_get_initial_state:
  * @animatable: a #ClutterAnimatable
- * @animation: a #ClutterAnimation
  * @property_name: the name of the animatable property to retrieve
  * @value: a #GValue initialized to the type of the property to retrieve
  *
@@ -172,21 +168,19 @@ clutter_animatable_find_property (ClutterAnimatable *animatable,
  */
 void
 clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
-                                      ClutterAnimation  *animation,
                                       const gchar       *property_name,
                                       GValue            *value)
 {
   ClutterAnimatableIface *iface;
 
   g_return_if_fail (CLUTTER_IS_ANIMATABLE (animatable));
-  g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
   g_return_if_fail (property_name != NULL);
 
   CLUTTER_NOTE (ANIMATION, "Getting initial state of '%s'", property_name);
 
   iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
   if (iface->get_initial_state != NULL)
-    iface->get_initial_state (animatable, animation, property_name, value);
+    iface->get_initial_state (animatable, property_name, value);
   else
     g_object_get_property (G_OBJECT (animatable), property_name, value);
 }
@@ -194,7 +188,6 @@ clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
 /**
  * clutter_animatable_set_final_state:
  * @animatable: a #ClutterAnimatable
- * @animation: a #ClutterAnimation
  * @property_name: the name of the animatable property to set
  * @value: the value of the animatable property to set
  *
@@ -204,21 +197,19 @@ clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
  */
 void
 clutter_animatable_set_final_state (ClutterAnimatable *animatable,
-                                    ClutterAnimation  *animation,
                                     const gchar       *property_name,
                                     const GValue      *value)
 {
   ClutterAnimatableIface *iface;
 
   g_return_if_fail (CLUTTER_IS_ANIMATABLE (animatable));
-  g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
   g_return_if_fail (property_name != NULL);
 
   CLUTTER_NOTE (ANIMATION, "Setting state of property '%s'", property_name);
 
   iface = CLUTTER_ANIMATABLE_GET_IFACE (animatable);
   if (iface->set_final_state != NULL)
-    iface->set_final_state (animatable, animation, property_name, value);
+    iface->set_final_state (animatable, property_name, value);
   else
     g_object_set_property (G_OBJECT (animatable), property_name, value);
 }
index bddcc5e..2edd6b0 100644 (file)
@@ -80,14 +80,11 @@ struct _ClutterAnimatableIface
                                      gdouble            progress,
                                      GValue            *value);
   GParamSpec *(* find_property)     (ClutterAnimatable *animatable,
-                                     ClutterAnimation  *animation,
                                      const gchar       *property_name);
   void        (* get_initial_state) (ClutterAnimatable *animatable,
-                                     ClutterAnimation  *animation,
                                      const gchar       *property_name,
                                      GValue            *value);
   void        (* set_final_state)   (ClutterAnimatable *animatable,
-                                     ClutterAnimation  *animation,
                                      const gchar       *property_name,
                                      const GValue      *value);
 };
@@ -103,14 +100,11 @@ gboolean    clutter_animatable_animate_property  (ClutterAnimatable *animatable,
                                                   GValue            *value);
 
 GParamSpec *clutter_animatable_find_property     (ClutterAnimatable *animatable,
-                                                  ClutterAnimation  *animation,
                                                   const gchar       *property_name);
 void        clutter_animatable_get_initial_state (ClutterAnimatable *animatable,
-                                                  ClutterAnimation  *animation,
                                                   const gchar       *property_name,
                                                   GValue            *value);
 void        clutter_animatable_set_final_state   (ClutterAnimatable *animatable,
-                                                  ClutterAnimation  *animation,
                                                   const gchar       *property_name,
                                                   const GValue      *value);
 
index 100013a..037d771 100644 (file)
@@ -241,9 +241,7 @@ clutter_animation_real_completed (ClutterAnimation *self)
         p_value = clutter_interval_peek_initial_value (interval);
 
       if (animatable != NULL)
-        clutter_animatable_set_final_state (animatable, self,
-                                            p_name,
-                                            p_value);
+        clutter_animatable_set_final_state (animatable, p_name, p_value);
       else
         g_object_set_property (priv->object, p_name, p_value);
     }
@@ -662,9 +660,7 @@ clutter_animation_validate_bind (ClutterAnimation *animation,
     {
       ClutterAnimatable *animatable = CLUTTER_ANIMATABLE (priv->object);
 
-      pspec = clutter_animatable_find_property (animatable,
-                                                animation,
-                                                property_name);
+      pspec = clutter_animatable_find_property (animatable, property_name);
     }
   else
     {
@@ -789,7 +785,6 @@ clutter_animation_bind (ClutterAnimation *animation,
 
   if (CLUTTER_IS_ANIMATABLE (priv->object))
     clutter_animatable_get_initial_state (CLUTTER_ANIMATABLE (priv->object),
-                                          animation,
                                           property_name,
                                           &initial);
   else
@@ -901,9 +896,7 @@ clutter_animation_update_interval (ClutterAnimation *animation,
     {
       ClutterAnimatable *animatable = CLUTTER_ANIMATABLE (priv->object);
 
-      pspec = clutter_animatable_find_property (animatable,
-                                                animation,
-                                                property_name);
+      pspec = clutter_animatable_find_property (animatable, property_name);
     }
   else
     {
@@ -1101,9 +1094,7 @@ on_alpha_notify (GObject          *gobject,
       if (apply)
         {
           if (is_animatable)
-            clutter_animatable_set_final_state (animatable, animation,
-                                                p_name,
-                                                &value);
+            clutter_animatable_set_final_state (animatable, p_name, &value);
           else
             g_object_set_property (priv->object, p_name, &value);
         }
@@ -1747,7 +1738,6 @@ done:
 
       if (CLUTTER_IS_ANIMATABLE (priv->object))
         clutter_animatable_get_initial_state (CLUTTER_ANIMATABLE (priv->object),
-                                              animation,
                                               property_name,
                                               &cur_value);
       else
@@ -1773,7 +1763,6 @@ done:
     {
       if (CLUTTER_IS_ANIMATABLE (priv->object))
         clutter_animatable_set_final_state (CLUTTER_ANIMATABLE (priv->object),
-                                            animation,
                                             property_name,
                                             &real_value);
       else
@@ -1812,9 +1801,7 @@ clutter_animation_setupv (ClutterAnimation    *animation,
         }
 
       if (animatable != NULL)
-        pspec = clutter_animatable_find_property (animatable,
-                                                  animation,
-                                                  property_name);
+        pspec = clutter_animatable_find_property (animatable, property_name);
       else
         pspec = g_object_class_find_property (klass, property_name);
 
@@ -1914,7 +1901,6 @@ clutter_animation_setup_valist (ClutterAnimation *animation,
 
           if (animatable != NULL)
             pspec = clutter_animatable_find_property (animatable,
-                                                      animation,
                                                       property_name);
           else
             pspec = g_object_class_find_property (klass, property_name);