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.cpp | |
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.cpp')
-rw-r--r-- | src/quick/items/qquickevents.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index ece6c3f07c..fc25de38b1 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -1424,6 +1424,36 @@ QQuickEventPoint *QQuickSinglePointEvent::point(int i) const return nullptr; } +QQuickPointerEvent *QQuickPointerScrollEvent::reset(QEvent *event) +{ + m_event = static_cast<QInputEvent*>(event); + if (!event) + return this; +#if QT_CONFIG(wheelevent) + if (event->type() == QEvent::Wheel) { + auto ev = static_cast<QWheelEvent*>(event); + m_device = QQuickPointerDevice::genericMouseDevice(); + m_device->eventDeliveryTargets().clear(); + // m_button = Qt::NoButton; + m_pressedButtons = ev->buttons(); + m_angleDelta = QVector2D(ev->angleDelta()); + m_pixelDelta = QVector2D(ev->pixelDelta()); + m_phase = ev->phase(); + m_synthSource = ev->source(); + m_inverted = ev->inverted(); + + m_point->reset(Qt::TouchPointMoved, ev->posF(), quint64(1) << 24, ev->timestamp()); // mouse has device ID 1 + } +#endif + // TODO else if (event->type() == QEvent::Scroll) ... + return this; +} + +void QQuickPointerScrollEvent::localize(QQuickItem *target) +{ + m_point->localizePosition(target); +} + QQuickEventPoint *QQuickPointerTouchEvent::point(int i) const { if (i >= 0 && i < m_pointCount) @@ -1698,6 +1728,39 @@ qreal QQuickPointerNativeGestureEvent::value() const #endif // QT_CONFIG(gestures) /*! + Returns whether the scroll event has Qt::ScrollBegin phase. On touchpads + which provide phase information, this is true when the fingers are placed + on the touchpad and scrolling begins. On other devices where this + information is not available, it remains false. +*/ +bool QQuickPointerScrollEvent::isPressEvent() const +{ + return phase() == Qt::ScrollBegin; +} + +/*! + Returns true when the scroll event has Qt::ScrollUpdate phase, or when the + phase is unknown. Some multi-touch-capable touchpads and trackpads provide + phase information; whereas ordinary mouse wheels and other types of + trackpads do not, and in such cases this is always true. +*/ +bool QQuickPointerScrollEvent::isUpdateEvent() const +{ + return phase() == Qt::ScrollUpdate || phase() == Qt::NoScrollPhase; +} + +/*! + Returns whether the scroll event has Qt::ScrollBegin phase. On touchpads + which provide phase information, this is true when the fingers are lifted + from the touchpad. On other devices where this information is not + available, it remains false. +*/ +bool QQuickPointerScrollEvent::isReleaseEvent() const +{ + return phase() == Qt::ScrollEnd; +} + +/*! \internal Returns a pointer to the QQuickEventPoint which has the \a pointId as \l {QQuickEventPoint::pointId}{pointId}. |