![]() |
![]() |
![]() |
Clutter 0.2 Reference Manual | ![]() |
---|---|---|---|---|
ClutterBehaviour; ClutterBehaviourClass; void clutter_behaviour_apply (ClutterBehaviour *behave, ClutterActor *actor); void clutter_behaviour_remove (ClutterBehaviour *behave, ClutterActor *actor); void (*ClutterBehaviourForeachFunc) (ClutterBehaviour *behaviour, ClutterActor *actor, gpointer data); void clutter_behaviour_actors_foreach (ClutterBehaviour *behave, ClutterBehaviourForeachFunc func, gpointer data); GSList* clutter_behaviour_get_actors (ClutterBehaviour *behave); gint clutter_behaviour_get_n_actors (ClutterBehaviour *behave); ClutterActor* clutter_behaviour_get_nth_actor (ClutterBehaviour *behave, gint index); ClutterAlpha* clutter_behaviour_get_alpha (ClutterBehaviour *behave); void clutter_behaviour_set_alpha (ClutterBehaviour *behave, ClutterAlpha *alpha);
GObject +----ClutterBehaviour +----ClutterBehaviourOpacity +----ClutterBehaviourPath +----ClutterBehaviourScale
ClutterBehaviour is the base class for implementing behaviours. A behaviour is a controller object for ClutterActors; you can use a behaviour to control one or more properties of an actor (such as its opacity, or its position). A ClutterBehaviour is driven by an "alpha function" stored inside a ClutterAlpha object; an alpha function is a function depending solely on time. The alpha function computes a value which is then applied to the properties of the actors driven by a behaviour.
Clutter provides some pre-defined behaviours, like ClutterBehaviourPath, which controls the position of a set of actors making them "walk" along a set of nodes; ClutterBehaviourOpacity, which controls the opacity of a set of actors; ClutterBehaviourScale, which controls the width and height of a set of actors.
In order to implement a new behaviour you should subclass ClutterBehaviour and override the "alpha_notify" virtual function; inside the overridden function you should obtain the alpha value from the ClutterAlpha instance bound to the behaviour and apply it to the desiderd property (or properties) of every actor controlled by the behaviour.
typedef struct { GObjectClass parent_class; /* vfunc, not signal */ void (*alpha_notify) (ClutterBehaviour *behave, guint32 alpha_value); /* padding, for future expansion */ void (*_clutter_behaviour1) (void); void (*_clutter_behaviour2) (void); void (*_clutter_behaviour3) (void); void (*_clutter_behaviour4) (void); void (*_clutter_behaviour5) (void); void (*_clutter_behaviour6) (void); } ClutterBehaviourClass;
Class structure.
GObjectClass parent_class ; |
parent class |
alpha_notify () |
Override this virtual function when creating a new behaviour. The alpha notify virtual function is called each time the alpha value computed by the ClutterAlpha object changes; in this virtual function you should update the properties driven by your behaviour for all the actors to which the behaviour applies. |
_clutter_behaviour1 () |
|
_clutter_behaviour2 () |
|
_clutter_behaviour3 () |
|
_clutter_behaviour4 () |
|
_clutter_behaviour5 () |
|
_clutter_behaviour6 () |
void clutter_behaviour_apply (ClutterBehaviour *behave, ClutterActor *actor);
Applies behave
to actor
. This function adds a reference on
the actor.
behave : |
a ClutterBehaviour |
actor : |
a ClutterActor |
Since 0.2
void clutter_behaviour_remove (ClutterBehaviour *behave, ClutterActor *actor);
Removes actor
from the list of ClutterActors to which
behave
applies. This function removes a reference on the actor.
behave : |
a ClutterBehaviour |
actor : |
a ClutterActor |
Since 0.2
void (*ClutterBehaviourForeachFunc) (ClutterBehaviour *behaviour, ClutterActor *actor, gpointer data);
The function used to iterate on every ClutterActor to which a behaviour applies.
behaviour : |
a ClutterBehaviour |
actor : |
a ClutterActor |
data : |
optional user data passed to this function |
void clutter_behaviour_actors_foreach (ClutterBehaviour *behave, ClutterBehaviourForeachFunc func, gpointer data);
Calls func
for every actor driven by behave
.
behave : |
a ClutterBehaviour |
func : |
a function called for each actor |
data : |
optional data to be passed to the function, or NULL
|
Since 0.2
GSList* clutter_behaviour_get_actors (ClutterBehaviour *behave);
Retrieves all the actors to which behave
applies. It is not recommended
derived classes use this in there alpha notify method but use
clutter_behaviour_actors_foreach as it avoids alot of needless allocations.
behave : |
a ClutterBehaviour |
Returns : | a list of actors. You should free the returned list
with g_slist_free() when finished using it.
|
Since 0.2
gint clutter_behaviour_get_n_actors (ClutterBehaviour *behave);
Gets the number of actors this behaviour is applied too.
behave : |
a ClutterBehaviour |
Returns : | The number of applied actors |
Since 0.2
ClutterActor* clutter_behaviour_get_nth_actor (ClutterBehaviour *behave, gint index);
Gets an actor the behaviour was applied to referenced by index num.
behave : |
a ClutterBehaviour |
index : |
the index of an actor this behaviour is applied too. |
Returns : | A Clutter actor or NULL if index is invalid. |
Since 0.2
ClutterAlpha* clutter_behaviour_get_alpha (ClutterBehaviour *behave);
Retrieves the ClutterAlpha object bound to behave
.
behave : |
a ClutterBehaviour |
Returns : | a ClutterAlpha object, or NULL if no alpha
object has been bound to this behaviour.
|
Since 0.2
void clutter_behaviour_set_alpha (ClutterBehaviour *behave, ClutterAlpha *alpha);
Binds alpha
to a ClutterBehaviour. The ClutterAlpha object
is what makes a behaviour work: for each tick of the timeline
used by ClutterAlpha a new value of the alpha parameter is
computed by the alpha function; the value should be used by
the ClutterBehaviour to update one or more properties of the
actors to which the behaviour applies.
behave : |
a ClutterBehaviour |
alpha : |
a ClutterAlpha or NULL to unset a previously set alpha
|
Since 0.2
alpha
" property"alpha" ClutterAlpha : Read / Write / Construct
Alpha Object to drive the behaviour.