From ecf0a1937d81e047e25ac551703a77f75767d881 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 27 Apr 2009 12:49:18 +1000 Subject: Rename GfxValue to QmlTimeLineValue. --- src/declarative/fx/qfxflickable.cpp | 2 +- src/declarative/fx/qfxflickable_p.h | 14 +-- src/declarative/fx/qfxpathview.h | 1 - src/declarative/fx/qfxpathview_p.h | 3 +- src/declarative/timeline/gfxvalueproxy.h | 86 -------------- src/declarative/timeline/qmltimeline.cpp | 140 +++++++++++------------ src/declarative/timeline/qmltimeline.h | 30 ++--- src/declarative/timeline/qmltimelinevalueproxy.h | 86 ++++++++++++++ src/declarative/timeline/timeline.pri | 2 +- src/declarative/util/qmlanimation.cpp | 24 ++-- src/declarative/util/qmlanimation_p.h | 26 ++--- 11 files changed, 207 insertions(+), 207 deletions(-) delete mode 100644 src/declarative/timeline/gfxvalueproxy.h create mode 100644 src/declarative/timeline/qmltimelinevalueproxy.h diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index a04fe97..04b4a3d 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE -ElasticValue::ElasticValue(GfxValue &val) +ElasticValue::ElasticValue(QmlTimeLineValue &val) : _value(val) { _to = _value.value(); diff --git a/src/declarative/fx/qfxflickable_p.h b/src/declarative/fx/qfxflickable_p.h index ce880f9..ebd0327 100644 --- a/src/declarative/fx/qfxflickable_p.h +++ b/src/declarative/fx/qfxflickable_p.h @@ -57,7 +57,7 @@ #include "qfxflickable.h" #include "qfxitem_p.h" #include "qml.h" -#include "gfxvalueproxy.h" +#include "qmltimelinevalueproxy.h" #include "private/qmlanimation_p.h" QT_BEGIN_NAMESPACE @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE class ElasticValue : public QAbstractAnimation { Q_OBJECT public: - ElasticValue(GfxValue &); + ElasticValue(QmlTimeLineValue &); void setValue(qreal to); void clear(); @@ -81,7 +81,7 @@ private: qreal _to; qreal _myValue; qreal _velocity; - GfxValue &_value; + QmlTimeLineValue &_value; QTime _startTime; }; @@ -98,8 +98,8 @@ public: public: QFxItem *_flick; - GfxValueProxy _moveX; - GfxValueProxy _moveY; + QmlTimeLineValueProxy _moveX; + QmlTimeLineValueProxy _moveY; QmlTimeLine _tl; int vWidth; int vHeight; @@ -128,12 +128,12 @@ public: int velocityDecay; void updateVelocity(); - struct Velocity : public GfxValue + struct Velocity : public QmlTimeLineValue { Velocity(QFxFlickablePrivate *p) : parent(p) {} virtual void setValue(qreal v) { - GfxValue::setValue(v); + QmlTimeLineValue::setValue(v); parent->updateVelocity(); } QFxFlickablePrivate *parent; diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h index 6d4280d..2cc0769 100644 --- a/src/declarative/fx/qfxpathview.h +++ b/src/declarative/fx/qfxpathview.h @@ -44,7 +44,6 @@ #include #include -#include QT_BEGIN_HEADER diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h index 43f4ffa..a19d778 100644 --- a/src/declarative/fx/qfxpathview_p.h +++ b/src/declarative/fx/qfxpathview_p.h @@ -58,6 +58,7 @@ #include "qfxitem_p.h" #include "qfxvisualitemmodel.h" #include "qml.h" +#include "qmltimelinevalueproxy.h" #include "private/qmlanimation_p.h" QT_BEGIN_NAMESPACE @@ -115,7 +116,7 @@ public: qreal snapPos; qreal dragMargin; QmlTimeLine tl; - GfxValueProxy moveOffset; + QmlTimeLineValueProxy moveOffset; QmlTimeLineEvent fixupOffsetEvent; int firstIndex; int pathItems; diff --git a/src/declarative/timeline/gfxvalueproxy.h b/src/declarative/timeline/gfxvalueproxy.h deleted file mode 100644 index 1bb716c..0000000 --- a/src/declarative/timeline/gfxvalueproxy.h +++ /dev/null @@ -1,86 +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 GFXVALUEPROXY_H -#define GFXVALUEPROXY_H - -#include "qmltimeline.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -template -class GfxValueProxy : public GfxValue -{ -public: - GfxValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.) - : GfxValue(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) - { - Q_ASSERT(_class); - } - - virtual void setValue(qreal v) - { - GfxValue::setValue(v); - if(_setFunctionReal) (_class->*_setFunctionReal)(v); - else if(_setFunctionInt) (_class->*_setFunctionInt)((int)v); - } - -private: - T *_class; - void (T::*_setFunctionReal)(qreal); - void (T::*_setFunctionInt)(int); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif//GFXVALUEPROXY diff --git a/src/declarative/timeline/qmltimeline.cpp b/src/declarative/timeline/qmltimeline.cpp index 7cbb3ce..fc901eb 100644 --- a/src/declarative/timeline/qmltimeline.cpp +++ b/src/declarative/timeline/qmltimeline.cpp @@ -56,12 +56,12 @@ QT_BEGIN_NAMESPACE // struct Update { - Update(GfxValue *_g, qreal _v) + Update(QmlTimeLineValue *_g, qreal _v) : g(_g), v(_v) {} Update(const QmlTimeLineEvent &_e) : g(0), v(0), e(_e) {} - GfxValue *g; + QmlTimeLineValue *g; qreal v; QmlTimeLineEvent e; }; @@ -142,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; } @@ -263,22 +263,22 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change 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(); + QmlTimeLineValue v(); 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 @@ -287,8 +287,8 @@ qreal QmlTimeLinePrivate::value(const Op &op, int time, qreal base, bool *change milliseconds: \code - GfxValue x(); - GfxValue y(); + QmlTimeLineValue x(); + QmlTimeLineValue y(); QmlTimeLine tl; tl.start(); @@ -355,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) { @@ -374,21 +374,21 @@ void QmlTimeLine::execute(const QmlTimeLineEvent &event) } /*! - 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; @@ -396,7 +396,7 @@ int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration) int time = static_cast(-1000 * velocity / acceleration); QmlTimeLinePrivate::Op op(QmlTimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++); - d->add(gfxValue, op); + d->add(timeLineValue, op); return time; } @@ -404,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); @@ -425,19 +425,19 @@ int QmlTimeLine::accel(GfxValue &gfxValue, qreal velocity, qreal acceleration, q int time = static_cast(-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; @@ -446,68 +446,68 @@ int QmlTimeLine::accelDistance(GfxValue &gfxValue, qreal velocity, qreal distanc int time = static_cast(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 QEasingCurve &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++, QmlTimeLineEvent(), easing); - d->add(gfxValue, op); + 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 QEasingCurve &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++, QmlTimeLineEvent(), easing); - d->add(gfxValue, op); + 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 @@ -516,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); } } @@ -620,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 { @@ -630,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 @@ -645,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 @@ -674,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) @@ -747,7 +747,7 @@ int QmlTimeLinePrivate::advance(int t) QList > updates; for(Ops::Iterator iter = ops.begin(); iter != ops.end(); ) { - GfxValue *v = static_cast(iter.key()); + QmlTimeLineValue *v = static_cast(iter.key()); TimeLine &tl = *iter; Q_ASSERT(!tl.ops.isEmpty()); @@ -868,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. diff --git a/src/declarative/timeline/qmltimeline.h b/src/declarative/timeline/qmltimeline.h index 603669c..ce9d1f2 100644 --- a/src/declarative/timeline/qmltimeline.h +++ b/src/declarative/timeline/qmltimeline.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QEasingCurve; -class GfxValue; +class QmlTimeLineValue; class QmlTimeLineEvent; struct QmlTimeLinePrivate; class QmlTimeLineObject; @@ -70,25 +70,25 @@ public: void pause(QmlTimeLineObject &, int); void execute(const QmlTimeLineEvent &); - void set(GfxValue &, qreal); + 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 QEasingCurve &, int time = 500); - void moveBy(GfxValue &, qreal change, int time = 500); - void moveBy(GfxValue &, qreal change, const QEasingCurve &, 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,7 +134,7 @@ 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; diff --git a/src/declarative/timeline/qmltimelinevalueproxy.h b/src/declarative/timeline/qmltimelinevalueproxy.h new file mode 100644 index 0000000..add45dd --- /dev/null +++ b/src/declarative/timeline/qmltimelinevalueproxy.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 QMLTIMELINEVALUEPROXY_H +#define QMLTIMELINEVALUEPROXY_H + +#include "qmltimeline.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +template +class QmlTimeLineValueProxy : public QmlTimeLineValue +{ +public: + QmlTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.) + : QmlTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0) + { + Q_ASSERT(_class); + } + + 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) + { + QmlTimeLineValue::setValue(v); + if(_setFunctionReal) (_class->*_setFunctionReal)(v); + else if(_setFunctionInt) (_class->*_setFunctionInt)((int)v); + } + +private: + T *_class; + void (T::*_setFunctionReal)(qreal); + void (T::*_setFunctionInt)(int); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif//QMLTIMELINEVALUEPROXY_H diff --git a/src/declarative/timeline/timeline.pri b/src/declarative/timeline/timeline.pri index 0a0875c..a7b3cb9 100644 --- a/src/declarative/timeline/timeline.pri +++ b/src/declarative/timeline/timeline.pri @@ -3,5 +3,5 @@ SOURCES += \ HEADERS += \ timeline/qmltimeline.h \ - timeline/gfxvalueproxy.h \ + timeline/qmltimelinevalueproxy.h \ diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index c0b89be..f71d203 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -653,7 +653,7 @@ QmlColorAnimation::~QmlColorAnimation() void QmlColorAnimationPrivate::init() { Q_Q(QmlColorAnimation); - ca = new GfxValueAnimator(q); + ca = new QmlTimeLineValueAnimator(q); ca->setStartValue(QVariant(0.0f)); ca->setEndValue(QVariant(1.0f)); } @@ -791,7 +791,7 @@ void QmlColorAnimation::prepare(QmlMetaProperty &p) else d->property = d->userProperty; d->fromSourced = false; - d->value.GfxValue::setValue(0.); + d->value.QmlTimeLineValue::setValue(0.); d->ca->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); } @@ -808,7 +808,7 @@ void QmlColorAnimation::transition(QmlStateActions &actions, Q_D(QmlColorAnimation); Q_UNUSED(direction); - struct NTransitionData : public GfxValue + struct NTransitionData : public QmlTimeLineValue { QmlStateActions actions; void write(QmlMetaProperty &property, const QColor &color) @@ -820,7 +820,7 @@ void QmlColorAnimation::transition(QmlStateActions &actions, void setValue(qreal v) { - GfxValue::setValue(v); + QmlTimeLineValue::setValue(v); for(int ii = 0; ii < actions.count(); ++ii) { Action &action = actions[ii]; @@ -1362,7 +1362,7 @@ QmlNumericAnimation::~QmlNumericAnimation() void QmlNumericAnimationPrivate::init() { Q_Q(QmlNumericAnimation); - na = new GfxValueAnimator(q); + na = new QmlTimeLineValueAnimator(q); na->setStartValue(QVariant(0.0f)); na->setEndValue(QVariant(1.0f)); } @@ -1600,7 +1600,7 @@ void QmlNumericAnimation::prepare(QmlMetaProperty &p) else d->property = d->userProperty; d->fromSourced = false; - d->value.GfxValue::setValue(0.); + d->value.QmlTimeLineValue::setValue(0.); d->na->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); } @@ -1617,12 +1617,12 @@ void QmlNumericAnimation::transition(QmlStateActions &actions, Q_D(QmlNumericAnimation); Q_UNUSED(direction); - struct NTransitionData : public GfxValue + struct NTransitionData : public QmlTimeLineValue { QmlStateActions actions; void setValue(qreal v) { - GfxValue::setValue(v); + QmlTimeLineValue::setValue(v); for(int ii = 0; ii < actions.count(); ++ii) { Action &action = actions[ii]; @@ -1951,7 +1951,7 @@ QmlVariantAnimation::~QmlVariantAnimation() void QmlVariantAnimationPrivate::init() { Q_Q(QmlVariantAnimation); - va = new GfxValueAnimator(q); + va = new QmlTimeLineValueAnimator(q); va->setStartValue(QVariant(0.0f)); va->setEndValue(QVariant(1.0f)); } @@ -2157,7 +2157,7 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p) d->convertVariant(d->from.value, (QVariant::Type)d->property.propertyType()); d->fromSourced = false; - d->value.GfxValue::setValue(0.); + d->value.QmlTimeLineValue::setValue(0.); d->va->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); } @@ -2168,12 +2168,12 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, Q_D(QmlVariantAnimation); Q_UNUSED(direction); - struct NTransitionData : public GfxValue + struct NTransitionData : public QmlTimeLineValue { QmlStateActions actions; void setValue(qreal v) { - GfxValue::setValue(v); + QmlTimeLineValue::setValue(v); for(int ii = 0; ii < actions.count(); ++ii) { Action &action = actions[ii]; diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index db7cb18..f14df82 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -52,7 +52,7 @@ #include #include #include -#include +#include QT_BEGIN_NAMESPACE @@ -112,13 +112,13 @@ private: DeletionPolicy policy; }; -//animates GfxValue (assumes start and end values will be reals or compatible) -class GfxValueAnimator : public QVariantAnimation +//animates QmlTimeLineValue (assumes start and end values will be reals or compatible) +class QmlTimeLineValueAnimator : public QVariantAnimation { public: - GfxValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), policy(KeepWhenStopped) {} - GfxValueAnimator(GfxValue *value, QObject *parent = 0) : QVariantAnimation(parent), animValue(value), policy(KeepWhenStopped) {} - void setAnimValue(GfxValue *value, DeletionPolicy p) + QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), policy(KeepWhenStopped) {} + QmlTimeLineValueAnimator(QmlTimeLineValue *value, QObject *parent = 0) : QVariantAnimation(parent), animValue(value), policy(KeepWhenStopped) {} + void setAnimValue(QmlTimeLineValue *value, DeletionPolicy p) { if (state() == Running) stop(); @@ -141,7 +141,7 @@ protected: } private: - GfxValue *animValue; + QmlTimeLineValue *animValue; DeletionPolicy policy; }; @@ -214,10 +214,10 @@ public: bool fromSourced; QColor fromValue; QColor toValue; - GfxValueAnimator *ca; + QmlTimeLineValueAnimator *ca; virtual void valueChanged(qreal); - GfxValueProxy value; + QmlTimeLineValueProxy value; }; class QmlRunScriptActionPrivate : public QmlAbstractAnimationPrivate @@ -295,10 +295,10 @@ public: bool fromSourced; qreal fromValue; - GfxValueAnimator *na; + QmlTimeLineValueAnimator *na; virtual void valueChanged(qreal); - GfxValueProxy value; + QmlTimeLineValueProxy value; }; class QmlAnimationGroupPrivate : public QmlAbstractAnimationPrivate @@ -360,10 +360,10 @@ public: bool fromSourced; QVariant fromValue; - GfxValueAnimator *va; + QmlTimeLineValueAnimator *va; virtual void valueChanged(qreal); - GfxValueProxy value; + QmlTimeLineValueProxy value; static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress); static void convertVariant(QVariant &variant, QVariant::Type type); -- cgit v0.12