[clutter/wip/apocalypses/apocalypse-6] timeline: Add more state accessors



commit 1a3a249cb5edfb072f804505e73e87825b0526cf
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Thu Mar 15 13:50:28 2012 +0000

    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(+), 0 deletions(-)
---
diff --git a/clutter/clutter-timeline.c b/clutter/clutter-timeline.c
index 82a7c83..3a585eb 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 3833a0c..488b4af 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 d5748f2..b0bb3cf 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 c4c1cb2..7f152ea 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
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]