diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-02-28 20:42:02 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-06-20 22:01:56 +0000 |
commit | f62abf14b0cc940b07e8fee84be979f34478ae2b (patch) | |
tree | 09ed1780dc5cf10cc02a163e77b13121c89d9899 /src/quick/items/qquickevents_p_p.h | |
parent | 5e1063b6671c3116653cebabc693fae4c0ed5aae (diff) |
Add QQuickPointerScrollEvent as a wrapper for QWheelEvent
We'll use this for delivery of QWheelEvents to both Items and
Pointer Handlers. Later we can perhaps use it for QScrollEvent too.
Task-number: QTBUG-68119
Change-Id: I04cbbc85fe1a86cf5fd0374d353876f7e6140b70
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickevents_p_p.h')
-rw-r--r-- | src/quick/items/qquickevents_p_p.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 1f6abdec84..2439193ef1 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -69,6 +69,7 @@ class QQuickPointerMouseEvent; #if QT_CONFIG(gestures) class QQuickPointerNativeGestureEvent; #endif +class QQuickPointerScrollEvent; class QQuickPointerTabletEvent; class QQuickPointerTouchEvent; class QQuickPointerHandler; @@ -419,12 +420,14 @@ public: // helpers for C++ only (during event delivery) #if QT_CONFIG(gestures) virtual QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() { return nullptr; } #endif + virtual QQuickPointerScrollEvent *asPointerScrollEvent() { return nullptr; } virtual const QQuickPointerMouseEvent *asPointerMouseEvent() const { return nullptr; } virtual const QQuickPointerTouchEvent *asPointerTouchEvent() const { return nullptr; } virtual const QQuickPointerTabletEvent *asPointerTabletEvent() const { return nullptr; } #if QT_CONFIG(gestures) virtual const QQuickPointerNativeGestureEvent *asPointerNativeGestureEvent() const { return nullptr; } #endif + virtual const QQuickPointerScrollEvent *asPointerScrollEvent() const { return nullptr; } virtual bool allPointsAccepted() const = 0; virtual bool allUpdatedPointsAccepted() const = 0; virtual bool allPointsGrabbed() const = 0; @@ -560,6 +563,50 @@ public: }; #endif // QT_CONFIG(gestures) +class Q_QUICK_PRIVATE_EXPORT QQuickPointerScrollEvent : public QQuickSinglePointEvent +{ + Q_OBJECT + Q_PROPERTY(QVector2D angleDelta READ angleDelta CONSTANT) + Q_PROPERTY(QVector2D pixelDelta READ pixelDelta CONSTANT) + Q_PROPERTY(bool hasAngleDelta READ hasAngleDelta CONSTANT) + Q_PROPERTY(bool hasPixelDelta READ hasPixelDelta CONSTANT) + Q_PROPERTY(bool inverted READ isInverted CONSTANT) + +public: + QQuickPointerScrollEvent(QObject *parent = nullptr, QQuickPointerDevice *device = nullptr) + : QQuickSinglePointEvent(parent, device) { } + + QQuickPointerEvent *reset(QEvent *) override; + void localize(QQuickItem *target) override; + bool isPressEvent() const override; + bool isUpdateEvent() const override; + bool isReleaseEvent() const override; + QQuickPointerScrollEvent *asPointerScrollEvent() override { return this; } + const QQuickPointerScrollEvent *asPointerScrollEvent() const override { return this; } + QVector2D angleDelta() const { return m_angleDelta; } + QVector2D pixelDelta() const { return m_pixelDelta; } + bool hasAngleDelta() const { return !angleDelta().isNull(); } + bool hasPixelDelta() const { return !pixelDelta().isNull(); } + bool isInverted() const { return m_inverted; } + Qt::ScrollPhase phase() const { return m_phase; } + +private: + // TODO add QQuickPointerDevice source() whenever QInputEvent is extended to have a source device + // then maybe Qt::MouseEventSource synthSource() will be obsolete... that's why it's not public now + Qt::MouseEventSource synthSource() const { return m_synthSource; } + +private: + QVector2D m_angleDelta; + QVector2D m_pixelDelta; + Qt::ScrollPhase m_phase = Qt::NoScrollPhase; + Qt::MouseEventSource m_synthSource = Qt::MouseEventNotSynthesized; + bool m_inverted = false; + + friend class QQuickWindowPrivate; + + Q_DISABLE_COPY(QQuickPointerScrollEvent) +}; + // ### Qt 6: move this to qtbase, replace QTouchDevice and the enums in QTabletEvent class Q_QUICK_PRIVATE_EXPORT QQuickPointerDevice : public QObject |