aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/animations/qcontinuinganimationgroupjob.cpp
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/qcontinuinganimationgroupjob.cpp
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/qcontinuinganimationgroupjob.cpp')
-rw-r--r--src/qml/animations/qcontinuinganimationgroupjob.cpp122
1 files changed, 122 insertions, 0 deletions
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
+