[gtk+/wip/frame-synchronization: 828/857] GtkTimeline: Wrap around the progress correctly when looping
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/frame-synchronization: 828/857] GtkTimeline: Wrap around the progress correctly when looping
- Date: Wed, 13 Feb 2013 06:13:08 +0000 (UTC)
commit ecd953efa047e71295e2d90298eac64f65459d40
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Fri Sep 28 12:38:14 2012 -0400
GtkTimeline: Wrap around the progress correctly when looping
When we have a looping animation for something like an angle,
we need to make sure that the distance we go past 1.0 becomes
the starting distance for the next frame. This prevents a
stutter at the loop position.
https://bugzilla.gnome.org/show_bug.cgi?id=685460
gtk/gtktimeline.c | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktimeline.c b/gtk/gtktimeline.c
index 55df628..ad2e7df 100644
--- a/gtk/gtktimeline.c
+++ b/gtk/gtktimeline.c
@@ -357,7 +357,7 @@ gtk_timeline_on_update (GdkFrameClock *clock,
GtkTimeline *timeline)
{
GtkTimelinePriv *priv;
- gdouble delta_progress, progress;
+ gdouble delta_progress, progress, adjust;
guint64 now;
/* the user may unref us during the signals, so save ourselves */
@@ -381,6 +381,21 @@ gtk_timeline_on_update (GdkFrameClock *clock,
priv->last_progress = progress;
+ /* When looping, if we go past the end, start that much into the
+ * next cycle */
+ if (progress < 0.0)
+ {
+ adjust = progress - ceil(progress);
+ progress = 0.0;
+ }
+ else if (progress > 1.0)
+ {
+ adjust = progress - floor(progress);
+ progress = 1.0;
+ }
+ else
+ adjust = 0.0;
+
progress = CLAMP (progress, 0., 1.);
}
else
@@ -398,7 +413,10 @@ gtk_timeline_on_update (GdkFrameClock *clock,
loop = priv->loop && priv->animations_enabled;
if (loop)
- gtk_timeline_rewind (timeline);
+ {
+ gtk_timeline_rewind (timeline);
+ priv->progress += adjust;
+ }
else
{
gtk_timeline_stop_running (timeline);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]