diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-02-12 17:36:14 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-02-15 10:12:50 +0100 |
commit | ee95f0e6830a504574ef5fa54b44a11b13d5a8ae (patch) | |
tree | b063956ad24c56480425fa427c2af62a88d1324e | |
parent | 751e92d50a23d1273af42a7a7836bb2eb336eced (diff) |
MultiPointTouchArea: update the TouchPoint.x and y properties together
Letting them change sequentially is inconvenient when they are used
to drive some sort of smooth stroke (drawing or motion).
Fixes: QTBUG-81944
Change-Id: I46c5948dbec927682244daf00a0df3453a0d92a6
Reviewed-by: Michael Brasser <michael.brasser@live.com>
-rw-r--r-- | src/quick/items/qquickmultipointtoucharea.cpp | 28 | ||||
-rw-r--r-- | src/quick/items/qquickmultipointtoucharea_p.h | 4 |
2 files changed, 13 insertions, 19 deletions
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp index 9a371207ce..3a807d3c66 100644 --- a/src/quick/items/qquickmultipointtoucharea.cpp +++ b/src/quick/items/qquickmultipointtoucharea.cpp @@ -88,20 +88,18 @@ void QQuickTouchPoint::setPointId(int id) These properties hold the current position of the touch point. */ -void QQuickTouchPoint::setX(qreal x) +void QQuickTouchPoint::setPosition(QPointF p) { - if (_x == x) + bool xch = (_x != p.x()); + bool ych = (_y != p.y()); + if (!xch && !ych) return; - _x = x; - emit xChanged(); -} - -void QQuickTouchPoint::setY(qreal y) -{ - if (_y == y) - return; - _y = y; - emit yChanged(); + _x = p.x(); + _y = p.y(); + if (xch) + emit xChanged(); + if (ych) + emit yChanged(); } /*! @@ -798,8 +796,7 @@ void QQuickMultiPointTouchArea::updateTouchPoint(QQuickTouchPoint *dtp, const QT //TODO: if !qmlDefined, could bypass setters. // also, should only emit signals after all values have been set dtp->setUniqueId(p->uniqueId()); - dtp->setX(p->pos().x()); - dtp->setY(p->pos().y()); + dtp->setPosition(p->pos()); dtp->setEllipseDiameters(p->ellipseDiameters()); dtp->setPressure(p->pressure()); dtp->setRotation(p->rotation()); @@ -817,8 +814,7 @@ void QQuickMultiPointTouchArea::updateTouchPoint(QQuickTouchPoint *dtp, const QM { dtp->setPreviousX(dtp->x()); dtp->setPreviousY(dtp->y()); - dtp->setX(e->localPos().x()); - dtp->setY(e->localPos().y()); + dtp->setPosition(e->localPos()); if (e->type() == QEvent::MouseButtonPress) { dtp->setStartX(e->localPos().x()); dtp->setStartY(e->localPos().y()); diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h index 363e62593b..e34a3faad6 100644 --- a/src/quick/items/qquickmultipointtoucharea_p.h +++ b/src/quick/items/qquickmultipointtoucharea_p.h @@ -97,10 +97,8 @@ public: void setUniqueId(const QPointingDeviceUniqueId &id); qreal x() const { return _x; } - void setX(qreal x); - qreal y() const { return _y; } - void setY(qreal y); + void setPosition(QPointF pos); QSizeF ellipseDiameters() const { return _ellipseDiameters; } void setEllipseDiameters(const QSizeF &d); |