aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-08-15 16:11:59 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2016-08-23 14:47:16 +0000
commitad96378ba27d5a89cf447d912cdb8ae6cd6c34ec (patch)
tree3163c22c4553f48aed918757f944db8b3422d8c7
parent4e2392cf14d8c33bd8478f3a0e584946f6c5b151 (diff)
add QQuickEventPoint::velocity property
Change-Id: Ifc3fc767546fc8d18ebaba0a07a1143239c2e194 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
-rw-r--r--src/quick/items/qquickevents.cpp7
-rw-r--r--src/quick/items/qquickevents_p_p.h5
2 files changed, 8 insertions, 4 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 51a7e8aec7..7e84d27836 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -511,7 +511,7 @@ QQuickPointerDevice *QQuickPointerDevice::tabletDevice(qint64 id)
return nullptr;
}
-void QQuickEventPoint::reset(Qt::TouchPointState state, QPointF scenePos, quint64 pointId, ulong timestamp)
+void QQuickEventPoint::reset(Qt::TouchPointState state, QPointF scenePos, quint64 pointId, ulong timestamp, QVector2D velocity)
{
m_scenePos = scenePos;
m_pointId = pointId;
@@ -521,7 +521,8 @@ void QQuickEventPoint::reset(Qt::TouchPointState state, QPointF scenePos, quint6
m_timestamp = timestamp;
if (state == Qt::TouchPointPressed)
m_pressTimestamp = timestamp;
- // TODO calculate velocity
+ // TODO if Q_LIKELY(velocity.isNull) calculate velocity
+ m_velocity = velocity;
}
QQuickItem *QQuickEventPoint::grabber() const
@@ -548,7 +549,7 @@ QQuickEventTouchPoint::QQuickEventTouchPoint(QQuickPointerTouchEvent *parent)
void QQuickEventTouchPoint::reset(const QTouchEvent::TouchPoint &tp, ulong timestamp)
{
- QQuickEventPoint::reset(tp.state(), tp.scenePos(), tp.id(), timestamp);
+ QQuickEventPoint::reset(tp.state(), tp.scenePos(), tp.id(), timestamp, tp.velocity());
m_rotation = tp.rotation();
m_pressure = tp.pressure();
m_uniqueId = tp.uniqueId();
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index bb3ab52d1a..c64478e856 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -250,6 +250,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickEventPoint : public QObject
{
Q_OBJECT
Q_PROPERTY(QPointF scenePos READ scenePos)
+ Q_PROPERTY(QVector2D velocity READ velocity)
Q_PROPERTY(State state READ state)
Q_PROPERTY(quint64 pointId READ pointId)
Q_PROPERTY(qreal timeHeld READ timeHeld)
@@ -268,12 +269,13 @@ public:
QQuickEventPoint(QQuickPointerEvent *parent);
- void reset(Qt::TouchPointState state, QPointF scenePos, quint64 pointId, ulong timestamp);
+ void reset(Qt::TouchPointState state, QPointF scenePos, quint64 pointId, ulong timestamp, QVector2D velocity = QVector2D());
void invalidate() { m_valid = false; }
QQuickPointerEvent *pointerEvent() const;
QPointF scenePos() const { return m_scenePos; }
+ QVector2D velocity() const { return m_velocity; }
State state() const { return m_state; }
quint64 pointId() const { return m_pointId; }
bool isValid() const { return m_valid; }
@@ -285,6 +287,7 @@ public:
private:
QPointF m_scenePos;
+ QVector2D m_velocity;
quint64 m_pointId;
QPointer<QQuickItem> m_grabber;
ulong m_timestamp;