Made animation time based not tick based
This commit is contained in:
parent
8db54f1179
commit
43897d214d
3 changed files with 25 additions and 11 deletions
|
|
@ -271,9 +271,9 @@ TimelineLayoutHelper::lookup_timeline_track(
|
||||||
void
|
void
|
||||||
TimelineLayoutHelper::begin_animation()
|
TimelineLayoutHelper::begin_animation()
|
||||||
{
|
{
|
||||||
animationTimer = Glib::signal_timeout().connect(
|
animationTimer = Glib::signal_idle().connect(
|
||||||
sigc::mem_fun(this, &TimelineLayoutHelper::on_animation_tick),
|
sigc::mem_fun(this, &TimelineLayoutHelper::on_animation_tick),
|
||||||
AnimationTimeout);
|
Glib::PRIORITY_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,12 @@ using namespace sigc;
|
||||||
namespace gui {
|
namespace gui {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
namespace timeline {
|
namespace timeline {
|
||||||
|
|
||||||
const int Track::NoAnimationState = -1;
|
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,
|
Track::Track(TimelineWidget &timeline_widget,
|
||||||
shared_ptr<model::Track> track) :
|
shared_ptr<model::Track> track) :
|
||||||
|
|
@ -50,6 +53,9 @@ Track::Track(TimelineWidget &timeline_widget,
|
||||||
{
|
{
|
||||||
REQUIRE(model_track);
|
REQUIRE(model_track);
|
||||||
|
|
||||||
|
// Ensure that the timer is running
|
||||||
|
timer.start();
|
||||||
|
|
||||||
titleMenuButton.set_relief(RELIEF_HALF);
|
titleMenuButton.set_relief(RELIEF_HALF);
|
||||||
|
|
||||||
buttonBar.append(enableButton);
|
buttonBar.append(enableButton);
|
||||||
|
|
@ -126,6 +132,8 @@ Track::expand_collapse(ExpandDirection direction)
|
||||||
expanded = false;
|
expanded = false;
|
||||||
expandAnimationState = MaxExpandAnimation;
|
expandAnimationState = MaxExpandAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastTickTime = timer.elapsed();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -139,7 +147,7 @@ Track::get_expand_animation_state() const
|
||||||
|
|
||||||
void
|
void
|
||||||
Track::tick_expand_animation()
|
Track::tick_expand_animation()
|
||||||
{
|
{
|
||||||
if(expandAnimationState <= NoAnimationState)
|
if(expandAnimationState <= NoAnimationState)
|
||||||
{
|
{
|
||||||
WARN(gui, "tick_expand_animation() was called when"
|
WARN(gui, "tick_expand_animation() was called when"
|
||||||
|
|
@ -147,18 +155,22 @@ Track::tick_expand_animation()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const double delta = MaxExpandAnimation * (timer.elapsed() - lastTickTime) / ExpandAnimationPeriod;
|
||||||
|
|
||||||
if(expandDirection == Expand)
|
if(expandDirection == Expand)
|
||||||
{
|
{
|
||||||
expandAnimationState++;
|
expandAnimationState += delta;
|
||||||
if(expandAnimationState >= MaxExpandAnimation)
|
if(expandAnimationState >= MaxExpandAnimation)
|
||||||
expandAnimationState = NoAnimationState;
|
expandAnimationState = NoAnimationState;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
expandAnimationState--;
|
expandAnimationState -= delta;
|
||||||
if(expandAnimationState <= 0)
|
if(expandAnimationState <= 0)
|
||||||
expandAnimationState = NoAnimationState;
|
expandAnimationState = NoAnimationState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastTickTime = timer.elapsed();
|
||||||
|
|
||||||
ENSURE((expandAnimationState >= 0 &&
|
ENSURE((expandAnimationState >= 0 &&
|
||||||
expandAnimationState <= MaxExpandAnimation) ||
|
expandAnimationState <= MaxExpandAnimation) ||
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ public:
|
||||||
public:
|
public:
|
||||||
static const int NoAnimationState;
|
static const int NoAnimationState;
|
||||||
static const int MaxExpandAnimation;
|
static const int MaxExpandAnimation;
|
||||||
|
static const double ExpandAnimationPeriod;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//----- Internals -----//
|
//----- Internals -----//
|
||||||
|
|
@ -97,10 +98,11 @@ protected:
|
||||||
private:
|
private:
|
||||||
bool expanded;
|
bool expanded;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ExpandDirection expandDirection;
|
ExpandDirection expandDirection;
|
||||||
int expandAnimationState;
|
double expandAnimationState;
|
||||||
|
|
||||||
|
static Glib::Timer timer;
|
||||||
|
double lastTickTime;
|
||||||
|
|
||||||
//----- Header Widgets ------//
|
//----- Header Widgets ------//
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue