From: Michael Brasser Date: Thu, 19 Jan 2012 00:09:40 +0000 (+1000) Subject: PathInterpolator should report angle in clockwise direction. X-Git-Tag: qt-v5.0.0-alpha1~575 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3bbe8fdbab9a1f2f3f8ca40d5e25e2d5c5fb1a75;p=profile%2Fivi%2Fqtdeclarative.git PathInterpolator should report angle in clockwise direction. This makes it much more intuitive when binding item rotation to angle. Change-Id: I5654866d9cd1c0ff5899c5571532fc7fedddd440 Reviewed-by: Yunqiao Yin Reviewed-by: Michael Brasser --- diff --git a/src/quick/util/qdeclarativepathinterpolator.cpp b/src/quick/util/qdeclarativepathinterpolator.cpp index 52b57e6..46038f9 100644 --- a/src/quick/util/qdeclarativepathinterpolator.cpp +++ b/src/quick/util/qdeclarativepathinterpolator.cpp @@ -113,6 +113,11 @@ void QDeclarativePathInterpolator::_q_pathUpdated() emit yChanged(); } + //convert to clockwise + angle = qreal(360) - angle; + if (qFuzzyCompare(angle, qreal(360))) + angle = qreal(0); + if (angle != _angle) { _angle = angle; emit angleChanged(); diff --git a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index bc4e132..d06085d 100644 --- a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -311,7 +311,7 @@ void tst_qdeclarativeanimations::pathInterpolator() QCOMPARE(interpolator->progress(), qreal(.5)); QCOMPARE(interpolator->x(), qreal(175)); QCOMPARE(interpolator->y(), qreal(175)); - QCOMPARE(interpolator->angle(), qreal(270)); + QCOMPARE(interpolator->angle(), qreal(90)); interpolator->setProgress(1); QCOMPARE(interpolator->progress(), qreal(1)); @@ -331,13 +331,13 @@ void tst_qdeclarativeanimations::pathInterpolatorBackwardJump() QCOMPARE(interpolator->progress(), qreal(0)); QCOMPARE(interpolator->x(), qreal(50)); QCOMPARE(interpolator->y(), qreal(50)); - QCOMPARE(interpolator->angle(), qreal(270)); + QCOMPARE(interpolator->angle(), qreal(90)); interpolator->setProgress(.5); QCOMPARE(interpolator->progress(), qreal(.5)); QCOMPARE(interpolator->x(), qreal(100)); QCOMPARE(interpolator->y(), qreal(75)); - QCOMPARE(interpolator->angle(), qreal(90)); + QCOMPARE(interpolator->angle(), qreal(270)); interpolator->setProgress(1); QCOMPARE(interpolator->progress(), qreal(1)); @@ -350,7 +350,7 @@ void tst_qdeclarativeanimations::pathInterpolatorBackwardJump() QCOMPARE(interpolator->progress(), qreal(0)); QCOMPARE(interpolator->x(), qreal(50)); QCOMPARE(interpolator->y(), qreal(50)); - QCOMPARE(interpolator->angle(), qreal(270)); + QCOMPARE(interpolator->angle(), qreal(90)); } {