From 9487cbbeba7654200339c1850503b494b46158d1 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 22 Apr 2010 10:58:39 +1000 Subject: Add duration and easing properties to AnchorAnimation. --- src/declarative/util/qdeclarativeanimation.cpp | 63 +++++++++++++++++++++++++- src/declarative/util/qdeclarativeanimation_p.h | 12 +++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 27f37df..4f7719b 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -1674,7 +1674,7 @@ void QDeclarativePropertyAnimationPrivate::init() /*! \qmlproperty int PropertyAnimation::duration - This property holds the duration of the transition, in milliseconds. + This property holds the duration of the animation, in milliseconds. The default value is 250. */ @@ -2690,6 +2690,67 @@ QDeclarativeListProperty QDeclarativeAnchorAnimation::targets( return QDeclarativeListProperty(this, d->targets); } +/*! + \qmlproperty int AnchorAnimation::duration + This property holds the duration of the animation, in milliseconds. + + The default value is 250. +*/ +int QDeclarativeAnchorAnimation::duration() const +{ + Q_D(const QDeclarativeAnchorAnimation); + return d->va->duration(); +} + +void QDeclarativeAnchorAnimation::setDuration(int duration) +{ + if (duration < 0) { + qmlInfo(this) << tr("Cannot set a duration of < 0"); + return; + } + + Q_D(QDeclarativeAnchorAnimation); + if (d->va->duration() == duration) + return; + d->va->setDuration(duration); + emit durationChanged(duration); +} + +/*! + \qmlproperty enumeration AnchorAnimation::easing.type + \qmlproperty real AnchorAnimation::easing.amplitude + \qmlproperty real AnchorAnimation::easing.overshoot + \qmlproperty real AnchorAnimation::easing.period + \brief the easing curve used for the animation. + + To specify an easing curve you need to specify at least the type. For some curves you can also specify + amplitude, period and/or overshoot. The default easing curve is + Linear. + + \qml + AnchorAnimation { easing.type: "InOutQuad" } + \endqml + + See the \l{PropertyAnimation::easing.type} documentation for information + about the different types of easing curves. +*/ + +QEasingCurve QDeclarativeAnchorAnimation::easing() const +{ + Q_D(const QDeclarativeAnchorAnimation); + return d->va->easingCurve(); +} + +void QDeclarativeAnchorAnimation::setEasing(const QEasingCurve &e) +{ + Q_D(QDeclarativeAnchorAnimation); + if (d->va->easingCurve() == e) + return; + + d->va->setEasingCurve(e); + emit easingChanged(e); +} + void QDeclarativeAnchorAnimation::transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction) diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index c839c2c..40c893c 100644 --- a/src/declarative/util/qdeclarativeanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -475,6 +475,8 @@ class QDeclarativeAnchorAnimation : public QDeclarativeAbstractAnimation Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeAnchorAnimation) Q_PROPERTY(QDeclarativeListProperty targets READ targets) + Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) + Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) public: QDeclarativeAnchorAnimation(QObject *parent=0); @@ -482,6 +484,16 @@ public: QDeclarativeListProperty targets(); + int duration() const; + void setDuration(int); + + QEasingCurve easing() const; + void setEasing(const QEasingCurve &); + +Q_SIGNALS: + void durationChanged(int); + void easingChanged(const QEasingCurve&); + protected: virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, -- cgit v0.12