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.
This commit is contained in:
Emmanuele Bassi 2012-03-15 13:50:28 +00:00
parent 1511e588df
commit 388f818f41
4 changed files with 63 additions and 0 deletions

View File

@ -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;
}

View File

@ -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__ */

View File

@ -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

View File

@ -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