mirror of https://github.com/procxx/kepka.git
Allow disabling new animations.
This commit is contained in:
parent
99bb09374d
commit
74dc4e0c62
|
@ -59,12 +59,11 @@ Manager::Manager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::start(not_null<Basic*> animation) {
|
void Manager::start(not_null<Basic*> animation) {
|
||||||
|
_forceImmediateUpdate = true;
|
||||||
if (_updating) {
|
if (_updating) {
|
||||||
_starting.emplace_back(animation.get());
|
_starting.emplace_back(animation.get());
|
||||||
} else {
|
} else {
|
||||||
if (empty(_active)) {
|
schedule();
|
||||||
updateQueued();
|
|
||||||
}
|
|
||||||
_active.emplace_back(animation.get());
|
_active.emplace_back(animation.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,9 +92,11 @@ void Manager::update() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
if (_lastUpdateTime + kIgnoreUpdatesTimeout >= now) {
|
if (!_forceImmediateUpdate
|
||||||
|
&& (_lastUpdateTime + kIgnoreUpdatesTimeout >= now)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_forceImmediateUpdate = false;
|
||||||
schedule();
|
schedule();
|
||||||
|
|
||||||
_updating = true;
|
_updating = true;
|
||||||
|
@ -129,13 +130,17 @@ void Manager::schedule() {
|
||||||
_scheduled = true;
|
_scheduled = true;
|
||||||
Ui::PostponeCall([=] {
|
Ui::PostponeCall([=] {
|
||||||
_scheduled = false;
|
_scheduled = false;
|
||||||
|
if (_forceImmediateUpdate) {
|
||||||
const auto next = _lastUpdateTime + kAnimationTimeout;
|
_forceImmediateUpdate = false;
|
||||||
const auto now = crl::now();
|
|
||||||
if (now < next) {
|
|
||||||
_timerId = startTimer(next - now, Qt::PreciseTimer);
|
|
||||||
} else {
|
|
||||||
updateQueued();
|
updateQueued();
|
||||||
|
} else {
|
||||||
|
const auto next = _lastUpdateTime + kAnimationTimeout;
|
||||||
|
const auto now = crl::now();
|
||||||
|
if (now < next) {
|
||||||
|
_timerId = startTimer(next - now, Qt::PreciseTimer);
|
||||||
|
} else {
|
||||||
|
updateQueued();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ private:
|
||||||
int _timerId = 0;
|
int _timerId = 0;
|
||||||
bool _updating = false;
|
bool _updating = false;
|
||||||
bool _scheduled = false;
|
bool _scheduled = false;
|
||||||
|
bool _forceImmediateUpdate = false;
|
||||||
std::vector<ActiveBasicPointer> _active;
|
std::vector<ActiveBasicPointer> _active;
|
||||||
std::vector<ActiveBasicPointer> _starting;
|
std::vector<ActiveBasicPointer> _starting;
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
@ -274,7 +275,9 @@ inline void Simple::start(
|
||||||
that = _data.get(),
|
that = _data.get(),
|
||||||
callback = Prepare(std::forward<Callback>(callback))
|
callback = Prepare(std::forward<Callback>(callback))
|
||||||
](crl::time now) {
|
](crl::time now) {
|
||||||
const auto time = (now - that->animation.started());
|
const auto time = anim::Disabled()
|
||||||
|
? that->duration
|
||||||
|
: (now - that->animation.started());
|
||||||
const auto finished = (time >= that->duration);
|
const auto finished = (time >= that->duration);
|
||||||
const auto progress = finished
|
const auto progress = finished
|
||||||
? that->delta
|
? that->delta
|
||||||
|
|
Loading…
Reference in New Issue