aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-06-11 07:38:46 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-07-19 10:56:06 +0000
commitca7cdd71ee33f0d77eb6bf1367d2532e26155cb2 (patch)
treeaf1b30bffea87bedb23e8cd795f23692f29b50a9 /tests
parentd310ca768bb5f45bae4fcec9a5d8151b6a366b8d (diff)
Make DragHandler a MultiPointHandler
That is, minimumPointCount can now be set to a value > 1 to require multiple fingers to do the dragging, or to track the displacement of multiple fingers to adjust some value (such as the tilt of a map). Task-number: QTBUG-68106 Change-Id: Ib35823e36deb81c8b277d3070fcc758c7c019564 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp2
-rw-r--r--tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp71
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml7
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp120
-rw-r--r--tests/manual/pointer/content/FakeFlickable.qml2
-rw-r--r--tests/manual/pointer/flingAnimation.qml6
-rw-r--r--tests/manual/pointer/map.qml14
-rw-r--r--tests/manual/pointer/singlePointHandlerProperties.qml43
8 files changed, 144 insertions, 121 deletions
diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp
index 6aa2eaa3cb..11a67cea82 100644
--- a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp
+++ b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp
@@ -93,7 +93,7 @@ void tst_FlickableInterop::createView(QScopedPointer<QQuickView> &window, const
window->show();
QVERIFY(QTest::qWaitForWindowActive(window.data()));
- QVERIFY(window->rootObject() != 0);
+ QVERIFY(window->rootObject() != nullptr);
}
void tst_FlickableInterop::initTestCase()
diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
index 0561a9e4f1..5ea5a42044 100644
--- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
+++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp
@@ -105,12 +105,12 @@ void tst_MptaInterop::touchDrag()
// Press one touchpoint:
// DragHandler gets a passive grab
// PinchHandler declines, because it wants 3 touchpoints
- // MPTA doesn't get a chance, because DragHandler accepted the single EventPoint
+ // MPTA grabs because DragHandler doesn't accept the single EventPoint
QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint();
touch.press(1, p1).commit();
QQuickTouchUtils::flush(window);
auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice);
- QCOMPARE(tp.at(0)->property("pressed").toBool(), false);
+ QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
QTRY_VERIFY(pointerEvent->point(0)->passiveGrabbers().contains(drag));
// Start moving
@@ -161,7 +161,7 @@ void tst_MptaInterop::touchesThenPinch()
QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint();
touch.press(1, p1).commit();
QQuickTouchUtils::flush(window);
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), nullptr);
+ QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
QTRY_COMPARE(pointerEvent->point(0)->passiveGrabbers().first(), drag);
// Press a second touchpoint: MPTA grabs it
@@ -170,31 +170,21 @@ void tst_MptaInterop::touchesThenPinch()
QQuickTouchUtils::flush(window);
QVERIFY(tp.at(0)->property("pressed").toBool());
QTRY_VERIFY(tp.at(1)->property("pressed").toBool());
- QCOMPARE(mptaPressedSpy.count(), 1);
+ QCOMPARE(mptaPressedSpy.count(), 2);
- // ATM it's required that when PinchHandler sees the third touchpoint,
- // the pre-existing points must have moved far enough to exceed the drag threshold.
- // If MPTA is allowed to grab that third point, then PinchHandler won't steal.
- // TODO should we change that? make sure that if PH has a passive grab, it always gets updated even though MPTA has the grab?
- for (int i = 0; i < 2; ++i) {
- p1 += QPoint(dragThreshold, dragThreshold);
- p2 += QPoint(dragThreshold, dragThreshold);
- touch.move(1, p1).move(2, p2).commit();
- }
-
- // Press a third touchpoint: PinchHandler grabs, MPTA loses its grabs
+ // Press a third touchpoint: MPTA grabs it too
QPoint p3 = mpta->mapToScene(QPointF(110, 200)).toPoint();
touch.stationary(1).stationary(2).press(3, p3).commit();
QQuickTouchUtils::flush(window);
- QCOMPARE(tp.at(0)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(1)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(2)->property("pressed").toBool(), false);
- QCOMPARE(mptaPressedSpy.count(), 1);
- QCOMPARE(mptaCanceledSpy.count(), 1);
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch);
- QTRY_COMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch);
- QTRY_COMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch);
- QVERIFY(pinch->active());
+ QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
+ QCOMPARE(tp.at(1)->property("pressed").toBool(), true);
+ QCOMPARE(tp.at(2)->property("pressed").toBool(), true);
+ QCOMPARE(mptaPressedSpy.count(), 3);
+ QCOMPARE(mptaCanceledSpy.count(), 0);
+ QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
+ QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
+ QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
+ QVERIFY(!pinch->active());
// Start moving: PinchHandler steals the exclusive grab from MPTA as soon as dragThreshold is exceeded
int pinchStoleGrab = 0;
@@ -204,11 +194,12 @@ void tst_MptaInterop::touchesThenPinch()
p3 += QPoint(-dragThreshold / 2, dragThreshold / 2);
touch.move(1, p1).move(2, p2).move(3, p3).commit();
QQuickTouchUtils::flush(window);
- QTRY_COMPARE(tp.at(0)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(1)->property("pressed").toBool(), false);
- QCOMPARE(tp.at(2)->property("pressed").toBool(), false);
- if (!pinchStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == pinch)
+ if (!pinchStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == pinch) {
pinchStoleGrab = i;
+ QCOMPARE(tp.at(0)->property("pressed").toBool(), false);
+ QCOMPARE(tp.at(1)->property("pressed").toBool(), false);
+ QCOMPARE(tp.at(2)->property("pressed").toBool(), false);
+ }
}
qCDebug(lcPointerTests) << "pinch started after" << pinchStoleGrab << "moves; ended with scale" << pinch->activeScale() << "rot" << pinch->rotation();
QTRY_VERIFY(pinch->rotation() > 4);
@@ -217,28 +208,26 @@ void tst_MptaInterop::touchesThenPinch()
// Press one more point (pinkie finger)
QPoint p4 = mpta->mapToScene(QPointF(300, 200)).toPoint();
touch.move(1, p1).move(2, p2).move(3, p3).press(4, p4).commit();
- // PinchHandler gives up its grabs (only on non-stationary points at this time: see QQuickPointerHandler::handlePointerEvent())
- // because it has minimum touch points 3, maximum touch points 3, and now there are 4 points.
- // MPTA grabs all points which are not already grabbed
- QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
+ // MPTA grabs the newly pressed point
+ QTRY_COMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch);
+ QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch);
+ QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch);
QCOMPARE(pointerEvent->point(3)->exclusiveGrabber(), mpta);
- // Move some more... MPTA keeps reacting
+ // Move some more... PinchHandler and MPTA both keep reacting
for (int i = 0; i < 8; ++i) {
p1 += QPoint(4, 4);
p2 += QPoint(4, 4);
p3 += QPoint(-4, 4);
p4 += QPoint(-4, -4);
touch.move(1, p1).move(2, p2).move(3, p3).move(4, p4).commit();
- QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), mpta);
- QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), mpta);
+ QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), pinch);
+ QCOMPARE(pointerEvent->point(1)->exclusiveGrabber(), pinch);
+ QCOMPARE(pointerEvent->point(2)->exclusiveGrabber(), pinch);
QCOMPARE(pointerEvent->point(3)->exclusiveGrabber(), mpta);
QCOMPARE(tp.at(0)->property("pressed").toBool(), true);
- QCOMPARE(tp.at(1)->property("pressed").toBool(), true);
- QCOMPARE(tp.at(2)->property("pressed").toBool(), true);
- QCOMPARE(tp.at(3)->property("pressed").toBool(), true);
+ QCOMPARE(tp.at(1)->property("pressed").toBool(), false);
+ QCOMPARE(tp.at(2)->property("pressed").toBool(), false);
+ QCOMPARE(tp.at(3)->property("pressed").toBool(), false);
}
// Release the pinkie: PinchHandler acquires passive grabs on the 3 remaining points
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml
index e468280ea6..7b3601bea0 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml
@@ -39,20 +39,21 @@ Item {
Rectangle {
id: ball
- objectName: "Ball " + index
+ objectName: "Ball " + (index + 1)
color: dragHandler.active ? "blue" : "lightsteelblue"
width: 80; height: 80; x: 200 + index * 200; y: 200; radius: width / 2
onParentChanged: console.log(this + " parent " + parent)
DragHandler {
id: dragHandler
- objectName: "DragHandler " + index
+ objectName: "DragHandler " + (index + 1)
}
Text {
color: "white"
anchors.centerIn: parent
- text: dragHandler.point.position.x.toFixed(1) + "," + dragHandler.point.position.y.toFixed(1)
+ horizontalAlignment: Text.AlignHCenter
+ text: ball.objectName + "\n" + dragHandler.centroid.position.x.toFixed(1) + "," + dragHandler.centroid.position.y.toFixed(1)
}
}
}
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
index 0271924c9b..f71145c2bc 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
@@ -119,11 +119,11 @@ void tst_DragHandler::defaultPropertyValues()
QCOMPARE(dragHandler->acceptedButtons(), Qt::LeftButton);
QCOMPARE(dragHandler->translation(), QVector2D());
- QCOMPARE(dragHandler->point().position(), QPointF());
- QCOMPARE(dragHandler->point().scenePosition(), QPointF());
- QCOMPARE(dragHandler->point().pressPosition(), QPointF());
- QCOMPARE(dragHandler->point().scenePressPosition(), QPointF());
- QCOMPARE(dragHandler->point().sceneGrabPosition(), QPointF());
+ QCOMPARE(dragHandler->centroid().position(), QPointF());
+ QCOMPARE(dragHandler->centroid().scenePosition(), QPointF());
+ QCOMPARE(dragHandler->centroid().pressPosition(), QPointF());
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), QPointF());
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), QPointF());
}
void tst_DragHandler::touchDrag()
@@ -146,10 +146,10 @@ void tst_DragHandler::touchDrag()
QTest::touchEvent(window, touchDevice).press(1, p1, window);
QQuickTouchUtils::flush(window);
QVERIFY(!dragHandler->active());
- QCOMPARE(dragHandler->point().position(), ballCenter);
- QCOMPARE(dragHandler->point().pressPosition(), ballCenter);
- QCOMPARE(dragHandler->point().scenePosition(), scenePressPos);
- QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().position(), ballCenter);
+ QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter);
+ QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
p1 += QPoint(dragThreshold, 0);
QTest::touchEvent(window, touchDevice).move(1, p1, window);
QQuickTouchUtils::flush(window);
@@ -161,22 +161,22 @@ void tst_DragHandler::touchDrag()
QCOMPARE(translationChangedSpy.count(), 0);
QCOMPARE(dragHandler->translation().x(), 0.0);
QPointF sceneGrabPos = p1;
- QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos);
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
p1 += QPoint(19, 0);
QTest::touchEvent(window, touchDevice).move(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(dragHandler->active());
- QCOMPARE(dragHandler->point().position(), ballCenter);
- QCOMPARE(dragHandler->point().pressPosition(), ballCenter);
- QCOMPARE(dragHandler->point().scenePosition(), ball->mapToScene(ballCenter));
- QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos);
- QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos);
+ QCOMPARE(dragHandler->centroid().position(), ballCenter);
+ QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter);
+ QCOMPARE(dragHandler->centroid().scenePosition(), ball->mapToScene(ballCenter));
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
QCOMPARE(dragHandler->translation().x(), dragThreshold + 20.0);
QCOMPARE(dragHandler->translation().y(), 0.0);
QTest::touchEvent(window, touchDevice).release(1, p1, window);
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!dragHandler->active());
- QCOMPARE(dragHandler->point().pressedButtons(), Qt::NoButton);
+ QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton);
QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1);
QCOMPARE(translationChangedSpy.count(), 1);
}
@@ -200,10 +200,10 @@ void tst_DragHandler::mouseDrag()
QPoint p1 = scenePressPos.toPoint();
QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
QVERIFY(!dragHandler->active());
- QCOMPARE(dragHandler->point().position(), ballCenter);
- QCOMPARE(dragHandler->point().pressPosition(), ballCenter);
- QCOMPARE(dragHandler->point().scenePosition(), scenePressPos);
- QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().position(), ballCenter);
+ QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter);
+ QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
p1 += QPoint(dragThreshold, 0);
QTest::mouseMove(window, p1);
QVERIFY(!dragHandler->active());
@@ -213,20 +213,20 @@ void tst_DragHandler::mouseDrag()
QCOMPARE(translationChangedSpy.count(), 0);
QCOMPARE(dragHandler->translation().x(), 0.0);
QPointF sceneGrabPos = p1;
- QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos);
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
p1 += QPoint(19, 0);
QTest::mouseMove(window, p1);
QTRY_VERIFY(dragHandler->active());
- QCOMPARE(dragHandler->point().position(), ballCenter);
- QCOMPARE(dragHandler->point().pressPosition(), ballCenter);
- QCOMPARE(dragHandler->point().scenePosition(), ball->mapToScene(ballCenter));
- QCOMPARE(dragHandler->point().scenePressPosition(), scenePressPos);
- QCOMPARE(dragHandler->point().sceneGrabPosition(), sceneGrabPos);
+ QCOMPARE(dragHandler->centroid().position(), ballCenter);
+ QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter);
+ QCOMPARE(dragHandler->centroid().scenePosition(), ball->mapToScene(ballCenter));
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), sceneGrabPos);
QCOMPARE(dragHandler->translation().x(), dragThreshold + 20.0);
QCOMPARE(dragHandler->translation().y(), 0.0);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
QTRY_VERIFY(!dragHandler->active());
- QCOMPARE(dragHandler->point().pressedButtons(), Qt::NoButton);
+ QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton);
QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1);
QCOMPARE(translationChangedSpy.count(), 1);
}
@@ -243,12 +243,14 @@ void tst_DragHandler::touchDragMulti()
QQuickDragHandler *dragHandler1 = ball1->findChild<QQuickDragHandler*>();
QVERIFY(dragHandler1);
QSignalSpy translationChangedSpy1(dragHandler1, SIGNAL(translationChanged()));
+ QSignalSpy centroidChangedSpy1(dragHandler1, SIGNAL(centroidChanged()));
QQuickItem *ball2 = window->rootObject()->childItems().at(1);
QVERIFY(ball2);
QQuickDragHandler *dragHandler2 = ball2->findChild<QQuickDragHandler*>();
QVERIFY(dragHandler2);
QSignalSpy translationChangedSpy2(dragHandler2, SIGNAL(translationChanged()));
+ QSignalSpy centroidChangedSpy2(dragHandler1, SIGNAL(centroidChanged()));
QPointF ball1Center = ball1->clipRect().center();
QPointF scenePressPos1 = ball1->mapToScene(ball1Center);
@@ -261,20 +263,33 @@ void tst_DragHandler::touchDragMulti()
touchSeq.press(1, p1, window).press(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(!dragHandler1->active());
- QCOMPARE(dragHandler1->point().position(), ball1Center);
- QCOMPARE(dragHandler1->point().pressPosition(), ball1Center);
- QCOMPARE(dragHandler1->point().scenePosition(), scenePressPos1);
- QCOMPARE(dragHandler1->point().scenePressPosition(), scenePressPos1);
+ QCOMPARE(centroidChangedSpy1.count(), 1);
+ QCOMPARE(dragHandler1->centroid().position(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().scenePosition(), scenePressPos1);
+ QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1);
QVERIFY(!dragHandler2->active());
- QCOMPARE(dragHandler2->point().position(), ball2Center);
- QCOMPARE(dragHandler2->point().pressPosition(), ball2Center);
- QCOMPARE(dragHandler2->point().scenePosition(), scenePressPos2);
- QCOMPARE(dragHandler2->point().scenePressPosition(), scenePressPos2);
+ QCOMPARE(centroidChangedSpy2.count(), 1);
+ QCOMPARE(dragHandler2->centroid().position(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().scenePosition(), scenePressPos2);
+ QCOMPARE(dragHandler2->centroid().scenePressPosition(), scenePressPos2);
p1 += QPoint(dragThreshold, 0);
p2 += QPoint(0, dragThreshold);
touchSeq.move(1, p1, window).move(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(!dragHandler1->active());
+ QCOMPARE(centroidChangedSpy1.count(), 2);
+ QCOMPARE(dragHandler1->centroid().position(), ball1Center + QPointF(dragThreshold, 0));
+ QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().scenePosition().toPoint(), p1);
+ QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1);
+ QVERIFY(!dragHandler2->active());
+ QCOMPARE(centroidChangedSpy2.count(), 2);
+ QCOMPARE(dragHandler2->centroid().position(), ball2Center + QPointF(0, dragThreshold));
+ QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().scenePosition().toPoint(), p2);
+ QCOMPARE(dragHandler2->centroid().scenePressPosition(), scenePressPos2);
p1 += QPoint(1, 0);
p2 += QPoint(0, 1);
touchSeq.move(1, p1, window).move(2, p2, window).commit();
@@ -285,37 +300,37 @@ void tst_DragHandler::touchDragMulti()
QCOMPARE(dragHandler1->translation().x(), 0.0);
QPointF sceneGrabPos1 = p1;
QPointF sceneGrabPos2 = p2;
- QCOMPARE(dragHandler1->point().sceneGrabPosition(), sceneGrabPos1);
- QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2);
+ QCOMPARE(dragHandler1->centroid().sceneGrabPosition(), sceneGrabPos1);
+ QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2);
p1 += QPoint(19, 0);
p2 += QPoint(0, 19);
QVERIFY(dragHandler2->active());
QCOMPARE(translationChangedSpy2.count(), 0);
QCOMPARE(dragHandler2->translation().x(), 0.0);
- QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2);
+ QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2);
touchSeq.move(1, p1, window).move(2, p2, window).commit();
QQuickTouchUtils::flush(window);
QVERIFY(dragHandler1->active());
QVERIFY(dragHandler2->active());
- QCOMPARE(dragHandler1->point().position(), ball1Center);
- QCOMPARE(dragHandler1->point().pressPosition(), ball1Center);
- QCOMPARE(dragHandler1->point().scenePosition(), ball1->mapToScene(ball1Center));
- QCOMPARE(dragHandler1->point().scenePressPosition(), scenePressPos1);
- QCOMPARE(dragHandler1->point().sceneGrabPosition(), sceneGrabPos1);
+ QCOMPARE(dragHandler1->centroid().position(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().pressPosition(), ball1Center);
+ QCOMPARE(dragHandler1->centroid().scenePosition(), ball1->mapToScene(ball1Center));
+ QCOMPARE(dragHandler1->centroid().scenePressPosition(), scenePressPos1);
+ QCOMPARE(dragHandler1->centroid().sceneGrabPosition(), sceneGrabPos1);
QCOMPARE(dragHandler1->translation().x(), dragThreshold + 20.0);
QCOMPARE(dragHandler1->translation().y(), 0.0);
- QCOMPARE(dragHandler2->point().position(), ball2Center);
- QCOMPARE(dragHandler2->point().pressPosition(), ball2Center);
- QCOMPARE(dragHandler2->point().scenePosition(), ball2->mapToScene(ball2Center));
- QCOMPARE(dragHandler2->point().scenePressPosition(), scenePressPos2);
- QCOMPARE(dragHandler2->point().sceneGrabPosition(), sceneGrabPos2);
+ QCOMPARE(dragHandler2->centroid().position(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().pressPosition(), ball2Center);
+ QCOMPARE(dragHandler2->centroid().scenePosition(), ball2->mapToScene(ball2Center));
+ QCOMPARE(dragHandler2->centroid().scenePressPosition(), scenePressPos2);
+ QCOMPARE(dragHandler2->centroid().sceneGrabPosition(), sceneGrabPos2);
QCOMPARE(dragHandler2->translation().x(), 0.0);
QCOMPARE(dragHandler2->translation().y(), dragThreshold + 20.0);
touchSeq.release(1, p1, window).stationary(2).commit();
QQuickTouchUtils::flush(window);
QTRY_VERIFY(!dragHandler1->active());
QVERIFY(dragHandler2->active());
- QCOMPARE(dragHandler1->point().pressedButtons(), Qt::NoButton);
+ QCOMPARE(dragHandler1->centroid().pressedButtons(), Qt::NoButton);
QCOMPARE(ball1->mapToScene(ball1Center).toPoint(), p1);
QCOMPARE(translationChangedSpy1.count(), 1);
touchSeq.release(2, p2, window).commit();
@@ -454,7 +469,12 @@ void tst_DragHandler::touchPassiveGrabbers()
QQuickDragHandler *dragHandler = nullptr;
for (QQuickPointerHandler *handler: expectedPassiveGrabbers) {
- QCOMPARE(static_cast<QQuickSinglePointHandler *>(handler)->point().scenePressPosition(), p1);
+ QPointF scenePressPos;
+ if (QQuickMultiPointHandler *mph = qmlobject_cast<QQuickMultiPointHandler *>(handler))
+ scenePressPos = mph->centroid().scenePressPosition();
+ else
+ scenePressPos = static_cast<QQuickSinglePointHandler *>(handler)->point().scenePressPosition();
+ QCOMPARE(scenePressPos, p1);
QQuickDragHandler *dh = qmlobject_cast<QQuickDragHandler *>(handler);
if (dh)
dragHandler = dh;
diff --git a/tests/manual/pointer/content/FakeFlickable.qml b/tests/manual/pointer/content/FakeFlickable.qml
index 5a20a6825a..ffb5c4e914 100644
--- a/tests/manual/pointer/content/FakeFlickable.qml
+++ b/tests/manual/pointer/content/FakeFlickable.qml
@@ -67,7 +67,7 @@ Item {
DragHandler {
id: dragHandler
- onActiveChanged: if (!active) anim.restart(point.velocity)
+ onActiveChanged: if (!active) anim.restart(centroid.velocity)
}
MomentumAnimation {
id: anim
diff --git a/tests/manual/pointer/flingAnimation.qml b/tests/manual/pointer/flingAnimation.qml
index b17429f4e4..2bc6de7065 100644
--- a/tests/manual/pointer/flingAnimation.qml
+++ b/tests/manual/pointer/flingAnimation.qml
@@ -90,7 +90,7 @@ Rectangle {
objectName: "dragHandler" + index
onActiveChanged: {
if (!active)
- anim.restart(point.velocity)
+ anim.restart(centroid.velocity)
}
}
Rectangle {
@@ -103,12 +103,12 @@ Rectangle {
Rectangle {
visible: width > 0
- width: dragHandler.point.velocity.length() * 100
+ width: dragHandler.centroid.velocity.length() * 100
height: 2
x: ball.width / 2
y: ball.height / 2
z: -1
- rotation: Math.atan2(dragHandler.point.velocity.y, dragHandler.point.velocity.x) * 180 / Math.PI
+ rotation: Math.atan2(dragHandler.centroid.velocity.y, dragHandler.centroid.velocity.x) * 180 / Math.PI
transformOrigin: Item.BottomLeft
antialiasing: true
diff --git a/tests/manual/pointer/map.qml b/tests/manual/pointer/map.qml
index ae7ec042d3..3ed732b523 100644
--- a/tests/manual/pointer/map.qml
+++ b/tests/manual/pointer/map.qml
@@ -39,6 +39,7 @@ Item {
y: (parent.height - height) / 2
width: image.width
height: image.height
+ transform: Rotation { id: tilt; origin.x: width / 2; origin.y: height / 2; axis { x: 1; y: 0; z: 0 } }
Image {
id: image
@@ -57,16 +58,29 @@ Item {
PinchHandler {
id: pinch
+ objectName: "two-point pinch"
target: map
minimumScale: 0.1
maximumScale: 10
onActiveChanged: if (!active) reRenderIfNecessary()
+ grabPermissions: PinchHandler.TakeOverForbidden // don't allow takeover if pinch has started
}
DragHandler {
+ objectName: "single-point drag"
target: map
}
+ DragHandler {
+ id: tiltHandler
+ objectName: "two-point tilt"
+ minimumPointCount: 2
+ maximumPointCount: 2
+ xAxis.enabled: false
+ target: null
+ onTranslationChanged: tilt.angle = translation.y / -2
+ }
+
function reRenderIfNecessary() {
var newSourceWidth = image.sourceSize.width * pinch.scale
var ratio = newSourceWidth / image.sourceSize.width
diff --git a/tests/manual/pointer/singlePointHandlerProperties.qml b/tests/manual/pointer/singlePointHandlerProperties.qml
index 40a4f49e5e..6ee88f9f9d 100644
--- a/tests/manual/pointer/singlePointHandlerProperties.qml
+++ b/tests/manual/pointer/singlePointHandlerProperties.qml
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the manual tests of the Qt Toolkit.
@@ -36,11 +36,11 @@ Rectangle {
Item {
id: crosshairs
- x: dragHandler.point.position.x - width / 2
- y: dragHandler.point.position.y - height / 2
+ x: dragHandler.centroid.position.x - width / 2
+ y: dragHandler.centroid.position.y - height / 2
width: parent.width / 2; height: parent.height / 2
visible: dragHandler.active
- rotation: dragHandler.point.rotation
+ rotation: dragHandler.centroid.rotation
Rectangle {
color: "goldenrod"
@@ -56,7 +56,7 @@ Rectangle {
}
Rectangle {
color: "goldenrod"
- width: Math.max(2, 50 * dragHandler.point.pressure)
+ width: Math.max(2, 50 * dragHandler.centroid.pressure)
height: width
radius: width / 2
anchors.centerIn: parent
@@ -69,9 +69,9 @@ Rectangle {
implicitHeight: label.implicitHeight
Text {
id: label
- text: 'id: ' + dragHandler.point.id.toString(16) + " uid: " + dragHandler.point.uniqueId.numericId +
- '\npos: (' + dragHandler.point.position.x.toFixed(2) + ', ' + dragHandler.point.position.y.toFixed(2) + ')' +
- '\nmodifiers: ' + dragHandler.point.modifiers.toString(16)
+ text: 'id: ' + dragHandler.centroid.id.toString(16) + " uid: " + dragHandler.centroid.uniqueId.numericId +
+ '\npos: (' + dragHandler.centroid.position.x.toFixed(2) + ', ' + dragHandler.centroid.position.y.toFixed(2) + ')' +
+ '\nmodifiers: ' + dragHandler.centroid.modifiers.toString(16)
}
}
}
@@ -79,8 +79,8 @@ Rectangle {
color: "transparent"
border.color: "white"
antialiasing: true
- width: dragHandler.point.ellipseDiameters.width
- height: dragHandler.point.ellipseDiameters.height
+ width: dragHandler.centroid.ellipseDiameters.width
+ height: dragHandler.centroid.ellipseDiameters.height
radius: Math.min(width / 2, height / 2)
anchors.centerIn: parent
}
@@ -88,11 +88,11 @@ Rectangle {
Rectangle {
id: velocityVector
visible: width > 0
- width: dragHandler.point.velocity.length() * 100
+ width: dragHandler.centroid.velocity.length() * 100
height: 2
- x: dragHandler.point.position.x
- y: dragHandler.point.position.y
- rotation: Math.atan2(dragHandler.point.velocity.y, dragHandler.point.velocity.x) * 180 / Math.PI
+ x: dragHandler.centroid.position.x
+ y: dragHandler.centroid.position.y
+ rotation: Math.atan2(dragHandler.centroid.velocity.y, dragHandler.centroid.velocity.x) * 180 / Math.PI
transformOrigin: Item.BottomLeft
antialiasing: true
@@ -138,15 +138,14 @@ Rectangle {
DragHandler {
id: dragHandler
target: null
- acceptedButtons: Qt.AllButtons
- onGrabChanged: if (active) { // 'point' is an implicit parameter referencing to a QQuickEventPoint instance
- console.log("grabbed " + point.pointId + " @ " + point.sceneGrabPos)
- grabbingLocationIndicator.createObject(root, {"x": point.sceneGrabPosition.x, "y": point.sceneGrabPosition.y - 16})
+// acceptedButtons: Qt.AllButtons // TODO: only SinglePointHandler has this so far
+ onGrabChanged: if (active) {
+ console.log("grabbed " + centroid.pointId + " @ " + centroid.sceneGrabPos)
+ grabbingLocationIndicator.createObject(root, {"x": centroid.sceneGrabPosition.x, "y": centroid.sceneGrabPosition.y - 16})
}
- onPointChanged: {
- // Here, 'point' is referring to the property of the DragHandler
- if (point.pressedButtons)
- mouseButtonIndicator.createObject(root, {"x": point.pressPosition.x - 44, "y": point.pressPosition.y - 64, "buttons": point.pressedButtons})
+ onCentroidChanged: {
+ if (centroid.pressedButtons)
+ mouseButtonIndicator.createObject(root, {"x": centroid.pressPosition.x - 44, "y": centroid.pressPosition.y - 64, "buttons": centroid.pressedButtons})
}
}
}