summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xanimators/animators.pro4
-rwxr-xr-xanimators/src/qmldir1
-rwxr-xr-xanimators/src/qsgabstractanimation.cpp128
-rwxr-xr-xanimators/src/qsgabstractanimation.h102
-rwxr-xr-xanimators/src/qsgabstractanimator.cpp306
-rwxr-xr-xanimators/src/qsgabstractanimator.h117
-rwxr-xr-xanimators/src/qsganimatedproperty.cpp143
-rwxr-xr-xanimators/src/qsganimatedproperty.h77
-rwxr-xr-xanimators/src/qsganimatedrotation.cpp126
-rwxr-xr-xanimators/src/qsganimatedrotation.h74
-rwxr-xr-xanimators/src/qsganimatedscale.cpp102
-rwxr-xr-xanimators/src/qsganimatedscale.h68
-rwxr-xr-xanimators/src/qsganimatedtransform.cpp51
-rwxr-xr-xanimators/src/qsganimatedtransform.h60
-rwxr-xr-xanimators/src/qsganimatedtranslate.cpp75
-rwxr-xr-xanimators/src/qsganimatedtranslate.h63
-rwxr-xr-xanimators/src/qsganimatorcontroller.cpp364
-rwxr-xr-xanimators/src/qsganimatorcontroller.h93
-rwxr-xr-xanimators/src/qsganimatoritem.cpp77
-rwxr-xr-xanimators/src/qsganimatoritem.h66
-rwxr-xr-xanimators/src/qsganimatornode.cpp108
-rwxr-xr-xanimators/src/qsganimatornode.h66
-rwxr-xr-xanimators/src/qsganimatorplugin.cpp74
-rwxr-xr-xanimators/src/qsganimatorshadereffect.cpp119
-rwxr-xr-xanimators/src/qsganimatorshadereffect.h67
-rwxr-xr-xanimators/src/qsgcoloranimation.cpp67
-rwxr-xr-xanimators/src/qsgcoloranimation.h67
-rwxr-xr-xanimators/src/qsgnumberanimation.cpp68
-rwxr-xr-xanimators/src/qsgnumberanimation.h67
-rwxr-xr-xanimators/src/qsgparallelanimation.cpp58
-rwxr-xr-xanimators/src/qsgparallelanimation.h62
-rwxr-xr-xanimators/src/qsgparallelanimator.cpp83
-rwxr-xr-xanimators/src/qsgparallelanimator.h60
-rwxr-xr-xanimators/src/qsgpauseanimation.cpp60
-rwxr-xr-xanimators/src/qsgpauseanimation.h66
-rwxr-xr-xanimators/src/qsgpauseanimator.cpp74
-rwxr-xr-xanimators/src/qsgpauseanimator.h63
-rwxr-xr-xanimators/src/qsgpropertyanimation.cpp190
-rwxr-xr-xanimators/src/qsgpropertyanimation.h107
-rwxr-xr-xanimators/src/qsgpropertyanimator.cpp272
-rwxr-xr-xanimators/src/qsgpropertyanimator.h90
-rwxr-xr-xanimators/src/qsgsequentialanimation.cpp59
-rwxr-xr-xanimators/src/qsgsequentialanimation.h60
-rwxr-xr-xanimators/src/qsgsequentialanimator.cpp92
-rwxr-xr-xanimators/src/qsgsequentialanimator.h60
-rwxr-xr-xanimators/src/qsgtoplevelanimator.cpp72
-rwxr-xr-xanimators/src/qsgtoplevelanimator.h59
-rwxr-xr-xanimators/src/qsgvector3danimation.cpp71
-rwxr-xr-xanimators/src/qsgvector3danimation.h68
-rwxr-xr-xanimators/src/src.pro71
-rwxr-xr-xanimators/test/Control.qml178
-rwxr-xr-xanimators/test/TestBed.qml262
-rwxr-xr-xanimators/test/TestBedModel.qml23
-rwxr-xr-xanimators/test/TestMultipleAnimation.qml106
-rwxr-xr-xanimators/test/TestMultipleProperties.qml116
-rwxr-xr-xanimators/test/TestNumberAnimation.qml77
-rwxr-xr-xanimators/test/TestNumberAnimationAlwaysRunToEnd.qml80
-rwxr-xr-xanimators/test/TestOpacity.qml107
-rwxr-xr-xanimators/test/TestParallelAnimation.qml106
-rwxr-xr-xanimators/test/TestPosition.qml78
-rwxr-xr-xanimators/test/TestPropertyAnimation.qml76
-rwxr-xr-xanimators/test/TestRectangleRotation.qml131
-rwxr-xr-xanimators/test/TestRotation.qml106
-rwxr-xr-xanimators/test/TestScale.qml108
-rwxr-xr-xanimators/test/TestSequentialAnimation.qml108
-rwxr-xr-xanimators/test/TestSequentialAnimationAlwaysRunToEnd.qml110
-rwxr-xr-xanimators/test/TestShaderEffect.qml173
-rwxr-xr-xanimators/test/TestShaderEffectOpacity.qml151
-rwxr-xr-xanimators/test/TestTransformRotatation.qml110
-rwxr-xr-xanimators/test/TestTransformRotationOriginPoint.qml118
-rwxr-xr-xanimators/test/TestTransformScale.qml116
-rwxr-xr-xanimators/test/TestTransformTranslate.qml112
-rw-r--r--customcontext/animationdriver.cpp4
-rw-r--r--customcontext/customcontext.pro1
-rw-r--r--customcontext/windowmanager.cpp235
-rw-r--r--customcontext/windowmanager.h5
76 files changed, 7328 insertions, 66 deletions
diff --git a/animators/animators.pro b/animators/animators.pro
new file mode 100755
index 0000000..66116a4
--- /dev/null
+++ b/animators/animators.pro
@@ -0,0 +1,4 @@
+TEMPLATE=subdirs
+
+SUBDIRS=src
+
diff --git a/animators/src/qmldir b/animators/src/qmldir
new file mode 100755
index 0000000..cf2fda8
--- /dev/null
+++ b/animators/src/qmldir
@@ -0,0 +1 @@
+plugin animators
diff --git a/animators/src/qsgabstractanimation.cpp b/animators/src/qsgabstractanimation.cpp
new file mode 100755
index 0000000..21ffb00
--- /dev/null
+++ b/animators/src/qsgabstractanimation.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qsgabstractanimation.h"
+
+QSGAbstractAnimation::QSGAbstractAnimation(QQuickItem *parent)
+ : QQuickItem(parent)
+ , m_running(false)
+ , m_paused(false)
+ , m_alwaysRunToEnd(false)
+ , m_loops(1)
+ , m_target(0)
+{
+}
+
+QObject* QSGAbstractAnimation::target()
+{
+ return m_target;
+}
+
+void QSGAbstractAnimation::setTarget(QObject* a)
+{
+ if (m_target != a) {
+ m_target = a;
+ emit targetChanged();
+ }
+}
+
+int QSGAbstractAnimation::loops()
+{
+ return m_loops;
+}
+
+void QSGAbstractAnimation::setLoops(int a)
+{
+ if (m_loops != a) {
+ m_loops = a;
+ emit loopCountChanged(m_loops);
+ }
+}
+
+bool QSGAbstractAnimation::isRunning()
+{
+ return m_running;
+}
+
+void QSGAbstractAnimation::setRunning(bool a)
+{
+ if (m_running != a) {
+ m_running = a;
+ emit runningChanged(m_running);
+ }
+}
+
+bool QSGAbstractAnimation::isPaused()
+{
+ return m_paused;
+}
+
+void QSGAbstractAnimation::setPaused(bool a)
+{
+ if (m_paused != a) {
+ m_paused = a;
+ emit pausedChanged(m_paused);
+ }
+}
+
+bool QSGAbstractAnimation::alwaysRunToEnd()
+{
+ return m_alwaysRunToEnd;
+}
+
+void QSGAbstractAnimation::setAlwaysRunToEnd(bool a)
+{
+ if (m_alwaysRunToEnd != a) {
+ m_alwaysRunToEnd = a;
+ emit alwaysRunToEndChanged(m_alwaysRunToEnd);
+ }
+}
+
+void QSGAbstractAnimation::complete()
+{
+ emit completed();
+ setRunning(false);
+}
+
+void QSGAbstractAnimation::prepare(bool)
+{
+}
diff --git a/animators/src/qsgabstractanimation.h b/animators/src/qsgabstractanimation.h
new file mode 100755
index 0000000..5be1bbd
--- /dev/null
+++ b/animators/src/qsgabstractanimation.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGABSTRACTANIMATION_H
+#define QSGABSTRACTANIMATION_H
+
+#include <QtCore>
+#include <QtQuick>
+
+class QSGAbstractAnimation : public QQuickItem
+{
+ Q_OBJECT
+ Q_ENUMS(Loops)
+ Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
+ Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged)
+ Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopCountChanged)
+ Q_PROPERTY(QObject* target READ target WRITE setTarget NOTIFY targetChanged)
+
+public:
+ QSGAbstractAnimation(QQuickItem *parent = 0);
+
+ enum Loops { Infinite = -2 };
+
+ bool isRunning();
+ void setRunning(bool);
+
+ bool isPaused();
+ void setPaused(bool);
+
+ bool alwaysRunToEnd();
+ void setAlwaysRunToEnd(bool);
+
+ int loops();
+ void setLoops(int);
+
+ QObject* target();
+ void setTarget(QObject*);
+
+public Q_SLOTS:
+ virtual void complete();
+ virtual void prepare(bool);
+
+Q_SIGNALS:
+ void completed();
+ void runningChanged(bool);
+ void pausedChanged(bool);
+ void alwaysRunToEndChanged(bool);
+ void loopCountChanged(int);
+ void targetChanged();
+
+protected:
+ bool m_running;
+ bool m_paused;
+ bool m_alwaysRunToEnd;
+ int m_loops;
+ QObject* m_target;
+
+private:
+ Q_DISABLE_COPY(QSGAbstractAnimation)
+
+};
+
+#endif // QSGABSTRACTANIMATION_H
diff --git a/animators/src/qsgabstractanimator.cpp b/animators/src/qsgabstractanimator.cpp
new file mode 100755
index 0000000..7d6468b
--- /dev/null
+++ b/animators/src/qsgabstractanimator.cpp
@@ -0,0 +1,306 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgabstractanimator.h"
+#include "qsgabstractanimation.h"
+#include "qsganimatorcontroller.h"
+#include <QDebug>
+
+QSGAbstractAnimator::QSGAbstractAnimator(QSGAnimatorController* controller, QSGAbstractAnimator *parent, QSGAbstractAnimation *qmlObject, qreal startTime)
+ : m_parent(parent)
+ , m_controller(controller)
+ , m_startTime(startTime)
+ , m_stopTime(0)
+ , m_elapsed(0)
+ , m_duration(0)
+ , m_loops(1)
+ , m_running(false)
+ , m_paused(false)
+ , m_alwaysRunToEnd(false)
+ , m_runningToEnd(false)
+ , m_hasControl(false)
+ , m_stopping(false)
+ , m_done(false)
+ , m_qmlObject(qmlObject)
+{
+ copyQmlObjectData();
+ if (m_parent)
+ m_parent->registerAnimator(this);
+}
+
+QSGAbstractAnimator::~QSGAbstractAnimator()
+{
+ for (int i = 0; i < m_animators.count(); i++) {
+ m_animators.at(i)->setParent(0);
+ delete m_animators.at(i);
+ }
+
+ if (m_parent)
+ m_parent->unregisterAnimator(this);
+}
+
+void QSGAbstractAnimator::advance(qreal t)
+{
+ if ((!m_running || m_paused) && !m_runningToEnd)
+ return;
+
+ m_elapsed += t;
+
+ if (m_hasControl && m_elapsed > m_startTime + m_duration * m_loops) {
+ m_stopping = true;
+ }
+
+ if (m_runningToEnd && m_elapsed > m_stopTime) {
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGAbstractAnimator::advance running to end, stopping soon. m_elapsed = " << m_elapsed << " m_stopTime = " << m_stopTime;
+#endif
+ m_runningToEnd = false;
+ m_done = true;
+ m_stopTime = 0.0;
+ m_elapsed = m_stopTime;
+ }
+}
+
+void QSGAbstractAnimator::copyQmlObjectData()
+{
+ if (m_qmlObject) {
+ m_loops = m_qmlObject->loops();
+ m_running = m_qmlObject->isRunning();
+ m_paused = m_qmlObject->isPaused();
+ m_alwaysRunToEnd = m_qmlObject->alwaysRunToEnd();
+ }
+}
+
+qreal QSGAbstractAnimator::sync(bool topLevelRunning, qreal startTime)
+{
+ m_startTime = startTime;
+ bool wasRunning = m_running;
+
+ copyQmlObjectData();
+ if (m_qmlObject) {
+ m_running = m_qmlObject->isRunning() || topLevelRunning;
+ m_hasControl = m_qmlObject->isRunning() && !topLevelRunning;
+ }
+
+ // Normal stop request detected from QML side.
+ if (!wasRunning && m_running && !m_runningToEnd) {
+ m_elapsed = 0.0;
+ }
+
+ // Stop request from QML side detected, but must run to the end. Calculate stoptime.
+ if (m_alwaysRunToEnd && wasRunning && !m_running && m_duration > 0 && !m_runningToEnd) {
+ m_runningToEnd = true;
+ m_stopTime = m_startTime + qMax(1, 1 + int((m_elapsed - m_startTime) / m_duration)) * m_duration;
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGAbstractAnimator::sync m_stopTime = " << m_stopTime << " m_elapsed = " << m_elapsed;
+#endif
+ }
+
+ // Running, cancel possible run to the end sequence etc.
+ if (m_running) {
+ m_done = false;
+ m_runningToEnd = false;
+ m_stopTime = 0.0;
+ }
+
+ // Stop because running to the end of the animation duration.
+ if (m_qmlObject && m_running && m_stopping) {
+ m_stopping = false;
+ m_running = false;
+ m_done = true;
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGAbstractAnimator::sync stopping because end of animation reached.";
+#endif
+ }
+
+ // If done, let QML side know about it.
+ if (m_qmlObject && m_done) {
+ m_done = false;
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGAbstractAnimator::sync calling complete";
+#endif
+ int count = m_animators.count();
+ for (int i = 0; i < count; i++) {
+ QObject *o = m_animators.at(i)->qmlObject();
+ if (o)
+ QMetaObject::invokeMethod(o, "complete", Qt::QueuedConnection);
+ }
+ QMetaObject::invokeMethod(m_qmlObject, "complete", Qt::QueuedConnection);
+ }
+
+ return 0.0;
+}
+
+void QSGAbstractAnimator::registerAnimator(QSGAbstractAnimator *a)
+{
+ if (!m_animators.contains(a)) {
+ m_animators.append(a);
+#ifdef ANIMATORS_DEBUG
+ qDebug() << " ";
+ qDebug() << "QSGAbstractAnimator::registerAnimator - " << a;
+#endif
+ }
+}
+
+void QSGAbstractAnimator::unregisterAnimator(QSGAbstractAnimator *a)
+{
+ m_animators.removeAll(a);
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGAbstractAnimator::unregisterAnimator - " << a;
+#endif
+}
+
+QSGAbstractAnimator* QSGAbstractAnimator::parent()
+{
+ return m_parent;
+}
+
+void QSGAbstractAnimator::setParent(QSGAbstractAnimator *a)
+{
+ m_parent = a;
+}
+
+
+QSGAbstractAnimation* QSGAbstractAnimator::qmlObject()
+{
+ return m_qmlObject;
+}
+
+void QSGAbstractAnimator::setQmlObject(QSGAbstractAnimation* a)
+{
+ m_qmlObject = a;
+}
+
+int QSGAbstractAnimator::startTime()
+{
+ return m_startTime;
+}
+
+void QSGAbstractAnimator::setStartTime(int a)
+{
+ m_startTime = a;
+}
+
+qreal QSGAbstractAnimator::elapsed()
+{
+ return m_elapsed;
+}
+
+void QSGAbstractAnimator::setElapsed(qreal a)
+{
+ m_elapsed = a;
+}
+
+int QSGAbstractAnimator::duration()
+{
+ return m_duration;
+}
+
+void QSGAbstractAnimator::setDuration(int a)
+{
+ m_duration = a;
+}
+
+int QSGAbstractAnimator::loops()
+{
+ return m_loops;
+}
+
+void QSGAbstractAnimator::setLoops(int a)
+{
+ m_loops = a;
+}
+
+bool QSGAbstractAnimator::running()
+{
+ return m_running;
+}
+
+void QSGAbstractAnimator::setRunning(bool a)
+{
+ m_running = a;
+}
+
+bool QSGAbstractAnimator::paused()
+{
+ return m_paused;
+}
+
+void QSGAbstractAnimator::setPaused(bool a)
+{
+ m_paused = a;
+}
+
+bool QSGAbstractAnimator::alwaysRunToEnd()
+{
+ return m_alwaysRunToEnd;
+}
+
+void QSGAbstractAnimator::setAlwaysRunToEnd(bool a)
+{
+ m_alwaysRunToEnd = a;
+}
+
+bool QSGAbstractAnimator::isActive()
+{
+ if (m_running || m_runningToEnd)
+ return true;
+
+ bool childRunning = false;
+
+ for (int i = 0; i < m_animators.count(); i++)
+ childRunning |= m_animators.at(i)->isActive();
+
+ return childRunning;
+}
+
+bool QSGAbstractAnimator::isUpdating()
+{
+ if ((m_running && !m_paused) || m_runningToEnd)
+ return true;
+
+ bool childRunning = false;
+
+ for (int i = 0; i < m_animators.count(); i++)
+ childRunning |= m_animators.at(i)->isUpdating();
+
+ return childRunning;
+}
diff --git a/animators/src/qsgabstractanimator.h b/animators/src/qsgabstractanimator.h
new file mode 100755
index 0000000..12267dc
--- /dev/null
+++ b/animators/src/qsgabstractanimator.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGANIMATOR_H
+#define QSGANIMATOR_H
+
+#include <QtCore>
+
+class QSGAnimatorController;
+class QSGAbstractAnimation;
+
+class QSGAbstractAnimator
+{
+public:
+ QSGAbstractAnimator();
+ QSGAbstractAnimator(QSGAnimatorController *, QSGAbstractAnimator *, QSGAbstractAnimation *, qreal);
+ virtual ~QSGAbstractAnimator();
+
+ virtual void advance(qreal t = 0.0);
+ virtual qreal sync(bool topLevelRunning, qreal startTime = 0.0);
+
+ void registerAnimator(QSGAbstractAnimator *);
+ void unregisterAnimator(QSGAbstractAnimator *);
+
+ QSGAbstractAnimator* parent();
+ void setParent(QSGAbstractAnimator *);
+
+ QSGAbstractAnimation* qmlObject();
+ void setQmlObject(QSGAbstractAnimation *);
+
+ int startTime();
+ void setStartTime(int);
+
+ qreal elapsed();
+ void setElapsed(qreal);
+
+ int duration();
+ void setDuration(int);
+
+ int loops();
+ void setLoops(int);
+
+ bool running();
+ void setRunning(bool);
+
+ bool paused();
+ void setPaused(bool);
+
+ bool alwaysRunToEnd();
+ void setAlwaysRunToEnd(bool);
+
+ bool isActive();
+ bool isUpdating();
+
+private:
+ void copyQmlObjectData();
+
+protected:
+ QSGAbstractAnimator *m_parent;
+ QSGAnimatorController* m_controller;
+ QList<QSGAbstractAnimator*> m_animators;
+ int m_startTime;
+ int m_stopTime;
+ qreal m_elapsed;
+ int m_duration;
+ int m_loops;
+ bool m_running;
+ bool m_paused;
+ bool m_alwaysRunToEnd;
+ bool m_runningToEnd;
+ bool m_hasControl;
+ bool m_stopping;
+ bool m_done;
+
+private:
+ QSGAbstractAnimation *m_qmlObject;
+};
+
+#endif // QSGANIMATOR_H
diff --git a/animators/src/qsganimatedproperty.cpp b/animators/src/qsganimatedproperty.cpp
new file mode 100755
index 0000000..bb45371
--- /dev/null
+++ b/animators/src/qsganimatedproperty.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsganimatedproperty.h"
+#include "qsganimatorcontroller.h"
+
+QSGAnimatedProperty::QSGAnimatedProperty() :
+ m_qmlObject(0)
+ , m_name("")
+ , m_changed(false)
+{
+}
+
+QSGAnimatedProperty::QSGAnimatedProperty(QObject *qmlObject, QString name, QVariant value) :
+ m_qmlObject(qmlObject)
+ , m_name(name)
+ , m_value(value)
+ , m_changed(false)
+{
+ if (m_qmlObject)
+ m_value = m_qmlObject->property(m_name.toAscii().constData());
+}
+
+QSGAnimatedProperty::~QSGAnimatedProperty()
+{
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGAnimatedProperty::~QSGAnimatedProperty() " << m_name;
+#endif
+}
+
+void QSGAnimatedProperty::setQmlObject(QObject *v)
+{
+ m_qmlObject = v;
+}
+
+QObject *QSGAnimatedProperty::qmlObject()
+{
+ return m_qmlObject;
+}
+
+void QSGAnimatedProperty::setValue(QVariant v)
+{
+ m_value = v;
+ m_changed = true;
+}
+
+QVariant QSGAnimatedProperty::value()
+{
+ return m_value;
+}
+
+void QSGAnimatedProperty::setName(QString& name)
+{
+ m_name = name;
+}
+
+QString QSGAnimatedProperty::name()
+{
+ return m_name;
+}
+
+void QSGAnimatedProperty::setChanged(bool value)
+{
+ m_changed = value;
+}
+
+bool QSGAnimatedProperty::changed()
+{
+ return m_changed;
+}
+
+void QSGAnimatedProperty::sync()
+{
+ if (!m_qmlObject)
+ return;
+
+ QString p = m_name;
+ if (p.contains(".x")) {
+ p = p.left(p.length() - 2);
+ QVariant v = m_qmlObject->property(p.toAscii().constData());
+ if (v.isValid()) {
+ QVector3D vec = qvariant_cast<QVector3D>(v);
+ m_value = vec.x();
+ qDebug() << m_name << " = " << m_value;
+ }
+ } else if (p.contains(".y")) {
+ QVariant v = m_qmlObject->property(p.toAscii().constData());
+ if (v.isValid()) {
+ QVector3D vec = qvariant_cast<QVector3D>(v);
+ m_value = vec.y();
+ qDebug() << m_name << " = " << m_value;
+ }
+ } else if (p.contains(".z")) {
+ QVariant v = m_qmlObject->property(p.toAscii().constData());
+ if (v.isValid()) {
+ QVector3D vec = qvariant_cast<QVector3D>(v);
+ m_value = vec.z();
+ qDebug() << m_name << " = " << m_value;
+ }
+ } else {
+ m_value = m_qmlObject->property(m_name.toAscii().constData());
+ }
+
+ m_changed = false;
+}
diff --git a/animators/src/qsganimatedproperty.h b/animators/src/qsganimatedproperty.h
new file mode 100755
index 0000000..d44f6ba
--- /dev/null
+++ b/animators/src/qsganimatedproperty.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGANIMATETPROPERTY_H
+#define QSGANIMATETPROPERTY_H
+
+#include <QtCore>
+
+class QSGAnimatorController;
+
+class QSGAnimatedProperty
+{
+public:
+ QSGAnimatedProperty();
+ QSGAnimatedProperty(QObject *, QString, QVariant);
+ ~QSGAnimatedProperty();
+
+ void setQmlObject(QObject *);
+ QObject *qmlObject();
+
+ void setName(QString&);
+ QString name();
+
+ void setValue(QVariant);
+ QVariant value();
+
+ void setChanged(bool);
+ bool changed();
+
+ void sync();
+
+private:
+ QObject *m_qmlObject;
+ QString m_name;
+ QVariant m_value;
+ bool m_changed;
+};
+
+#endif // QSGANIMATETPROPERTY_H
diff --git a/animators/src/qsganimatedrotation.cpp b/animators/src/qsganimatedrotation.cpp
new file mode 100755
index 0000000..41a1db5
--- /dev/null
+++ b/animators/src/qsganimatedrotation.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsganimatedrotation.h"
+#include "qsganimatedproperty.h"
+#include "qsganimatorcontroller.h"
+#include <QtGui>
+
+QSGAnimatedRotation::QSGAnimatedRotation(QSGAnimatorController* controller, QObject* qmlObject) : QSGAnimatedTransform(controller, qmlObject)
+{
+ m_angle = new QSGAnimatedProperty(m_qmlObject, "angle", 0.0);
+ m_axisX = new QSGAnimatedProperty(m_qmlObject, "axis.x", 0.0);
+ m_axisY = new QSGAnimatedProperty(m_qmlObject, "axis.y", 0.0);
+ m_axisZ = new QSGAnimatedProperty(m_qmlObject, "axis.z", 1.0);
+ m_originX = new QSGAnimatedProperty(m_qmlObject, "origin.x", 0.0);
+ m_originY = new QSGAnimatedProperty(m_qmlObject, "origin.y", 0.0);
+
+ // controller takes owneship
+ controller->registerProperty(m_angle);
+ controller->registerProperty(m_axisX);
+ controller->registerProperty(m_axisY);
+ controller->registerProperty(m_axisZ);
+ controller->registerProperty(m_originX);
+ controller->registerProperty(m_originY);
+
+ if (qmlObject) {
+ setAngle(qmlObject->property("angle"));
+ setAxis(qmlObject->property("axis"));
+ setOrigin(qmlObject->property("origin"));
+ }
+}
+
+void QSGAnimatedRotation::setAngle(QVariant v)
+{
+ m_angle->setValue(v);
+}
+
+void QSGAnimatedRotation::setAxis(QVariant v)
+{
+ if (v.isValid() && v.type() == QVariant::Vector3D){
+ QVector3D vec = qvariant_cast<QVector3D>(v);
+ m_axisX->setValue(vec.x());
+ m_axisY->setValue(vec.y());
+ m_axisZ->setValue(vec.z());
+ }
+}
+
+void QSGAnimatedRotation::setAxisX(QVariant v)
+{
+ m_axisX->setValue(v);
+}
+
+void QSGAnimatedRotation::setAxisY(QVariant v)
+{
+ m_axisY->setValue(v);
+}
+
+void QSGAnimatedRotation::setAxisZ(QVariant v)
+{
+ m_axisZ->setValue(v);
+}
+
+void QSGAnimatedRotation::setOrigin(QVariant v)
+{
+ if (v.isValid() && v.type() == QVariant::Vector3D){
+ QVector3D vec = qvariant_cast<QVector3D>(v);
+ m_originX->setValue(vec.x());
+ m_originY->setValue(vec.y());
+ }
+}
+
+void QSGAnimatedRotation::setOriginX(QVariant v)
+{
+ m_originX->setValue(v);
+}
+
+void QSGAnimatedRotation::setOriginY(QVariant v)
+{
+ m_originY->setValue(v);
+}
+
+void QSGAnimatedRotation::applyTo(QMatrix4x4 &m)
+{
+ m.translate(m_originX->value().toReal(), m_originY->value().toReal());
+ m.rotate(m_angle->value().toReal(), m_axisX->value().toReal(), m_axisY->value().toReal(), m_axisZ->value().toReal());
+ m.translate(-m_originX->value().toReal(), -m_originY->value().toReal());
+}
+
diff --git a/animators/src/qsganimatedrotation.h b/animators/src/qsganimatedrotation.h
new file mode 100755
index 0000000..fec879e
--- /dev/null
+++ b/animators/src/qsganimatedrotation.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSGANIMATEDROTATION_H
+#define QSGANIMATEDROTATION_H
+
+#include <QtCore>
+#include "qsganimatedtransform.h"
+
+class QSGAnimatedProperty;
+
+class QSGAnimatedRotation : public QSGAnimatedTransform
+{
+public:
+ QSGAnimatedRotation(QSGAnimatorController *, QObject *);
+ virtual void applyTo(QMatrix4x4 &);
+ void setAngle(QVariant);
+ void setAxis(QVariant);
+ void setAxisX(QVariant);
+ void setAxisY(QVariant);
+ void setAxisZ(QVariant);
+ void setOrigin(QVariant);
+ void setOriginX(QVariant);
+ void setOriginY(QVariant);
+
+private:
+ QSGAnimatedProperty *m_angle;
+ QSGAnimatedProperty *m_axisX;
+ QSGAnimatedProperty *m_axisY;
+ QSGAnimatedProperty *m_axisZ;
+ QSGAnimatedProperty *m_originX;
+ QSGAnimatedProperty *m_originY;
+};
+
+#endif // QSGANIMATEDROTATION_H
diff --git a/animators/src/qsganimatedscale.cpp b/animators/src/qsganimatedscale.cpp
new file mode 100755
index 0000000..32a859d
--- /dev/null
+++ b/animators/src/qsganimatedscale.cpp
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsganimatedscale.h"
+#include "qsganimatedproperty.h"
+#include "qsganimatorcontroller.h"
+#include <QtGui>
+
+QSGAnimatedScale::QSGAnimatedScale(QSGAnimatorController* controller, QObject* qmlObject) : QSGAnimatedTransform(controller, qmlObject)
+{
+ m_xScale = new QSGAnimatedProperty(m_qmlObject, "xScale", 1.0);
+ m_yScale = new QSGAnimatedProperty(m_qmlObject, "yScale", 1.0);
+ m_originX = new QSGAnimatedProperty(m_qmlObject, "origin.x", 0.0);
+ m_originY = new QSGAnimatedProperty(m_qmlObject, "origin.y", 0.0);
+
+ // controller takes ownership
+ controller->registerProperty(m_xScale);
+ controller->registerProperty(m_yScale);
+ controller->registerProperty(m_originX);
+ controller->registerProperty(m_originY);
+
+ if (qmlObject) {
+ setXScale(qmlObject->property("xScale"));
+ setYScale(qmlObject->property("yScale"));
+ setOrigin(qmlObject->property("origin"));
+ }
+}
+
+void QSGAnimatedScale::setOrigin(QVariant v)
+{
+ if (v.isValid() && v.type() == QVariant::Vector3D){
+ QVector3D vec = qvariant_cast<QVector3D>(v);
+ m_originX->setValue(vec.x());
+ m_originY->setValue(vec.y());
+ }
+}
+
+void QSGAnimatedScale::setXScale(QVariant v)
+{
+ m_xScale->setValue(v);
+}
+
+void QSGAnimatedScale::setYScale(QVariant v)
+{
+ m_yScale->setValue(v);
+}
+
+void QSGAnimatedScale::setOriginX(QVariant v)
+{
+ m_originX->setValue(v);
+}
+
+void QSGAnimatedScale::setOriginY(QVariant v)
+{
+ m_originY->setValue(v);
+}
+
+void QSGAnimatedScale::applyTo(QMatrix4x4 &m)
+{
+ m.translate(m_originX->value().toReal(), m_originY->value().toReal());
+ m.scale(m_xScale->value().toReal(), m_yScale->value().toReal());
+ m.translate(-m_originX->value().toReal(), -m_originY->value().toReal());
+}
+
diff --git a/animators/src/qsganimatedscale.h b/animators/src/qsganimatedscale.h
new file mode 100755
index 0000000..8737398
--- /dev/null
+++ b/animators/src/qsganimatedscale.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGANIMATEDSCALE_H
+#define QSGANIMATEDSCALE_H
+
+#include <QtCore>
+#include "qsganimatedtransform.h"
+
+class QSGAnimatedProperty;
+
+class QSGAnimatedScale : public QSGAnimatedTransform
+{
+public:
+ QSGAnimatedScale(QSGAnimatorController *, QObject *);
+ virtual void applyTo(QMatrix4x4 &);
+ void setXScale(QVariant);
+ void setYScale(QVariant);
+ void setOrigin(QVariant);
+ void setOriginX(QVariant);
+ void setOriginY(QVariant);
+
+private:
+ QSGAnimatedProperty *m_originX;
+ QSGAnimatedProperty *m_originY;
+ QSGAnimatedProperty *m_yScale;
+ QSGAnimatedProperty *m_xScale;
+};
+
+#endif // QSGANIMATEDSCALE_H
diff --git a/animators/src/qsganimatedtransform.cpp b/animators/src/qsganimatedtransform.cpp
new file mode 100755
index 0000000..44b338b
--- /dev/null
+++ b/animators/src/qsganimatedtransform.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsganimatedtransform.h"
+#include "qsganimatedproperty.h"
+#include "qsganimatorcontroller.h"
+#include <QtGui>
+
+QSGAnimatedTransform::QSGAnimatedTransform(QSGAnimatorController* controller, QObject* qmlObject)
+ : m_qmlObject(qmlObject)
+{
+}
+
diff --git a/animators/src/qsganimatedtransform.h b/animators/src/qsganimatedtransform.h
new file mode 100755
index 0000000..fff5f69
--- /dev/null
+++ b/animators/src/qsganimatedtransform.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGANIMATEDTRANSFORM_H
+#define QSGANIMATEDTRANSFORM_H
+
+#include <QtCore>
+
+class QSGAnimatorController;
+
+class QSGAnimatedTransform
+{
+public:
+ QSGAnimatedTransform(QSGAnimatorController *, QObject *);
+ virtual void applyTo(QMatrix4x4 &) = 0;
+
+protected:
+ QObject *m_qmlObject;
+};
+
+
+#endif // QSGANIMATEDTRANSFORM_H
diff --git a/animators/src/qsganimatedtranslate.cpp b/animators/src/qsganimatedtranslate.cpp
new file mode 100755
index 0000000..00b6fbb
--- /dev/null
+++ b/animators/src/qsganimatedtranslate.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsganimatedtranslate.h"
+#include "qsganimatedproperty.h"
+#include "qsganimatorcontroller.h"
+#include <QtGui>
+
+QSGAnimatedTranslate::QSGAnimatedTranslate(QSGAnimatorController* controller, QObject* qmlObject) : QSGAnimatedTransform(controller, qmlObject)
+{
+ m_x = new QSGAnimatedProperty(m_qmlObject, "x", 0.0);
+ m_y = new QSGAnimatedProperty(m_qmlObject, "y", 0.0);
+
+ // controller takes owneship
+ controller->registerProperty(m_x);
+ controller->registerProperty(m_y);
+
+ if (qmlObject) {
+ setX(qmlObject->property("x"));
+ setY(qmlObject->property("y"));
+ }
+}
+
+void QSGAnimatedTranslate::setX(QVariant x)
+{
+ m_x->setValue(x);
+}
+
+void QSGAnimatedTranslate::setY(QVariant y)
+{
+ m_y->setValue(y);
+}
+
+void QSGAnimatedTranslate::applyTo(QMatrix4x4 &m)
+{
+ m.translate(m_x->value().toReal(), m_y->value().toReal());
+}
diff --git a/animators/src/qsganimatedtranslate.h b/animators/src/qsganimatedtranslate.h
new file mode 100755
index 0000000..2e5ce07
--- /dev/null
+++ b/animators/src/qsganimatedtranslate.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGANIMATEDTRANSLATE_H
+#define QSGANIMATEDTRANSLATE_H
+
+#include <QtCore>
+#include "qsganimatedtransform.h"
+
+class QSGAnimatedProperty;
+
+class QSGAnimatedTranslate : public QSGAnimatedTransform
+{
+public:
+ QSGAnimatedTranslate(QSGAnimatorController *, QObject *);
+ virtual void applyTo(QMatrix4x4 &);
+ void setX(QVariant);
+ void setY(QVariant);
+
+private:
+ QSGAnimatedProperty *m_x;
+ QSGAnimatedProperty *m_y;
+};
+
+#endif // QSGANIMATEDTRANSLATE_H
diff --git a/animators/src/qsganimatorcontroller.cpp b/animators/src/qsganimatorcontroller.cpp
new file mode 100755
index 0000000..b7b421b
--- /dev/null
+++ b/animators/src/qsganimatorcontroller.cpp
@@ -0,0 +1,364 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsganimatorcontroller.h"
+#include "qsganimatoritem.h"
+#include "qsganimatedtranslate.h"
+#include "qsganimatedscale.h"
+#include "qsganimatedrotation.h"
+#include "qsgpropertyanimator.h"
+#include "qsgsequentialanimator.h"
+#include "qsgparallelanimator.h"
+#include "qsgpauseanimator.h"
+
+#include "qsgpropertyanimation.h"
+#include "qsgsequentialanimation.h"
+#include "qsgparallelanimation.h"
+#include "qsgpauseanimation.h"
+
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformnativeinterface.h>
+#include <private/qguiapplication_p.h>
+
+#include <QtQuick>
+#include <QtQuick/private/qquickitem_p.h>
+
+const char *FILE_NAME = "/tmp/.sgavsd";
+
+float get_env_float(const char *name, float defaultValue)
+{
+ QByteArray content = qgetenv(name);
+ bool ok = false;
+ float value = content.toFloat(&ok);
+ return ok ? value : defaultValue;
+}
+
+QSGAnimatorController::QSGAnimatorController(QQuickItem *item)
+ : m_item(item)
+ , m_initialized(false)
+ , m_frameCounter(0)
+ , m_stableVsync(0)
+ , m_currentAnimationTime(0.0)
+ , m_currentAnimationDelay(0)
+ , m_currentAnimationCatchup(0)
+ , m_thresholdForCatchup(250.0)
+ , m_catchupRatio(0.05)
+
+{
+ m_thresholdForCatchup = get_env_float("QML_ANIMATION_DRIVER_CATCHUP_THRESHOLD", 250);
+ m_catchupRatio = get_env_float("QML_ANIMATION_DRIVER_CATCHUP_RATIO", 0.05);
+
+ QPlatformNativeInterface *iface = QGuiApplicationPrivate::platform_integration->nativeInterface();
+ void *ptr = iface->nativeResourceForIntegration("vsync-delta-from-ioctl");
+
+ if (ptr) {
+ m_stableVsync = *static_cast<float *>(ptr);
+ } else {
+ FILE *file = fopen(FILE_NAME, "r");
+ if (file) {
+ float value = 0;
+ int size = fread(&value, sizeof(float), 1, file);
+ fclose(file);
+
+ // basic sanity check on the value...
+ if (size == sizeof(float) && value > 10 && value < 35) {
+ m_stableVsync = value;
+ }
+ }
+ }
+
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGAnimatorController::QSGAnimatorController() VSYNC: " << m_stableVsync;
+#endif
+
+ connect(item->canvas(), SIGNAL(beforeRendering()), SLOT(advance()),Qt::DirectConnection);
+}
+
+QSGAnimatorController::~QSGAnimatorController()
+{
+ int tc = m_transform.count();
+ for (int i = 0; i < tc; i++)
+ delete m_transform.at(i);
+
+ QList<QSGAnimatedProperty*> properties = m_registeredProperties.values();
+ int pc = properties.count();
+ for (int i = 0; i < pc; i++) {
+ delete properties.at(i);
+ }
+}
+
+bool QSGAnimatorController::isInitialized()
+{
+ return m_initialized;
+}
+
+bool QSGAnimatorController::isUpdating()
+{
+ return m_topLevelAnimator.isUpdating();
+}
+
+void QSGAnimatorController::advance()
+{
+ qreal previousTime = m_currentAnimationTime;
+ qint64 t = m_timer.elapsed();
+
+ if (m_frameCounter == 0) {
+ t = 0;
+ m_timer.restart();
+ m_currentAnimationTime = 0.0;
+ previousTime = 0.0;
+ m_frameCounter++;
+ m_currentAnimationDelay = 0.0;
+ m_currentAnimationCatchup = 0.0;
+ }
+
+ if (m_topLevelAnimator.isUpdating()) {
+ if (m_stableVsync > 0) {
+ m_currentAnimationTime += (m_stableVsync + m_currentAnimationCatchup);
+ m_currentAnimationDelay -= m_currentAnimationCatchup;
+
+ if (m_currentAnimationDelay < m_currentAnimationCatchup * 0.5) {
+ m_currentAnimationDelay = 0.0;
+ m_currentAnimationCatchup = 0.0;
+ }
+
+ if (m_currentAnimationTime < t) {
+ m_currentAnimationDelay = t - m_currentAnimationTime;
+ m_currentAnimationTime = qFloor((t / m_stableVsync) + 1) * m_stableVsync;
+
+ if (m_currentAnimationDelay > m_thresholdForCatchup) {
+ m_currentAnimationTime += m_currentAnimationDelay;
+ m_currentAnimationDelay = 0.0;
+ }
+ m_currentAnimationCatchup = m_currentAnimationDelay * m_catchupRatio;
+#ifdef ANIMATORS_DEBUG
+ if (m_currentAnimationCatchup > 0)
+ qDebug() << "QSGAnimatorController::advance() m_currentAnimationCatchup = " << m_currentAnimationCatchup;
+#endif
+ }
+ //qDebug() << "QSGAnimatorController::advance() m_currentAnimationTime = " << m_currentAnimationTime;
+ //qDebug() << "QSGAnimatorController::advance() m_currentAnimationDelay = " << m_currentAnimationDelay;
+ //qDebug() << "QSGAnimatorController::advance() m_currentAnimationCatchup = " << m_currentAnimationCatchup;
+ //qDebug() << "----";
+
+ } else {
+ m_currentAnimationTime = t;
+ }
+
+ m_topLevelAnimator.advance(m_currentAnimationTime - previousTime);
+ } else {
+ m_frameCounter = 0;
+ }
+}
+
+void QSGAnimatorController::sync()
+{
+ if (!m_initialized) {
+ createProperties();
+ createAnimators();
+ m_initialized = true;
+
+ if (m_topLevelAnimator.isUpdating())
+ m_item->update();
+
+ return;
+ }
+
+ // How to handle reading back property values from qml...
+ // for now just avoid it when *any* animator is active.
+ bool syncProperties = !m_topLevelAnimator.isActive();
+
+ m_topLevelAnimator.sync(false, 0.0);
+
+ if (syncProperties) {
+ QList<QSGAnimatedProperty*> properties = m_registeredProperties.values();
+ for (int i = 0; i < properties.count(); i++)
+ properties.at(i)->sync();
+ }
+
+ if (m_topLevelAnimator.isUpdating())
+ m_item->update();
+}
+
+void QSGAnimatorController::registerProperty(QSGAnimatedProperty *p)
+{
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "registerProperty: " << p->name() << " of " << p->qmlObject() << " value = " << p->value();
+#endif
+ QString key = QString::number((quint64) p->qmlObject()) + "_" + p->name();
+
+ if (!m_registeredProperties.contains(key))
+ m_registeredProperties.insert(key, p);
+
+}
+
+void QSGAnimatorController::unregisterProperty(QSGAnimatedProperty *p)
+{
+ QString key = QString::number((quint64)p->qmlObject()) + "_" + p->name();
+ m_registeredProperties.remove(key);
+
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "unregisterProperty: " << p->name() << " of " << p->qmlObject();
+#endif
+}
+
+QSGAnimatedProperty *QSGAnimatorController::registeredProperty(QString name, QObject *o)
+{
+ QObject* qmlObject = 0;
+
+ if (o)
+ qmlObject = o;
+ else
+ qmlObject = m_item;
+
+ QString key = QString::number((quint64)qmlObject) + "_" + name;
+ return m_registeredProperties.value(key);
+}
+
+QMatrix4x4 QSGAnimatorController::transformMatrix()
+{
+ QMatrix4x4 m;
+ int count = m_transform.count();
+ for (int i = 0; i < count; i++) {
+ m_transform.at(i)->applyTo(m);
+ }
+ return m;
+}
+
+void QSGAnimatorController::createProperties()
+{
+ int propertyCount = m_item->metaObject()->propertyCount();
+ for (int i = 0; i < propertyCount; i++) {
+ QString name = m_item->metaObject()->property(i).name();
+ QVariant v = m_item->property(name.toAscii().constData());
+ QSGAnimatedProperty *p = new QSGAnimatedProperty(m_item, name, v);
+ registerProperty(p);
+ }
+
+ QQuickItemPrivate *o = QQuickItemPrivate::get(m_item);
+
+ if (!o)
+ return;
+
+ QQmlListProperty<QQuickTransform> list = m_item->transform();
+ int tc = o->transform_count(&list);
+ for (int i = 0; i < tc; i++) {
+ QQuickTransform *t = o->transform_at(&list, i);
+
+ // Not possible to qobject_cast QQuickTransform (not exported), so we use metaobject.
+ QString n = QString(t->metaObject()->className());
+ if (n == "QQuickTranslate") {
+ QSGAnimatedTranslate *tr = new QSGAnimatedTranslate(this, t);
+ m_transform.append(tr);
+ }
+ else if (n == "QQuickScale") {
+ QSGAnimatedScale *tr = new QSGAnimatedScale(this, t);
+ m_transform.append(tr);
+ }
+ else if (n == "QQuickRotation") {
+ QSGAnimatedRotation *tr = new QSGAnimatedRotation(this, t);
+ m_transform.append(tr);
+ }
+ }
+}
+
+void QSGAnimatorController::createAnimators()
+{
+ int count = m_item->children().count();
+ qreal duration = 0.0;
+ for (int i = 0; i < count; i++) {
+ duration = createAnimators(&m_topLevelAnimator, m_item->children().at(i), false, 0.0);
+ m_topLevelAnimator.setDuration(duration);
+ }
+}
+
+qreal QSGAnimatorController::createAnimators(QSGAbstractAnimator *controller, QObject *o, bool topLevelRunning, qreal startTime)
+{
+ if (!o)
+ return 0.0;
+
+ QString n = QString(o->metaObject()->className());
+ qreal duration = 0.0;
+
+ if (n == "QSGPropertyAnimation" || n == "QSGNumberAnimation" || n == "QSGColorAnimation" || n == "QSGVector3DAnimation") {
+ QSGPropertyAnimation *propertyAnimation = qobject_cast<QSGPropertyAnimation*> (o);
+ QSGPropertyAnimator *animator = new QSGPropertyAnimator(this, controller, propertyAnimation, startTime);
+ animator->setRunning(animator->running() || topLevelRunning);
+ duration += propertyAnimation->duration();
+ duration *= propertyAnimation->loops();
+ QObject::connect(propertyAnimation, SIGNAL(runningChanged(bool)), m_item, SLOT(update()));
+ QObject::connect(propertyAnimation, SIGNAL(pausedChanged(bool)), m_item, SLOT(update()));
+ } else if (n == "QSGSequentialAnimation") {
+ QSGAbstractAnimation *sequentialAnimation = qobject_cast<QSGAbstractAnimation*> (o);
+ QSGSequentialAnimator *animator = new QSGSequentialAnimator(this, controller, sequentialAnimation, startTime);
+ animator->setRunning(animator->running() || topLevelRunning);
+ int count = sequentialAnimation->children().count();
+ for (int i = 0; i < count; i++) {
+ duration += createAnimators(animator, sequentialAnimation->children().at(i), sequentialAnimation->isRunning() || topLevelRunning, startTime + duration);
+ }
+ animator->setDuration(duration);
+ duration *= sequentialAnimation->loops();
+ QObject::connect(sequentialAnimation, SIGNAL(runningChanged(bool)), m_item, SLOT(update()));
+ QObject::connect(sequentialAnimation, SIGNAL(pausedChanged(bool)), m_item, SLOT(update()));
+ } else if (n == "QSGParallelAnimation") {
+ QSGParallelAnimation *parallelAnimation = qobject_cast<QSGParallelAnimation*> (o);
+ QSGParallelAnimator *animator = new QSGParallelAnimator(this, controller, parallelAnimation, startTime);
+ animator->setRunning(animator->running() || topLevelRunning);
+ int count = parallelAnimation->children().count();
+ for (int i = 0; i < count; i++) {
+ qreal childAnimationDuration = createAnimators(animator, parallelAnimation->children().at(i), parallelAnimation->isRunning() || topLevelRunning, startTime);
+ duration = qMax(duration, childAnimationDuration);
+ }
+ animator->setDuration(duration);
+ duration *= parallelAnimation->loops();
+ QObject::connect(parallelAnimation, SIGNAL(runningChanged(bool)), m_item, SLOT(update()));
+ QObject::connect(parallelAnimation, SIGNAL(pausedChanged(bool)), m_item, SLOT(update()));
+ } else if (n == "QSGPauseAnimation") {
+ QSGPauseAnimation *pauseAnimation = qobject_cast<QSGPauseAnimation*> (o);
+ QSGPauseAnimator *animator = new QSGPauseAnimator(this, controller, pauseAnimation, startTime);
+ animator->setRunning(animator->running() || topLevelRunning);
+ duration = pauseAnimation->duration();
+ duration *= pauseAnimation->loops();
+ QObject::connect(pauseAnimation, SIGNAL(runningChanged(bool)), m_item, SLOT(update()));
+ QObject::connect(pauseAnimation, SIGNAL(pausedChanged(bool)), m_item, SLOT(update()));
+ }
+ return duration;
+}
diff --git a/animators/src/qsganimatorcontroller.h b/animators/src/qsganimatorcontroller.h
new file mode 100755
index 0000000..69d1876
--- /dev/null
+++ b/animators/src/qsganimatorcontroller.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSGANIMATORCONTROLLER_H
+#define QSGANIMATORCONTROLLER_H
+
+#include "qsgtoplevelanimator.h"
+#include "qsganimatedtransform.h"
+#include "qsganimatedproperty.h"
+
+class QQuickItem;
+
+class QSGAnimatorController : public QObject
+{
+ Q_OBJECT
+public:
+ QSGAnimatorController(QQuickItem *);
+ ~QSGAnimatorController();
+
+ void sync();
+
+ void registerProperty(QSGAnimatedProperty *);
+ void unregisterProperty(QSGAnimatedProperty *);
+ QSGAnimatedProperty *registeredProperty(QString, QObject *o = 0);
+
+ bool isInitialized();
+ bool isUpdating();
+ QMatrix4x4 transformMatrix();
+
+public Q_SLOTS:
+ void advance();
+
+private:
+ void createProperties();
+ void createAnimators();
+ qreal createAnimators(QSGAbstractAnimator *, QObject *, bool, qreal);
+
+private:
+ QQuickItem *m_item;
+ QList<QSGAnimatedTransform*> m_transform;
+ bool m_initialized;
+ QSGTopLevelAnimator m_topLevelAnimator;
+ QElapsedTimer m_timer;
+ int m_frameCounter;
+ qreal m_stableVsync;
+ qreal m_currentAnimationTime;
+ qreal m_currentAnimationDelay;
+ qreal m_currentAnimationCatchup;
+ qreal m_thresholdForCatchup;
+ qreal m_catchupRatio;
+ QHash<QString, QSGAnimatedProperty*> m_registeredProperties;
+};
+
+#endif
diff --git a/animators/src/qsganimatoritem.cpp b/animators/src/qsganimatoritem.cpp
new file mode 100755
index 0000000..ed84255
--- /dev/null
+++ b/animators/src/qsganimatoritem.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qsganimatoritem.h"
+#include "qsganimatorcontroller.h"
+#include "qsganimatornode.h"
+#include <QtQuick/QQuickItem>
+#include <QDebug>
+
+QSGAnimatorItem::QSGAnimatorItem(QQuickItem *parent)
+ : QQuickItem(parent)
+ , m_animatorNode(0)
+{
+ setFlag(ItemHasContents);
+}
+
+QSGAnimatorItem::~QSGAnimatorItem()
+{
+}
+
+QSGNode *QSGAnimatorItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
+{
+ QSGTransformNode *transformNode = static_cast<QSGTransformNode*>(QQuickItemPrivate::get(this)->itemNode());
+ QSGOpacityNode *opacityNode = static_cast<QSGOpacityNode*>(QQuickItemPrivate::get(this)->opacityNode());
+
+ if (!node) {
+ m_animatorNode = new QSGAnimatorNode(this);
+ m_animatorNode->setFlag(QSGNode::UsePreprocess, true);
+ }
+
+ if (m_animatorNode) {
+ m_animatorNode->controller().sync();
+ m_animatorNode->setTransformNode(transformNode);
+ m_animatorNode->setOpacityNode(opacityNode);
+ }
+
+ return m_animatorNode;
+}
diff --git a/animators/src/qsganimatoritem.h b/animators/src/qsganimatoritem.h
new file mode 100755
index 0000000..c40de7e
--- /dev/null
+++ b/animators/src/qsganimatoritem.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGANIMATORITEM_H
+#define QSGANIMATORITEM_H
+
+#include <QtQuick/QQuickItem>
+#include "qsganimatorcontroller.h"
+
+class QSGAnimatorNode;
+class QSGAnimatorController;
+
+class QSGAnimatorItem : public QQuickItem
+{
+ Q_OBJECT
+public:
+ QSGAnimatorItem(QQuickItem *parent = 0);
+ ~QSGAnimatorItem();
+
+protected:
+ virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+
+private:
+ QSGAnimatorNode *m_animatorNode;
+ Q_DISABLE_COPY(QSGAnimatorItem)
+};
+
+#endif // QSGANIMATORITEM_H
diff --git a/animators/src/qsganimatornode.cpp b/animators/src/qsganimatornode.cpp
new file mode 100755
index 0000000..209c2b8
--- /dev/null
+++ b/animators/src/qsganimatornode.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsganimatornode.h"
+#include "qsganimatorcontroller.h"
+
+#define MIN_OPACITY 0.001
+#define MAX_OPACITY 0.999
+
+QSGAnimatorNode::QSGAnimatorNode(QQuickItem *item)
+ : m_item(item)
+ , m_controller(0)
+ , m_transformNode(0)
+ , m_opacityNode(0)
+{
+ m_controller = new QSGAnimatorController(item);
+}
+
+QSGAnimatorNode::~QSGAnimatorNode()
+{
+ delete m_controller;
+}
+
+void QSGAnimatorNode::setTransformNode(QSGTransformNode *n)
+{
+ m_transformNode = n;
+}
+
+void QSGAnimatorNode::setOpacityNode(QSGOpacityNode *n)
+{
+ m_opacityNode = n;
+}
+
+void QSGAnimatorNode::preprocess()
+{
+ QSGNode::preprocess();
+ if (m_controller->isInitialized()) {
+ if (m_transformNode) {
+ qreal x = m_controller->registeredProperty("x")->value().toReal();
+ qreal y = m_controller->registeredProperty("y")->value().toReal();
+ QMatrix4x4 m = m_controller->transformMatrix();
+ QPointF transformOrigin = m_controller->registeredProperty("transformOriginPoint")->value().toPointF();
+ qreal scale = m_controller->registeredProperty("scale")->value().toReal();
+ qreal rotation = m_controller->registeredProperty("rotation")->value().toReal();
+ m.translate(transformOrigin.x(), transformOrigin.y());
+ m.scale(scale);
+ m.rotate(rotation, 0, 0, 1);
+ m.translate(-transformOrigin.x(), -transformOrigin.y());
+ m.translate(x, y);
+ m_transformNode->setMatrix(m);
+
+ if (m_controller->isUpdating())
+ m_transformNode->markDirty(QSGNode::DirtyMatrix);
+ }
+
+ if (m_opacityNode) {
+ qreal opacity = m_controller->registeredProperty("opacity")->value().toReal();
+ m_opacityNode->setOpacity(qMin(qreal(MAX_OPACITY), qMax(qreal(MIN_OPACITY), opacity)));
+
+ if (m_controller->isUpdating())
+ m_opacityNode->markDirty(QSGNode::DirtyOpacity);
+ }
+ }
+}
+
+QSGAnimatorController& QSGAnimatorNode::controller()
+{
+ return *m_controller;
+}
+
diff --git a/animators/src/qsganimatornode.h b/animators/src/qsganimatornode.h
new file mode 100755
index 0000000..5402b39
--- /dev/null
+++ b/animators/src/qsganimatornode.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGANIMATORNODE_H
+#define QSGANIMATORNODE_H
+
+#include <QtQuick/private/qquickitem_p.h>
+
+class QSGAnimatorController;
+
+class QSGAnimatorNode : public QSGNode
+{
+public:
+ QSGAnimatorNode(QQuickItem *item);
+ ~QSGAnimatorNode();
+ virtual void preprocess();
+ QSGAnimatorController& controller();
+ void setTransformNode(QSGTransformNode *);
+ void setOpacityNode(QSGOpacityNode *);
+
+protected:
+ QQuickItem *m_item;
+ QSGAnimatorController *m_controller;
+ QSGTransformNode *m_transformNode;
+ QSGOpacityNode *m_opacityNode;
+};
+
+#endif // QSGANIMATORNODE_H
diff --git a/animators/src/qsganimatorplugin.cpp b/animators/src/qsganimatorplugin.cpp
new file mode 100755
index 0000000..e2000b7
--- /dev/null
+++ b/animators/src/qsganimatorplugin.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/qqmlextensionplugin.h>
+#include "qsganimatoritem.h"
+#include "qsganimatorshadereffect.h"
+#include "qsgpauseanimation.h"
+#include "qsgpropertyanimation.h"
+#include "qsgsequentialanimation.h"
+#include "qsgparallelanimation.h"
+#include "qsgnumberanimation.h"
+#include "qsgcoloranimation.h"
+#include "qsgvector3danimation.h"
+
+class QSGAnimatorPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("Animators"));
+ Q_UNUSED(uri);
+ qmlRegisterType<QSGAnimatorItem>(uri, 1, 0, "Item");
+ qmlRegisterType<QSGAnimatorShaderEffect>(uri, 1, 0, "ShaderEffect");
+ qmlRegisterType<QSGPauseAnimation>(uri, 1, 0, "PauseAnimation");
+ qmlRegisterType<QSGPropertyAnimation>(uri, 1, 0, "PropertyAnimation");
+ qmlRegisterType<QSGColorAnimation>(uri, 1, 0, "ColorAnimation");
+ qmlRegisterType<QSGNumberAnimation>(uri, 1, 0, "NumberAnimation");
+ qmlRegisterType<QSGVector3DAnimation>(uri, 1, 0, "Vector3DAnimation");
+ qmlRegisterType<QSGSequentialAnimation>(uri, 1, 0, "SequentialAnimation");
+ qmlRegisterType<QSGParallelAnimation>(uri, 1, 0, "ParallelAnimation");
+ }
+};
+
+#include "qsganimatorplugin.moc"
diff --git a/animators/src/qsganimatorshadereffect.cpp b/animators/src/qsganimatorshadereffect.cpp
new file mode 100755
index 0000000..f4b2a46
--- /dev/null
+++ b/animators/src/qsganimatorshadereffect.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsganimatorshadereffect.h"
+#include "qsganimatornode.h"
+
+class QSGShaderEffectAnimatorNode : public QSGAnimatorNode
+{
+public:
+ QSGShaderEffectAnimatorNode(QSGAnimatorShaderEffect *item)
+ : QSGAnimatorNode(item)
+ , m_shaderEffectNode(0)
+ {
+ }
+
+ ~QSGShaderEffectAnimatorNode()
+ {
+ }
+
+ void preprocess()
+ {
+ QSGAnimatorNode::preprocess();
+ if (m_controller->isInitialized()) {
+ QQuickShaderEffectMaterial *material = static_cast<QQuickShaderEffectMaterial *>(m_shaderEffectNode->material());
+
+ for (int shaderType = 0; shaderType < Key::ShaderTypeCount; ++shaderType) {
+ for (int i = 0; i < material->uniforms[shaderType].size(); ++i) {
+ QQuickShaderEffectMaterial::UniformData &d = material->uniforms[shaderType][i];
+ QSGAnimatedProperty *ap = m_controller->registeredProperty(d.name);
+ if (ap) d.value = ap->value();
+ }
+ }
+
+ m_shaderEffectNode->markDirty(QSGNode::DirtyMaterial);
+ }
+ }
+
+ void setShaderEffectNode(QQuickShaderEffectNode *n)
+ {
+ m_shaderEffectNode = n;
+ }
+
+private:
+ typedef QQuickShaderEffectMaterialKey Key;
+ QQuickShaderEffectNode *m_shaderEffectNode;
+};
+
+QSGAnimatorShaderEffect::QSGAnimatorShaderEffect(QQuickItem *parent)
+ : QQuickShaderEffect(parent)
+ , m_animatorNode(0)
+{
+ setFlag(ItemHasContents);
+}
+
+QSGAnimatorShaderEffect::~QSGAnimatorShaderEffect()
+{
+}
+
+QSGNode *QSGAnimatorShaderEffect::updatePaintNode(QSGNode *node, UpdatePaintNodeData *data)
+{
+ QSGTransformNode *transformNode = static_cast<QSGTransformNode*>(QQuickItemPrivate::get(this)->itemNode());
+ QSGOpacityNode *opacityNode = static_cast<QSGOpacityNode*>(QQuickItemPrivate::get(this)->opacityNode());
+ m_shaderEffectNode = static_cast<QQuickShaderEffectNode*>(QQuickShaderEffect::updatePaintNode(node, data));
+
+ if (!node) {
+ if (m_shaderEffectNode) {
+ m_animatorNode = new QSGShaderEffectAnimatorNode(this);
+ m_animatorNode->setFlag(QSGNode::UsePreprocess, true);
+ m_shaderEffectNode->appendChildNode(m_animatorNode);
+ }
+ }
+
+ if (m_animatorNode) {
+ m_animatorNode->controller().sync();
+ m_animatorNode->setTransformNode(transformNode);
+ m_animatorNode->setOpacityNode(opacityNode);
+ m_animatorNode->setShaderEffectNode(m_shaderEffectNode);
+ }
+
+ return m_shaderEffectNode;
+}
diff --git a/animators/src/qsganimatorshadereffect.h b/animators/src/qsganimatorshadereffect.h
new file mode 100755
index 0000000..f492fee
--- /dev/null
+++ b/animators/src/qsganimatorshadereffect.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGANIMATORSHADEREFFECT_H
+#define QSGANIMATORSHADEREFFECT_H
+
+#include <QSGNode>
+#include <QtQuick/private/qquickshadereffect_p.h>
+#include <QtQuick/private/qquickshadereffectnode_p.h>
+#include "qsganimatorcontroller.h"
+
+class QSGShaderEffectAnimatorNode;
+
+class QSGAnimatorShaderEffect : public QQuickShaderEffect
+{
+public:
+ QSGAnimatorShaderEffect(QQuickItem *parent = 0);
+ ~QSGAnimatorShaderEffect();
+
+protected:
+ virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
+
+private:
+ QQuickShaderEffectNode *m_shaderEffectNode;
+ QSGShaderEffectAnimatorNode *m_animatorNode;
+ Q_DISABLE_COPY(QSGAnimatorShaderEffect)
+};
+
+#endif // QSGANIMATORSHADEREFFECT_H
diff --git a/animators/src/qsgcoloranimation.cpp b/animators/src/qsgcoloranimation.cpp
new file mode 100755
index 0000000..3910023
--- /dev/null
+++ b/animators/src/qsgcoloranimation.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgcoloranimation.h"
+
+QSGColorAnimation::QSGColorAnimation(QQuickItem *parent)
+ : QSGPropertyAnimation(parent)
+{
+}
+
+QColor QSGColorAnimation::from()
+{
+ return qvariant_cast<QColor>(QSGPropertyAnimation::from());
+}
+
+void QSGColorAnimation::setFrom(QColor a)
+{
+ QSGPropertyAnimation::setFrom(a);
+}
+
+QColor QSGColorAnimation::to()
+{
+ return qvariant_cast<QColor>(QSGPropertyAnimation::to());
+}
+
+void QSGColorAnimation::setTo(QColor a)
+{
+ QSGPropertyAnimation::setTo(a);
+}
diff --git a/animators/src/qsgcoloranimation.h b/animators/src/qsgcoloranimation.h
new file mode 100755
index 0000000..4781d8e
--- /dev/null
+++ b/animators/src/qsgcoloranimation.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGCOLORANIMATION_H
+#define QSGCOLORANIMATION_H
+
+#include "qsgpropertyanimation.h"
+
+class QSGColorAnimation : public QSGPropertyAnimation
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QColor from READ from WRITE setFrom)
+ Q_PROPERTY(QColor to READ to WRITE setTo)
+
+public:
+ QSGColorAnimation(QQuickItem *parent = 0);
+
+ QColor from();
+ void setFrom(QColor);
+
+ QColor to();
+ void setTo(QColor);
+
+private:
+ Q_DISABLE_COPY(QSGColorAnimation)
+};
+
+#endif // QSGCOLORANIMATION_H
diff --git a/animators/src/qsgnumberanimation.cpp b/animators/src/qsgnumberanimation.cpp
new file mode 100755
index 0000000..f0b478c
--- /dev/null
+++ b/animators/src/qsgnumberanimation.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgnumberanimation.h"
+#include <QDebug>
+
+QSGNumberAnimation::QSGNumberAnimation(QQuickItem *parent)
+ : QSGPropertyAnimation(parent)
+{
+}
+
+qreal QSGNumberAnimation::from()
+{
+ return QSGPropertyAnimation::from().toReal();
+}
+
+void QSGNumberAnimation::setFrom(qreal a)
+{
+ QSGPropertyAnimation::setFrom(a);
+}
+
+qreal QSGNumberAnimation::to()
+{
+ return QSGPropertyAnimation::to().toReal();
+}
+
+void QSGNumberAnimation::setTo(qreal a)
+{
+ QSGPropertyAnimation::setTo(a);
+}
diff --git a/animators/src/qsgnumberanimation.h b/animators/src/qsgnumberanimation.h
new file mode 100755
index 0000000..01cbbb2
--- /dev/null
+++ b/animators/src/qsgnumberanimation.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGNUMBERANIMATION_H
+#define QSGNUMBERANIMATION_H
+
+#include "qsgpropertyanimation.h"
+
+class QSGNumberAnimation : public QSGPropertyAnimation
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal from READ from WRITE setFrom)
+ Q_PROPERTY(qreal to READ to WRITE setTo)
+
+public:
+ QSGNumberAnimation(QQuickItem *parent = 0);
+
+ qreal from();
+ void setFrom(qreal);
+
+ qreal to();
+ void setTo(qreal);
+
+private:
+ Q_DISABLE_COPY(QSGNumberAnimation)
+};
+
+#endif // QSGNUMBERANIMATION_H
diff --git a/animators/src/qsgparallelanimation.cpp b/animators/src/qsgparallelanimation.cpp
new file mode 100755
index 0000000..0772126
--- /dev/null
+++ b/animators/src/qsgparallelanimation.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgparallelanimation.h"
+
+QSGParallelAnimation::QSGParallelAnimation(QQuickItem *parent)
+ : QSGAbstractAnimation(parent)
+{
+ connect(this, SIGNAL(runningChanged(bool)), SLOT(prepare(bool)));
+}
+
+void QSGParallelAnimation::prepare(bool v)
+{
+ int count = children().count();
+ for (int i = 0; i < count; i++) {
+ QSGAbstractAnimation *a = qobject_cast<QSGAbstractAnimation*>(children().at(i));
+ if (a)
+ a->prepare(v);
+ }
+}
diff --git a/animators/src/qsgparallelanimation.h b/animators/src/qsgparallelanimation.h
new file mode 100755
index 0000000..969a721
--- /dev/null
+++ b/animators/src/qsgparallelanimation.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSGPARALLELANIMATION_H
+#define QSGPARALLELANIMATION_H
+
+#include "qsgabstractanimation.h"
+
+class QSGParallelAnimation : public QSGAbstractAnimation
+{
+ Q_OBJECT
+public:
+ QSGParallelAnimation(QQuickItem *parent = 0);
+
+public Q_SLOTS:
+ virtual void prepare(bool);
+
+private:
+ Q_DISABLE_COPY(QSGParallelAnimation)
+
+};
+
+#endif // QSGPARALLELANIMATION_H
diff --git a/animators/src/qsgparallelanimator.cpp b/animators/src/qsgparallelanimator.cpp
new file mode 100755
index 0000000..8fbc400
--- /dev/null
+++ b/animators/src/qsgparallelanimator.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgparallelanimator.h"
+#include "qsgparallelanimation.h"
+#include "qsganimatorcontroller.h"
+#include <QDebug>
+
+QSGParallelAnimator::QSGParallelAnimator(QSGAnimatorController* controller, QSGAbstractAnimator *parent, QSGParallelAnimation *qmlObject, qreal startTime)
+ : QSGAbstractAnimator(controller, parent, qmlObject, startTime)
+{
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGParallelAnimator::QSGParallelAnimator" << this;
+#endif
+}
+
+void QSGParallelAnimator::advance(qreal t)
+{
+ if ((!m_running || m_paused) && !m_runningToEnd)
+ return;
+
+ QSGAbstractAnimator::advance(t);
+
+ if (m_elapsed > m_startTime && ((m_elapsed < m_startTime + m_loops * m_duration) || (m_loops < 0))) {
+ qreal tx = int(m_elapsed - m_startTime) % int(m_duration);
+ for (int i = 0; i < m_animators.count(); i++) {
+ m_animators.at(i)->setElapsed(tx);
+ m_animators.at(i)->advance();
+ }
+ }
+}
+
+qreal QSGParallelAnimator::sync(bool topLevelRunning, qreal startTime)
+{
+ QSGAbstractAnimator::sync(topLevelRunning, startTime);
+ qreal duration = 0.0;
+
+ for (int i = 0; i < m_animators.count(); i++) {
+ qreal childAnimationDuration = m_animators.at(i)->sync(topLevelRunning || (m_running && !m_paused) || m_runningToEnd, startTime);
+ duration = qMax(duration, childAnimationDuration);
+ }
+
+ duration *= m_loops;
+ return duration;
+}
diff --git a/animators/src/qsgparallelanimator.h b/animators/src/qsgparallelanimator.h
new file mode 100755
index 0000000..a757013
--- /dev/null
+++ b/animators/src/qsgparallelanimator.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSGPARALLELANIMATOR_H
+#define QSGPARALLELANIMATOR_H
+
+#include "qsgabstractanimator.h"
+
+class QSGPropertyController;
+class QSGParallelAnimation;
+
+class QSGParallelAnimator : public QSGAbstractAnimator
+{
+public:
+ QSGParallelAnimator(QSGAnimatorController *, QSGAbstractAnimator *, QSGParallelAnimation *, qreal);
+
+ virtual void advance(qreal);
+ virtual qreal sync(bool, qreal startTime = 0.0);
+};
+
+#endif // QSGPARALLELANIMATOR_H
diff --git a/animators/src/qsgpauseanimation.cpp b/animators/src/qsgpauseanimation.cpp
new file mode 100755
index 0000000..a3c34c3
--- /dev/null
+++ b/animators/src/qsgpauseanimation.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgpauseanimation.h"
+
+QSGPauseAnimation::QSGPauseAnimation(QQuickItem* parent)
+ : QSGAbstractAnimation(parent)
+{
+}
+
+int QSGPauseAnimation::duration()
+{
+ return m_duration;
+}
+
+void QSGPauseAnimation::setDuration(int a)
+{
+ if (m_duration != a) {
+ m_duration = a;
+ emit durationChanged(m_duration);
+ }
+}
diff --git a/animators/src/qsgpauseanimation.h b/animators/src/qsgpauseanimation.h
new file mode 100755
index 0000000..24abb33
--- /dev/null
+++ b/animators/src/qsgpauseanimation.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSGPAUSEANIMATION_H
+#define QSGPAUSEANIMATION_H
+
+#include "qsgabstractanimation.h"
+
+class QSGPauseAnimation : public QSGAbstractAnimation
+{
+ Q_OBJECT
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+
+public:
+ QSGPauseAnimation(QQuickItem *parent = 0);
+ int duration();
+ void setDuration(int);
+
+Q_SIGNALS:
+ void durationChanged(int);
+
+private:
+ int m_duration;
+ Q_DISABLE_COPY(QSGPauseAnimation)
+};
+
+#endif // QSGPAUSEANIMATION_H
diff --git a/animators/src/qsgpauseanimator.cpp b/animators/src/qsgpauseanimator.cpp
new file mode 100755
index 0000000..0203b86
--- /dev/null
+++ b/animators/src/qsgpauseanimator.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgpauseanimator.h"
+#include "qsgpauseanimation.h"
+#include "qsganimatorcontroller.h"
+#include <QDebug>
+
+QSGPauseAnimator::QSGPauseAnimator(QSGAnimatorController* controller, QSGAbstractAnimator *parent, QSGPauseAnimation *qmlObject, qreal startTime)
+ : QSGAbstractAnimator(controller, parent, qmlObject, startTime)
+ , m_qmlObject(qmlObject)
+{
+ if (m_qmlObject)
+ m_duration = m_qmlObject->duration();
+
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGPauseAnimator::QSGPauseAnimator" << this;
+ qDebug() << " startTime: " << startTime;
+ qDebug() << " duration: " << qmlObject->duration();
+#endif
+}
+
+void QSGPauseAnimator::advance(qreal t)
+{
+ QSGAbstractAnimator::advance(t);
+}
+
+qreal QSGPauseAnimator::sync(bool topLevelRunning, qreal startTime)
+{
+ QSGAbstractAnimator::sync(topLevelRunning, startTime);
+
+ if (m_qmlObject)
+ m_duration = m_qmlObject->duration();
+
+ return m_duration * m_loops;
+}
diff --git a/animators/src/qsgpauseanimator.h b/animators/src/qsgpauseanimator.h
new file mode 100755
index 0000000..b6e6c70
--- /dev/null
+++ b/animators/src/qsgpauseanimator.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGPAUSEANIMATOR_H
+#define QSGPAUSEANIMATOR_H
+
+#include "qsgabstractanimator.h"
+
+class QSGPropertyController;
+class QSGPauseAnimation;
+
+class QSGPauseAnimator : public QSGAbstractAnimator
+{
+public:
+ QSGPauseAnimator(QSGAnimatorController *, QSGAbstractAnimator *, QSGPauseAnimation *, qreal);
+
+ virtual void advance(qreal);
+ virtual qreal sync(bool, qreal startTime = 0.0);
+
+private:
+ QSGPauseAnimation *m_qmlObject;
+};
+
+
+#endif // QSGPAUSEANIMATOR_H
diff --git a/animators/src/qsgpropertyanimation.cpp b/animators/src/qsgpropertyanimation.cpp
new file mode 100755
index 0000000..3af456a
--- /dev/null
+++ b/animators/src/qsgpropertyanimation.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgpropertyanimation.h"
+
+#define MIN_OPACITY 0.001
+#define MAX_OPACITY 0.999
+
+QSGPropertyAnimation::QSGPropertyAnimation(QQuickItem *parent)
+ : QSGAbstractAnimation(parent)
+ , m_duration(0)
+ , m_from(0)
+ , m_to(0)
+ , m_target(0)
+{
+ connect(this, SIGNAL(runningChanged(bool)), SLOT(prepare(bool)));
+}
+
+int QSGPropertyAnimation::duration()
+{
+ return m_duration;
+}
+
+void QSGPropertyAnimation::setDuration(int a)
+{
+ if (m_duration != a) {
+ m_duration = a;
+ emit durationChanged(m_duration);
+ }
+}
+
+QVariant QSGPropertyAnimation::from()
+{
+ return m_from;
+}
+
+void QSGPropertyAnimation::setFrom(QVariant a)
+{
+ if (m_from != a) {
+ m_from = a;
+ emit fromChanged(m_from);
+ }
+}
+
+QVariant QSGPropertyAnimation::to()
+{
+ return m_to;
+}
+
+void QSGPropertyAnimation::setTo(QVariant a)
+{
+ if (m_to != a) {
+ m_to = a;
+ emit toChanged(m_to);
+ }
+}
+
+const QEasingCurve& QSGPropertyAnimation::easing()
+{
+ return m_easing;
+}
+
+void QSGPropertyAnimation::setEasing(const QEasingCurve& a)
+{
+ if (m_easing != a) {
+ m_easing = a;
+ emit easingChanged(m_easing);
+ }
+}
+
+QObject* QSGPropertyAnimation::target()
+{
+ return m_target;
+}
+
+void QSGPropertyAnimation::setTarget(QObject* a)
+{
+ if (m_target != a) {
+ m_target = a;
+ emit targetChanged();
+ }
+}
+
+const QString& QSGPropertyAnimation::property()
+{
+ return m_property;
+}
+
+void QSGPropertyAnimation::setProperty(QString a)
+{
+ if (m_property != a) {
+ m_property = a;
+ emit propertyChanged();
+ }
+}
+
+const QString& QSGPropertyAnimation::properties()
+{
+ return m_properties;
+}
+
+void QSGPropertyAnimation::setProperties(QString a)
+{
+ if (m_properties != a) {
+ m_properties = a;
+ emit propertiesChanged();
+ }
+}
+
+void QSGPropertyAnimation::complete()
+{
+ if (m_target) {
+ QVariant v = m_to;
+ QString p = m_property;
+ if (m_property.contains(".x")) {
+ p = m_property.left(m_property.length() - 2);
+ v = m_target->property(p.toAscii().constData());
+ QVector3D vec = qvariant_cast<QVector3D>(v);
+ vec.setX(m_to.toReal());
+ v = vec;
+ } else if (m_property.contains(".y")) {
+ v = m_target->property(p.toAscii().constData());
+ QVector3D vec = qvariant_cast<QVector3D>(v);
+ vec.setY(m_to.toReal());
+ v = vec;
+ } else if (m_property.contains(".z")) {
+ v = m_target->property(p.toAscii().constData());
+ QVector3D vec = qvariant_cast<QVector3D>(v);
+ vec.setZ(m_to.toReal());
+ v = vec;
+ }
+ m_target->setProperty(p.toAscii().constData(), v);
+ }
+ QSGAbstractAnimation::complete();
+}
+
+void QSGPropertyAnimation::prepare(bool v)
+{
+ // Make sure opacity node exists
+ QQuickItem *t = qobject_cast<QQuickItem*> (m_target);
+ if (t && v && m_property == "opacity") {
+ if (t->opacity() < MIN_OPACITY) {
+ t->setOpacity(MIN_OPACITY);
+ }
+ else if (t->opacity() > MAX_OPACITY) {
+ t->setOpacity(MAX_OPACITY);
+ }
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGPropertyAnimation::prepare opacity is now " << t->opacity();
+#endif
+ }
+}
diff --git a/animators/src/qsgpropertyanimation.h b/animators/src/qsgpropertyanimation.h
new file mode 100755
index 0000000..ac39338
--- /dev/null
+++ b/animators/src/qsgpropertyanimation.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSGPROPERTYANIMATION_H
+#define QSGPROPERTYANIMATION_H
+
+#include "qsgabstractanimation.h"
+
+class QSGPropertyAnimation : public QSGAbstractAnimation
+{
+ Q_OBJECT
+ Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
+ Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
+ Q_PROPERTY(QObject* target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
+ Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
+
+public:
+ QSGPropertyAnimation(QQuickItem *parent = 0);
+
+ int duration();
+ void setDuration(int);
+
+ QVariant from();
+ void setFrom(QVariant);
+
+ QVariant to();
+ void setTo(QVariant);
+
+ const QEasingCurve& easing();
+ void setEasing(const QEasingCurve&);
+
+ QObject* target();
+ void setTarget(QObject *);
+
+ const QString& property();
+ void setProperty(QString);
+
+ const QString& properties();
+ void setProperties(QString);
+
+public Q_SLOTS:
+ virtual void complete();
+ virtual void prepare(bool);
+
+Q_SIGNALS:
+ void durationChanged(int);
+ void fromChanged(QVariant);
+ void toChanged(QVariant);
+ void easingChanged(const QEasingCurve &);
+ void targetChanged();
+ void propertyChanged();
+ void propertiesChanged();
+
+private:
+ int m_duration;
+ QVariant m_from;
+ QVariant m_to;
+ QEasingCurve m_easing;
+ QObject *m_target;
+ QString m_property;
+ QString m_properties;
+ Q_DISABLE_COPY(QSGPropertyAnimation)
+};
+
+#endif // QSGPROPERTYANIMATION_H
diff --git a/animators/src/qsgpropertyanimator.cpp b/animators/src/qsgpropertyanimator.cpp
new file mode 100755
index 0000000..25df651
--- /dev/null
+++ b/animators/src/qsgpropertyanimator.cpp
@@ -0,0 +1,272 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgpropertyanimator.h"
+#include "qsgpropertyanimation.h"
+#include "qsganimatorcontroller.h"
+#include <QDebug>
+
+QSGPropertyAnimator::QSGPropertyAnimator(QSGAnimatorController* controller, QSGAbstractAnimator *parent, QSGPropertyAnimation *qmlObject, qreal startTime)
+ : QSGAbstractAnimator(controller, parent, qmlObject, startTime)
+ , m_qmlObject(qmlObject)
+ , m_target(0)
+ , m_property("")
+ , m_from(0.0)
+ , m_to(0.0)
+{
+ copyQmlObjectData();
+#ifdef ANIMATORS_DEBUG
+ qDebug() << " target: " << qmlObject->target();
+ qDebug() << " property: " << qmlObject->property();
+ qDebug() << " properties: " << qmlObject->properties();
+ qDebug() << " from: " << qmlObject->from();
+ qDebug() << " to: " << qmlObject->to();
+ qDebug() << " duration: " << qmlObject->duration();
+
+ qDebug() << " running: " << qmlObject->isRunning();
+ qDebug() << " startTime: " << startTime;
+ qDebug() << " loops: " << qmlObject->loops();
+ qDebug() << " easing.type: " << qmlObject->easing().type();
+#endif
+}
+
+void QSGPropertyAnimator::updateProperty(QObject *target, const QString& p)
+{
+ QSGAnimatedProperty *ap = m_controller->registeredProperty(p, target);
+ if (ap && m_duration > 0) {
+ if (m_elapsed > m_startTime && ((m_elapsed < m_startTime + m_loops * m_duration) || (m_loops < 0))) {
+
+ QVariant value = ap->value();
+ qreal tx = int(m_elapsed - m_startTime) % int(m_duration);
+
+ switch (value.type()) {
+ case QMetaType::Float:
+ case QMetaType::Double:
+ value = QVariant(m_from.toReal() + (m_to.toReal() - m_from.toReal()) * m_easing.valueForProgress(tx / m_duration));
+ break;
+ case QMetaType::QColor:
+ {
+ QColor from = qvariant_cast<QColor>(m_from);
+ QColor to = qvariant_cast<QColor>(m_to);
+ QColor result = qvariant_cast<QColor>(value);
+ result.setRed(from.red() + (to.red() - from.red()) * m_easing.valueForProgress(tx / m_duration));
+ result.setGreen(from.green() + (to.green() - from.green()) * m_easing.valueForProgress(tx / m_duration));
+ result.setBlue(from.blue() + (to.blue() - from.blue()) * m_easing.valueForProgress(tx / m_duration));
+ result.setAlpha(from.alpha() + (to.alpha() - from.alpha()) * m_easing.valueForProgress(tx / m_duration));
+ value = result;
+ break;
+ }
+ case QMetaType::Int:
+ value = QVariant(m_from.toInt() + (m_to.toInt() - m_from.toInt()) * m_easing.valueForProgress(tx / m_duration));
+ break;
+ case QMetaType::QSize:
+ {
+ QSize from = m_from.toSize();
+ QSize to = m_to.toSize();
+ QSize result = value.toSize();
+ result.setWidth(from.width() + (to.width() - from.width()) * m_easing.valueForProgress(tx / m_duration));
+ result.setHeight(from.height() + (to.height() - from.height()) * m_easing.valueForProgress(tx / m_duration));
+ value = result;
+ break;
+ }
+ case QMetaType::QSizeF:
+ {
+ QSizeF from = m_from.toSize();
+ QSizeF to = m_to.toSize();
+ QSizeF result = value.toSize();
+ result.setWidth(from.width() + (to.width() - from.width()) * m_easing.valueForProgress(tx / m_duration));
+ result.setHeight(from.height() + (to.height() - from.height()) * m_easing.valueForProgress(tx / m_duration));
+ value = result;
+ break;
+ }
+ case QMetaType::QPoint:
+ {
+ QPoint from = m_from.toPoint();
+ QPoint to = m_to.toPoint();
+ QPoint result = value.toPoint();
+ result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration));
+ result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration));
+ value = result;
+ break;
+ }
+ case QMetaType::QPointF:
+ {
+ QPointF from = m_from.toPointF();
+ QPointF to = m_to.toPointF();
+ QPointF result = value.toPointF();
+ result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration));
+ result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration));
+ value = result;
+ break;
+ }
+ case QMetaType::QRect:
+ {
+ QRect from = m_from.toRect();
+ QRect to = m_to.toRect();
+ QRect result = value.toRect();
+ result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration));
+ result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration));
+ result.setWidth(from.width() + (to.width() - from.width()) * m_easing.valueForProgress(tx / m_duration));
+ result.setHeight(from.height() + (to.height() - from.height()) * m_easing.valueForProgress(tx / m_duration));
+ value = result;
+ break;
+ }
+ case QMetaType::QRectF:
+ {
+ QRectF from = m_from.toRectF();
+ QRectF to = m_to.toRectF();
+ QRectF result = value.toRectF();
+ result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration));
+ result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration));
+ result.setWidth(from.width() + (to.width() - from.width()) * m_easing.valueForProgress(tx / m_duration));
+ result.setHeight(from.height() + (to.height() - from.height()) * m_easing.valueForProgress(tx / m_duration));
+ value = result;
+ break;
+ }
+ case QMetaType::QVector3D:
+ {
+ QVector3D from = qvariant_cast<QVector3D>(m_from);
+ QVector3D to = qvariant_cast<QVector3D>(m_to);
+ QVector3D result = qvariant_cast<QVector3D>(value);
+ result.setX(from.x() + (to.x() - from.x()) * m_easing.valueForProgress(tx / m_duration));
+ result.setY(from.y() + (to.y() - from.y()) * m_easing.valueForProgress(tx / m_duration));
+ result.setZ(from.z() + (to.z() - from.z()) * m_easing.valueForProgress(tx / m_duration));
+ value = result;
+ break;
+ }
+ default:
+ break;
+ }
+ ap->setValue(value);
+ }
+ }
+}
+
+void QSGPropertyAnimator::advance(qreal t)
+{
+ if ((!m_running || m_paused) && !m_runningToEnd)
+ return;
+
+ QSGAbstractAnimator::advance(t);
+
+ if (!m_target)
+ return;
+
+ QStringList properties;
+ if (!m_properties.isEmpty()) {
+ properties = m_properties.split(",");
+ for (int i = 0; i < properties.count(); i++)
+ updateProperty(m_target, properties[i].trimmed());
+ } else {
+ updateProperty(m_target, m_property);
+ }
+}
+
+qreal QSGPropertyAnimator::sync(bool topLevelRunning, qreal startTime)
+{
+ QSGAbstractAnimator::sync(topLevelRunning, startTime);
+ copyQmlObjectData();
+ return m_duration;
+}
+
+void QSGPropertyAnimator::copyQmlObjectData()
+{
+ if (m_qmlObject) {
+ m_target = m_qmlObject->target();
+ m_property = m_qmlObject->property();
+ m_properties = m_qmlObject->properties();
+ m_from = m_qmlObject->from();
+ m_to = m_qmlObject->to();
+ m_duration = m_qmlObject->duration();
+ m_easing = m_qmlObject->easing();
+ }
+}
+
+
+QObject* QSGPropertyAnimator::target()
+{
+ return m_target;
+}
+
+void QSGPropertyAnimator::setTarget(QObject* a)
+{
+ m_target = a;
+}
+
+const QString& QSGPropertyAnimator::property()
+{
+ return m_property;
+}
+
+void QSGPropertyAnimator::setProperty(QString a)
+{
+ m_property = a;
+}
+
+QVariant QSGPropertyAnimator::from()
+{
+ return m_from;
+}
+
+void QSGPropertyAnimator::setFrom(QVariant a)
+{
+ m_from = a;
+}
+
+QVariant QSGPropertyAnimator::to()
+{
+ return m_to;
+}
+
+void QSGPropertyAnimator::setTo(QVariant a)
+{
+ m_to = a;
+}
+
+const QEasingCurve& QSGPropertyAnimator::easing()
+{
+ return m_easing;
+}
+
+void QSGPropertyAnimator::setEasing(const QEasingCurve& a)
+{
+ m_easing = a;
+}
diff --git a/animators/src/qsgpropertyanimator.h b/animators/src/qsgpropertyanimator.h
new file mode 100755
index 0000000..befbb1c
--- /dev/null
+++ b/animators/src/qsgpropertyanimator.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGPROPERTYANIMATOR_H
+#define QSGPROPERTYANIMATOR_H
+
+#include "qsgabstractanimator.h"
+
+class QSGPropertyController;
+class QSGPropertyAnimation;
+
+class QSGPropertyAnimator : public QSGAbstractAnimator
+{
+public:
+ QSGPropertyAnimator(QSGAnimatorController *, QSGAbstractAnimator *, QSGPropertyAnimation *, qreal);
+
+ virtual void advance(qreal);
+ virtual qreal sync(bool, qreal startTime = 0.0);
+
+ QObject* target();
+ void setTarget(QObject *);
+
+ const QString& property();
+ void setProperty(QString);
+
+ QVariant from();
+ void setFrom(QVariant);
+
+ QVariant to();
+ void setTo(QVariant);
+
+ const QEasingCurve& easing();
+ void setEasing(const QEasingCurve &);
+
+private:
+ void updateProperty(QObject *, const QString &);
+ void copyQmlObjectData();
+
+private:
+ QSGPropertyAnimation *m_qmlObject;
+ QObject *m_target;
+ QList<QObject*> m_targets;
+ QList<QObject*> m_excluded;
+ QString m_property;
+ QString m_properties;
+ QString m_exludedProperties;
+ QVariant m_from;
+ QVariant m_to;
+ QEasingCurve m_easing;
+};
+
+#endif // QSGPROPERTYANIMATOR_H
diff --git a/animators/src/qsgsequentialanimation.cpp b/animators/src/qsgsequentialanimation.cpp
new file mode 100755
index 0000000..624d0b5
--- /dev/null
+++ b/animators/src/qsgsequentialanimation.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qsgsequentialanimation.h"
+
+QSGSequentialAnimation::QSGSequentialAnimation(QQuickItem *parent)
+ : QSGAbstractAnimation(parent)
+{
+ connect(this, SIGNAL(runningChanged(bool)), SLOT(prepare(bool)));
+}
+
+void QSGSequentialAnimation::prepare(bool v)
+{
+ int count = children().count();
+ for (int i = 0; i < count; i++) {
+ QSGAbstractAnimation *a = qobject_cast<QSGAbstractAnimation*>(children().at(i));
+ if (a)
+ a->prepare(v);
+ }
+}
diff --git a/animators/src/qsgsequentialanimation.h b/animators/src/qsgsequentialanimation.h
new file mode 100755
index 0000000..5f39128
--- /dev/null
+++ b/animators/src/qsgsequentialanimation.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGSEQUENTIALANIMATION_H
+#define QSGSEQUENTIALANIMATION_H
+
+#include "qsgabstractanimation.h"
+
+class QSGSequentialAnimation : public QSGAbstractAnimation
+{
+ Q_OBJECT
+public:
+ QSGSequentialAnimation(QQuickItem *parent = 0);
+
+public Q_SLOTS:
+ virtual void prepare(bool);
+
+private:
+ Q_DISABLE_COPY(QSGSequentialAnimation)
+};
+
+#endif // QSGSEQUENTIALANIMATION_H
diff --git a/animators/src/qsgsequentialanimator.cpp b/animators/src/qsgsequentialanimator.cpp
new file mode 100755
index 0000000..99e9ee1
--- /dev/null
+++ b/animators/src/qsgsequentialanimator.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qsgsequentialanimator.h"
+#include "qsgsequentialanimation.h"
+#include "qsganimatorcontroller.h"
+#include <QDebug>
+
+QSGSequentialAnimator::QSGSequentialAnimator(QSGAnimatorController* controller, QSGAbstractAnimator *parent, QSGAbstractAnimation *qmlObject, qreal startTime)
+ : QSGAbstractAnimator(controller, parent, qmlObject, startTime)
+{
+#ifdef ANIMATORS_DEBUG
+ qDebug() << "QSGSequentialAnimator::QSGSequentialAnimator" << this;
+ qDebug() << " startTime: " << startTime;
+ qDebug() << " loops: " << qmlObject->loops();
+#endif
+}
+
+void QSGSequentialAnimator::advance(qreal t)
+{
+ if ((!m_running || m_paused) && !m_runningToEnd)
+ return;
+
+ QSGAbstractAnimator::advance(t);
+
+ if (m_elapsed > m_startTime && ((m_elapsed < m_startTime + m_loops * m_duration) || (m_loops < 0))) {
+ qreal tx = int(m_elapsed - m_startTime) % int(m_duration);
+ for (int i = 0; i < m_animators.count(); i++) {
+ QSGAbstractAnimator *child = m_animators.at(i);
+ int childStartTime = child->startTime();
+ int childDuration = child->duration();
+ int childLoops = child->loops();
+
+ qreal cx = int(m_startTime + tx - childStartTime) % int(childDuration);
+ if (m_startTime + tx > childStartTime && m_startTime + tx < childStartTime + childDuration * childLoops) {
+ child->setElapsed(childStartTime + cx);
+ child->advance();
+ }
+ }
+ }
+}
+
+qreal QSGSequentialAnimator::sync(bool topLevelRunning, qreal startTime)
+{
+ QSGAbstractAnimator::sync(topLevelRunning, startTime);
+
+ qreal duration = 0.0;
+ for (int i = 0; i < m_animators.count(); i++)
+ duration += m_animators.at(i)->sync(topLevelRunning || (m_running && !m_paused) || m_runningToEnd, startTime + duration);
+
+ duration *= m_loops;
+ return duration;
+}
diff --git a/animators/src/qsgsequentialanimator.h b/animators/src/qsgsequentialanimator.h
new file mode 100755
index 0000000..0d34f69
--- /dev/null
+++ b/animators/src/qsgsequentialanimator.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSGSEQUENTIALANIMATOR_H
+#define QSGSEQUENTIALANIMATOR_H
+
+#include "qsgabstractanimator.h"
+
+class QSGPropertyController;
+class QSGAbstractAnimation;
+
+class QSGSequentialAnimator : public QSGAbstractAnimator
+{
+public:
+ QSGSequentialAnimator(QSGAnimatorController *, QSGAbstractAnimator *, QSGAbstractAnimation *, qreal);
+
+ virtual void advance(qreal);
+ virtual qreal sync(bool, qreal startTime = 0.0);
+};
+
+#endif // QSGSEQUENTIALANIMATOR_H
diff --git a/animators/src/qsgtoplevelanimator.cpp b/animators/src/qsgtoplevelanimator.cpp
new file mode 100755
index 0000000..bd8a4bc
--- /dev/null
+++ b/animators/src/qsgtoplevelanimator.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qsgtoplevelanimator.h"
+#include "qsganimatorcontroller.h"
+#include <QDebug>
+
+QSGTopLevelAnimator::QSGTopLevelAnimator()
+ : QSGAbstractAnimator(0, 0, 0, 0)
+{
+}
+
+void QSGTopLevelAnimator::advance(qreal t)
+{
+ QSGAbstractAnimator::advance(t);
+
+ for (int i = 0; i < m_animators.count(); i++) {
+ m_animators.at(i)->advance(t);
+ }
+}
+
+qreal QSGTopLevelAnimator::sync(bool topLevelRunning, qreal startTime)
+{
+ QSGAbstractAnimator::sync(topLevelRunning, startTime);
+
+ qreal duration = 0.0;
+ for (int i = 0; i < m_animators.count(); i++) {
+ qreal childAnimationDuration = m_animators.at(i)->sync(topLevelRunning, startTime);
+ duration = qMax(duration, childAnimationDuration);
+ }
+ duration *= m_loops;
+ return duration;
+}
diff --git a/animators/src/qsgtoplevelanimator.h b/animators/src/qsgtoplevelanimator.h
new file mode 100755
index 0000000..d9a4d5a
--- /dev/null
+++ b/animators/src/qsgtoplevelanimator.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of %MODULE%.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGTOPLEVELANIMATOR_H
+#define QSGTOPLEVELANIMATOR_H
+
+#include "qsgabstractanimator.h"
+#include <QtQuick/private/qquickanimation_p.h>
+
+class QSGPropertyController;
+
+class QSGTopLevelAnimator : public QSGAbstractAnimator
+{
+public:
+ QSGTopLevelAnimator();
+
+ virtual void advance(qreal);
+ virtual qreal sync(bool, qreal startTime = 0.0);
+};
+
+#endif // QSGTOPLEVELANIMATOR_H
diff --git a/animators/src/qsgvector3danimation.cpp b/animators/src/qsgvector3danimation.cpp
new file mode 100755
index 0000000..229f522
--- /dev/null
+++ b/animators/src/qsgvector3danimation.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qsgvector3danimation.h"
+#include "qsgpropertyanimation.h"
+
+QSGVector3DAnimation::QSGVector3DAnimation(QQuickItem *parent)
+ : QSGPropertyAnimation(parent)
+{
+}
+
+QVector3D QSGVector3DAnimation::from()
+{
+ return qvariant_cast<QVector3D>(QSGPropertyAnimation::from());
+}
+
+void QSGVector3DAnimation::setFrom(QVector3D a)
+{
+ QSGPropertyAnimation::setFrom(a);
+}
+
+QVector3D QSGVector3DAnimation::to()
+{
+ return qvariant_cast<QVector3D>(QSGPropertyAnimation::to());
+}
+
+void QSGVector3DAnimation::setTo(QVector3D a)
+{
+ QSGPropertyAnimation::setTo(a);
+}
+
+
diff --git a/animators/src/qsgvector3danimation.h b/animators/src/qsgvector3danimation.h
new file mode 100755
index 0000000..bcdf68b
--- /dev/null
+++ b/animators/src/qsgvector3danimation.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the Scenegraph Playground module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSGVECTOR3DANIMATION_H
+#define QSGVECTOR3DANIMATION_H
+
+#include "qsgpropertyanimation.h"
+
+class QSGVector3DAnimation : public QSGPropertyAnimation
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QVector3D from READ from WRITE setFrom)
+ Q_PROPERTY(QVector3D to READ to WRITE setTo)
+
+public:
+ QSGVector3DAnimation(QQuickItem *parent = 0);
+
+ QVector3D from();
+ void setFrom(QVector3D);
+
+ QVector3D to();
+ void setTo(QVector3D);
+
+private:
+ Q_DISABLE_COPY(QSGVector3DAnimation)
+};
+
+#endif // QSGVECTOR3DANIMATION_H
diff --git a/animators/src/src.pro b/animators/src/src.pro
new file mode 100755
index 0000000..ee5f4e3
--- /dev/null
+++ b/animators/src/src.pro
@@ -0,0 +1,71 @@
+TARGET = animators
+TEMPLATE = lib
+
+QT = core gui v8 qml quick
+QT += quick-private qml-private v8-private gui-private core-private
+
+CONFIG += plugin
+
+DEFINES += ANIMATORS_DEBUG
+
+HEADERS += \
+ qsganimatorcontroller.h \
+ qsganimatedtransform.h \
+ qsganimatedtranslate.h \
+ qsganimatedscale.h \
+ qsganimatedrotation.h \
+ qsganimatoritem.h \
+ qsgsequentialanimator.h \
+ qsgparallelanimator.h \
+ qsgtoplevelanimator.h \
+ qsgpauseanimator.h \
+ qsganimatedproperty.h \
+ qsgpropertyanimator.h \
+ qsgabstractanimator.h \
+ qsgsequentialanimation.h \
+ qsgpropertyanimation.h \
+ qsgpauseanimation.h \
+ qsgparallelanimation.h \
+ qsgabstractanimation.h \
+ qsgnumberanimation.h \
+ qsgcoloranimation.h \
+ qsgvector3danimation.h \
+ qsganimatorshadereffect.h \
+ qsganimatornode.h
+
+SOURCES += \
+ qsganimatoritem.cpp \
+ qsganimatorplugin.cpp \
+ qsganimatorcontroller.cpp \
+ qsganimatedtransform.cpp \
+ qsganimatedtranslate.cpp \
+ qsganimatedscale.cpp \
+ qsganimatedrotation.cpp \
+ qsgsequentialanimator.cpp \
+ qsgparallelanimator.cpp \
+ qsgtoplevelanimator.cpp \
+ qsgpauseanimator.cpp \
+ qsganimatedproperty.cpp \
+ qsgpropertyanimator.cpp \
+ qsgabstractanimator.cpp \
+ qsgsequentialanimation.cpp \
+ qsgpropertyanimation.cpp \
+ qsgpauseanimation.cpp \
+ qsgparallelanimation.cpp \
+ qsgabstractanimation.cpp \
+ qsgvector3danimation.cpp \
+ qsgnumberanimation.cpp \
+ qsgcoloranimation.cpp \
+ qsganimatorshadereffect.cpp \
+ qsganimatornode.cpp
+
+target.path = $$[QT_INSTALL_IMPORTS]/Animators
+
+qmldir.files = qmldir
+qmldir.path = $$[QT_INSTALL_IMPORTS]/Animators
+
+INSTALLS = target qmldir
+
+
+
+
diff --git a/animators/test/Control.qml b/animators/test/Control.qml
new file mode 100755
index 0000000..f40feb8
--- /dev/null
+++ b/animators/test/Control.qml
@@ -0,0 +1,178 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: control
+
+ property bool testing: false
+ property bool running: false
+ property bool paused: false
+ property bool blocking: false
+
+ onBlockingChanged: {
+ blockerStopTimer.running = blocking
+ }
+
+ Timer {
+ id: blockerStopTimer
+ interval: 20000
+ repeat: false
+ running: false
+ onTriggered: control.blocking = false
+ }
+
+ width: 320
+ height: 65
+ color: "#2e2e2e"
+
+ Rectangle {
+ width: parent.width
+ height: 4
+ gradient: Gradient {
+ GradientStop { position: 1.0; color: "#2e2e2e" }
+ GradientStop { position: 0.0; color: "black" }
+ }
+ }
+
+ Row {
+ x: 10
+ y: 10
+ spacing: 5
+ Rectangle {
+ width: 70
+ height: 40
+ color: "#3e3e3e"
+ Text {
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ text: "Back"
+ color: "white"
+ font.pixelSize: 14
+ font.family: "Nokia Pure Text"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ control.testing = !control.testing
+ control.running = false
+ control.paused = false
+ control.blocking = false
+ main.state = ""
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: pauseButton
+ width: 70
+ height: 40
+ color: "#3e3e3e"
+ Text {
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ text: control.paused ? "Continue" : "Pause"
+ color: "white"
+ font.pixelSize: 14
+ font.family: "Nokia Pure Text"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ control.paused = !control.paused
+ }
+ }
+ }
+ Text {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.bottom
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: "Paused"
+ color: "red"
+ font.pixelSize: 10
+ visible: control.paused
+ }
+ }
+
+ Rectangle {
+ id: stopButton
+ width: 70
+ height: 40
+ color: "#3e3e3e"
+ Text {
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ text: control.running ? "Stop" : "Start"
+ color: "white"
+ font.pixelSize: 14
+ font.family: "Nokia Pure Text"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ control.running = !control.running
+ }
+ }
+ }
+ Text {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.bottom
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: "Running"
+ color: "red"
+ font.pixelSize: 10
+ visible: control.running
+ }
+ }
+
+ Rectangle {
+ id: blockButton
+ width: 70
+ height: 40
+ color: "#3e3e3e"
+ Text {
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ text: control.blocking ? "No block" : "Block"
+ color: "white"
+ font.pixelSize: 14
+ font.family: "Nokia Pure Text"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ control.blocking = !control.blocking
+ }
+ }
+ }
+ Text {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.bottom
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: "Blocking"
+ color: "red"
+ font.pixelSize: 10
+ visible: control.blocking
+ }
+ }
+ }
+
+ Timer {
+ id: blockerTimer
+ interval: 200
+ repeat: true
+ running: control.blocking
+ onTriggered: blocker()
+ function blocker() {
+ var date = new Date();
+ while (new Date().getTime() - date.getTime() < 100) {
+ var x = 1 + 2;
+ }
+ }
+ }
+}
diff --git a/animators/test/TestBed.qml b/animators/test/TestBed.qml
new file mode 100755
index 0000000..9c95d9a
--- /dev/null
+++ b/animators/test/TestBed.qml
@@ -0,0 +1,262 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: main
+ width: 320
+ height: 480
+ color: "black"
+
+ property string currentTest: ""
+ property bool renderThreadAnimationsDisabled: false
+ property bool mainThreadAnimationsDisabled: false
+
+ Loader {
+ id: testLoader
+ anchors.left: menuView.right
+ width: 320
+ height: 480
+ }
+
+ Component {
+ id: sectionHeading
+ Text {
+ id: sectionText
+ text: section
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ height: 30
+ width: parent.width
+ color: "white"
+ verticalAlignment: Text.AlignVCenter
+ font.family: "Nokia Pure Text"
+ font.bold: true
+ font.pixelSize: 18
+ }
+ }
+
+ Rectangle {
+ id: menuView
+ width: parent.width
+ height: parent.height
+ color: "black"
+
+ ListView {
+ id: testCaseList
+
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 40
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ model: TestBedModel {}
+
+ section.property: "group"
+ section.criteria: ViewSection.FullString
+ section.delegate: sectionHeading
+
+ Component.onCompleted: contentY = 0
+
+ delegate: Item {
+ width: testCaseList.width
+ height: 50
+
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 5
+ color: "#2e2e2e"
+ }
+
+ Text {
+ id: delegateText;
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ text: name.slice(4, name.indexOf("."))
+ width: parent.width
+ height: 50
+ font.family: "Nokia Pure Text"
+ font.pixelSize: 16
+ verticalAlignment: Text.AlignVCenter
+ color: "#e6e6e6"
+ }
+ MouseArea {
+ id: delegateMouseArea
+ anchors.fill: parent;
+ onClicked: {
+ main.state = "testRunning"
+ testLoader.source = name
+ currentTest = name.slice(4, name.indexOf("."))
+ }
+ }
+ }
+ }
+ }
+
+ states: State {
+ name: "testRunning"
+ PropertyChanges { target: menuView; x: -width }
+ }
+
+ transitions: [
+ Transition {
+ to: "testRunning"
+ SequentialAnimation {
+ NumberAnimation {
+ property: "x"
+ duration: 200
+ }
+ PropertyAction {
+ target: menuView
+ property: "visible"
+ value: false
+ }
+ }
+ },
+ Transition {
+ to: ""
+ SequentialAnimation {
+ PropertyAction {
+ target: menuView
+ property: "visible"
+ value: true
+ }
+ NumberAnimation {
+ property: "x"
+ duration: 200
+ }
+ PropertyAction {
+ target: testLoader
+ property: "source"
+ value: ""
+ }
+ }
+ }
+ ]
+
+ Rectangle {
+ id: mainControl
+ anchors.bottom: parent.bottom
+ property bool keepalive: false
+ visible: main.state == ""
+
+ width: 320
+ height: 65
+ color: "#2e2e2e"
+
+ Rectangle {
+ width: parent.width
+ height: 4
+ gradient: Gradient {
+ GradientStop { position: 1.0; color: "#2e2e2e" }
+ GradientStop { position: 0.0; color: "black" }
+ }
+ }
+
+ Row {
+ x: 10
+ y: 10
+ spacing: 5
+ Rectangle {
+ width: 90
+ height: 40
+ color: "#3e3e3e"
+ Text {
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ text: !mainControl.keepalive ? "Keepalive" : "No keepalive"
+ color: "white"
+ font.pixelSize: 14
+ font.family: "Nokia Pure Text"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ mainControl.keepalive = !mainControl.keepalive
+ }
+ }
+ }
+ Text {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.bottom
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: "Keepalive"
+ color: "red"
+ font.pixelSize: 10
+ opacity: mainControl.keepalive ? 0.5 : 0.0
+ NumberAnimation on opacity {
+ running: mainControl.keepalive
+ from: 0.5
+ to: 0.1
+ duration: 2000
+ loops: Animation.Infinite
+ }
+ }
+ }
+ Rectangle {
+ width: 90
+ height: 40
+ color: "#3e3e3e"
+ Text {
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ text: renderThreadAnimationsDisabled ? "Enable RT" : "Disable RT"
+ color: "white"
+ font.pixelSize: 14
+ font.family: "Nokia Pure Text"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ renderThreadAnimationsDisabled = !renderThreadAnimationsDisabled
+ }
+ }
+ }
+ Text {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.bottom
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: "RT disabled"
+ color: "red"
+ font.pixelSize: 10
+ visible: renderThreadAnimationsDisabled
+ }
+ }
+ Rectangle {
+ width: 90
+ height: 40
+ color: "#3e3e3e"
+ Text {
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ anchors.fill: parent
+ text: mainThreadAnimationsDisabled ? "Enable MT" : "Disable MT"
+ color: "white"
+ font.pixelSize: 14
+ font.family: "Nokia Pure Text"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ mainThreadAnimationsDisabled = !mainThreadAnimationsDisabled
+ }
+ }
+ }
+ Text {
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.bottom
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: "RT disabled"
+ color: "red"
+ font.pixelSize: 10
+ visible: mainThreadAnimationsDisabled
+ }
+ }
+ }
+ }
+}
diff --git a/animators/test/TestBedModel.qml b/animators/test/TestBedModel.qml
new file mode 100755
index 0000000..fc31916
--- /dev/null
+++ b/animators/test/TestBedModel.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+
+ListModel {
+ id: testcaseModel
+ ListElement { name: "TestPosition.qml"; group: "Item properties"; last: false }
+ ListElement { name: "TestScale.qml"; group: "Item properties"; last: false }
+ ListElement { name: "TestOpacity.qml"; group: "Item properties"; last: false }
+ ListElement { name: "TestRotation.qml"; group: "Item properties"; last: false }
+ ListElement { name: "TestTransformTranslate.qml"; group: "Item properties"; last: false }
+ ListElement { name: "TestTransformScale.qml"; group: "Item properties"; last: false }
+ ListElement { name: "TestTransformRotatation.qml"; group: "Item properties"; last: false }
+ ListElement { name: "TestTransformRotationOriginPoint.qml"; group: "Item properties"; last: false }
+ ListElement { name: "TestMultipleProperties.qml"; group: "Item properties"; last: true }
+ ListElement { name: "TestShaderEffect.qml"; group: "ShaderEffect properties"; last: false }
+ ListElement { name: "TestShaderEffectOpacity.qml"; group: "ShaderEffect properties"; last: true }
+ ListElement { name: "TestPropertyAnimation.qml"; group: "Animations"; last: false }
+ ListElement { name: "TestNumberAnimation.qml"; group: "Animations"; last: false }
+ ListElement { name: "TestParallelAnimation.qml"; group: "Animations"; last: false }
+ ListElement { name: "TestSequentialAnimation.qml"; group: "Animations"; last: true }
+ ListElement { name: "TestMultipleAnimation.qml"; group: "Animations"; last: false }
+ ListElement { name: "TestSequentialAnimationAlwaysRunToEnd.qml"; group: "Animations"; last: false }
+ ListElement { name: "TestNumberAnimationAlwaysRunToEnd.qml"; group: "Animations"; last: true }
+}
diff --git a/animators/test/TestMultipleAnimation.qml b/animators/test/TestMultipleAnimation.qml
new file mode 100755
index 0000000..5f04373
--- /dev/null
+++ b/animators/test/TestMultipleAnimation.qml
@@ -0,0 +1,106 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.NumberAnimation {
+ id: testAnimation
+ loops: 1
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ target: renderThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ onCompleted: {
+ testAnimation2.running = true
+ }
+ }
+ Rt.NumberAnimation {
+ id: testAnimation2
+ loops: 1
+ running: false
+ paused: control.paused
+ target: renderThreadItem
+ property: "scale"
+ from: 1.0
+ to: 0.5
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ NumberAnimation {
+ id: referenceAnimation
+ loops: 1
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ target: mainThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ onCompleted: referenceAnimation2.running = true
+ }
+ NumberAnimation {
+ id: referenceAnimation2
+ loops: 1
+ running: false
+ paused: control.paused
+ target: mainThreadItem
+ property: "scale"
+ from: 1.0
+ to: 0.5
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestMultipleProperties.qml b/animators/test/TestMultipleProperties.qml
new file mode 100755
index 0000000..4792ff9
--- /dev/null
+++ b/animators/test/TestMultipleProperties.qml
@@ -0,0 +1,116 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ transform: [
+ Scale { id: scaleTransform; origin.x: renderThreadItem.width / 2; origin.y: renderThreadItem.height / 2; }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: scaleTransform
+ properties: "xScale, yScale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: scaleTransform
+ properties: "xScale, yScale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ transform: [
+ Scale { id: referenceScaleTransform; origin.x: renderThreadItem.width / 2; origin.y: renderThreadItem.height / 2; }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: referenceScaleTransform
+ properties: "xScale, yScale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: referenceScaleTransform
+ properties: "xScale, yScale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestNumberAnimation.qml b/animators/test/TestNumberAnimation.qml
new file mode 100755
index 0000000..eecdca5
--- /dev/null
+++ b/animators/test/TestNumberAnimation.qml
@@ -0,0 +1,77 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.NumberAnimation {
+ id: testAnimation
+ loops: 1
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ target: renderThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ onCompleted: console.log("onCompleted value = " + renderThreadItem.rotation)
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ NumberAnimation {
+ id: referenceAnimation
+ loops: 1
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ target: mainThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestNumberAnimationAlwaysRunToEnd.qml b/animators/test/TestNumberAnimationAlwaysRunToEnd.qml
new file mode 100755
index 0000000..48880a5
--- /dev/null
+++ b/animators/test/TestNumberAnimationAlwaysRunToEnd.qml
@@ -0,0 +1,80 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.NumberAnimation {
+ id: testAnimation
+ alwaysRunToEnd: true
+ loops: 5
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ target: renderThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ onCompleted: console.log("onCompleted")
+ onRunningChanged: console.log("Running changed")
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ NumberAnimation {
+ id: referenceAnimation
+ alwaysRunToEnd: true
+ loops: 5
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ target: mainThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestOpacity.qml b/animators/test/TestOpacity.qml
new file mode 100755
index 0000000..1160a71
--- /dev/null
+++ b/animators/test/TestOpacity.qml
@@ -0,0 +1,107 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ property int koe: 42
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "opacity"
+ from: 0.0
+ to: 1.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "opacity"
+ from: 1.0
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ NumberAnimation {
+ loops: 1
+ target: mainThreadItem
+ property: "opacity"
+ from: 0.0
+ to: 1.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ target: mainThreadItem
+ property: "opacity"
+ from: 1.0
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestParallelAnimation.qml b/animators/test/TestParallelAnimation.qml
new file mode 100755
index 0000000..7b1b490
--- /dev/null
+++ b/animators/test/TestParallelAnimation.qml
@@ -0,0 +1,106 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.ParallelAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "opacity"
+ from: 1.0
+ to: 0.3
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ ParallelAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "opacity"
+ from: 1.0
+ to: 0.3
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestPosition.qml b/animators/test/TestPosition.qml
new file mode 100755
index 0000000..5b88fb4
--- /dev/null
+++ b/animators/test/TestPosition.qml
@@ -0,0 +1,78 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+import ".."
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ x: 150
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.PropertyAnimation {
+ id: testAnimation
+ loops: 1
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ target: renderThreadItem
+ property: "x"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ PropertyAnimation {
+ id: referenceAnimation
+ loops: 1
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ target: mainThreadItem
+ property: "x"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestPropertyAnimation.qml b/animators/test/TestPropertyAnimation.qml
new file mode 100755
index 0000000..ca2ecd1
--- /dev/null
+++ b/animators/test/TestPropertyAnimation.qml
@@ -0,0 +1,76 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.PropertyAnimation {
+ id: testAnimation
+ loops: 3
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ target: renderThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ PropertyAnimation {
+ id: referenceAnimation
+ loops: 3
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ target: mainThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestRectangleRotation.qml b/animators/test/TestRectangleRotation.qml
new file mode 100755
index 0000000..6c84c14
--- /dev/null
+++ b/animators/test/TestRectangleRotation.qml
@@ -0,0 +1,131 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Rectangle {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ color: "red"
+ visible: !renderThreadAnimationsDisabled
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ Rt.ColorAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "color"
+ from: "red"
+ to: "blue"
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "opacity"
+ from: 1.0
+ to: 0.2
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Rectangle {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ color: "red"
+ visible: !mainThreadAnimationsDisabled
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ ColorAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "color"
+ from: "red"
+ to: "blue"
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "opacity"
+ from: 1.0
+ to: 0.2
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestRotation.qml b/animators/test/TestRotation.qml
new file mode 100755
index 0000000..6983308
--- /dev/null
+++ b/animators/test/TestRotation.qml
@@ -0,0 +1,106 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 1
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "rotation"
+ from: 360.0
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 1
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "rotation"
+ from: 360.0
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestScale.qml b/animators/test/TestScale.qml
new file mode 100755
index 0000000..c6596c4
--- /dev/null
+++ b/animators/test/TestScale.qml
@@ -0,0 +1,108 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running
+ paused: control.paused
+ loops: 3
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "scale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "scale"
+ from: 2.0
+ to: 1.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "scale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "scale"
+ from: 2.0
+ to: 1.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestSequentialAnimation.qml b/animators/test/TestSequentialAnimation.qml
new file mode 100755
index 0000000..849fd18
--- /dev/null
+++ b/animators/test/TestSequentialAnimation.qml
@@ -0,0 +1,108 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "rotation"
+ from: 360.0
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "rotation"
+ from: 360.0
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestSequentialAnimationAlwaysRunToEnd.qml b/animators/test/TestSequentialAnimationAlwaysRunToEnd.qml
new file mode 100755
index 0000000..43dbe90
--- /dev/null
+++ b/animators/test/TestSequentialAnimationAlwaysRunToEnd.qml
@@ -0,0 +1,110 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 10
+ alwaysRunToEnd: true
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: renderThreadItem
+ property: "rotation"
+ from: 360.0
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 10
+ alwaysRunToEnd: true
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "rotation"
+ from: 0.0
+ to: 360.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: mainThreadItem
+ property: "rotation"
+ from: 360.0
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestShaderEffect.qml b/animators/test/TestShaderEffect.qml
new file mode 100755
index 0000000..4699087
--- /dev/null
+++ b/animators/test/TestShaderEffect.qml
@@ -0,0 +1,173 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.ShaderEffect {
+ id: effect
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ property variant source: ShaderEffectSource {
+ sourceItem: Rectangle { width: 100; height: 100; color: "red" }
+ hideSource: true
+ }
+ property real c: 0.0
+
+ fragmentShader:
+ "
+ varying highp vec2 qt_TexCoord0;
+ uniform sampler2D source;
+ uniform highp float c;
+
+ void main() {
+ lowp vec4 color = texture2D(source, qt_TexCoord0);
+ gl_FragColor = mix(color, vec4(0.4), c);
+ }
+ "
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 10
+
+ Rt.NumberAnimation {
+ loops: 1
+ target: effect
+ property: "scale"
+ from: 1.0
+ to: 0.8
+ duration: 1500
+ }
+
+ Rt.SequentialAnimation {
+ loops: 2
+ Rt.NumberAnimation {
+ loops: 1
+ target: effect
+ property: "c"
+ from: 0.0
+ to: 1.0
+ duration: 1500
+ }
+ Rt.NumberAnimation {
+ loops: 1
+ target: effect
+ property: "c"
+ from: 1.0
+ to: 0.0
+ duration: 1500
+ }
+ }
+
+ Rt.NumberAnimation {
+ loops: 1
+ target: effect
+ property: "scale"
+ from: 0.8
+ to: 1.0
+ duration: 1500
+ }
+
+ }
+ }
+
+ ShaderEffect {
+ id: refeffect
+ y: parent.height / 2 + 5
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+ property var source: ShaderEffectSource {
+ sourceItem: Rectangle { width: 100; height: 100; color: "red" }
+ hideSource: true
+ }
+ property real c: 0.0
+
+ fragmentShader:
+ "
+ varying highp vec2 qt_TexCoord0;
+ uniform sampler2D source;
+ uniform highp float c;
+
+ void main() {
+ lowp vec4 color = texture2D(source, qt_TexCoord0);
+ gl_FragColor = mix(color, vec4(0.4), c);
+ }
+ "
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: refAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 10
+
+ NumberAnimation {
+ loops: 1
+ target: refeffect
+ property: "scale"
+ from: 1.0
+ to: 0.8
+ duration: 1500
+ }
+
+ SequentialAnimation {
+ loops: 2
+ NumberAnimation {
+ loops: 1
+ target: refeffect
+ property: "c"
+ from: 0.0
+ to: 1.0
+ duration: 1500
+ }
+ NumberAnimation {
+ loops: 1
+ target: refeffect
+ property: "c"
+ from: 1.0
+ to: 0.0
+ duration: 1500
+ }
+ }
+
+ NumberAnimation {
+ loops: 1
+ target: refeffect
+ property: "scale"
+ from: 0.8
+ to: 1.0
+ duration: 1500
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+ }
diff --git a/animators/test/TestShaderEffectOpacity.qml b/animators/test/TestShaderEffectOpacity.qml
new file mode 100755
index 0000000..a63defa
--- /dev/null
+++ b/animators/test/TestShaderEffectOpacity.qml
@@ -0,0 +1,151 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Timer {
+ running: true
+ interval: 2
+ onTriggered: loader.sourceComponent = com
+ repeat: false
+ }
+
+ Loader {
+ id: loader
+ sourceComponent: undefined
+ anchors.fill: parent
+ }
+
+ Component {
+ id: com
+ Item {
+ anchors.fill: parent
+ Rt.ShaderEffect {
+ id: effect
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ property variant source: ShaderEffectSource {
+ sourceItem: Rectangle { width: 100; height: 100; color: "red" }
+ hideSource: true
+ }
+ property real c: 0.0
+
+ fragmentShader:
+ "
+ varying highp vec2 qt_TexCoord0;
+ uniform sampler2D source;
+ uniform highp float c;
+ uniform highp float qt_Opacity;
+
+ void main() {
+ lowp vec4 color = texture2D(source, qt_TexCoord0);
+ gl_FragColor = mix(color, vec4(0.4), c) * qt_Opacity;
+ }
+ "
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.ParallelAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 10
+
+ Rt.NumberAnimation {
+ loops: 1
+ target: effect
+ property: "opacity"
+ from: 1.0
+ to: 0.0
+ duration: 3000
+ }
+ Rt.NumberAnimation {
+ loops: 1
+ target: effect
+ property: "c"
+ from: 0.0
+ to: 1.0
+ duration: 1500
+ }
+ }
+ }
+
+ ShaderEffect {
+ id: refeffect
+ y: parent.height / 2 + 5
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+ property var source: ShaderEffectSource {
+ sourceItem: Rectangle { width: 100; height: 100; color: "red" }
+ hideSource: true
+ }
+ property real c: 0.0
+
+ fragmentShader:
+ "
+ varying highp vec2 qt_TexCoord0;
+ uniform sampler2D source;
+ uniform highp float c;
+ uniform highp float qt_Opacity;
+
+ void main() {
+ lowp vec4 color = texture2D(source, qt_TexCoord0);
+ gl_FragColor = mix(color, vec4(0.4), c) * qt_Opacity;
+ }
+ "
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ ParallelAnimation {
+ id: refAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 10
+
+ NumberAnimation {
+ loops: 1
+ target: refeffect
+ property: "opacity"
+ from: 1.0
+ to: 0.0
+ duration: 3000
+ }
+
+ NumberAnimation {
+ loops: 1
+ target: refeffect
+ property: "c"
+ from: 0.0
+ to: 1.0
+ duration: 1500
+ }
+ }
+ }
+ }
+ }
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestTransformRotatation.qml b/animators/test/TestTransformRotatation.qml
new file mode 100755
index 0000000..606d56e
--- /dev/null
+++ b/animators/test/TestTransformRotatation.qml
@@ -0,0 +1,110 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ transform: [
+ Rotation { id: rotationTransform; origin.x: renderThreadItem.width / 2; origin.y: renderThreadItem.height / 2; }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ Rt.NumberAnimation {
+ loops: 1
+ target: rotationTransform
+ property: "angle"
+ from: 0.0
+ to: 360
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ target: rotationTransform
+ property: "angle"
+ from: 360
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ transform: [
+ Rotation { id: referenceRotationTransform; origin.x: renderThreadItem.width / 2; origin.y: renderThreadItem.height / 2; }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ NumberAnimation {
+ loops: 1
+ target: referenceRotationTransform
+ property: "angle"
+ from: 0.0
+ to: 360
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ target: referenceRotationTransform
+ property: "angle"
+ from: 360
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestTransformRotationOriginPoint.qml b/animators/test/TestTransformRotationOriginPoint.qml
new file mode 100755
index 0000000..af7fd56
--- /dev/null
+++ b/animators/test/TestTransformRotationOriginPoint.qml
@@ -0,0 +1,118 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ transform: [
+ Rotation {
+ id: rotationTransform;
+ angle: 45; origin.x: renderThreadItem.width / 2; origin.y: renderThreadItem.height / 2;
+ onOriginChanged: console.log("onOriginChanged " + origin)
+ }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ onRunningChanged: console.log("onRunningChanged " + rotationTransform.origin)
+ Rt.NumberAnimation {
+ loops: 1
+ target: rotationTransform
+ property: "origin.x"
+ from: 0.0
+ to: 360
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ target: rotationTransform
+ property: "origin.x"
+ from: 360
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ onCompleted: console.log("onCompleted " + rotationTransform.origin)
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ transform: [
+ Rotation { id: referenceRotationTransform; angle: 45; origin.x: renderThreadItem.width / 2; origin.y: renderThreadItem.height / 2; }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ NumberAnimation {
+ loops: 1
+ target: referenceRotationTransform
+ property: "origin.x"
+ from: 0.0
+ to: 360
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ onCompleted: console.log("test1")
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ target: referenceRotationTransform
+ property: "origin.x"
+ from: 360
+ to: 0.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ onCompleted: console.log("test2")
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestTransformScale.qml b/animators/test/TestTransformScale.qml
new file mode 100755
index 0000000..c42b54f
--- /dev/null
+++ b/animators/test/TestTransformScale.qml
@@ -0,0 +1,116 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ transform: [
+ Scale { id: scaleTransform; origin.x: renderThreadItem.width / 2; origin.y: renderThreadItem.height / 2; }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: scaleTransform
+ property: "xScale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ running: false
+ target: scaleTransform
+ property: "yScale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ transform: [
+ Scale { id: referenceScaleTransform; origin.x: renderThreadItem.width / 2; origin.y: renderThreadItem.height / 2; }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 3
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: referenceScaleTransform
+ property: "xScale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ running: false
+ target: referenceScaleTransform
+ property: "yScale"
+ from: 1.0
+ to: 2.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/animators/test/TestTransformTranslate.qml b/animators/test/TestTransformTranslate.qml
new file mode 100755
index 0000000..5f8d26d
--- /dev/null
+++ b/animators/test/TestTransformTranslate.qml
@@ -0,0 +1,112 @@
+import QtQuick 2.0
+import Animators 1.0 as Rt
+
+Rectangle {
+ id: root
+ width: 320
+ height: 480
+ color: "black"
+ property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
+ property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]
+
+ Rt.Item {
+ id: renderThreadItem
+ width: parent.width
+ height: parent.height / 2
+ visible: !renderThreadAnimationsDisabled
+
+ transform: [
+ Translate { id: translateTransform; }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Render thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ Rt.SequentialAnimation {
+ id: testAnimation
+ running: control.running && !renderThreadAnimationsDisabled
+ paused: control.paused
+ loops: 1
+ Rt.NumberAnimation {
+ loops: 1
+ target: translateTransform
+ property: "x"
+ from: 0.0
+ to: 100.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ Rt.PauseAnimation { duration: 2000 }
+ Rt.NumberAnimation {
+ loops: 1
+ target: translateTransform
+ property: "y"
+ from: 0.0
+ to: 50.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Item {
+ id: mainThreadItem
+ y: parent.height / 2
+ width: parent.width
+ height: parent.height / 2
+ visible: !mainThreadAnimationsDisabled
+
+ transform: [
+ Translate { id: referenceTranslateTransform; }
+ ]
+
+ Text {
+ anchors.centerIn: parent
+ text: "Main thread animation"
+ smooth: true
+ color: "white"
+ font.pixelSize: 20
+ }
+
+ SequentialAnimation {
+ id: referenceAnimation
+ running: control.running && !mainThreadAnimationsDisabled
+ paused: control.paused
+ loops: 1
+ NumberAnimation {
+ loops: 1
+ target: referenceTranslateTransform
+ property: "x"
+ from: 0.0
+ to: 100.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ PauseAnimation { duration: 2000 }
+ NumberAnimation {
+ loops: 1
+ target: referenceTranslateTransform
+ property: "y"
+ from: 0.0
+ to: 50.0
+ duration: 3*2000
+ easing.type: Easing.Bezier
+ easing.bezierCurve: out60in33
+ }
+ }
+ }
+
+ Control {
+ id: control
+ anchors.bottom: parent.bottom
+ running: true
+ }
+}
diff --git a/customcontext/animationdriver.cpp b/customcontext/animationdriver.cpp
index f1abe9b..0b882db 100644
--- a/customcontext/animationdriver.cpp
+++ b/customcontext/animationdriver.cpp
@@ -88,7 +88,7 @@ void AnimationDriver::maybeUpdateDelta()
qint64 AnimationDriver::elapsed() const
{
- if (WindowManager::fakeRendering || !isRunning() || m_stable_vsync < -1)
+ if (!isRunning() || m_stable_vsync < -1)
return startTime() + m_timer.elapsed();
else
return startTime() + m_current_animation_time;
@@ -108,7 +108,7 @@ void AnimationDriver::advance()
{
maybeUpdateDelta();
- if (WindowManager::fakeRendering || m_stable_vsync < 0) {
+ if (m_stable_vsync < 0) {
m_current_animation_time = m_timer.elapsed();
} else {
diff --git a/customcontext/customcontext.pro b/customcontext/customcontext.pro
index 432f215..cf0c255 100644
--- a/customcontext/customcontext.pro
+++ b/customcontext/customcontext.pro
@@ -36,3 +36,4 @@ arm_build {
DEFINES += DESKTOP_BUILD
}
+verbose:DEFINES+=CUSTOMCONTEXT_DEBUG
diff --git a/customcontext/windowmanager.cpp b/customcontext/windowmanager.cpp
index 5f86b03..fbe97c5 100644
--- a/customcontext/windowmanager.cpp
+++ b/customcontext/windowmanager.cpp
@@ -71,6 +71,16 @@
# define WMDEBUG(x)
#endif
+
+int get_env_int(const char *name, int defaultValue)
+{
+ QByteArray content = qgetenv(name);
+
+ bool ok = false;
+ int value = content.toInt(&ok);
+ return ok ? value : defaultValue;
+}
+
#define QQUICK_WINDOW_TIMING
#ifdef QQUICK_WINDOW_TIMING
static bool qquick_window_timing = !qgetenv("QML_WINDOW_TIMING").isEmpty();
@@ -80,13 +90,11 @@ static int renderTime;
static int sinceLastTime;
#endif
-bool WindowManager::fakeRendering = false;
-
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
const QEvent::Type WM_Show = QEvent::Type(QEvent::User + 1);
const QEvent::Type WM_Hide = QEvent::Type(QEvent::User + 2);
-const QEvent::Type WM_SyncAndAdvance = QEvent::Type(QEvent::User + 3);
+const QEvent::Type WM_LockAndSync = QEvent::Type(QEvent::User + 3);
const QEvent::Type WM_RequestSync = QEvent::Type(QEvent::User + 4);
const QEvent::Type WM_NotifyDoneRender = QEvent::Type(QEvent::User + 5);
const QEvent::Type WM_TryRelease = QEvent::Type(QEvent::User + 6);
@@ -94,7 +102,7 @@ const QEvent::Type WM_ReleaseHandled = QEvent::Type(QEvent::User + 7);
const QEvent::Type WM_Grab = QEvent::Type(QEvent::User + 8);
const QEvent::Type WM_GrabResult = QEvent::Type(QEvent::User + 9);
const QEvent::Type WM_EnterWait = QEvent::Type(QEvent::User + 10);
-const QEvent::Type WM_Polish = QEvent::Type(QEvent::User + 11);
+const QEvent::Type WM_AdvanceAnimations = QEvent::Type(QEvent::User + 11);
template <typename T> T *windowFor(const QList<T> list, QQuickWindow *window)
{
@@ -142,10 +150,20 @@ class RenderThread : public QThread
{
Q_OBJECT
public:
+
+ enum SyncState {
+ SyncNotSpecified,
+ SyncPendingInGui,
+ SyncAcceptedInGui,
+ SyncAbortedByRender
+ };
+
+
RenderThread(WindowManager *w)
: wm(w)
, gl(0)
, sg(QSGContext::createDefaultContext())
+ , waitForGuiTime(0)
, pendingUpdate(false)
, sleeping(false)
, animationRunning(false)
@@ -153,10 +171,18 @@ public:
, shouldExit(false)
, allowMainThreadProcessing(true)
, inSync(true)
+ , syncState(SyncNotSpecified)
{
sg->moveToThread(this);
+
+ waitForGuiTime = get_env_int("QML_RENDERLOOP_WAIT_FOR_GUI_TIME", 5);
+
+#ifdef CUSTOMCONTEXT_DEBUG
+ qDebug("CustomContext: setting GUI wait to %d ms", waitForGuiTime);
+#endif
}
+
void invalidateOpenGL(QQuickWindow *window);
void initializeOpenGL();
@@ -164,6 +190,7 @@ public:
void run();
void syncAndRender();
+ void sync();
void lockGuiFromRender(QEvent::Type eventType)
{
@@ -197,6 +224,9 @@ public slots:
sceneChanged = true;
}
+
+
+
public:
WindowManager *wm;
QOpenGLContext *gl;
@@ -204,19 +234,29 @@ public:
QEventLoop eventLoop;
+ int waitForGuiTime;
+
uint pendingUpdate : 1;
uint sleeping : 1;
uint animationRunning : 1;
uint sceneChanged : 1;
+ // New canvas has been added, we must perform a full sync in order for
+ // the renderer to be created and the initial scene graph built.
+ uint canvasAdded : 1;
+
volatile bool shouldExit;
+
volatile bool allowMainThreadProcessing;
volatile bool inSync : 1;
+ volatile SyncState syncState;
QMutex mutex;
QWaitCondition waitCondition;
+ QElapsedTimer m_timer;
+
struct Window {
QQuickWindow *window;
QSize size;
@@ -241,8 +281,10 @@ bool RenderThread::event(QEvent *e)
Window window;
window.window = se->window;
window.size = se->size;
+ window.sceneChanged = true;
m_windows << window;
pendingUpdate = true;
+ canvasAdded = true;
if (sleeping)
exit();
return true; }
@@ -364,6 +406,57 @@ void RenderThread::initializeOpenGL()
sg->initialize(gl);
}
+/*!
+ * Makes an attemt to lock the GUI thread so we can perform the synchronizaiton
+ * of the QML scene's state into the scene graph.
+ *
+ * We return the number of views that did not trigger any changes.
+ */
+void RenderThread::sync()
+{
+ WMDEBUG(" Render: about to lock for sync");
+ mutex.lock();
+ allowMainThreadProcessing = false;
+ syncState = SyncPendingInGui;
+
+ WMDEBUG(" Render: posting WM_SyncAndAdvance to GUI");
+ QCoreApplication::postEvent(wm, new QEvent(WM_LockAndSync));
+ waitCondition.wait(&mutex, canvasAdded ? 99999 : waitForGuiTime);
+
+ // Gui thread did not process the event in time, so abort it...
+ if (syncState == SyncPendingInGui) {
+ WMDEBUG(" Render: aborting...");
+ syncState = SyncAbortedByRender;
+ }
+ pendingUpdate = false;
+
+ if (syncState == SyncAcceptedInGui) {
+ WMDEBUG(" Render: performing sync");
+ inSync = true;
+ for (int i=0; i<m_windows.size(); ++i) {
+ Window &w = const_cast<Window &>(m_windows.at(i));
+ gl->makeCurrent(w.window);
+ QQuickWindowPrivate *d = QQuickWindowPrivate::get(w.window);
+
+ bool hasRenderer = d->renderer != 0;
+ sceneChanged = !hasRenderer || wm->checkAndResetForceUpdate(w.window);
+ d->syncSceneGraph(); // May trigger sceneWasChanged...
+ w.sceneChanged |= sceneChanged;
+
+ // If there was no renderer before, this was the first render pass and
+ // we register for the sceneGraphChanged signal..
+ if (!hasRenderer)
+ connect(d->renderer, SIGNAL(sceneGraphChanged()), this, SLOT(sceneWasChanged()));
+
+ canvasAdded = false;
+ }
+ inSync = false;
+ }
+
+ WMDEBUG(" Render: unlocking after sync");
+ unlockGuiFromRender();
+}
+
void RenderThread::syncAndRender()
{
@@ -371,41 +464,22 @@ void RenderThread::syncAndRender()
if (qquick_window_timing)
sinceLastTime = threadTimer.restart();
#endif
+ WMDEBUG(" Render: Sync & Render")
- WMDEBUG(" Render: about to lock");
- lockGuiFromRender(WM_SyncAndAdvance);
- pendingUpdate = false;
- inSync = true;
- WMDEBUG(" Render: performing sync");
- int skippedRenders = 0;
- for (int i=0; i<m_windows.size(); ++i) {
- Window &w = const_cast<Window &>(m_windows.at(i));
- gl->makeCurrent(w.window);
- QQuickWindowPrivate *d = QQuickWindowPrivate::get(w.window);
-
- bool hasRenderer = d->renderer != 0;
- sceneChanged = !hasRenderer || wm->checkAndResetForceUpdate(w.window);
- d->syncSceneGraph(); // May trigger sceneWasChanged...
- w.sceneChanged = sceneChanged;
+ bool updateWasPending = pendingUpdate;
- if (!sceneChanged)
- ++skippedRenders;
+ if (pendingUpdate)
+ sync();
- // If there was no renderer before, this was the first render pass and
- // we register for the sceneGraphChanged signal..
- if (!hasRenderer)
- connect(d->renderer, SIGNAL(sceneGraphChanged()), this, SLOT(sceneWasChanged()));
+ // Posting animation request to GUI, but only if it is currently alive and
+ // kicking, otherwise we would pile up events and the animation system
+ // would spend a lot of time advancing in addition to the predictive times
+ // being way off.
+ if (animationRunning && syncState == SyncAcceptedInGui) {
+ WMDEBUG(" Render: posting animate to gui..");
+ QCoreApplication::postEvent(wm, new QEvent(WM_AdvanceAnimations));
}
- // When we are skipping renders, animations we are not tracking vsync, so the
- // increment in the animation driver will be wrong, causing a drift over time.
- // Make this knowledge public so the animation driver can pick it up.
- WindowManager::fakeRendering = skippedRenders == m_windows.size();
-
- inSync = false;
- unlockGuiFromRender();
- WMDEBUG(" Render: sync done, on to rendering..");
-
#ifdef QQUICK_WINDOW_TIMING
if (qquick_window_timing)
syncTime = threadTimer.elapsed();
@@ -414,30 +488,24 @@ void RenderThread::syncAndRender()
for (int i=0; i<m_windows.size(); ++i) {
Window &w = const_cast<Window &>(m_windows.at(i));
QQuickWindowPrivate *d = QQuickWindowPrivate::get(w.window);
- if (w.sceneChanged) {
- gl->makeCurrent(w.window);
- d->renderSceneGraph(w.size);
+ gl->makeCurrent(w.window);
+ d->renderSceneGraph(w.size);
#ifdef QQUICK_WINDOW_TIMING
- if (qquick_window_timing && i == 0)
- renderTime = threadTimer.elapsed();
+ if (qquick_window_timing && i == 0)
+ renderTime = threadTimer.elapsed();
#endif
- gl->swapBuffers(w.window);
- d->fireFrameSwapped();
- }
+ gl->swapBuffers(w.window);
+ d->fireFrameSwapped();
}
WMDEBUG(" Render: rendering done");
- if (WindowManager::fakeRendering)
- msleep(16);
-
#ifdef QQUICK_WINDOW_TIMING
if (qquick_window_timing)
- qDebug("window Time: sinceLast=%d, sync=%d, render=%d, swap=%d%s",
+ qDebug("window Time: sinceLast=%d, sync=%d, render=%d, swap=%d",
sinceLastTime,
syncTime,
renderTime - syncTime,
- threadTimer.elapsed() - renderTime,
- WindowManager::fakeRendering ? ", fake frame" : "");
+ threadTimer.elapsed() - renderTime);
#endif
}
@@ -691,12 +759,13 @@ void WindowManager::handleObscurity(QQuickWindow *window)
*/
void WindowManager::maybeUpdate(QQuickWindow *window)
{
- WMDEBUG("GUI: maybeUpdate called");
- if (m_thread->inSync) {
+ if (QThread::currentThread() == m_thread) {
+ WMDEBUG("GUI: maybeUpdate on render thread...");
m_thread->pendingUpdate = true;
return;
}
+ WMDEBUG("GUI: maybeUpdate...");
Window *w = windowFor(m_windows, window);
if (!w || w->pendingUpdate || !m_thread->isRunning())
return;
@@ -716,6 +785,16 @@ void WindowManager::maybeUpdate(QQuickWindow *window)
*/
void WindowManager::update(QQuickWindow *window)
{
+ if (QThread::currentThread() == m_thread) {
+ WMDEBUG("Gui: update called on render thread");
+ RenderThread::Window *w = windowFor(m_thread->m_windows, window);
+ if (w) {
+ w->sceneChanged = true;
+ m_thread->pendingUpdate = true;
+ }
+ return;
+ }
+
WMDEBUG("Gui: update called");
maybeUpdate(window);
Window *w = windowFor(m_windows, window);
@@ -821,7 +900,7 @@ bool WindowManager::event(QEvent *e)
wakeAndWait(m_thread);
break;
- case WM_SyncAndAdvance: {
+ case WM_LockAndSync: {
#ifdef QQUICK_WINDOW_TIMING
QElapsedTimer timer;
int polishTime;
@@ -839,24 +918,62 @@ bool WindowManager::event(QEvent *e)
if (qquick_window_timing)
polishTime = timer.elapsed();
#endif
- wakeAndWait(m_thread);
+
+ bool aborted = false;
+ m_thread->mutex.lock();
+
+ if (m_thread->syncState == RenderThread::SyncPendingInGui) {
+ m_thread->syncState = RenderThread::SyncAcceptedInGui;
+
+ // The lock down the GUI thread and wake render for doing the sync
+ m_thread->waitCondition.wakeOne();
+ WMDEBUG("GUI: woke up render, now waiting...");
+ m_thread->waitCondition.wait(&m_thread->mutex);
+
+ WMDEBUG("GUI: done with the waiting...");
+
+ } else {
+ WMDEBUG("GUI: sync aborted...")
+ aborted = true;
+ }
+ m_thread->mutex.unlock();
+
WMDEBUG("GUI: clearing update flags...");
- // The lock down the GUI thread and wake render for doing the sync
renderPassScheduled = false;
for (int i=0; i<m_windows.size(); ++i) {
m_windows[i].pendingUpdate = false;
}
+
+ if (aborted) {
+ // Force another sync-round since this one is aborted..
+ if (m_windows.size())
+ maybeUpdate(m_windows.at(0).window);
+ }
+
+#ifdef QQUICK_CANVAS_TIMING
+ if (qquick_canvas_timing)
+ qDebug(" - polish=%d aborted=%s", polishTime, aborted ? "yes" : "no");
+#endif
+ WMDEBUG("GUI: sync done...");
+ return true;
+ }
+
+ case WM_AdvanceAnimations:
+ WMDEBUG("GUI: got animate request..");
if (m_animation_driver->isRunning()) {
+#ifdef QQUICK_CANVAS_TIMING
+ QElapsedTimer timer;
+ timer.start();
+#endif
m_animation_driver->advance();
WMDEBUG("GUI: animations advanced..");
- }
-#ifdef QQUICK_WINDOW_TIMING
- if (qquick_window_timing)
- qDebug(" - polish=%d, animation=%d", polishTime, (int) (timer.elapsed() - polishTime));
+#ifdef QQUICK_CANVAS_TIMING
+ if (qquick_canvas_timing)
+ qDebug(" - animation: %d", (int) timer.elapsed());
#endif
- WMDEBUG("GUI: sync and animate done...");
+ }
return true;
- }
+
case WM_NotifyDoneRender:
WMDEBUG("GUI: render done notification...");
diff --git a/customcontext/windowmanager.h b/customcontext/windowmanager.h
index 9066a7d..29e0e1f 100644
--- a/customcontext/windowmanager.h
+++ b/customcontext/windowmanager.h
@@ -80,11 +80,6 @@ public:
void wakeup();
- // Set to true when we are spinning the scene graph render loop to
- // drive animations but not really rendering or swapping, only
- // sync'ing and animating.
- static bool fakeRendering;
-
public slots:
void animationStarted();
void animationStopped();