From b35d793648a24b229aac75ea43d5a175967304ca Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 14 Mar 2013 13:27:35 +1000 Subject: Smooth dragging an item with MouseArea. Calculate drag distance relative to the mouse position when a drag is detected rather than the press position so there isn't a large change in position on the first move. Task-number: QTBUG-30188 Change-Id: I46918a7b3c62bdaef567b6a9fed651ce33434247 Reviewed-by: Martin Jones --- .../tst_qdeclarativemousearea.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/auto/declarative/qdeclarativemousearea') diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index 855ad602..0415c5c9 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -239,18 +239,18 @@ void tst_QDeclarativeMouseArea::dragging() QApplication::sendEvent(scene, &moveEvent); QVERIFY(drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); + QCOMPARE(blackRect->x(), 61.0); + QCOMPARE(blackRect->y(), 61.0); QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(110, 110)); + releaseEvent.setScenePos(QPointF(122, 122)); releaseEvent.setButton(Qt::LeftButton); releaseEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &releaseEvent); QVERIFY(!drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); + QCOMPARE(blackRect->x(), 61.0); + QCOMPARE(blackRect->y(), 61.0); delete canvas; } @@ -741,14 +741,14 @@ void tst_QDeclarativeMouseArea::changeAxis() QApplication::sendEvent(scene, &moveEvent); QVERIFY(drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); + QCOMPARE(blackRect->x(), 61.0); + QCOMPARE(blackRect->y(), 61.0); QCOMPARE(drag->axis(), QDeclarativeDrag::XandYAxis); /* When blackRect.x becomes bigger than 75, the drag axis is change to * Drag.YAxis by the QML code. Verify that this happens, and that the drag * movement is effectively constrained to the Y axis. */ - moveEvent.setScenePos(QPointF(133, 133)); + moveEvent.setScenePos(QPointF(144, 144)); moveEvent.setButton(Qt::LeftButton); moveEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &moveEvent); @@ -757,7 +757,7 @@ void tst_QDeclarativeMouseArea::changeAxis() QCOMPARE(blackRect->y(), 83.0); QCOMPARE(drag->axis(), QDeclarativeDrag::YAxis); - moveEvent.setScenePos(QPointF(144, 144)); + moveEvent.setScenePos(QPointF(155, 155)); moveEvent.setButton(Qt::LeftButton); moveEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &moveEvent); @@ -766,7 +766,7 @@ void tst_QDeclarativeMouseArea::changeAxis() QCOMPARE(blackRect->y(), 94.0); QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(144, 144)); + releaseEvent.setScenePos(QPointF(155, 155)); releaseEvent.setButton(Qt::LeftButton); releaseEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &releaseEvent); -- cgit v1.2.3