diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-03-26 14:10:28 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-04-27 20:12:50 +0200 |
commit | 31f90e99b8f04d9a228c5a0b01319b3f112c1490 (patch) | |
tree | c9253bb4457b7d0572f78647f848ea7eff338139 /src/gui/kernel/qevent.h | |
parent | 62f5a6ca4274d72bab78db4bc374c481717871b0 (diff) |
Add storage for (pixel) deltas and fingerCount to QNativeGestureEvent
It's not clear now whether trackpad gestures on Windows will need to be
so different than on macOS; however, any reasonable int value can be
stored in a qreal, and in Qt Quick we like to use floating-point numbers
for all "real" values and measurements. So since we need to add more
storage, and quint64 m_intValue has never been used, we now replace it
with a QVector2D, which should have the same size. The intended use
is that PanNativeGesture will include a displacement, probably in
pixels, by which the viewport or some target item should be panned or
moved. The naming of deltas() is flexible enough to support any gesture
with some incremental 2D valuators, though, just as value() has
gesture-dependent semantics.
fingerCount() will be useful for Qt Quick pointer handlers to filter
out events that have the wrong number of fingers, e.g. to require that
either a 3-finger pan gesture or 3 individual touchpoints are required
to activate DragHandler { minimumPointCount: 3 } (assuming we implement
pan gesture support in DragHandler).
Fixes: QTBUG-92179
Task-number: QTBUG-92098
Change-Id: I5462aea9047beed6e99075294a62011edd8a59f5
Reviewed-by: Povilas Kanapickas <povilas@radix.lt>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent.h')
-rw-r--r-- | src/gui/kernel/qevent.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 3f8b53262f..db886bdd98 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -408,14 +408,22 @@ class Q_GUI_EXPORT QNativeGestureEvent : public QSinglePointEvent { Q_EVENT_DISABLE_COPY(QNativeGestureEvent); public: +#if QT_DEPRECATED_SINCE(6, 2) + QT_DEPRECATED_VERSION_X_6_2("Use the other constructor") QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *dev, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, qreal value, quint64 sequenceId, quint64 intArgument); +#endif + QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *dev, int fingerCount, + const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, + qreal value, QVector2D deltas, quint64 sequenceId = UINT64_MAX); ~QNativeGestureEvent(); QNativeGestureEvent *clone() const override { return new QNativeGestureEvent(*this); } Qt::NativeGestureType gestureType() const { return m_gestureType; } + int fingerCount() const { return m_fingerCount; } qreal value() const { return m_realValue; } + QVector2D deltas() const { return m_deltas; } #if QT_DEPRECATED_SINCE(6, 0) #ifndef QT_NO_INTEGER_EVENT_COORDINATES @@ -434,10 +442,11 @@ public: protected: quint64 m_sequenceId; - quint64 m_intValue; + QVector2D m_deltas; qreal m_realValue; Qt::NativeGestureType m_gestureType; - quint32 m_reserved; + quint32 m_fingerCount : 4; + quint32 m_reserved : 28; }; #endif // QT_CONFIG(gestures) |