From 388f818f419b9aa745ca1d6ad6bd300c4b859df7 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi <ebassi@linux.intel.com> Date: Thu, 15 Mar 2012 13:50:28 +0000 Subject: [PATCH] timeline: Add more state accessors It should be possible to ask a timeline what is its duration, taking into account eventual repeats, and which repeat is the one currently in progress. These two functions allow writing animations that depend on the current state of another timeline. --- clutter/clutter-timeline.c | 54 ++++++++++++++++++++++ clutter/clutter-timeline.h | 5 ++ clutter/clutter.symbols | 2 + doc/reference/clutter/clutter-sections.txt | 2 + 4 files changed, 63 insertions(+) diff --git a/clutter/clutter-timeline.c b/clutter/clutter-timeline.c index 82a7c8335..3a585ebc0 100644 --- a/clutter/clutter-timeline.c +++ b/clutter/clutter-timeline.c @@ -2174,3 +2174,57 @@ clutter_timeline_get_progress_mode (ClutterTimeline *timeline) return timeline->priv->progress_mode; } + +/** + * clutter_timeline_get_duration_hint: + * @timeline: a #ClutterTimeline + * + * Retrieves the full duration of the @timeline, taking into account the + * current value of the #ClutterTimeline:repeat-count property. + * + * If the #ClutterTimeline:repeat-count property is set to -1, this function + * will return %G_MAXINT64. + * + * The returned value is to be considered a hint, and it's only valid + * as long as the @timeline hasn't been changed. + * + * Return value: the full duration of the #ClutterTimeline + * + * Since: 1.10 + */ +gint64 +clutter_timeline_get_duration_hint (ClutterTimeline *timeline) +{ + ClutterTimelinePrivate *priv; + + g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); + + priv = timeline->priv; + + if (priv->repeat_count == 0) + return priv->duration; + else if (priv->repeat_count < 0) + return G_MAXINT64; + else + return priv->repeat_count * priv->duration; +} + +/** + * clutter_timeline_get_current_repeat: + * @timeline: a #ClutterTimeline + * + * Retrieves the current repeat for a timeline. + * + * Repeats start at 0. + * + * Return value: the current repeat + * + * Since: 1.10 + */ +gint +clutter_timeline_get_current_repeat (ClutterTimeline *timeline) +{ + g_return_val_if_fail (CLUTTER_IS_TIMELINE (timeline), 0); + + return timeline->priv->current_repeat; +} diff --git a/clutter/clutter-timeline.h b/clutter/clutter-timeline.h index 3833a0cc0..488b4af59 100644 --- a/clutter/clutter-timeline.h +++ b/clutter/clutter-timeline.h @@ -169,6 +169,11 @@ void clutter_timeline_set_progress_mode (Clutter CLUTTER_AVAILABLE_IN_1_10 ClutterAnimationMode clutter_timeline_get_progress_mode (ClutterTimeline *timeline); +CLUTTER_AVAILABLE_IN_1_10 +gint64 clutter_timeline_get_duration_hint (ClutterTimeline *timeline); +CLUTTER_AVAILABLE_IN_1_10 +gint clutter_timeline_get_current_repeat (ClutterTimeline *timeline); + G_END_DECLS #endif /* _CLUTTER_TIMELINE_H__ */ diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols index d5748f207..b0bb3cfb6 100644 --- a/clutter/clutter.symbols +++ b/clutter/clutter.symbols @@ -1287,9 +1287,11 @@ clutter_timeline_new clutter_timeline_clone clutter_timeline_direction_get_type clutter_timeline_get_auto_reverse +clutter_timeline_get_current_repeat clutter_timeline_get_delay clutter_timeline_get_delta clutter_timeline_get_direction +clutter_timeline_get_duration_hint clutter_timeline_get_duration clutter_timeline_get_elapsed_time clutter_timeline_get_loop diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 6c2803e2b..df3cd7e48 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -746,6 +746,8 @@ clutter_timeline_set_progress_mode clutter_timeline_get_progress_mode ClutterTimelineProgressFunc clutter_timeline_set_progress_func +clutter_timeline_get_duration_hint +clutter_timeline_get_current_repeat clutter_timeline_set_loop clutter_timeline_get_loop