aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2012-02-08 13:17:56 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-17 04:29:47 +0100
commit70c08e83cd47945a9cbaf6864d8da1b0de900e52 (patch)
tree43877f6bc692f663ec0b5e60d03d14d23e9facc4 /src
parentceb09a144afae488057c1841ec68a2fa0117a3f3 (diff)
Add velocity data to TouchPoint
Change-Id: I0555b3ad41e8c08563188e1ba9190e54d4bb3784 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp14
-rw-r--r--src/quick/items/qquickmultipointtoucharea_p.h6
2 files changed, 20 insertions, 0 deletions
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());
diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h
index e611ce3ace..ccb086fd7e 100644
--- a/src/quick/items/qquickmultipointtoucharea_p.h
+++ b/src/quick/items/qquickmultipointtoucharea_p.h
@@ -63,6 +63,7 @@ class Q_AUTOTEST_EXPORT QQuickTouchPoint : public QObject
Q_PROPERTY(qreal x READ x NOTIFY xChanged)
Q_PROPERTY(qreal y READ y NOTIFY yChanged)
Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged)
+ Q_PROPERTY(QVector2D velocity READ velocity NOTIFY velocityChanged)
Q_PROPERTY(QRectF area READ area NOTIFY areaChanged)
Q_PROPERTY(qreal startX READ startX NOTIFY startXChanged)
@@ -96,6 +97,9 @@ public:
qreal pressure() const { return _pressure; }
void setPressure(qreal pressure);
+ QVector2D velocity() const { return _velocity; }
+ void setVelocity(const QVector2D &velocity);
+
QRectF area() const { return _area; }
void setArea(const QRectF &area);
@@ -131,6 +135,7 @@ Q_SIGNALS:
void xChanged();
void yChanged();
void pressureChanged();
+ void velocityChanged();
void areaChanged();
void startXChanged();
void startYChanged();
@@ -145,6 +150,7 @@ private:
qreal _x;
qreal _y;
qreal _pressure;
+ QVector2D _velocity;
QRectF _area;
bool _qmlDefined;
bool _inUse; //whether the point is currently in use (only valid when _qmlDefined == true)