1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Migrating from ClutterBehaviour</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="Clutter Reference Manual">
8 <link rel="up" href="migration.html" title="Part IX. Migrating from previous version of Clutter">
9 <link rel="prev" href="using-cairo.html" title="Integration with Cairo">
10 <link rel="next" href="deprecated.html" title="Part X. Deprecated Classes">
11 <meta name="generator" content="GTK-Doc V1.18.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="using-cairo.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="migration.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">Clutter Reference Manual</th>
20 <td><a accesskey="n" href="deprecated.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <div class="titlepage"><div>
24 <div><h2 class="title">
25 <a name="migrating-ClutterBehaviour"></a>Migrating from ClutterBehaviour</h2></div>
26 <div><div class="author">
28 <span class="firstname">Emmanuele</span> <span class="surname">Bassi</span>
30 <div class="affiliation"><div class="address"><p><br>
31 <code class="email"><<a class="email" href="mailto:ebassilinux.intel.com">ebassi<em class="parameter"><code>linux.intel.com</code></em></a>></code><br>
35 <p>The <a class="link" href="ClutterBehaviour.html" title="ClutterBehaviour"><span class="type">ClutterBehaviour</span></a> class and its sub-classes have been deprecated
36 since Clutter 1.6. The animation framework provided by <a class="link" href="clutter-Implicit-Animations.html#ClutterAnimation"><span class="type">ClutterAnimation</span></a>,
37 <a class="link" href="ClutterAnimator.html" title="ClutterAnimator"><span class="type">ClutterAnimator</span></a> and <a class="link" href="ClutterState.html" title="ClutterState"><span class="type">ClutterState</span></a> fully replaces all functionality from the
38 <a class="link" href="ClutterBehaviour.html" title="ClutterBehaviour"><span class="type">ClutterBehaviour</span></a> classes.</p>
39 <p>Generally, animations using <a class="link" href="ClutterBehaviour.html" title="ClutterBehaviour"><span class="type">ClutterBehaviour</span></a> sub-classes can be
40 effectively re-implemented just by using <a class="link" href="ClutterActor.html" title="ClutterActor"><span class="type">ClutterActor</span></a> properties.</p>
41 <p>Here is an example of an animation using a
42 <a class="link" href="ClutterBehaviourOpacity.html" title="ClutterBehaviourOpacity"><span class="type">ClutterBehaviourOpacity</span></a> instance:</p>
43 <div class="informalexample">
44 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
47 <td class="listing_lines" align="right"><pre>1
54 <td class="listing_code"><pre class="programlisting"><span class="usertype">ClutterTimeline</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">timeline </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterTimeline.html#clutter-timeline-new">clutter_timeline_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="number">250</span><span class="symbol">);</span>
55 <span class="usertype">ClutterAlpha</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">alpha </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterAlpha.html#clutter-alpha-new-full">clutter_alpha_new_full</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">,</span><span class="normal"> <a href="clutter-Implicit-Animations.html#CLUTTER-LINEAR:CAPS">CLUTTER_LINEAR</a></span><span class="symbol">);</span>
56 <span class="usertype">ClutterBehaviour</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">behaviour </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterBehaviourOpacity.html#clutter-behaviour-opacity-new">clutter_behaviour_opacity_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">alpha</span><span class="symbol">,</span><span class="normal"> </span><span class="number">255</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">);</span>
58 <span class="function"><a href="ClutterBehaviour.html#clutter-behaviour-apply">clutter_behaviour_apply</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">behaviour</span><span class="symbol">,</span><span class="normal"> some_actor</span><span class="symbol">);</span>
60 <span class="function"><a href="ClutterTimeline.html#clutter-timeline-start">clutter_timeline_start</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">);</span></pre></td>
66 <p>The same effect can be achieved by using <a class="link" href="clutter-Implicit-Animations.html#clutter-actor-animate" title="clutter_actor_animate ()"><code class="function">clutter_actor_animate()</code></a> and
67 the <a class="link" href="ClutterActor.html#ClutterActor--opacity" title='The "opacity" property'><span class="type">"opacity"</span></a> property:</p>
68 <div class="informalexample">
69 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
72 <td class="listing_lines" align="right"><pre>1
76 <td class="listing_code"><pre class="programlisting"><span class="function"><a href="ClutterActor.html#clutter-actor-set-opacity">clutter_actor_set_opacity</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">some_actor</span><span class="symbol">,</span><span class="normal"> </span><span class="number">255</span><span class="symbol">);</span>
77 <span class="function"><a href="clutter-Implicit-Animations.html#clutter-actor-animate">clutter_actor_animate</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">some_actor</span><span class="symbol">,</span><span class="normal"> <a href="clutter-Implicit-Animations.html#CLUTTER-LINEAR:CAPS">CLUTTER_LINEAR</a></span><span class="symbol">,</span><span class="normal"> </span><span class="number">250</span><span class="symbol">,</span>
78 <span class="normal"> </span><span class="string">"opacity"</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span>
79 <span class="normal"> <a href="/home/ebassi/gnome3/install/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS">NULL</a></span><span class="symbol">);</span></pre></td>
85 <p><a class="link" href="ClutterBehaviour.html" title="ClutterBehaviour"><span class="type">ClutterBehaviour</span></a>s used for continuous animations with looping
86 timelines can still be effectively replaced by looping animations; for
87 instance, the following example of a "pulsating" actor using
88 <a class="link" href="ClutterBehaviourScale.html" title="ClutterBehaviourScale"><span class="type">ClutterBehaviourScale</span></a>:</p>
89 <div class="informalexample">
90 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
93 <td class="listing_lines" align="right"><pre>1
122 <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
123 <span class="function">reverse_timeline</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">ClutterTimeline</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">timeline</span><span class="symbol">)</span>
124 <span class="cbracket">{</span>
125 <span class="normal"> </span><span class="usertype">ClutterTimelineDirection</span><span class="normal"> dir </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterTimeline.html#clutter-timeline-get-direction">clutter_timeline_get_direction</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">);</span>
127 <span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">dir </span><span class="symbol">==</span><span class="normal"> <a href="ClutterTimeline.html#CLUTTER-TIMELINE-FORWARD:CAPS">CLUTTER_TIMELINE_FORWARD</a></span><span class="symbol">)</span>
128 <span class="normal"> dir </span><span class="symbol">=</span><span class="normal"> <a href="ClutterTimeline.html#CLUTTER-TIMELINE-BACKWARD:CAPS">CLUTTER_TIMELINE_BACKWARD</a></span><span class="symbol">;</span>
129 <span class="normal"> </span><span class="keyword">else</span>
130 <span class="normal"> dir </span><span class="symbol">=</span><span class="normal"> <a href="ClutterTimeline.html#CLUTTER-TIMELINE-FORWARD:CAPS">CLUTTER_TIMELINE_FORWARD</a></span><span class="symbol">;</span>
132 <span class="normal"> </span><span class="function"><a href="ClutterTimeline.html#clutter-timeline-set-direction">clutter_timeline_set_direction</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">,</span><span class="normal"> dir</span><span class="symbol">);</span>
133 <span class="cbracket">}</span>
135 <span class="normal"> </span><span class="usertype">ClutterTimeline</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">timeline </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterTimeline.html#clutter-timeline-new">clutter_timeline_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="number">500</span><span class="symbol">);</span>
136 <span class="normal"> </span><span class="usertype">ClutterAlpha</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">alpha </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterAlpha.html#clutter-alpha-new-full">clutter_alpha_new_full</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">,</span><span class="normal"> <a href="clutter-Implicit-Animations.html#CLUTTER-LINEAR:CAPS">CLUTTER_LINEAR</a></span><span class="symbol">);</span>
137 <span class="normal"> </span><span class="usertype">ClutterBehaviour</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">behaviour</span><span class="symbol">;</span>
139 <span class="normal"> </span><span class="function">g_object_set</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">some_actor</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"scale-gravity"</span><span class="symbol">,</span><span class="normal"> <a href="ClutterBehaviourScale.html#CLUTTER-GRAVITY-CENTER:CAPS">CLUTTER_GRAVITY_CENTER</a></span><span class="symbol">,</span><span class="normal"> <a href="/home/ebassi/gnome3/install/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS">NULL</a></span><span class="symbol">);</span>
140 <span class="normal"> behaviour </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="ClutterBehaviourScale.html#clutter-behaviour-scale-new">clutter_behaviour_scale_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">alpha</span><span class="symbol">,</span>
141 <span class="normal"> </span><span class="number">1.0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2.0</span><span class="symbol">,</span>
142 <span class="normal"> </span><span class="number">1.0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2.0</span><span class="symbol">);</span>
143 <span class="normal"> </span><span class="function"><a href="ClutterBehaviour.html#clutter-behaviour-apply">clutter_behaviour_apply</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">behaviour</span><span class="symbol">,</span><span class="normal"> some_actor</span><span class="symbol">);</span>
145 <span class="normal"> </span><span class="function">g_signal_connect</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">,</span>
146 <span class="normal"> </span><span class="string">"completed"</span><span class="symbol">,</span><span class="normal"> </span><span class="function">G_CALLBACK</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">reverse_timeline</span><span class="symbol">),</span>
147 <span class="normal"> <a href="/home/ebassi/gnome3/install/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS">NULL</a></span><span class="symbol">);</span>
149 <span class="normal"> </span><span class="function"><a href="ClutterTimeline.html#clutter-timeline-set-loop">clutter_timeline_set_loop</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">);</span>
150 <span class="normal"> </span><span class="function"><a href="ClutterTimeline.html#clutter-timeline-start">clutter_timeline_start</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">);</span></pre></td>
156 <p>The same effect can be achieved using a <a class="link" href="clutter-Implicit-Animations.html#ClutterAnimation"><span class="type">ClutterAnimation</span></a>:</p>
157 <div class="informalexample">
158 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
161 <td class="listing_lines" align="right"><pre>1
171 <td class="listing_code"><pre class="programlisting"><span class="usertype">ClutterAnimation</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">animation </span><span class="symbol">=</span>
172 <span class="normal"> </span><span class="function"><a href="clutter-Implicit-Animations.html#clutter-actor-animate">clutter_actor_animate</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">some_actor</span><span class="symbol">,</span><span class="normal"> <a href="clutter-Implicit-Animations.html#CLUTTER-LINEAR:CAPS">CLUTTER_LINEAR</a></span><span class="symbol">,</span><span class="normal"> </span><span class="number">500</span><span class="symbol">,</span>
173 <span class="normal"> </span><span class="string">"scale-x"</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2.0</span><span class="symbol">,</span>
174 <span class="normal"> </span><span class="string">"scale-y"</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2.0</span><span class="symbol">,</span>
175 <span class="normal"> </span><span class="string">"fixed::scale-gravity"</span><span class="symbol">,</span><span class="normal"> <a href="ClutterBehaviourScale.html#CLUTTER-GRAVITY-CENTER:CAPS">CLUTTER_GRAVITY_CENTER</a></span><span class="symbol">,</span>
176 <span class="normal"> <a href="/home/ebassi/gnome3/install/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS">NULL</a></span><span class="symbol">);</span>
178 <span class="usertype">ClutterTimeline</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">timeline </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="clutter-Implicit-Animations.html#clutter-animation-get-timeline">clutter_animation_get_timeline</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">animation</span><span class="symbol">);</span>
179 <span class="function"><a href="ClutterTimeline.html#clutter-timeline-set-repeat-count">clutter_timeline_set_repeat_count</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">1</span><span class="symbol">);</span>
180 <span class="function"><a href="ClutterTimeline.html#clutter-timeline-set-auto-reverse">clutter_timeline_set_auto_reverse</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeline</span><span class="symbol">,</span><span class="normal"> TRUE</span><span class="symbol">);</span></pre></td>
186 <p><a class="link" href="ClutterBehaviour.html" title="ClutterBehaviour"><span class="type">ClutterBehaviour</span></a> sub-classes can be applied to multiple actors, in
187 order to share the duration and the easing mode. It is possible to use the
188 same underlying <a class="link" href="ClutterTimeline.html" title="ClutterTimeline"><span class="type">ClutterTimeline</span></a> and <a class="link" href="ClutterAlpha.html" title="ClutterAlpha"><span class="type">ClutterAlpha</span></a> instances with
189 <a class="link" href="clutter-Implicit-Animations.html#ClutterAnimation"><span class="type">ClutterAnimation</span></a> to achieve the same effect. Complex animations, spanning
190 multiple actors, should use the <a class="link" href="ClutterAnimator.html" title="ClutterAnimator"><span class="type">ClutterAnimator</span></a> and <a class="link" href="ClutterState.html" title="ClutterState"><span class="type">ClutterState</span></a> classes
195 Generated by GTK-Doc V1.18.1</div>