summaryrefslogtreecommitdiffstats
path: root/src/declarative/timeline
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-04-27 06:52:38 (GMT)
committerRoberto Raggi <roberto.raggi@nokia.com>2009-04-27 06:52:38 (GMT)
commit6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb (patch)
tree68d6c4928dbd91d50e08b5b9d09a1178dffad092 /src/declarative/timeline
parent5d8ce4c43c3c2816cd5dca03ddd429f26b96d34d (diff)
parent7e94543a9b013b6b1140137ba64406b74a363afc (diff)
downloadQt-6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb.zip
Qt-6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb.tar.gz
Qt-6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb.tar.bz2
Merge branch 'kinetic-declarativeui' of git://scm.dev.nokia.troll.no/qt/kinetic into kinetic-declarativeui-qfx
Diffstat (limited to 'src/declarative/timeline')
-rw-r--r--src/declarative/timeline/gfxeasing.cpp811
-rw-r--r--src/declarative/timeline/gfxeasing.h107
-rw-r--r--src/declarative/timeline/qmltimeline.cpp (renamed from src/declarative/timeline/gfxtimeline.cpp)195
-rw-r--r--src/declarative/timeline/qmltimeline.h (renamed from src/declarative/timeline/gfxtimeline.h)54
-rw-r--r--src/declarative/timeline/qmltimelinevalueproxy.h (renamed from src/declarative/timeline/gfxvalueproxy.h)21
-rw-r--r--src/declarative/timeline/timeline.pri8
6 files changed, 138 insertions, 1058 deletions
diff --git a/src/declarative/timeline/gfxeasing.cpp b/src/declarative/timeline/gfxeasing.cpp
deleted file mode 100644
index 45b84eb..0000000
--- a/src/declarative/timeline/gfxeasing.cpp
+++ /dev/null
@@ -1,811 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "gfxeasing.h"
-#include <math.h>
-#include <QHash>
-#include <QPainter>
-#include <QVariant>
-#include <QDebug>
-#include <QStringList>
-#include <QMouseEvent>
-#include "gfxtimeline.h"
-
-
-QT_BEGIN_NAMESPACE
-typedef QHash<QString, qreal> GfxEasingProperties;
-class GfxEasingFunction
-{
-public:
- virtual ~GfxEasingFunction() {}
- virtual float value(float t, float b, float c, float d) = 0;
- virtual GfxEasingFunction *copy() const = 0;
-};
-
-#include "../3rdparty/easing.cpp"
-
-struct ElasticEase : public GfxEasingFunction
-{
- enum Type { In, Out };
- ElasticEase(Type t) : _t(t), _p(0.0f), _a(0.0f) {}
-
- Type _t;
- qreal _p;
- qreal _a;
-
- GfxEasingFunction *copy() const
- {
- ElasticEase *rv = new ElasticEase(_t);
- rv->_p = _p;
- rv->_a = _a;
- return rv;
- }
-
- float value(float t, float b, float c, float d)
- {
- if (t==0) return b;
- float t_adj = (float)t / (float)d;
- if (t_adj==1) return b+c;
-
- qreal p = _p?_p:(d * 0.3f);
-
- qreal a;
- qreal s;
-
- if(!_a || _a < ::fabs(c)) {
- a = c;
- s = p / 4.0f;
- } else {
- a = _a;
- s = p / (2 * M_PI) * ::asin(c / a);
- }
-
- if(_t == In)
- t_adj -= 1.0f;
-
- return (a*::pow(2,-10*t_adj) * ::sin( (t_adj*d-s)*(2*M_PI)/p ) + c + b);
- }
-};
-
-struct BounceEase : public GfxEasingFunction
-{
- enum Type { In, Out };
- BounceEase(Type t) : _t(t), _a(-1.0) {}
-
- Type _t;
- qreal _a;
-
- GfxEasingFunction *copy() const
- {
- BounceEase *rv = new BounceEase(_t);
- rv->_t = _t;
- rv->_a = _a;
- return rv;
- }
-
- float value(float t, float b, float c, float d)
- {
- if(In == _t)
- return c - bounce(d - t, 0, c, d) + b;
- else
- return bounce(t, b, c, d);
- }
-
- float bounce(float t, float b, float c, float d)
- {
- float t_adj = (float)t / (float)d;
- float amp = (_a == -1.0)?c:_a;
- if ((t_adj) < (1/2.75)) {
- if(c == 0. && _a != -1.0) {
- t_adj -= (0.5f/2.75f);
- return -amp * (1. - (30.25*t_adj*t_adj)) + b;
- } else {
- return c*(7.5625*t_adj*t_adj) + b;
- }
- } else if (t_adj < (2/2.75)) {
- t_adj -= (1.5f/2.75f);
- return -amp * (1. - (7.5625*t_adj*t_adj + .75)) + (b + c);
- } else if (t_adj < (2.5/2.75)) {
- t_adj -= (2.25f/2.75f);
- return -amp * (1. - (7.5625*t_adj*t_adj + .9375)) + (b + c);
- } else {
- t_adj -= (2.65f/2.75f);
- return -amp * (1. - (7.5625*t_adj*t_adj + .984375)) + (b + c);
- }
- }
-};
-
-static GfxEasingFunction *easeInElasticC(const GfxEasingProperties &p)
-{
- ElasticEase *rv = new ElasticEase(ElasticEase::In);
- rv->_p = p[QLatin1String("period")];
- rv->_a = p[QLatin1String("amplitude")];
- return rv;
-}
-
-
-static GfxEasingFunction *easeOutElasticC(const GfxEasingProperties &p)
-{
- ElasticEase *rv = new ElasticEase(ElasticEase::Out);
- rv->_p = p[QLatin1String("period")];
- rv->_a = p[QLatin1String("amplitude")];
- return rv;
-}
-
-static GfxEasingFunction *easeOutBounceC(const GfxEasingProperties &p)
-{
- BounceEase *rv = new BounceEase(BounceEase::Out);
- rv->_a = p[QLatin1String("amplitude")];
- return rv;
-}
-
-static GfxEasingFunction *easeInBounceC(const GfxEasingProperties &p)
-{
- BounceEase *rv = new BounceEase(BounceEase::Out);
- rv->_a = p[QLatin1String("amplitude")];
- return rv;
-}
-
-
-struct SimpleConfig : public GfxEasingFunction
-{
- GfxEasing::Function func;
-
- float value(float t, float b, float c, float d)
- {
- return func(t, b, c, d);
- }
-
- GfxEasingFunction *copy() const
- {
- SimpleConfig *rv = new SimpleConfig;
- rv->func = func;
- return rv;
- }
-};
-
-GfxEasing::Function curveToFunc(GfxEasing::Curve curve)
-{
- switch(curve)
- {
- case GfxEasing::None:
- return &easeNone;
- case GfxEasing::InQuad:
- return &easeInQuad;
- case GfxEasing::OutQuad:
- return &easeOutQuad;
- case GfxEasing::InOutQuad:
- return &easeInOutQuad;
- case GfxEasing::OutInQuad:
- return &easeOutInQuad;
- case GfxEasing::InCubic:
- return &easeInCubic;
- case GfxEasing::OutCubic:
- return &easeOutCubic;
- case GfxEasing::InOutCubic:
- return &easeInOutCubic;
- case GfxEasing::OutInCubic:
- return &easeOutInCubic;
- case GfxEasing::InQuart:
- return &easeInQuart;
- case GfxEasing::OutQuart:
- return &easeOutQuart;
- case GfxEasing::InOutQuart:
- return &easeInOutQuart;
- case GfxEasing::OutInQuart:
- return &easeOutInQuart;
- case GfxEasing::InQuint:
- return &easeInQuint;
- case GfxEasing::OutQuint:
- return &easeOutQuint;
- case GfxEasing::InOutQuint:
- return &easeInOutQuint;
- case GfxEasing::OutInQuint:
- return &easeOutInQuint;
- case GfxEasing::InSine:
- return &easeInSine;
- case GfxEasing::OutSine:
- return &easeOutSine;
- case GfxEasing::InOutSine:
- return &easeInOutSine;
- case GfxEasing::OutInSine:
- return &easeOutInSine;
- case GfxEasing::InExpo:
- return &easeInExpo;
- case GfxEasing::OutExpo:
- return &easeOutExpo;
- case GfxEasing::InOutExpo:
- return &easeInOutExpo;
- case GfxEasing::OutInExpo:
- return &easeOutInExpo;
- case GfxEasing::InCirc:
- return &easeInCirc;
- case GfxEasing::OutCirc:
- return &easeOutCirc;
- case GfxEasing::InOutCirc:
- return &easeInOutCirc;
- case GfxEasing::OutInCirc:
- return &easeOutInCirc;
- case GfxEasing::InElastic:
- return &easeInElastic;
- case GfxEasing::OutElastic:
- return &easeOutElastic;
- case GfxEasing::InOutElastic:
- return &easeInOutElastic;
- case GfxEasing::OutInElastic:
- return &easeOutInElastic;
- case GfxEasing::InBack:
- return &easeInBack;
- case GfxEasing::OutBack:
- return &easeOutBack;
- case GfxEasing::InOutBack:
- return &easeInOutBack;
- case GfxEasing::OutInBack:
- return &easeOutInBack;
- case GfxEasing::InBounce:
- return &easeInBounce;
- case GfxEasing::OutBounce:
- return &easeOutBounce;
- case GfxEasing::InOutBounce:
- return &easeInOutBounce;
- case GfxEasing::OutInBounce:
- return &easeOutInBounce;
- default:
- return 0;
- };
-}
-
-struct NameFunctionMap : public QHash<QString, GfxEasing::Function>
-{
- NameFunctionMap()
- {
- insert(QLatin1String("easeNone"), easeNone);
- insert(QLatin1String("easeInQuad"), easeInQuad);
- insert(QLatin1String("easeOutQuad"), easeOutQuad);
- insert(QLatin1String("easeInOutQuad"), easeInOutQuad);
- insert(QLatin1String("easeOutInQuad"), easeOutInQuad);
- insert(QLatin1String("easeInCubic"), easeInCubic);
- insert(QLatin1String("easeOutCubic"), easeOutCubic);
- insert(QLatin1String("easeInOutCubic"), easeInOutCubic);
- insert(QLatin1String("easeOutInCubic"), easeOutInCubic);
- insert(QLatin1String("easeInQuart"), easeInQuart);
- insert(QLatin1String("easeOutQuart"), easeOutQuart);
- insert(QLatin1String("easeInOutQuart"), easeInOutQuart);
- insert(QLatin1String("easeOutInQuart"), easeOutInQuart);
- insert(QLatin1String("easeInQuint"), easeInQuint);
- insert(QLatin1String("easeOutQuint"), easeOutQuint);
- insert(QLatin1String("easeInOutQuint"), easeInOutQuint);
- insert(QLatin1String("easeOutInQuint"), easeOutInQuint);
- insert(QLatin1String("easeInSine"), easeInSine);
- insert(QLatin1String("easeOutSine"), easeOutSine);
- insert(QLatin1String("easeInOutSine"), easeInOutSine);
- insert(QLatin1String("easeOutInSine"), easeOutInSine);
- insert(QLatin1String("easeInExpo"), easeInExpo);
- insert(QLatin1String("easeOutExpo"), easeOutExpo);
- insert(QLatin1String("easeInOutExpo"), easeInOutExpo);
- insert(QLatin1String("easeOutInExpo"), easeOutInExpo);
- insert(QLatin1String("easeInCirc"), easeInCirc);
- insert(QLatin1String("easeOutCirc"), easeOutCirc);
- insert(QLatin1String("easeInOutCirc"), easeInOutCirc);
- insert(QLatin1String("easeOutInCirc"), easeOutInCirc);
- insert(QLatin1String("easeInElastic"), easeInElastic);
- insert(QLatin1String("easeOutElastic"), easeOutElastic);
- insert(QLatin1String("easeInOutElastic"), easeInOutElastic);
- insert(QLatin1String("easeOutInElastic"), easeOutInElastic);
- insert(QLatin1String("easeInBack"), easeInBack);
- insert(QLatin1String("easeOutBack"), easeOutBack);
- insert(QLatin1String("easeInOutBack"), easeInOutBack);
- insert(QLatin1String("easeOutInBack"), easeOutInBack);
- insert(QLatin1String("easeInBounce"), easeInBounce);
- insert(QLatin1String("easeOutBounce"), easeOutBounce);
- insert(QLatin1String("easeInOutBounce"), easeInOutBounce);
- insert(QLatin1String("easeOutInBounce"), easeOutInBounce);
- }
-};
-Q_GLOBAL_STATIC(NameFunctionMap, nameFunctionMap);
-
-typedef GfxEasingFunction *(*ConfigurableFunction)(const GfxEasingProperties &);
-struct ConfigFunctionMap : public QHash<QString, ConfigurableFunction>
-{
- ConfigFunctionMap()
- {
- insert(QLatin1String("easeInElastic"), easeInElasticC);
- insert(QLatin1String("easeOutElastic"), easeOutElasticC);
- insert(QLatin1String("easeInBounce"), easeInBounceC);
- insert(QLatin1String("easeOutBounce"), easeOutBounceC);
- }
-};
-Q_GLOBAL_STATIC(ConfigFunctionMap, configFunctionMap);
-
-/*!
- \class GfxEasing
- \ingroup group_animation
- \brief The GfxEasing class provides easing curves for controlling animation.
-
- Easing curves describe a function that controls how a value changes over
- time. Easing curves allow transitions from one value to another to appear
- more natural than a simple linear motion would allow. The GfxEasing class
- is usually used in conjunction with the GfxTimeLine class, but can be used
- on its own.
-
- To calculate the value at a given time, the easing curve function requires
- the starting value, the final value and the total time to change from the
- starting to the final value. When using the GfxEasing class with
- GfxTimeLine, these values are supplied by the GfxTimeLine. When using
- the GfxEasing class on its own, the programmer must specify them using
- the GfxEasing::setFrom(), GfxEasing::setTo() and GfxEasing::setLength()
- methods, or by passing them explicitly to the GfxEasing::valueAt() method.
-
- For example,
- \code
- GfxEasing easing(GfxEasing::InOutQuad);
- easing.setFrom(0);
- easing.setTo(1000);
- easing.setLength(1000);
-
- for(int milliseconds = 0; milliseconds < 1000; ++milliseconds)
- qWarning() << "Value at" << milliseconds << "milliseconds is
- << easing.valueAt(milliseconds);
- \endcode
- will print the value at each millisecond for an InOutQuad transition from
- 0 to 1000 over 1 second.
-
- When using a GfxTimeLine, the values are communicated implicitly.
- \code
- GfxTimeLine timeline;
- GfxValue value(0);
-
- timeline.move(value, 1000, GfxEasing(GfxEasing::InOutQuad), 1000);
- \endcode
- In this case, any values set using the previous setter methods would be
- ignored.
- */
-
-/*!
- \qmlproperty string NumericAnimation::easing
- \brief the easing curve used for the transition.
-
- Available values are:
-
- \list
- \i \e easeNone - Easing equation function for a simple linear tweening, with no easing.
- \i \e easeInQuad - Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
- \i \e easeOutQuad - Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
- \i \e easeInOutQuad - Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInQuad - Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInCubic - Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
- \i \e easeOutCubic - Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
- \i \e easeInOutCubic - Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInCubic - Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInQuart - Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
- \i \e easeOutQuart - Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
- \i \e easeInOutQuart - Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInQuart - Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInQuint - Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
- \i \e easeOutQuint - Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
- \i \e easeInOutQuint - Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInQuint - Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInSine - Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
- \i \e easeOutSine - Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
- \i \e easeInOutSine - Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInSine - Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInExpo - Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
- \i \e easeOutExpo - Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
- \i \e easeInOutExpo - Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInExpo - Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
- \i \e easeOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
- \i \e easeInOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the \i amplitude parameter, and the period of decay by the \i period parameter.
- \i \e easeOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the \i amplitude parameter, and the period of decay by the \i period parameter.
- \i \e easeInOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
- \i \e easeOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
- \i \e easeInOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
- \i \e easeOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
- \i \e easeInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
- \i \e easeInOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
- \i \e easeOutInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
- \endlist
-*/
-
-/*!
- \enum GfxEasing::Curve
-
- The type of easing curve.
-
- \value None
- Easing equation function for a simple linear tweening, with no easing.
-
- \value InQuad
- Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity.
-
- \value OutQuad
- Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity.
-
- \value InOutQuad
- Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInQuad
- Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration.
-
- \value InCubic
- Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity.
-
- \value OutCubic
- Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity.
-
- \value InOutCubic
- Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInCubic
- Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration.
-
- \value InQuart
- Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity.
-
- \value OutQuart
- Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity.
-
- \value InOutQuart
- Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInQuart
- Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration.
-
- \value InQuint
- Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity.
-
- \value OutQuint
- Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity.
-
- \value InOutQuint
- Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInQuint
- Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration.
-
- \value InSine
- Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
-
- \value OutSine
- Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
-
- \value InOutSine
- Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInSine
- Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration.
-
- \value InExpo
- Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity.
-
- \value OutExpo
- Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity.
-
- \value InOutExpo
- Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInExpo
- Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration.
-
- \value InCirc
- Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity.
-
- \value OutCirc
- Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity.
-
- \value InOutCirc
- Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInCirc
- Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration.
-
- \value InElastic
- Easing equation function for an elastic (exponentially decaying
- sine wave) easing in: accelerating from zero velocity. The peak
- amplitude can be set with the \e amplitude parameter, and the
- period of decay by the \e period parameter.
-
- \value OutElastic
- Easing equation function for an elastic (exponentially decaying
- sine wave) easing out: decelerating from zero velocity. The peak
- amplitude can be set with the \e amplitude parameter, and the
- period of decay by the \e period parameter.
-
- \value InOutElastic
- Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInElastic
- Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration.
-
- \value InBack
- Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
-
- \value OutBack
- Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity.
-
- \value InOutBack
- Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInBack
- Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
-
- \value OutBounce
- Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity.
-
- \value InBounce
- Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity.
-
- \value InOutBounce
- Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration.
-
- \value OutInBounce
- Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration.
-*/
-
-/*!
- Construct a linear easing object. This is equivalent to \c {GfxEasing(GfxEasing::None)}.
- */
-GfxEasing::GfxEasing()
-: _config(0), _func(&easeNone), _b(0.), _c(1.), _d(1.)
-{
-}
-
-/*!
- Construct an easing object with the given \a curve.
- */
-GfxEasing::GfxEasing(Curve curve)
-: _config(0), _func(0), _b(0.), _c(1.), _d(1.)
-{
- _func = curveToFunc(curve);
- if(!_func) {
- qWarning("GfxEasing: Invalid curve type %d", curve);
- _func = &easeNone;
- }
-}
-
-/*!
- Construct an easing object with the given \a curve. If \a curve does not
- describe a legal curve, a linear easing object is constructed.
-
- Curve names have the form
- \c {ease<CurveName>[(<arg>: <arg value>[, <arg2>: <arg value>])]}. The
- \e CurveName is equivalent to the GfxEasing::Curve enum name. Some more
- advanced curves can take arguments to further refine their behaviour. Where
- applicable, these parameters are described in the corresponding
- GfxEasing::Curve value documentation.
-
- For example,
- \code
- GfxEasing easing("easeInOutQuad");
- GfxEasing easing2("easeInElastic(period: 5, amplitude: 100)");
- \endcode
- */
-GfxEasing::GfxEasing(const QString &curve)
-: _config(0), _func(&easeNone), _b(0.), _c(1.), _d(1.)
-{
- if(curve.contains(QLatin1Char('('))) {
- QString easeName = curve.trimmed();
- GfxEasingProperties prop;
- if(!easeName.endsWith(QLatin1Char(')'))) {
- qWarning("GfxEasing: Unmatched perenthesis in easing function '%s'",
- curve.toLatin1().constData());
- return;
- }
-
- int idx = easeName.indexOf(QLatin1Char('('));
- QString prop_str =
- easeName.mid(idx + 1, easeName.length() - 1 - idx - 1);
- easeName = easeName.left(idx);
-
- QStringList props = prop_str.split(QLatin1Char(','));
- foreach(QString str, props) {
- int sep = str.indexOf(QLatin1Char(':'));
-
- if(sep == -1) {
- qWarning("GfxEasing: Improperly specified property in easing function '%s'",
- curve.toLatin1().constData());
- return;
- }
-
- QString propName = str.left(sep).trimmed();
- bool isOk;
- qreal propValue = str.mid(sep + 1).trimmed().toDouble(&isOk);
-
- if(propName.isEmpty() || !isOk) {
- qWarning("GfxEasing: Improperly specified property in easing function '%s'",
- curve.toLatin1().constData());
- return;
- }
-
- prop.insert(propName, propValue);
- }
-
- QHash<QString, ConfigurableFunction>::Iterator iter =
- configFunctionMap()->find(easeName);
-
- if(iter != configFunctionMap()->end())
- _config = (*iter)(prop);
- } else {
- if(nameFunctionMap()->contains(curve))
- _func = *(nameFunctionMap()->find(curve));
- }
-
- if(!_func && !_config) {
- qWarning("GfxEasing: Unknown easing curve '%s'",
- curve.toLatin1().constData());
- _func = &easeNone;
- }
-}
-
-/*!
- Construct a copy of \a other.
- */
-GfxEasing::GfxEasing(const GfxEasing &other)
-: _config(0), _func(other._func), _b(other._b), _c(other._c), _d(other._d)
-{
- if(other._config) _config = other._config->copy();
-}
-
-/*!
- Copy \a other.
- */
-GfxEasing &GfxEasing::operator=(const GfxEasing &other)
-{
- if(_config) { delete _config; _config = 0; }
- if(other._config) _config = other._config->copy();
-
- _func = other._func;
- _b = other._b;
- _c = other._c;
- _d = other._d;
-
- return *this;
-}
-
-/*!
- Returns true if this is a linear easing object.
- */
-bool GfxEasing::isLinear() const
-{
- return !_config && _func == &easeNone;
-}
-
-/*!
- Return the starting value for the easing curve. By default this is 0.
- */
-qreal GfxEasing::from() const
-{
- return _b;
-}
-
-/*!
- Set the starting value for the easing curve to \a from.
- */
-void GfxEasing::setFrom(qreal from)
-{
- _b = from;
-}
-
-/*!
- Return the final value for the easing curve. By default this is 0.
- */
-qreal GfxEasing::to() const
-{
- return _c;
-}
-
-/*!
- Set the final value for the easing curve to \a to.
- */
-void GfxEasing::setTo(qreal to)
-{
- _c = to;
-}
-
-/*!
- Return the length of the easing curve, in milliseconds. By default this
- is 1.
- */
-qreal GfxEasing::length() const
-{
- return _d;
-}
-
-/*!
- Set the \a length of the easing curve, in milliseconds.
- */
-void GfxEasing::setLength(qreal length)
-{
- Q_ASSERT(length > 0);
- _d = length;
-}
-
-/*!
- Return the value for the easing curve at time \a t milliseconds, based on
- the parameters returned by GfxEasing::from(), GfxEasing::to() and
- GfxEasing::length().
-
- \a t is clamped to (0, GfxEasing::length()).
- */
-qreal GfxEasing::valueAt(qreal t) const
-{
- if(t < 0) t = 0;
- else if(t > length()) t = length();
-
- if(_config)
- return _config->value(t, _b, _c - _b, _d);
- else
- return _func(t, _b, _c - _b, _d);
-}
-
-/*
- Return the value for the easing curve at time \a t milliseconds, based on
- the provided parameters \a from, \a to and \a length. The values returned
- from the object's GfxEasing::from(), GfxEasing::to() and GfxEasing::length()
- methods are ignored.
-
- \a t is clamped to (0, \a length).
- */
-qreal GfxEasing::valueAt(qreal t, qreal from, qreal to, qreal length) const
-{
- if(t < 0) t = 0;
- else if(t > length) t = length;
-
- if(_config)
- return _config->value(t, from, to - from, length);
- else
- return _func(t, from, to - from, length);
-}
-
-/*!
- \internal
- */
-QStringList GfxEasing::curves()
-{
- return nameFunctionMap()->keys();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/timeline/gfxeasing.h b/src/declarative/timeline/gfxeasing.h
deleted file mode 100644
index c15aadc..0000000
--- a/src/declarative/timeline/gfxeasing.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GFXEASING_H
-#define GFXEASING_H
-
-#include <qfxglobal.h>
-#include <QList>
-#include <QPair>
-#include <QWidget>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class GfxEasingFunction;
-class Q_DECLARATIVE_EXPORT GfxEasing
-{
-public:
- enum Curve {
- None,
- InQuad, OutQuad, InOutQuad, OutInQuad,
- InCubic, OutCubic, InOutCubic, OutInCubic,
- InQuart, OutQuart, InOutQuart, OutInQuart,
- InQuint, OutQuint, InOutQuint, OutInQuint,
- InSine, OutSine, InOutSine, OutInSine,
- InExpo, OutExpo, InOutExpo, OutInExpo,
- InCirc, OutCirc, InOutCirc, OutInCirc,
- InElastic, OutElastic, InOutElastic, OutInElastic,
- InBack, OutBack, InOutBack, OutInBack,
- InBounce, OutBounce, InOutBounce, OutInBounce
- };
-
- GfxEasing();
- GfxEasing(Curve);
- GfxEasing(const QString &);
- GfxEasing(const GfxEasing &);
- GfxEasing &operator=(const GfxEasing &);
-
- bool isLinear() const;
-
- qreal from() const;
- void setFrom(qreal);
- qreal to() const;
- void setTo(qreal);
- qreal length() const;
- void setLength(qreal);
-
- qreal valueAt(qreal t) const;
- qreal valueAt(qreal t, qreal from, qreal to, qreal length) const;
-
- static QStringList curves();
-
- typedef float (*Function)(float t, float b, float c, float d);
-private:
- GfxEasingFunction *_config;
- Function _func;
-
- qreal _b, _c, _d;
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif
diff --git a/src/declarative/timeline/gfxtimeline.cpp b/src/declarative/timeline/qmltimeline.cpp
index 3e84df8..fc901eb 100644
--- a/src/declarative/timeline/gfxtimeline.cpp
+++ b/src/declarative/timeline/qmltimeline.cpp
@@ -39,33 +39,31 @@
**
****************************************************************************/
-#include "gfxtimeline.h"
+#include "qmltimeline.h"
#include <QDebug>
#include <QMutex>
#include <QThread>
#include <QWaitCondition>
#include <QEvent>
#include <QCoreApplication>
-#include "gfxeasing.h"
+#include <QEasingCurve>
#include <QTime>
QT_BEGIN_NAMESPACE
-#define TIMETICK 5
-
//
// Timeline stuff
//
struct Update {
- Update(GfxValue *_g, qreal _v)
+ Update(QmlTimeLineValue *_g, qreal _v)
: g(_g), v(_v) {}
- Update(const GfxEvent &_e)
+ Update(const QmlTimeLineEvent &_e)
: g(0), v(0), e(_e) {}
- GfxValue *g;
+ QmlTimeLineValue *g;
qreal v;
- GfxEvent e;
+ QmlTimeLineEvent e;
};
struct QmlTimeLinePrivate
@@ -84,7 +82,7 @@ struct QmlTimeLinePrivate
};
Op() {}
Op(Type t, int l, qreal v, qreal v2, int o,
- const GfxEvent &ev = GfxEvent(), const GfxEasing &es = GfxEasing())
+ const QmlTimeLineEvent &ev = QmlTimeLineEvent(), const QEasingCurve &es = QEasingCurve())
: type(t), length(l), value(v), value2(v2), order(o), event(ev),
easing(es) {}
Op(const Op &o)
@@ -103,8 +101,8 @@ struct QmlTimeLinePrivate
qreal value2;
int order;
- GfxEvent event;
- GfxEasing easing;
+ QmlTimeLineEvent event;
+ QEasingCurve easing;
};
struct TimeLine
{
@@ -144,7 +142,7 @@ QmlTimeLinePrivate::QmlTimeLinePrivate(QmlTimeLine *parent)
void QmlTimeLinePrivate::add(QmlTimeLineObject &g, const Op &o)
{
if(g._t && g._t != q) {
- qWarning() << "QmlTimeLine: Cannot modify a GfxValue owned by"
+ qWarning() << "QmlTimeLine: Cannot modify a QmlTimeLineValue owned by"
<< "another timeline.";
return;
}
@@ -208,13 +206,12 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
} else if(time == (op.length)) {
return op.value;
} else {
- if(op.easing.isLinear()) {
- qreal delta = op.value - base;
- qreal pTime = (qreal)(time) / (qreal)op.length;
+ qreal delta = op.value - base;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if(op.easing.type() == QEasingCurve::Linear)
return base + delta * pTime;
- } else {
- return op.easing.valueAt(time, base, op.value, op.length);
- }
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
}
case Op::MoveBy:
if(time == 0) {
@@ -222,13 +219,12 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
} else if(time == (op.length)) {
return base + op.value;
} else {
- if(op.easing.isLinear()) {
- qreal delta = op.value;
- qreal pTime = (qreal)(time) / (qreal)op.length;
+ qreal delta = op.value;
+ qreal pTime = (qreal)(time) / (qreal)op.length;
+ if(op.easing.type() == QEasingCurve::Linear)
return base + delta * pTime;
- } else {
- return op.easing.valueAt(time, base, base + op.value, op.length);
- }
+ else
+ return base + delta * op.easing.valueForProgress(pTime);
}
case Op::Accel:
if(time == 0) {
@@ -260,28 +256,29 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
}
/*!
+ \internal
\class QmlTimeLine
\ingroup group_animation
\brief The QmlTimeLine class provides a timeline for controlling animations.
QmlTimeLine is similar to QTimeLine except:
\list
- \i It updates GfxValue instances directly, rather than maintaining a single
+ \i It updates QmlTimeLineValue instances directly, rather than maintaining a single
current value.
For example, the following animates a simple value over 200 milliseconds:
\code
- GfxValue v(<starting value>);
+ QmlTimeLineValue v(<starting value>);
QmlTimeLine tl;
tl.move(v, 100., 200);
tl.start()
\endcode
If your program needs to know when values are changed, it can either
- connect to the QmlTimeLine's updated() signal, or inherit from GfxValue
- and reimplement the GfxValue::setValue() method.
+ connect to the QmlTimeLine's updated() signal, or inherit from QmlTimeLineValue
+ and reimplement the QmlTimeLineValue::setValue() method.
- \i Supports multiple GfxValue, arbitrary start and end values and allows
+ \i Supports multiple QmlTimeLineValue, arbitrary start and end values and allows
animations to be strung together for more complex effects.
For example, the following animation moves the x and y coordinates of
@@ -290,8 +287,8 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change
milliseconds:
\code
- GfxValue x(<starting value>);
- GfxValue y(<starting value>);
+ QmlTimeLineValue x(<starting value>);
+ QmlTimeLineValue y(<starting value>);
QmlTimeLine tl;
tl.start();
@@ -358,7 +355,7 @@ void QmlTimeLine::setSyncMode(SyncMode syncMode)
}
/*!
- Pause \a gfxValue for \a time milliseconds.
+ Pause \a obj for \a time milliseconds.
*/
void QmlTimeLine::pause(QmlTimeLineObject &obj, int time)
{
@@ -370,28 +367,28 @@ void QmlTimeLine::pause(QmlTimeLineObject &obj, int time)
/*!
Execute the \a event.
*/
-void QmlTimeLine::execute(const GfxEvent &event)
+void QmlTimeLine::execute(const QmlTimeLineEvent &event)
{
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, event);
d->add(*event.eventObject(), op);
}
/*!
- Set the \a value of \a gfxValue.
+ Set the \a value of \a timeLineValue.
*/
-void QmlTimeLine::set(GfxValue &gfxValue, qreal value)
+void QmlTimeLine::set(QmlTimeLineValue &timeLineValue, qreal value)
{
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Set, 0, value, 0., d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
}
/*!
- Decelerate \a gfxValue from the starting \a velocity to zero at the
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
given \a acceleration rate. Although the \a acceleration is technically
a deceleration, it should always be positive. The QmlTimeLine will ensure
that the deceleration is in the opposite direction to the initial velocity.
*/
-int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration)
+int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration)
{
if((velocity > 0.0f) == (acceleration > 0.0f))
acceleration = acceleration * -1.0f;
@@ -399,7 +396,7 @@ int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration)
int time = static_cast<int>(-1000 * velocity / acceleration);
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
return time;
}
@@ -407,14 +404,14 @@ int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration)
/*!
\overload
- Decelerate \a gfxValue from the starting \a velocity to zero at the
+ Decelerate \a timeLineValue from the starting \a velocity to zero at the
given \a acceleration rate over a maximum distance of maxDistance.
If necessary, QmlTimeLine will reduce the acceleration to ensure that the
entire operation does not require a move of more than \a maxDistance.
\a maxDistance should always be positive.
*/
-int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration, qreal maxDistance)
+int QmlTimeLine::accel(QmlTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance)
{
Q_ASSERT(acceleration >= 0.0f && maxDistance >= 0.0f);
@@ -428,19 +425,19 @@ int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration, q
int time = static_cast<int>(-1000 * velocity / acceleration);
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
return time;
}
/*!
- Decelerate \a gfxValue from the starting \a velocity to zero over the given
+ Decelerate \a timeLineValue from the starting \a velocity to zero over the given
\a distance. This is like accel(), but the QmlTimeLine calculates the exact
deceleration to use.
\a distance should be positive.
*/
-int QmlTimeLine::accelDistance(GfxValue &gfxValue, qreal velocity, qreal distance)
+int QmlTimeLine::accelDistance(QmlTimeLineValue &timeLineValue, qreal velocity, qreal distance)
{
if (distance == 0.0f || velocity == 0.0f)
return -1;
@@ -449,68 +446,68 @@ int QmlTimeLine::accelDistance(GfxValue &gfxValue, qreal velocity, qreal distanc
int time = static_cast<int>(1000 * (2.0f * distance) / velocity);
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
return time;
}
/*!
- Linearly change the \a gfxValue from its current value to the given
+ Linearly change the \a timeLineValue from its current value to the given
\a destination value over \a time milliseconds.
*/
-void QmlTimeLine::move(GfxValue &gfxValue, qreal destination, int time)
+void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, int time)
{
if(time <= 0) return;
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
}
/*!
- Change the \a gfxValue from its current value to the given \a destination
+ Change the \a timeLineValue from its current value to the given \a destination
value over \a time milliseconds using the \a easing curve.
*/
-void QmlTimeLine::move(GfxValue &gfxValue, qreal destination, const GfxEasing &easing, int time)
+void QmlTimeLine::move(QmlTimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time)
{
if(time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, GfxEvent(), easing);
- d->add(gfxValue, op);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ d->add(timeLineValue, op);
}
/*!
- Linearly change the \a gfxValue from its current value by the \a change amount
+ Linearly change the \a timeLineValue from its current value by the \a change amount
over \a time milliseconds.
*/
-void QmlTimeLine::moveBy(GfxValue &gfxValue, qreal change, int time)
+void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, int time)
{
if(time <= 0) return;
QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++);
- d->add(gfxValue, op);
+ d->add(timeLineValue, op);
}
/*!
- Change the \a gfxValue from its current value by the \a change amount over
+ Change the \a timeLineValue from its current value by the \a change amount over
\a time milliseconds using the \a easing curve.
*/
-void QmlTimeLine::moveBy(GfxValue &gfxValue, qreal change, const GfxEasing &easing, int time)
+void QmlTimeLine::moveBy(QmlTimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time)
{
if(time <= 0) return;
- QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, GfxEvent(), easing);
- d->add(gfxValue, op);
+ QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QmlTimeLineEvent(), easing);
+ d->add(timeLineValue, op);
}
/*!
- Cancel (but don't complete) all scheduled actions for \a gfxValue.
+ Cancel (but don't complete) all scheduled actions for \a timeLineValue.
*/
-void QmlTimeLine::reset(GfxValue &gfxValue)
+void QmlTimeLine::reset(QmlTimeLineValue &timeLineValue)
{
- if(!gfxValue._t)
+ if(!timeLineValue._t)
return;
- if(gfxValue._t != this) {
- qWarning() << "QmlTimeLine: Cannot reset a GfxValue owned by another timeline.";
+ if(timeLineValue._t != this) {
+ qWarning() << "QmlTimeLine: Cannot reset a QmlTimeLineValue owned by another timeline.";
return;
}
- remove(&gfxValue);
- gfxValue._t = 0;
+ remove(&timeLineValue);
+ timeLineValue._t = 0;
}
int QmlTimeLine::duration() const
@@ -519,48 +516,48 @@ int QmlTimeLine::duration() const
}
/*!
- Synchronize the end point of \a gfxValue to the endpoint of \a syncTo
+ Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo
within this timeline.
- Following operations on \a gfxValue in this timeline will be scheduled after
+ Following operations on \a timeLineValue in this timeline will be scheduled after
all the currently scheduled actions on \a syncTo are complete. In
psuedo-code this is equivalent to:
\code
- QmlTimeLine::pause(gfxValue, min(0, length_of(syncTo) - length_of(gfxValue)))
+ QmlTimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue)))
\endcode
*/
-void QmlTimeLine::sync(GfxValue &gfxValue, GfxValue &syncTo)
+void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue, QmlTimeLineValue &syncTo)
{
QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo);
if(iter == d->ops.end())
return;
int length = iter->length;
- iter = d->ops.find(&gfxValue);
+ iter = d->ops.find(&timeLineValue);
if(iter == d->ops.end()) {
- pause(gfxValue, length);
+ pause(timeLineValue, length);
} else {
int glength = iter->length;
- pause(gfxValue, length - glength);
+ pause(timeLineValue, length - glength);
}
}
/*!
- Synchronize the end point of \a gfxValue to the endpoint of the longest
- action currently scheduled in the timeline.
+ Synchronize the end point of \a timeLineValue to the endpoint of the longest
+ action cursrently scheduled in the timeline.
In psuedo-code, this is equivalent to:
\code
- QmlTimeLine::pause(gfxValue, length_of(timeline) - length_of(gfxValue))
+ QmlTimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue))
\endcode
*/
-void QmlTimeLine::sync(GfxValue &gfxValue)
+void QmlTimeLine::sync(QmlTimeLineValue &timeLineValue)
{
- QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&gfxValue);
+ QmlTimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue);
if(iter == d->ops.end()) {
- pause(gfxValue, d->length);
+ pause(timeLineValue, d->length);
} else {
- pause(gfxValue, d->length - iter->length);
+ pause(timeLineValue, d->length - iter->length);
}
}
@@ -623,7 +620,7 @@ int QmlTimeLine::syncPoint() const
/*!
Returns true if the timeline is active. An active timeline is one where
- GfxValue actions are still pending.
+ QmlTimeLineValue actions are still pending.
*/
bool QmlTimeLine::isActive() const
{
@@ -633,7 +630,7 @@ bool QmlTimeLine::isActive() const
/*!
Completes the timeline. All queued actions are played to completion, and then discarded. For example,
\code
- GfxValue v(0.);
+ QmlTimeLineValue v(0.);
QmlTimeLine tl;
tl.move(v, 100., 1000.);
// 500 ms passes
@@ -648,9 +645,9 @@ void QmlTimeLine::complete()
}
/*!
- Resets the timeline. All queued actions are discarded and GfxValue's retain their current value. For example,
+ Resets the timeline. All queued actions are discarded and QmlTimeLineValue's retain their current value. For example,
\code
- GfxValue v(0.);
+ QmlTimeLineValue v(0.);
QmlTimeLine tl;
tl.move(v, 100., 1000.);
// 500 ms passes
@@ -677,8 +674,8 @@ int QmlTimeLine::time() const
/*!
\fn void QmlTimeLine::updated()
- Emitted each time the timeline modifies GfxValues. Even if multiple
- GfxValues are changed, this signal is only emitted once for each clock tick.
+ Emitted each time the timeline modifies QmlTimeLineValues. Even if multiple
+ QmlTimeLineValues are changed, this signal is only emitted once for each clock tick.
*/
void QmlTimeLine::updateCurrentTime(int v)
@@ -750,7 +747,7 @@ int QmlTimeLinePrivate::advance(int t)
QList<QPair<int, Update> > updates;
for(Ops::Iterator iter = ops.begin(); iter != ops.end(); ) {
- GfxValue *v = static_cast<GfxValue *>(iter.key());
+ QmlTimeLineValue *v = static_cast<QmlTimeLineValue *>(iter.key());
TimeLine &tl = *iter;
Q_ASSERT(!tl.ops.isEmpty());
@@ -871,31 +868,31 @@ void QmlTimeLine::remove(QmlTimeLineObject *v)
}
/*!
- \class GfxValue
+ \class QmlTimeLineValue
\ingroup group_animation
- \brief The GfxValue class is modified by QmlTimeLine.
+ \brief The QmlTimeLineValue class is modified by QmlTimeLine.
*/
/*!
- \fn GfxValue::GfxValue(qreal value = 0)
+ \fn QmlTimeLineValue::QmlTimeLineValue(qreal value = 0)
- Construct a new GfxValue with an initial \a value.
+ Construct a new QmlTimeLineValue with an initial \a value.
*/
/*!
- \fn qreal GfxValue::value() const
+ \fn qreal QmlTimeLineValue::value() const
Return the current value.
*/
/*!
- \fn void GfxValue::setValue(qreal value)
+ \fn void QmlTimeLineValue::setValue(qreal value)
Set the current \a value.
*/
/*!
- \fn QmlTimeLine *GfxValue::timeLine() const
+ \fn QmlTimeLine *QmlTimeLineValue::timeLine() const
If a QmlTimeLine is operating on this value, return a pointer to it,
otherwise return null.
@@ -915,17 +912,17 @@ QmlTimeLineObject::~QmlTimeLineObject()
}
}
-GfxEvent::GfxEvent()
+QmlTimeLineEvent::QmlTimeLineEvent()
: d0(0), d1(0), d2(0)
{
}
-GfxEvent::GfxEvent(const GfxEvent &o)
+QmlTimeLineEvent::QmlTimeLineEvent(const QmlTimeLineEvent &o)
: d0(o.d0), d1(o.d1), d2(o.d2)
{
}
-GfxEvent &GfxEvent::operator=(const GfxEvent &o)
+QmlTimeLineEvent &QmlTimeLineEvent::operator=(const QmlTimeLineEvent &o)
{
d0 = o.d0;
d1 = o.d1;
@@ -933,12 +930,12 @@ GfxEvent &GfxEvent::operator=(const GfxEvent &o)
return *this;
}
-void GfxEvent::execute() const
+void QmlTimeLineEvent::execute() const
{
d0(d1);
}
-QmlTimeLineObject *GfxEvent::eventObject() const
+QmlTimeLineObject *QmlTimeLineEvent::eventObject() const
{
return d2;
}
diff --git a/src/declarative/timeline/gfxtimeline.h b/src/declarative/timeline/qmltimeline.h
index 0bdddaf..ce9d1f2 100644
--- a/src/declarative/timeline/gfxtimeline.h
+++ b/src/declarative/timeline/qmltimeline.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef GFXTIMELINE_H
-#define GFXTIMELINE_H
+#ifndef QMLTIMELINE_H
+#define QMLTIMELINE_H
#include <QObject>
#include <qfxglobal.h>
@@ -52,9 +52,9 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class GfxEasing;
-class GfxValue;
-class GfxEvent;
+class QEasingCurve;
+class QmlTimeLineValue;
+class QmlTimeLineEvent;
struct QmlTimeLinePrivate;
class QmlTimeLineObject;
class Q_DECLARATIVE_EXPORT QmlTimeLine : public QAbstractAnimation
@@ -69,26 +69,26 @@ public:
void setSyncMode(SyncMode);
void pause(QmlTimeLineObject &, int);
- void execute(const GfxEvent &);
- void set(GfxValue &, qreal);
+ void execute(const QmlTimeLineEvent &);
+ void set(QmlTimeLineValue &, qreal);
- int accel(GfxValue &, qreal velocity, qreal accel);
- int accel(GfxValue &, qreal velocity, qreal accel, qreal maxDistance);
- int accelDistance(GfxValue &, qreal velocity, qreal distance);
+ int accel(QmlTimeLineValue &, qreal velocity, qreal accel);
+ int accel(QmlTimeLineValue &, qreal velocity, qreal accel, qreal maxDistance);
+ int accelDistance(QmlTimeLineValue &, qreal velocity, qreal distance);
- void move(GfxValue &, qreal destination, int time = 500);
- void move(GfxValue &, qreal destination, const GfxEasing &, int time = 500);
- void moveBy(GfxValue &, qreal change, int time = 500);
- void moveBy(GfxValue &, qreal change, const GfxEasing &, int time = 500);
+ void move(QmlTimeLineValue &, qreal destination, int time = 500);
+ void move(QmlTimeLineValue &, qreal destination, const QEasingCurve &, int time = 500);
+ void moveBy(QmlTimeLineValue &, qreal change, int time = 500);
+ void moveBy(QmlTimeLineValue &, qreal change, const QEasingCurve &, int time = 500);
void sync();
void setSyncPoint(int);
int syncPoint() const;
- void sync(GfxValue &);
- void sync(GfxValue &, GfxValue &);
+ void sync(QmlTimeLineValue &);
+ void sync(QmlTimeLineValue &, QmlTimeLineValue &);
- void reset(GfxValue &);
+ void reset(QmlTimeLineValue &);
void complete();
void clear();
@@ -123,10 +123,10 @@ protected:
QmlTimeLine *_t;
};
-class Q_DECLARATIVE_EXPORT GfxValue : public QmlTimeLineObject
+class Q_DECLARATIVE_EXPORT QmlTimeLineValue : public QmlTimeLineObject
{
public:
- GfxValue(qreal v = 0.) : _v(v) {}
+ QmlTimeLineValue(qreal v = 0.) : _v(v) {}
qreal value() const { return _v; }
virtual void setValue(qreal v) { _v = v; }
@@ -134,21 +134,21 @@ public:
QmlTimeLine *timeLine() const { return _t; }
operator qreal() const { return _v; }
- GfxValue &operator=(qreal v) { setValue(v); return *this; }
+ QmlTimeLineValue &operator=(qreal v) { setValue(v); return *this; }
private:
friend class QmlTimeLine;
friend struct QmlTimeLinePrivate;
qreal _v;
};
-class Q_DECLARATIVE_EXPORT GfxEvent
+class Q_DECLARATIVE_EXPORT QmlTimeLineEvent
{
public:
- GfxEvent();
- GfxEvent(const GfxEvent &o);
+ QmlTimeLineEvent();
+ QmlTimeLineEvent(const QmlTimeLineEvent &o);
template<class T, void (T::*method)()>
- GfxEvent(QmlTimeLineObject *b, T *c)
+ QmlTimeLineEvent(QmlTimeLineObject *b, T *c)
{
d0 = &callFunc<T, method>;
d1 = (void *)c;
@@ -156,16 +156,16 @@ public:
}
template<class T, void (T::*method)()>
- static GfxEvent gfxEvent(QmlTimeLineObject *b, T *c)
+ static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c)
{
- GfxEvent rv;
+ QmlTimeLineEvent rv;
rv.d0 = &callFunc<T, method>;
rv.d1 = (void *)c;
rv.d2 = b;
return rv;
}
- GfxEvent &operator=(const GfxEvent &o);
+ QmlTimeLineEvent &operator=(const QmlTimeLineEvent &o);
void execute() const;
QmlTimeLineObject *eventObject() const;
diff --git a/src/declarative/timeline/gfxvalueproxy.h b/src/declarative/timeline/qmltimelinevalueproxy.h
index 1eaf44e..add45dd 100644
--- a/src/declarative/timeline/gfxvalueproxy.h
+++ b/src/declarative/timeline/qmltimelinevalueproxy.h
@@ -39,8 +39,11 @@
**
****************************************************************************/
-#ifndef GFXVALUEPROXY_H
-#define GFXVALUEPROXY_H
+#ifndef QMLTIMELINEVALUEPROXY_H
+#define QMLTIMELINEVALUEPROXY_H
+
+#include "qmltimeline.h"
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -48,24 +51,24 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
template<class T>
-class GfxValueProxy : public GfxValue
+class QmlTimeLineValueProxy : public QmlTimeLineValue
{
public:
- GfxValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
- : GfxValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
+ QmlTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
+ : QmlTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
{
Q_ASSERT(_class);
}
- GfxValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
- : GfxValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
+ QmlTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.)
+ : QmlTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func)
{
Q_ASSERT(_class);
}
virtual void setValue(qreal v)
{
- GfxValue::setValue(v);
+ QmlTimeLineValue::setValue(v);
if(_setFunctionReal) (_class->*_setFunctionReal)(v);
else if(_setFunctionInt) (_class->*_setFunctionInt)((int)v);
}
@@ -80,4 +83,4 @@ QT_END_NAMESPACE
QT_END_HEADER
-#endif//GFXVALUEPROXY
+#endif//QMLTIMELINEVALUEPROXY_H
diff --git a/src/declarative/timeline/timeline.pri b/src/declarative/timeline/timeline.pri
index 8994c78..a7b3cb9 100644
--- a/src/declarative/timeline/timeline.pri
+++ b/src/declarative/timeline/timeline.pri
@@ -1,9 +1,7 @@
SOURCES += \
- timeline/gfxeasing.cpp \
- timeline/gfxtimeline.cpp \
+ timeline/qmltimeline.cpp \
HEADERS += \
- timeline/gfxeasing.h \
- timeline/gfxtimeline.h \
- timeline/gfxvalueproxy.h \
+ timeline/qmltimeline.h \
+ timeline/qmltimelinevalueproxy.h \