PathInterpolator should report angle in clockwise direction.
authorMichael Brasser <michael.brasser@nokia.com>
Thu, 19 Jan 2012 00:09:40 +0000 (10:09 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 27 Jan 2012 05:23:15 +0000 (06:23 +0100)
This makes it much more intuitive when binding item rotation to angle.

Change-Id: I5654866d9cd1c0ff5899c5571532fc7fedddd440
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
src/quick/util/qdeclarativepathinterpolator.cpp
tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp

index 52b57e6..46038f9 100644 (file)
@@ -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();
index bc4e132..d06085d 100644 (file)
@@ -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));
     }
 
     {