diff options
author | Antti Määttä <antti.maatta@qt.io> | 2021-10-04 12:30:24 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-10-19 04:14:38 +0000 |
commit | a5dfbb04a7404eab223151dda160597a7698c704 (patch) | |
tree | 6c440320f37af3383bc5affd37fd142f553c1fd2 /src | |
parent | 11705b9f06e01bbc30ebd9cb211a8aa1c5ad5209 (diff) |
Allow negative delta for designer animation driver
The designer animation driver needs the ability to drive the animation
both forwards and backwards.
Task-number: QDS-4910
Change-Id: Ie2b1855d062bb254b28b216328cb618d90ee8454
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 9f763a5f3f31d432da5008ba9a8e0b0af36fb27e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 7 | ||||
-rw-r--r-- | src/corelib/animation/qabstractanimation_p.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 16621036e2..76a9648f03 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -219,7 +219,7 @@ Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer) QUnifiedTimer::QUnifiedTimer() : QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), currentAnimationIdx(0), insideTick(false), insideRestart(false), consistentTiming(false), slowMode(false), - startTimersPending(false), stopTimerPending(false), + startTimersPending(false), stopTimerPending(false), allowNegativeDelta(false), slowdownFactor(5.0f), profilerCallback(nullptr), driverStartTime(0), temporalDrift(0) { @@ -315,7 +315,7 @@ void QUnifiedTimer::updateAnimationTimers() // when the CPU load is high //* it might happen in some cases that the delta is negative because the animation driver // advances faster than time.elapsed() - if (delta > 0) { + if (delta != 0 && (allowNegativeDelta || delta > 0)) { QScopedValueRollback<bool> guard(insideTick, true); if (profilerCallback) profilerCallback(delta); @@ -517,6 +517,8 @@ void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d) if (running) stopAnimationDriver(); driver = d; + if (driver) + allowNegativeDelta = driver->property("allowNegativeDelta").toBool(); if (running) startAnimationDriver(); } @@ -532,6 +534,7 @@ void QUnifiedTimer::uninstallAnimationDriver(QAnimationDriver *d) if (running) stopAnimationDriver(); driver = &defaultDriver; + allowNegativeDelta = false; if (running) startAnimationDriver(); } diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 6a94d2bb8a..6b033de4c7 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -224,6 +224,7 @@ private: bool slowMode; bool startTimersPending; bool stopTimerPending; + bool allowNegativeDelta; // This factor will be used to divide the DEFAULT_TIMER_INTERVAL at each tick // when slowMode is enabled. Setting it to 0 or higher than DEFAULT_TIMER_INTERVAL (16) |