![]() |
![]() |
![]() |
Clutter Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties |
ClutterAnimator; ClutterAnimatorClass; ClutterAnimator * clutter_animator_new (void); void clutter_animator_set (ClutterAnimator *animator, gpointer first_object, const gchar *first_property_name, guint first_mode, gdouble first_progress, ...); ClutterAnimator * clutter_animator_set_key (ClutterAnimator *animator, GObject *object, const gchar *property_name, guint mode, gdouble progress, const GValue *value); void clutter_animator_remove_key (ClutterAnimator *animator, GObject *object, const gchar *property_name, gdouble progress); GList * clutter_animator_get_keys (ClutterAnimator *animator, GObject *object, const gchar *property_name, gdouble progress); ClutterTimeline * clutter_animator_run (ClutterAnimator *animator); void clutter_animator_set_timeline (ClutterAnimator *animator, ClutterTimeline *timeline); ClutterTimeline * clutter_animator_get_timeline (ClutterAnimator *animator); void clutter_animator_set_duration (ClutterAnimator *animator, guint duration); guint clutter_animator_get_duration (ClutterAnimator *animator); void clutter_animator_property_set_ease_in (ClutterAnimator *animator, GObject *object, const gchar *property_name, gboolean ease_in); gboolean clutter_animator_property_get_ease_in (ClutterAnimator *animator, GObject *object, const gchar *property_name); enum ClutterInterpolation; void clutter_animator_property_set_interpolation (ClutterAnimator *animator, GObject *object, const gchar *property_name, ClutterInterpolation interpolation); ClutterInterpolation clutter_animator_property_get_interpolation (ClutterAnimator *animator, GObject *object, const gchar *property_name, ClutterInterpolation interpolation); ClutterAnimatorKey; GObject * clutter_animator_key_get_object (const ClutterAnimatorKey *key); const gchar * clutter_animator_key_get_property_name (const ClutterAnimatorKey *key); GType clutter_animator_key_get_property_type (const ClutterAnimatorKey *key); gulong clutter_animator_key_get_mode (const ClutterAnimatorKey *key); gdouble clutter_animator_key_get_progress (const ClutterAnimatorKey *key); gboolean clutter_animator_key_get_value (const ClutterAnimatorKey *key, GValue *value);
ClutterAnimator is an object providing declarative animations for GObject properties belonging to one or more GObjects to ClutterIntervals.
ClutterAnimator is used to build and describe complex animations in terms of "key frames". ClutterAnimator is meant to be used through the ClutterScript definition format, but it comes with a convenience C API.
ClutterAnimator defines a custom "properties" property which allows describing the key frames for objects.
The "properties" property has the following syntax:
{ "properties" : [ { "object" : <id of an object>, "name" : <name of the property>, "ease-in" : <boolean>, "interpolation" : <ClutterInterpolation value>, "keys" : [ [ <progress>, <easing mode>, <final value> ] ] ] }
Example 5. ClutterAnimator definition
The following JSON fragment defines a ClutterAnimator with the duration of 1 second and operating on the x and y properties of a ClutterActor named "rect-01", with two frames for each property. The first frame will linearly move the actor from its current position to the 100, 100 position in 20 percent of the duration of the animation; the second will using a cubic easing to move the actor to the 200, 200 coordinates.
{ "type" : "ClutterAnimator", "duration" : 1000, "properties" : [ { "object" : "rect-01", "name" : "x", "ease-in" : true, "keys" : [ [ 0.2, "linear", 100.0 ], [ 1.0, "easeOutCubic", 200.0 ] ] }, { "object" : "rect-01", "name" : "y", "ease-in" : true, "keys" : [ [ 0.2, "linear", 100.0 ], [ 1.0, "easeOutCubic", 200.0 ] ] } ] }
ClutterAnimator is available since Clutter 1.2
typedef struct _ClutterAnimator ClutterAnimator;
The ClutterAnimator structure contains only private data and should be accessed using the provided API
Since 1.2
typedef struct { } ClutterAnimatorClass;
The ClutterAnimatorClass structure contains only private data
Since 1.2
ClutterAnimator * clutter_animator_new (void);
Create a new ClutterAnimator instance.
Returns : |
a new ClutterAnimator. |
void clutter_animator_set (ClutterAnimator *animator, gpointer first_object, const gchar *first_property_name, guint first_mode, gdouble first_progress, ...);
Adds multiple keys to a ClutterAnimator, specifying the value a given
property should have at a given progress of the animation. The mode
specified is the mode used when going to this key from the previous key of
the property_name
If a given (object, property, progress) tuple already exist the mode and value will be replaced with the new values.
|
a ClutterAnimator |
|
a GObject |
|
the property to specify a key for |
|
the id of the alpha function to use |
|
at which stage of the animation this value applies; the range is a normalized floating point value between 0 and 1 |
|
the value first_property_name should have for first_object
at first_progress, followed by more (object, property_name, mode,
progress, value) tuples, followed by NULL
|
Since 1.2
ClutterAnimator * clutter_animator_set_key (ClutterAnimator *animator, GObject *object, const gchar *property_name, guint mode, gdouble progress, const GValue *value);
Sets a single key in the ClutterAnimator for the property_name
of
object
at progress
.
See also: clutter_animator_set()
|
a ClutterAnimator |
|
a GObject |
|
the property to specify a key for |
|
the id of the alpha function to use |
|
the normalized range at which stage of the animation this value applies |
|
the value property_name should have at progress. |
Returns : |
The animator instance. transfer none. |
Since 1.2
void clutter_animator_remove_key (ClutterAnimator *animator, GObject *object, const gchar *property_name, gdouble progress);
|
|
|
|
|
|
|
GList * clutter_animator_get_keys (ClutterAnimator *animator, GObject *object, const gchar *property_name, gdouble progress);
Returns a list of pointers to opaque structures with accessor functions that describe the keys added to an animator.
|
a ClutterAnimator instance |
|
a GObject to search for or NULL for all |
|
a specific property name to query for or NULL for all |
|
a specific progress to search for or a negative value for all |
Returns : |
transfer container) (element-type ClutterAnimatorKey. transfer container. element-type ClutterAnimatorKey. |
Since 1.2
ClutterTimeline * clutter_animator_run (ClutterAnimator *animator);
Start the ClutterAnimator, this is a thin wrapper that rewinds and starts the animators current timeline.
|
a ClutterAnimator |
Returns : |
the ClutterTimeline that drives the animator. |
void clutter_animator_set_timeline (ClutterAnimator *animator, ClutterTimeline *timeline);
Sets an external timeline that will be used for driving the animation
|
a ClutterAnimator |
|
a ClutterTimeline |
Since 1.2
ClutterTimeline * clutter_animator_get_timeline (ClutterAnimator *animator);
Get the timeline hooked up for driving the ClutterAnimator
|
a ClutterAnimator |
Returns : |
the ClutterTimeline that drives the animator. |
void clutter_animator_set_duration (ClutterAnimator *animator, guint duration);
Runs the timeline of the ClutterAnimator with a duration in msecs as specified.
|
a ClutterAnimator |
|
milliseconds a run of the animator should last. |
Since 1.2
guint clutter_animator_get_duration (ClutterAnimator *animator);
Retrieves the current duration of an animator
|
a ClutterAnimator |
Returns : |
the duration of the animation, in milliseconds |
Since 1.2
void clutter_animator_property_set_ease_in (ClutterAnimator *animator, GObject *object, const gchar *property_name, gboolean ease_in);
Sets whether a property value is to be eased into the animation.
|
a ClutterAnimatorKey |
|
a GObject |
|
the name of a property on object |
|
we are going to be easing in this property |
Since 1.2
gboolean clutter_animator_property_get_ease_in (ClutterAnimator *animator, GObject *object, const gchar *property_name);
Checks if a property value is to be eased into the animation.
|
a ClutterAnimatorKey |
|
a GObject |
|
the name of a property on object |
Returns : |
TRUE if the property is eased in
|
Since 1.2
typedef enum { CLUTTER_INTERPOLATION_LINEAR, CLUTTER_INTERPOLATION_CUBIC } ClutterInterpolation;
The mode of interpolation between key frames
Since 1.2
void clutter_animator_property_set_interpolation (ClutterAnimator *animator, GObject *object, const gchar *property_name, ClutterInterpolation interpolation);
Set the interpolation method to use, CLUTTER_INTERPOLATION_LINEAR causes the values to linearly change between the values, CLUTTER_INTERPOLATION_CUBIC causes the values to smoothly change between the values.
|
a ClutterAnimatorKey |
|
a GObject |
|
the name of a property on object |
|
the ClutterInterpolation to use |
Since 1.2
ClutterInterpolation clutter_animator_property_get_interpolation (ClutterAnimator *animator, GObject *object, const gchar *property_name, ClutterInterpolation interpolation);
|
|
|
|
|
|
|
|
Returns : |
typedef struct _ClutterAnimatorKey ClutterAnimatorKey;
A key frame inside a ClutterAnimator
Since 1.2
GObject * clutter_animator_key_get_object (const ClutterAnimatorKey *key);
Retrieves the object a key applies to.
|
a ClutterAnimatorKey |
Returns : |
the object an animator_key exist for.. transfer none. |
Since 1.2
const gchar * clutter_animator_key_get_property_name (const ClutterAnimatorKey *key);
Retrieves the name of the property a key applies to.
|
a ClutterAnimatorKey |
Returns : |
the name of the property an animator_key exist for. |
Since 1.2
GType clutter_animator_key_get_property_type (const ClutterAnimatorKey *key);
Retrieves the GType of the property a key applies to
You can use this type to initialize the GValue to pass to
clutter_animator_key_get_value()
|
a ClutterAnimatorKey |
Returns : |
the GType of the property |
Since 1.2
gulong clutter_animator_key_get_mode (const ClutterAnimatorKey *key);
Retrieves the mode of a ClutterAnimator key, for the first key of a property for an object this represents the whether the animation is open ended and or curved for the remainding keys for the property it represents the easing mode.
|
a ClutterAnimatorKey |
Returns : |
the mode of a ClutterAnimatorKey |
Since 1.2
gdouble clutter_animator_key_get_progress (const ClutterAnimatorKey *key);
Retrieves the progress of an clutter_animator_key
|
a ClutterAnimatorKey |
Returns : |
the progress defined for a ClutterAnimator key. |
Since 1.2
gboolean clutter_animator_key_get_value (const ClutterAnimatorKey *key, GValue *value);
Retrieves a copy of the value for a ClutterAnimatorKey.
The passed in GValue needs to be already initialized for the value type of the key or to a type that allow transformation from the value type of the key.
Use g_value_unset()
when done.
|
a ClutterAnimatorKey |
|
a GValue initialized with the correct type for the animator key |
Returns : |
TRUE if the passed GValue was successfully set, and
FALSE otherwise
|
Since 1.2
"duration"
property"duration" guint : Read / Write
The duration of the ClutterTimeline used by the ClutterAnimator to drive the animation
Default value: 2000
Since 1.2