Add ability to disable animations.

This commit is contained in:
John Preston 2017-08-03 16:10:55 +02:00
parent a143505fd6
commit 417f5684dc
2 changed files with 13 additions and 1 deletions

View File

@ -40,6 +40,7 @@ ReaderPointer::~ReaderPointer() {
namespace { namespace {
AnimationManager *_manager = nullptr; AnimationManager *_manager = nullptr;
bool AnimationsDisabled = false;
} // namespace } // namespace
@ -109,6 +110,14 @@ void registerClipManager(Media::Clip::Manager *manager) {
manager->connect(manager, SIGNAL(callback(Media::Clip::Reader*,qint32,qint32)), _manager, SLOT(clipCallback(Media::Clip::Reader*,qint32,qint32))); manager->connect(manager, SIGNAL(callback(Media::Clip::Reader*,qint32,qint32)), _manager, SLOT(clipCallback(Media::Clip::Reader*,qint32,qint32)));
} }
bool Disabled() {
return AnimationsDisabled;
}
void SetDisabled(bool disabled) {
AnimationsDisabled = disabled;
}
} // anim } // anim
void BasicAnimation::start() { void BasicAnimation::start() {

View File

@ -417,6 +417,9 @@ QPainterPath path(QPointF (&from)[N]) {
return result; return result;
} }
bool Disabled();
void SetDisabled(bool disabled);
}; };
class BasicAnimation; class BasicAnimation;
@ -668,7 +671,7 @@ private:
, updateCallback(std::move(updateCallback)) { , updateCallback(std::move(updateCallback)) {
} }
void step(float64 ms, bool timer) { void step(float64 ms, bool timer) {
auto dt = (ms >= duration) ? 1. : (ms / duration); auto dt = (ms >= duration || anim::Disabled()) ? 1. : (ms / duration);
if (dt >= 1) { if (dt >= 1) {
value.finish(); value.finish();
a_animation.stop(); a_animation.stop();