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
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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<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
|
||||
|
|
@ -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) ||
|
||||
|
|
|
|||
|
|
@ -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 ------//
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue