From 70c08e83cd47945a9cbaf6864d8da1b0de900e52 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 8 Feb 2012 13:17:56 +1000 Subject: Add velocity data to TouchPoint Change-Id: I0555b3ad41e8c08563188e1ba9190e54d4bb3784 Reviewed-by: Martin Jones --- src/quick/items/qquickmultipointtoucharea.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/quick/items/qquickmultipointtoucharea.cpp') diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp index 766ce67e43..c1c60c1756 100644 --- a/src/quick/items/qquickmultipointtoucharea.cpp +++ b/src/quick/items/qquickmultipointtoucharea.cpp @@ -102,14 +102,19 @@ void QQuickTouchPoint::setY(qreal y) /*! \qmlproperty real QtQuick2::TouchPoint::pressure + \qmlproperty vector2d QtQuick2::TouchPoint::velocity \qmlproperty rectangle QtQuick2::TouchPoint::area These properties hold additional information about the current state of the touch point. \list \i \c pressure is a value in the range of 0.0 to 1.0. + \i \c velocity is a vector with magnitude reported in pixels per second. \i \c area is a rectangle covering the area of the touch point, centered on the current position of the touch point. \endlist + + Not all touch devices support velocity. If velocity is not supported, it will be reported + as 0,0. */ void QQuickTouchPoint::setPressure(qreal pressure) { @@ -119,6 +124,14 @@ void QQuickTouchPoint::setPressure(qreal pressure) emit pressureChanged(); } +void QQuickTouchPoint::setVelocity(const QVector2D &velocity) +{ + if (_velocity == velocity) + return; + _velocity = velocity; + emit velocityChanged(); +} + void QQuickTouchPoint::setArea(const QRectF &area) { if (_area == area) @@ -548,6 +561,7 @@ void QQuickMultiPointTouchArea::updateTouchPoint(QQuickTouchPoint *dtp, const QT dtp->setX(p->pos().x()); dtp->setY(p->pos().y()); dtp->setPressure(p->pressure()); + dtp->setVelocity(p->velocity()); dtp->setArea(p->rect()); dtp->setStartX(p->startPos().x()); dtp->setStartY(p->startPos().y()); -- cgit v1.2.3