diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-06-30 11:59:30 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2010-06-30 12:49:11 (GMT) |
commit | f141de3daa267c266f67def765adb934138db080 (patch) | |
tree | b79a602ad210f65f15f44f31ba3f3bc6bae0c784 /src/corelib | |
parent | 176024dfea7d354451a65b61fa2e82dd422b4dfb (diff) | |
download | Qt-f141de3daa267c266f67def765adb934138db080.zip Qt-f141de3daa267c266f67def765adb934138db080.tar.gz Qt-f141de3daa267c266f67def765adb934138db080.tar.bz2 |
Adds slowdownFactor to UnifiedTimer in abstract animation
The slowdown factor is useful for debugging complex animations.
Setting it to 0 will stop all animations when slowMode is enabled.
Submitted-by: Lasse
Reviewed-by: Thierry
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 11 | ||||
-rw-r--r-- | src/corelib/animation/qabstractanimation_p.h | 9 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 04342e7..7feb3f7 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -168,7 +168,7 @@ Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer) QUnifiedTimer::QUnifiedTimer() : QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), currentAnimationIdx(0), consistentTiming(false), slowMode(false), - isPauseTimerActive(false), runningLeafAnimations(0) + slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0) { time.invalidate(); } @@ -208,8 +208,13 @@ void QUnifiedTimer::updateAnimationsTime() // ignore consistentTiming in case the pause timer is active int delta = (consistentTiming && !isPauseTimerActive) ? timingInterval : time.elapsed() - lastTick; - if (slowMode) - delta /= 5; + if (slowMode) { + if (slowdownFactor > 0) + delta = qRound(delta / slowdownFactor); + else + delta = 0; + } + lastTick = time.elapsed(); //we make sure we only call update time if the time has actually changed diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index fcfe824..6ff18f5 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -145,8 +145,9 @@ public: */ void setConsistentTiming(bool consistent) { consistentTiming = consistent; } - //this facilitates fine-tuning of complex animations + //these facilitate fine-tuning of complex animations void setSlowModeEnabled(bool enabled) { slowMode = enabled; } + void setSlowdownFactor(qreal factor) { slowdownFactor = factor; } /* this is used for updating the currentTime of all animations in case the pause @@ -176,6 +177,12 @@ private: int currentAnimationIdx; bool consistentTiming; bool slowMode; + + // 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) + // stops all animations. + qreal slowdownFactor; + // bool to indicate that only pause animations are active bool isPauseTimerActive; |