Properly adjust msecs_delta when clamping elapsed time
authorOwen W. Taylor <otaylor@fishsoup.net>
Mon, 8 Jun 2009 11:57:41 +0000 (07:57 -0400)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 8 Jun 2009 14:03:16 +0000 (15:03 +0100)
When we complete a timeline, we clamp the elapsed_time variable
to the range of the timeline. We need to adjust msecs_delta so that
when we check for hit markers we have the correct interval.

http://bugzilla.openedhand.com/show_bug.cgi?id=1641

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
clutter/clutter-timeline.c

index 4e8ef16..fa31c44 100644 (file)
@@ -566,11 +566,19 @@ clutter_timeline_advance_internal (ClutterTimeline *timeline)
       gint end_msecs;
 
       /* Update the current elapsed time in case the signal handlers
-         want to take a peek. */
+       * want to take a peek. If we clamp elapsed time, then we need
+       * to correpondingly reduce msecs_delta to reflect the correct
+       * range of times */
       if (priv->direction == CLUTTER_TIMELINE_FORWARD)
-        priv->elapsed_time = priv->duration;
+       {
+         priv->msecs_delta -= (priv->elapsed_time - priv->duration);
+         priv->elapsed_time = priv->duration;
+       }
       else if (priv->direction == CLUTTER_TIMELINE_BACKWARD)
-        priv->elapsed_time = 0;
+       {
+         priv->msecs_delta -= - priv->elapsed_time;
+         priv->elapsed_time = 0;
+       }
 
       end_msecs = priv->elapsed_time;