diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-06-11 09:24:12 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-07-14 10:25:47 +0200 |
commit | 37d5aaa4b42f9c837f0d27edb9da2185971d02be (patch) | |
tree | 867c23bfbff55f3d27dfee553ab20b015a938aa0 /tests/auto | |
parent | 80f7494e8a9f9a70e3b53833a098d74d8c2331d9 (diff) |
Change QWindow/QWidget::map(To/From)(Global/Parent) to operate in float
Change the functions to operate in float and add the
QPoint versions as overload calling them. This is
more in-line with the event accessors using float
and allows for removing some workarounds using a delta when
converting touch points.
Leave QPlatformWindow::map(To/From)Global() as is
for now and add helpers for float.
Change-Id: I2d46b8dbda8adff26539e358074b55073dc80b6f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 6 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 65ba1920ff..29e863776a 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -260,10 +260,16 @@ void tst_QWindow::mapGlobal() c.setGeometry(40, 40, 100, 100); QCOMPARE(a.mapToGlobal(QPoint(100, 100)), QPoint(110, 110)); + auto delta = a.mapToGlobal(QPointF(100.5, 100.5)) - QPointF(110.5, 110.5); + QVERIFY(qFuzzyIsNull(delta.manhattanLength())); + QCOMPARE(b.mapToGlobal(QPoint(100, 100)), QPoint(130, 130)); QCOMPARE(c.mapToGlobal(QPoint(100, 100)), QPoint(170, 170)); QCOMPARE(a.mapFromGlobal(QPoint(100, 100)), QPoint(90, 90)); + delta = a.mapFromGlobal(QPointF(100.5, 100.5)) - QPointF(90.5, 90.5); + QVERIFY(qFuzzyIsNull(delta.manhattanLength())); + QCOMPARE(b.mapFromGlobal(QPoint(100, 100)), QPoint(70, 70)); QCOMPARE(c.mapFromGlobal(QPoint(100, 100)), QPoint(30, 30)); } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 6e9224cb5f..1ec296211f 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -1608,6 +1608,8 @@ void tst_QWidget::mapFromAndTo() QCOMPARE(window.mapToGlobal(QPoint(-10, 0)), QPoint(90, 100)); QCOMPARE(window.mapToGlobal(QPoint(0, -10)), QPoint(100, 90)); QCOMPARE(window.mapToGlobal(QPoint(100, 100)), QPoint(200, 200)); + auto delta = window.mapToGlobal(QPointF(100.5, 100.5)) - QPointF(200.5, 200.5); + QVERIFY(qFuzzyIsNull(delta.manhattanLength())); QCOMPARE(window.mapToGlobal(QPoint(110, 100)), QPoint(210, 200)); QCOMPARE(window.mapToGlobal(QPoint(100, 110)), QPoint(200, 210)); QCOMPARE(window.mapFromGlobal(QPoint(100, 100)), QPoint(0, 0)); @@ -1616,6 +1618,8 @@ void tst_QWidget::mapFromAndTo() QCOMPARE(window.mapFromGlobal(QPoint(90, 100)), QPoint(-10, 0)); QCOMPARE(window.mapFromGlobal(QPoint(100, 90)), QPoint(0, -10)); QCOMPARE(window.mapFromGlobal(QPoint(200, 200)), QPoint(100, 100)); + delta = window.mapFromGlobal(QPointF(200.5, 200.5)) - QPointF(100.5, 100.5); + QVERIFY(qFuzzyIsNull(delta.manhattanLength())); QCOMPARE(window.mapFromGlobal(QPoint(210, 200)), QPoint(110, 100)); QCOMPARE(window.mapFromGlobal(QPoint(200, 210)), QPoint(100, 110)); QCOMPARE(window.mapToParent(QPoint(0, 0)), QPoint(100, 100)); |