Made animation time based not tick based

This commit is contained in:
Joel Holdsworth 2009-01-05 00:05:14 +00:00
parent 8db54f1179
commit 43897d214d
3 changed files with 25 additions and 11 deletions

View file

@ -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

View file

@ -37,7 +37,10 @@ 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<model::Track> 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
@ -147,19 +155,23 @@ 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) ||
expandAnimationState == NoAnimationState);

View file

@ -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 ------//