From a1411040f15a12a08b48dd8ef5ac44cd534459ba Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sun, 11 Mar 2007 21:39:00 -0400 Subject: [PATCH] Make frame animation faster and smoother --- shell/view/frame/frame.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/shell/view/frame/frame.py b/shell/view/frame/frame.py index 0d2231ea..6586cd33 100644 --- a/shell/view/frame/frame.py +++ b/shell/view/frame/frame.py @@ -232,7 +232,15 @@ class Frame: def do_slide_in(self, current=0, n_frames=0): if _ANIMATION: - self._move(float(current + 1) / float(n_frames)) + if current + 1 == n_frames: + # hardcode last frame to avoid precision errors in division + self._move(1) + else: + # each frame, move half the remaining distance + pos = 0.0 + for i in range(0, current + 1): + pos += float((1.0 - float(pos)) / 2.0) + self._move(pos) elif current == 0: self._move(1) if self._event_frame.is_visible(): @@ -240,7 +248,15 @@ class Frame: def do_slide_out(self, current=0, n_frames=0): if _ANIMATION: - self._move(1 - (float(current + 1) / float(n_frames))) + if current + 1 == n_frames: + # hardcode last frame to avoid precision errors in division + self._move(0) + else: + # each frame, move half the remaining distance + pos = 0.0 + for i in range(0, current + 1): + pos += float((1.0 - float(pos)) / 2.0) + self._move(1.0 - float(pos)) elif current == 0: self._move(0) if not self._event_frame.is_visible():