[docs] Update the "creating new behaviours" chapter
The signature of the ::alpha_notify virtual function has been changed with the switch to float ClutterAlpha.
This commit is contained in:
parent
c87fea6cf1
commit
ed005685c9
@ -12,50 +12,40 @@
|
|||||||
</chapterinfo>
|
</chapterinfo>
|
||||||
|
|
||||||
<title>Creating You Own Behaviours</title>
|
<title>Creating You Own Behaviours</title>
|
||||||
<para>
|
<para>Clutter comes with a number of fairly generic prebuilt behaviour
|
||||||
|
|
||||||
Clutter comes with a number of fairly generic prebuilt behaviour
|
|
||||||
classes which provide a basis for transitions, animations and other
|
classes which provide a basis for transitions, animations and other
|
||||||
visual effects. However even with the ability to combine a number of
|
visual effects. However even with the ability to combine a number of
|
||||||
these behaviours sometimes they are not enough and a custom
|
these behaviours sometimes they are not enough and a custom behaviour
|
||||||
behaviour is needed to create a spcific animation.
|
is needed to create a spcific animation.</para>
|
||||||
|
|
||||||
</para>
|
<para>In order to implement a new #ClutterBehaviour subclass the usual
|
||||||
|
|
||||||
<para>
|
|
||||||
|
|
||||||
In order to implement a new #ClutterBehaviour subclass the usual
|
|
||||||
machinery for subclassing a GObject should be used. The new subclass
|
machinery for subclassing a GObject should be used. The new subclass
|
||||||
then just overides the ClutterBehaviour::alpha_notify() method. This
|
then just overides the #ClutterBehaviour::alpha_notify() method. This
|
||||||
method is passed an alpha value which is then used to compute
|
method is passed an alpha value which is then used to compute
|
||||||
modifications to any actors the behaviour is applied to.
|
modifications to any actors the behaviour is applied to.</para>
|
||||||
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<example id="clutter-behaviour-alpha-notify-example">
|
<example id="clutter-behaviour-alpha-notify-example">
|
||||||
|
<title>Implementing the alpha-notify virtual function<title>
|
||||||
<para>This example demonstrates a behaviour that produces a vertical
|
<para>This example demonstrates a behaviour that produces a vertical
|
||||||
'wipe' like affect by modifying the actors clip region</para>
|
'wipe' like affect by modifying the actors clip region</para>
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
static void
|
static void
|
||||||
clutter_behaviour_foo_alpha_notify (ClutterBehaviour *behaviour,
|
clutter_behaviour_foo_alpha_notify (ClutterBehaviour *behaviour,
|
||||||
guint32 alpha_value)
|
gdouble factor)
|
||||||
{
|
{
|
||||||
ClutterActor *actor
|
ClutterActor *actor
|
||||||
gint i, n;
|
gint i, n;
|
||||||
gdouble factor;
|
|
||||||
|
|
||||||
/* Normalise alpha value */
|
|
||||||
factor = (gdouble) alpha_value / CLUTTER_ALPHA_MAX_ALPHA;
|
|
||||||
|
|
||||||
n = clutter_behaviour_get_n_actors (behaviour);
|
n = clutter_behaviour_get_n_actors (behaviour);
|
||||||
|
|
||||||
/* Change clip height of each applied actor. Note usually better to use
|
/* Change clip height of each applied actor. Note that it is
|
||||||
* clutter_behaviour_actors_foreach () for performance reasons.
|
* usually better to use clutter_behaviour_actors_foreach()
|
||||||
|
* to avoid iterating multiple times
|
||||||
*/
|
*/
|
||||||
for (i = 0; i<n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
int clip_height;
|
gfloat clip_height;
|
||||||
|
|
||||||
actor = clutter_behaviour_get_nth_actor (behaviour, i);
|
actor = clutter_behaviour_get_nth_actor (behaviour, i);
|
||||||
|
|
||||||
@ -72,10 +62,7 @@ clutter_behaviour_foo_alpha_notify (ClutterBehaviour *behaviour,
|
|||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>If the new behaviour is meant to set an initial state on the
|
||||||
If the new behaviour is meant to set an initial state on the
|
|
||||||
actors to which its applied to, then the ClutterBehaviour::applied
|
actors to which its applied to, then the ClutterBehaviour::applied
|
||||||
signal class handler should be overridden.
|
signal class handler should be overridden.</para>
|
||||||
</para>
|
|
||||||
|
|
||||||
</chapter>
|
</chapter>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user