diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2012-05-10 10:39:42 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-11 01:42:02 +0200 |
commit | 7226361aed3259b7f4b68e1836f17b3e698c30af (patch) | |
tree | 602f660c8c243c81704a7c93b06673ae9427ffad | |
parent | b6e4c859d38674e77fb3b1372cb7751f3cfe1682 (diff) |
Make sure animation drivers knows about the temporal offset after a pause
Change-Id: I932e469389241f6a12816b52180936f061cd78f8
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
Reviewed-by: J-P Nurmi <j-p.nurmi@nokia.com>
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 28 | ||||
-rw-r--r-- | src/corelib/animation/qabstractanimation.h | 3 | ||||
-rw-r--r-- | src/corelib/animation/qabstractanimation_p.h | 3 |
3 files changed, 33 insertions, 1 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 04df52c6f0..969a54775b 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -317,6 +317,7 @@ void QUnifiedTimer::localRestart() } else if (!driver->isRunning()) { if (pauseTimer.isActive()) pauseTimer.stop(); + driver->setStartTime(time.isValid() ? time.elapsed() : 0); driver->start(); } @@ -339,6 +340,7 @@ void QUnifiedTimer::setTimingInterval(int interval) if (driver->isRunning() && !pauseTimer.isActive()) { //we changed the timing interval driver->stop(); + driver->setStartTime(time.isValid() ? time.elapsed() : 0); driver->start(); } } @@ -477,6 +479,7 @@ void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d) if (driver->isRunning()) { driver->stop(); + d->setStartTime(time.isValid() ? time.elapsed() : 0); d->start(); } @@ -495,6 +498,7 @@ void QUnifiedTimer::uninstallAnimationDriver(QAnimationDriver *d) if (d->isRunning()) { d->stop(); + driver->setStartTime(time.isValid() ? time.elapsed() : 0); driver->start(); } } @@ -732,6 +736,28 @@ QAnimationDriver::~QAnimationDriver() } +/*! + Sets the time at which an animation driver should start at. + + This is to take into account that pauses can occur in running + animations which will stop the driver, but the time still + increases. + */ +void QAnimationDriver::setStartTime(qint64 startTime) +{ + Q_D(QAnimationDriver); + d->startTime = startTime; +} + +/*! + Returns the start time of the animation. + */ +qint64 QAnimationDriver::startTime() const +{ + Q_D(const QAnimationDriver); + return d->startTime; +} + /*! Advances the animation based to the specified \a timeStep. This function should @@ -821,6 +847,8 @@ void QAnimationDriver::stop() qint64 QAnimationDriver::elapsed() const { + // The default implementation picks up the elapsed time from the + // unified timer and can ignore the time offset. return QUnifiedTimer::instance()->time.elapsed(); } diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h index 34ddbc606f..fe0a72f86d 100644 --- a/src/corelib/animation/qabstractanimation.h +++ b/src/corelib/animation/qabstractanimation.h @@ -151,6 +151,9 @@ public: virtual qint64 elapsed() const; + void setStartTime(qint64 startTime); + qint64 startTime() const; + Q_SIGNALS: void started(); void stopped(); diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 02a3c02ddc..fcf50a7638 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -132,8 +132,9 @@ private: class Q_CORE_EXPORT QAnimationDriverPrivate : public QObjectPrivate { public: - QAnimationDriverPrivate() : running(false) {} + QAnimationDriverPrivate() : running(false), startTime(0) {} bool running; + qint64 startTime; }; class Q_CORE_EXPORT QAbstractAnimationTimer : public QObject |