[gtk+/multitouch: 3/124] timeline: Add _gtk_timeline_get_elapsed_time()



commit b924aa997f9e38a80cc2a77a1ac592fda1079ed7
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Wed Feb 9 08:53:03 2011 +0100

    timeline: Add _gtk_timeline_get_elapsed_time()
    
    To get the time in milliseconds since the last frame

 gtk/gtktimeline.c |   25 ++++++++++++++++++++++---
 gtk/gtktimeline.h |    1 +
 2 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtktimeline.c b/gtk/gtktimeline.c
index db9b0be..68283b6 100644
--- a/gtk/gtktimeline.c
+++ b/gtk/gtktimeline.c
@@ -35,6 +35,7 @@ struct GtkTimelinePriv
   guint source_id;
 
   GTimer *timer;
+  gdouble elapsed_time;
 
   gdouble progress;
   gdouble last_progress;
@@ -309,16 +310,15 @@ gtk_timeline_run_frame (GtkTimeline *timeline)
 {
   GtkTimelinePriv *priv;
   gdouble delta_progress, progress;
-  guint elapsed_time;
 
   priv = timeline->priv;
 
-  elapsed_time = (guint) (g_timer_elapsed (priv->timer, NULL) * 1000);
+  priv->elapsed_time = (guint) (g_timer_elapsed (priv->timer, NULL) * 1000);
   g_timer_start (priv->timer);
 
   if (priv->animations_enabled)
     {
-      delta_progress = (gdouble) elapsed_time / priv->duration;
+      delta_progress = (gdouble) priv->elapsed_time / priv->duration;
       progress = priv->last_progress;
 
       if (priv->direction == GTK_TIMELINE_DIRECTION_BACKWARD)
@@ -510,6 +510,25 @@ _gtk_timeline_is_running (GtkTimeline *timeline)
 }
 
 /**
+ * gtk_timeline_get_elapsed_time:
+ * @timeline: A #GtkTimeline
+ *
+ * Returns the elapsed time since the last GtkTimeline::frame signal
+ *
+ * Return Value: elapsed time in milliseconds since the last frame
+ **/
+guint
+_gtk_timeline_get_elapsed_time (GtkTimeline *timeline)
+{
+  GtkTimelinePriv *priv;
+
+  g_return_val_if_fail (GTK_IS_TIMELINE (timeline), 0);
+
+  priv = timeline->priv;
+  return priv->elapsed_time;
+}
+
+/**
  * gtk_timeline_get_fps:
  * @timeline: A #GtkTimeline
  *
diff --git a/gtk/gtktimeline.h b/gtk/gtktimeline.h
index 0b0aee1..90d5725 100644
--- a/gtk/gtktimeline.h
+++ b/gtk/gtktimeline.h
@@ -84,6 +84,7 @@ void                    _gtk_timeline_pause             (GtkTimeline
 void                    _gtk_timeline_rewind            (GtkTimeline             *timeline);
 
 gboolean                _gtk_timeline_is_running        (GtkTimeline             *timeline);
+guint                   _gtk_timeline_get_elapsed_time  (GtkTimeline             *timeline);
 
 guint                   _gtk_timeline_get_fps           (GtkTimeline             *timeline);
 void                    _gtk_timeline_set_fps           (GtkTimeline             *timeline,



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