From bfb51adf97e3a702c47d3c5d0b7c2a575caf8ddc Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Fri, 9 Jul 2010 11:27:57 +0100 Subject: [PATCH 1/3] docs: Enabled animation section --- doc/cookbook/clutter-cookbook.xml.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/cookbook/clutter-cookbook.xml.in b/doc/cookbook/clutter-cookbook.xml.in index f6d858387..c0ea9ce43 100644 --- a/doc/cookbook/clutter-cookbook.xml.in +++ b/doc/cookbook/clutter-cookbook.xml.in @@ -42,9 +42,7 @@ - Contributing to this document From 6a443a0cd3a7a661d3cf727f682d636c3dab08a1 Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Mon, 12 Jul 2010 15:34:23 +0100 Subject: [PATCH 2/3] cookbook: Added "inverting an animation" recipe Added a new recipe (based on the skeleton in the animations section of the cookbook) about inverting an animation by reversing the direction of its timeline. Uses clutter_actor_animate() as the basic approach, but mentions ClutterState and ClutterAnimator as well. --- doc/cookbook/animations.xml | 149 +++++++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 3 deletions(-) diff --git a/doc/cookbook/animations.xml b/doc/cookbook/animations.xml index 1c310060a..4cdcf840e 100644 --- a/doc/cookbook/animations.xml +++ b/doc/cookbook/animations.xml @@ -15,7 +15,7 @@ introduction -
+
Inverting Animations
@@ -28,13 +28,156 @@
Solution - ... + Reverse the direction of the ClutterTimeline + associated with the animation. + + For example, here's how to invert an implicit + animation which moves an actor along the x + axis. The direction of the animation is inverted when the + movement along the x axis is completed; it is + also inverted if the mouse button is pressed on the actor. + + First, set up the animation: + + + + + + + + Next, add a function for inverting the timeline: + + + + + + + + Then add a function which calls _invert_timeline + when the animation completes. More importantly, the callback should + stop emission of the "completed" signal by the animation. This + prevents the ClutterAnimation underlying the implicit + animation from being unreferenced; which in turn allows it to be + inverted: + + + + + + + + Finally, the click callback function uses the same + _invert_timeline function if the animation + is playing; but if the animation is stopped, it will + start it instead: + + + + + + +
Discussion - ... + If you are using ClutterAnimator rather than + implicit animations, clutter_animator_get_timeline() + enables you to get the underlying timeline; you could then use + the techniques shown above to invert it. + + ClutterState enables a different approach + to "inverting" an animation: rather than having a single animation + which you invert, you would define two or more + keys for an actor (or set of actors) and + transition between them. + + For the example above, you would define two keys: + one for the actor's initial position; and a second for the actor + at x = 300.0. You would also define the + transition between them: 2000 milliseconds with a + CLUTTER_EASE_IN_OUT_CUBIC easing mode. + + With the states defined, you would then use + clutter_state_set_state() inside callbacks to + animate the actor between the two x positions. + Behind the scenes, ClutterState would handle the + animations and timelines for you. +
From 9d96c21de6578efeb6099295da8c4cb1e189dad8 Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Mon, 12 Jul 2010 16:59:38 +0100 Subject: [PATCH 3/3] cookbook: Fixed invalid XML tag --- doc/cookbook/animations.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cookbook/animations.xml b/doc/cookbook/animations.xml index 4cdcf840e..20b0af580 100644 --- a/doc/cookbook/animations.xml +++ b/doc/cookbook/animations.xml @@ -155,7 +155,7 @@ _on_click_cb (ClutterActor *actor,
Discussion - If you are using ClutterAnimator rather than + If you are using ClutterAnimator rather than implicit animations, clutter_animator_get_timeline() enables you to get the underlying timeline; you could then use the techniques shown above to invert it.