From 43897d214dbb308ffb1cdf720183dc831771f243 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Mon, 5 Jan 2009 00:05:14 +0000 Subject: [PATCH] Made animation time based not tick based --- .../timeline/timeline-layout-helper.cpp | 4 ++-- src/gui/widgets/timeline/timeline-track.cpp | 24 ++++++++++++++----- src/gui/widgets/timeline/timeline-track.hpp | 8 ++++--- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/gui/widgets/timeline/timeline-layout-helper.cpp b/src/gui/widgets/timeline/timeline-layout-helper.cpp index 0550926b7..75974cc6c 100644 --- a/src/gui/widgets/timeline/timeline-layout-helper.cpp +++ b/src/gui/widgets/timeline/timeline-layout-helper.cpp @@ -271,9 +271,9 @@ TimelineLayoutHelper::lookup_timeline_track( void TimelineLayoutHelper::begin_animation() { - animationTimer = Glib::signal_timeout().connect( + animationTimer = Glib::signal_idle().connect( sigc::mem_fun(this, &TimelineLayoutHelper::on_animation_tick), - AnimationTimeout); + Glib::PRIORITY_DEFAULT); } bool diff --git a/src/gui/widgets/timeline/timeline-track.cpp b/src/gui/widgets/timeline/timeline-track.cpp index 910b0e237..be692f296 100644 --- a/src/gui/widgets/timeline/timeline-track.cpp +++ b/src/gui/widgets/timeline/timeline-track.cpp @@ -35,9 +35,12 @@ using namespace sigc; namespace gui { namespace widgets { namespace timeline { - + const int Track::NoAnimationState = -1; -const int Track::MaxExpandAnimation = 10; +const int Track::MaxExpandAnimation = 65536; +const double Track::ExpandAnimationPeriod = 0.15; + +Glib::Timer Track::timer; Track::Track(TimelineWidget &timeline_widget, shared_ptr track) : @@ -50,6 +53,9 @@ Track::Track(TimelineWidget &timeline_widget, { REQUIRE(model_track); + // Ensure that the timer is running + timer.start(); + titleMenuButton.set_relief(RELIEF_HALF); buttonBar.append(enableButton); @@ -126,6 +132,8 @@ Track::expand_collapse(ExpandDirection direction) expanded = false; expandAnimationState = MaxExpandAnimation; } + + lastTickTime = timer.elapsed(); } int @@ -139,7 +147,7 @@ Track::get_expand_animation_state() const void Track::tick_expand_animation() -{ +{ if(expandAnimationState <= NoAnimationState) { WARN(gui, "tick_expand_animation() was called when" @@ -147,18 +155,22 @@ Track::tick_expand_animation() return; } + const double delta = MaxExpandAnimation * (timer.elapsed() - lastTickTime) / ExpandAnimationPeriod; + if(expandDirection == Expand) { - expandAnimationState++; + expandAnimationState += delta; if(expandAnimationState >= MaxExpandAnimation) expandAnimationState = NoAnimationState; } else { - expandAnimationState--; + expandAnimationState -= delta; if(expandAnimationState <= 0) expandAnimationState = NoAnimationState; - } + } + + lastTickTime = timer.elapsed(); ENSURE((expandAnimationState >= 0 && expandAnimationState <= MaxExpandAnimation) || diff --git a/src/gui/widgets/timeline/timeline-track.hpp b/src/gui/widgets/timeline/timeline-track.hpp index 9a33b9ce6..8c20d9c26 100644 --- a/src/gui/widgets/timeline/timeline-track.hpp +++ b/src/gui/widgets/timeline/timeline-track.hpp @@ -77,6 +77,7 @@ public: public: static const int NoAnimationState; static const int MaxExpandAnimation; + static const double ExpandAnimationPeriod; private: //----- Internals -----// @@ -97,10 +98,11 @@ protected: private: bool expanded; - - ExpandDirection expandDirection; - int expandAnimationState; + double expandAnimationState; + + static Glib::Timer timer; + double lastTickTime; //----- Header Widgets ------//