[animation] Rework animation chaining
authorEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 15 Jun 2009 09:53:43 +0000 (10:53 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 15 Jun 2009 10:49:33 +0000 (11:49 +0100)
commit9799750c0338218a542334c9f4dbf2177beafa4f
treea147bab035c05e6f1d4155cf36e030dd4c048661
parent612d1cded77c07b6a4884e5ec3c0bf5b8929bff9
[animation] Rework animation chaining

In order to chain up animations using clutter_actor_animate() and
friends you have to use an idle handler that guarantees that the
main loop spins at least once after the animation pointer has been
detached from the actor.

This has several drawbacks, first and foremost the fact that the
slice of the main loop for the idle handler might be starved by
other operations, like redrawing. This inevitably leads to tricks
with priorities and the like, contributing to the overall complexity.

Instead, we should guarantee that the animation instance created by
clutter_actor_animate() is valid for the ::completed signal until
it reaches its default handler; after that, the animation is detached
from the actor and destroyed. This means that it's possible to
create a new animation after the first is complete by simply using
g_signal_connect_after().

This unfortunately makes it impossible to keep a reference to the
animation pointer attached to the actor by using g_object_ref(); a
way to "fix" this would be to have a clutter_animation_attach()
and a clutter_animation_detach() pair of methods that allow attaching
any animation to an actor. This might overcomplicate what it is
the simple animation API, though, so it's currently not implemented
and left for future versions.

The test-easing interactive demo has been modified to show how
the animation queuing works by adding a command line switch that
recenters the animated actor once the first animation has ended.
clutter/clutter-animation.c
tests/interactive/test-easing.c