aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/animations
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@jollamobile.com>2014-02-12 23:31:22 -0600
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-20 04:27:15 +0100
commit7da483bfbefcaabb1dbbf3e2f1d5b5f7aadc3b06 (patch)
tree30a6bdb4cf3d7275c3acf8ffcfaa5aae0b594819 /src/qml/animations
parent587444f033cf51251f36321321ae358d187f37f9 (diff)
Make SmoothedAnimation and SpringAnimation smoothly transition again.
Fix regression introduced in Qt 5.0 when animation backend was rewritten. Task-number: QTBUG-36709 Change-Id: Ib8caa4bc6a38e3bb4c1d1d3961f775fdd2b342c7 Reviewed-by: Martin Jones <martin.jones@jollamobile.com>
Diffstat (limited to 'src/qml/animations')
-rw-r--r--src/qml/animations/animations.pri2
-rw-r--r--src/qml/animations/qabstractanimationjob.cpp9
-rw-r--r--src/qml/animations/qabstractanimationjob_p.h3
-rw-r--r--src/qml/animations/qcontinuinganimationgroupjob.cpp122
-rw-r--r--src/qml/animations/qcontinuinganimationgroupjob_p.h67
5 files changed, 194 insertions, 9 deletions
diff --git a/src/qml/animations/animations.pri b/src/qml/animations/animations.pri
index 01ac25af46..a379692567 100644
--- a/src/qml/animations/animations.pri
+++ b/src/qml/animations/animations.pri
@@ -5,6 +5,7 @@ HEADERS += \
$$PWD/qanimationgroupjob_p.h \
$$PWD/qsequentialanimationgroupjob_p.h \
$$PWD/qparallelanimationgroupjob_p.h \
+ $$PWD/qcontinuinganimationgroupjob_p.h \
$$PWD/qpauseanimationjob_p.h \
$$PWD/qanimationjobutil_p.h
@@ -13,4 +14,5 @@ SOURCES += \
$$PWD/qanimationgroupjob.cpp \
$$PWD/qsequentialanimationgroupjob.cpp \
$$PWD/qparallelanimationgroupjob.cpp \
+ $$PWD/qcontinuinganimationgroupjob.cpp \
$$PWD/qpauseanimationjob.cpp
diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp
index d9e3aff5a4..7fd72d97d2 100644
--- a/src/qml/animations/qabstractanimationjob.cpp
+++ b/src/qml/animations/qabstractanimationjob.cpp
@@ -59,7 +59,7 @@ QAnimationJobChangeListener::~QAnimationJobChangeListener()
}
QQmlAnimationTimer::QQmlAnimationTimer() :
- QAbstractAnimationTimer(), lastTick(0), lastDelta(0),
+ QAbstractAnimationTimer(), lastTick(0),
currentAnimationIdx(0), insideTick(false),
startAnimationPending(false), stopTimerPending(false),
runningLeafAnimations(0)
@@ -103,7 +103,6 @@ void QQmlAnimationTimer::updateAnimationsTime(qint64 delta)
return;
lastTick += delta;
- lastDelta = delta;
//we make sure we only call update time if the time has actually changed
//it might happen in some cases that the time doesn't change because events are delayed
@@ -142,8 +141,7 @@ void QQmlAnimationTimer::startAnimations()
{
startAnimationPending = false;
//force timer to update, which prevents large deltas for our newly added animations
- if (!animations.isEmpty())
- QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime();
+ QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime();
//we transfer the waiting animations into the "really running" state
animations += animationsToStart;
@@ -155,12 +153,11 @@ void QQmlAnimationTimer::startAnimations()
void QQmlAnimationTimer::stopTimer()
{
stopTimerPending = false;
- if (animations.isEmpty()) {
+ if (animations.isEmpty() && !startAnimationPending) {
QUnifiedTimer::resumeAnimationTimer(this);
QUnifiedTimer::stopAnimationTimer(this);
// invalidate the start reference time
lastTick = 0;
- lastDelta = 0;
}
}
diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h
index d50bc4d849..e8745c8c92 100644
--- a/src/qml/animations/qabstractanimationjob_p.h
+++ b/src/qml/animations/qabstractanimationjob_p.h
@@ -209,8 +209,6 @@ public:
void restartAnimationTimer();
void updateAnimationsTime(qint64 timeStep);
- int currentDelta() { return lastDelta; }
-
//useful for profiling/debugging
int runningAnimationCount() { return animations.count(); }
@@ -220,7 +218,6 @@ private Q_SLOTS:
private:
qint64 lastTick;
- int lastDelta;
int currentAnimationIdx;
bool insideTick;
bool startAnimationPending;
diff --git a/src/qml/animations/qcontinuinganimationgroupjob.cpp b/src/qml/animations/qcontinuinganimationgroupjob.cpp
new file mode 100644
index 0000000000..eb54b6e9aa
--- /dev/null
+++ b/src/qml/animations/qcontinuinganimationgroupjob.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qcontinuinganimationgroupjob_p.h"
+#include "private/qanimationjobutil_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QContinuingAnimationGroupJob::QContinuingAnimationGroupJob()
+ : QAnimationGroupJob()
+{
+}
+
+QContinuingAnimationGroupJob::~QContinuingAnimationGroupJob()
+{
+}
+
+void QContinuingAnimationGroupJob::updateCurrentTime(int /*currentTime*/)
+{
+ if (!firstChild())
+ return;
+
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ if (animation->state() == state()) {
+ RETURN_IF_DELETED(animation->setCurrentTime(m_currentTime));
+ }
+ }
+}
+
+void QContinuingAnimationGroupJob::updateState(QAbstractAnimationJob::State newState,
+ QAbstractAnimationJob::State oldState)
+{
+ QAnimationGroupJob::updateState(newState, oldState);
+
+ switch (newState) {
+ case Stopped:
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
+ animation->stop();
+ break;
+ case Paused:
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling())
+ if (animation->isRunning())
+ animation->pause();
+ break;
+ case Running:
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ resetUncontrolledAnimationFinishTime(animation);
+ animation->setDirection(m_direction);
+ animation->start();
+ }
+ break;
+ }
+}
+
+void QContinuingAnimationGroupJob::updateDirection(QAbstractAnimationJob::Direction direction)
+{
+ if (!isStopped()) {
+ for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
+ animation->setDirection(direction);
+ }
+ }
+}
+
+void QContinuingAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation)
+{
+ Q_ASSERT(animation && (animation->duration() == -1));
+ int uncontrolledRunningCount = 0;
+
+ for (QAbstractAnimationJob *child = firstChild(); child; child = child->nextSibling()) {
+ if (child == animation)
+ setUncontrolledAnimationFinishTime(animation, animation->currentTime());
+ else if (uncontrolledAnimationFinishTime(child) == -1)
+ ++uncontrolledRunningCount;
+ }
+
+ if (uncontrolledRunningCount > 0)
+ return;
+
+ setUncontrolledAnimationFinishTime(this, currentTime());
+ stop();
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/qml/animations/qcontinuinganimationgroupjob_p.h b/src/qml/animations/qcontinuinganimationgroupjob_p.h
new file mode 100644
index 0000000000..7578ab9709
--- /dev/null
+++ b/src/qml/animations/qcontinuinganimationgroupjob_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCONTINUINGANIMATIONGROUPJOB_P_H
+#define QCONTINUINGANIMATIONGROUPJOB_P_H
+
+#include "private/qanimationgroupjob_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class Q_QML_PRIVATE_EXPORT QContinuingAnimationGroupJob : public QAnimationGroupJob
+{
+ Q_DISABLE_COPY(QContinuingAnimationGroupJob)
+public:
+ QContinuingAnimationGroupJob();
+ ~QContinuingAnimationGroupJob();
+
+ int duration() const { return -1; }
+
+protected:
+ void updateCurrentTime(int currentTime);
+ void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState);
+ void updateDirection(QAbstractAnimationJob::Direction direction);
+ void uncontrolledAnimationFinished(QAbstractAnimationJob *animation);
+};
+
+QT_END_NAMESPACE
+
+#endif // QCONTINUINGANIMATIONGROUPJOB_P_H