timeline: Add repeat-count

Being able to easily set the number of repeats has been a request for
the animation framework for some time now. The usual way to implement
this is: connect to the ::completed signal, use a static counter, and
stop the timeline when the counter hits a specific spot.

In the same light as the :auto-reverse property, we can make it easier
to implement this common functionality by adding a :repeat-count
property that, when set, limits the amount of loops that a Timeline can
perform before stopping itself.

In fact, we can implement the :loop property in terms of the
:repeat-count property just by using a sentinel value mapping to
"infinity", and map loop=FALSE to repeat-count=0, and loop=TRUE to
repeat-count=-1.
This commit is contained in:
Emmanuele Bassi
2012-02-13 14:45:06 +00:00
parent 4277468928
commit 97feb06a6f
4 changed files with 163 additions and 39 deletions

View File

@ -107,12 +107,12 @@ void clutter_timeline_set_direction (Clutter
void clutter_timeline_start (ClutterTimeline *timeline);
void clutter_timeline_pause (ClutterTimeline *timeline);
void clutter_timeline_stop (ClutterTimeline *timeline);
void clutter_timeline_set_loop (ClutterTimeline *timeline,
gboolean loop);
gboolean clutter_timeline_get_loop (ClutterTimeline *timeline);
void clutter_timeline_set_auto_reverse (ClutterTimeline *timeline,
gboolean reverse);
gboolean clutter_timeline_get_auto_reverse (ClutterTimeline *timeline);
void clutter_timeline_set_repeat_count (ClutterTimeline *timeline,
gint count);
gint clutter_timeline_get_repeat_count (ClutterTimeline *timeline);
void clutter_timeline_rewind (ClutterTimeline *timeline);
void clutter_timeline_skip (ClutterTimeline *timeline,
guint msecs);
@ -141,6 +141,13 @@ void clutter_timeline_advance_to_marker (Clutter
CLUTTER_DEPRECATED_FOR(clutter_timeline_new)
ClutterTimeline * clutter_timeline_clone (ClutterTimeline *timeline);
CLUTTER_DEPRECATED_FOR(clutter_timeline_set_repeat_count)
void clutter_timeline_set_loop (ClutterTimeline *timeline,
gboolean loop);
CLUTTER_DEPRECATED_FOR(clutter_timeline_get_repeat_count)
gboolean clutter_timeline_get_loop (ClutterTimeline *timeline);
G_END_DECLS
#endif /* _CLUTTER_TIMELINE_H__ */