From: Martin Jones Date: Thu, 8 Dec 2011 00:36:44 +0000 (+1000) Subject: Add basic custom easing curve docs and test X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=2a3990fc4125eeb0c73eaae05450789717dfd045;p=konrad%2Fqtdeclarative.git Add basic custom easing curve docs and test Change-Id: Id38434cb71417276635b501d13d0145759de9864 Reviewed-by: Michael Brasser --- diff --git a/src/quick/util/qdeclarativeanimation.cpp b/src/quick/util/qdeclarativeanimation.cpp index 8c21d11..0c31806 100644 --- a/src/quick/util/qdeclarativeanimation.cpp +++ b/src/quick/util/qdeclarativeanimation.cpp @@ -1916,6 +1916,7 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) \qmlproperty real QtQuick2::PropertyAnimation::easing.amplitude \qmlproperty real QtQuick2::PropertyAnimation::easing.overshoot \qmlproperty real QtQuick2::PropertyAnimation::easing.period + \qmlproperty list QtQuick2::PropertyAnimation::easing.bezierCurve \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 @@ -2095,6 +2096,10 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) \o \c Easing.OutInBounce \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration. \o \inlineimage qeasingcurve-outinbounce.png + \row + \o \c Easing.Bezier + \o Custom easing curve defined by the easing.bezierCurve property. + \o \endtable \c easing.amplitude is only applicable for bounce and elastic curves (curves of type @@ -2107,6 +2112,10 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) \c easing.period is only applicable if easing.type is: \c Easing.InElastic, \c Easing.OutElastic, \c Easing.InOutElastic or \c Easing.OutInElastic. + \c easing.bezierCurve is only applicable if easing.type is: \c Easing.Bezier. This property is a list containing + groups of three points defining a curve from 0,0 to 1,1 - control1, control2, + end point: [cx1, cy1, cx2, cy2, endx, endy, ...]. The last point must be 1,1. + See the \l {declarative/animation/easing}{easing} example for a demonstration of the different easing settings. */ diff --git a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index ca32926..2a2055e 100644 --- a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -938,6 +938,22 @@ void tst_qdeclarativeanimations::easingProperties() QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack); QCOMPARE(animObject->easing().overshoot(), 2.0); } + + { + QDeclarativeEngine engine; + QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"Bezier\"; easing.bezierCurve: [0.5, 0.2, 0.13, 0.65, 1.0, 1.0] }"; + QDeclarativeComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline); + QList points = animObject->easing().cubicBezierSpline(); + QCOMPARE(points.count(), 3); + QCOMPARE(points.at(0), QPointF(0.5, 0.2)); + QCOMPARE(points.at(1), QPointF(0.13, 0.65)); + QCOMPARE(points.at(2), QPointF(1.0, 1.0)); + } } void tst_qdeclarativeanimations::rotation()