diff --git a/doc/reference/clutter/Makefile.am b/doc/reference/clutter/Makefile.am index 06353f7e9..f85fe1a62 100644 --- a/doc/reference/clutter/Makefile.am +++ b/doc/reference/clutter/Makefile.am @@ -133,7 +133,8 @@ content_files= \ building-clutter.xml \ running-clutter.xml \ migrating-ClutterEffect.xml \ - migrating-ClutterPath.xml + migrating-ClutterPath.xml \ + migrating-ClutterBehaviour.xml # SGML files where gtk-doc abbrevations (#GtkWidget) are expanded # These files must be listed here *and* in content_files @@ -147,7 +148,8 @@ expand_content_files= \ building-clutter.xml \ running-clutter.xml \ migrating-ClutterEffect.xml \ - migrating-ClutterPath.xml + migrating-ClutterPath.xml \ + migrating-ClutterBehaviour.xml # CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. # Only needed if you are using gtkdoc-scangobj to dynamically query widget diff --git a/doc/reference/clutter/migrating-ClutterBehaviour.xml b/doc/reference/clutter/migrating-ClutterBehaviour.xml new file mode 100644 index 000000000..20dd1f6d7 --- /dev/null +++ b/doc/reference/clutter/migrating-ClutterBehaviour.xml @@ -0,0 +1,122 @@ + + + + + + + Emmanuele + Bassi + +
+ ebassi@linux.intel.com +
+
+
+
+ + Migrating from ClutterBehaviour + + The #ClutterBehaviour class and its sub-classes have been deprecated + since Clutter 1.6. The animation framework provided by #ClutterAnimation, + #ClutterAnimator and #ClutterState fully replaces all functionality from the + #ClutterBehaviour classes. + + Generally, animations using #ClutterBehaviour sub-classes can be + effectively re-implemented just by using #ClutterActor properties. + + Here is an example of an animation using a + #ClutterBehaviourOpacity instance: + + + + ClutterTimeline *timeline = clutter_timeline_new (250); + ClutterAlpha *alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); + ClutterBehaviour *behaviour = clutter_behaviour_opacity_new (alpha, 255, 0); + + clutter_behaviour_apply (behaviour, some_actor); + + clutter_timeline_start (timeline); + + + + The same effect can be achieved by using clutter_actor_animate() and + the #ClutterActor:opacity property: + + + + clutter_actor_set_opacity (some_actor, 255); + clutter_actor_animate (some_actor, CLUTTER_LINEAR, 250, + "opacity", 0, + NULL); + + + + #ClutterBehaviours used for continuous animations with looping + timelines can still be effectively replaced by looping animations; for + instance, the following example of a "pulsating" actor using + #ClutterBehaviourScale: + + + +static void +reverse_timeline (ClutterTimeline *timeline) +{ + ClutterTimelineDirection dir = clutter_timeline_get_direction (timeline); + + if (dir == CLUTTER_TIMELINE_FORWARD) + dir = CLUTTER_TIMELINE_BACKWARD; + else + dir = CLUTTER_TIMELINE_FORWARD; + + clutter_timeline_set_direction (timeline, dir); +} + + ClutterTimeline *timeline = clutter_timeline_new (500); + ClutterAlpha *alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); + ClutterBehaviour *behaviour; + + g_object_set (some_actor, "scale-gravity", CLUTTER_GRAVITY_CENTER, NULL); + behaviour = clutter_behaviour_scale_new (alpha, + 1.0, 2.0, + 1.0, 2.0); + clutter_behaviour_apply (behaviour, some_actor); + + g_signal_connect (timeline, + "completed", G_CALLBACK (reverse_timeline), + NULL); + + clutter_timeline_set_loop (timeline); + clutter_timeline_start (timeline); + + + + The same effect can be achieved using a #ClutterAnimation: + + + + ClutterAnimation *animation = + clutter_actor_animate (some_actor, CLUTTER_LINEAR, 500, + "scale-x", 2.0, + "scale-y", 2.0, + "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER, + NULL); + + clutter_animation_set_loop (animation, TRUE); + + g_signal_connect (clutter_animation_get_timeline (animation), + "completed", G_CALLBACK (reverse_timeline), + NULL); + + + + #ClutterBehaviour sub-classes can be applied to multiple actors, in + order to share the duration and the easing mode. It is possible to use the + same underlying #ClutterTimeline and #ClutterAlpha instances with + #ClutterAnimation to achieve the same effect. Complex animations, spanning + multiple actors, should use the #ClutterAnimator and #ClutterState classes + instead. + +