| 1 | // Copyright (C) 2018 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICKHANDLERPOINT_H |
| 5 | #define QQUICKHANDLERPOINT_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qquickpointerdevicehandler_p.h" |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | |
| 22 | class QQuickMultiPointHandler; |
| 23 | class QQuickSinglePointHandler; |
| 24 | |
| 25 | class Q_QUICK_EXPORT QQuickHandlerPoint { |
| 26 | Q_GADGET |
| 27 | Q_PROPERTY(int id READ id FINAL) |
| 28 | Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId FINAL) |
| 29 | Q_PROPERTY(QPointF position READ position FINAL) |
| 30 | Q_PROPERTY(QPointF scenePosition READ scenePosition FINAL) |
| 31 | Q_PROPERTY(QPointF pressPosition READ pressPosition FINAL) |
| 32 | Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition FINAL) |
| 33 | Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition FINAL) |
| 34 | Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons FINAL) |
| 35 | Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers FINAL) |
| 36 | Q_PROPERTY(QVector2D velocity READ velocity FINAL) |
| 37 | Q_PROPERTY(qreal rotation READ rotation FINAL) |
| 38 | Q_PROPERTY(qreal pressure READ pressure FINAL) |
| 39 | Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters FINAL) |
| 40 | Q_PROPERTY(QPointingDevice *device READ device FINAL) |
| 41 | QML_ANONYMOUS |
| 42 | |
| 43 | public: |
| 44 | QQuickHandlerPoint(); |
| 45 | |
| 46 | int id() const { return m_id; } |
| 47 | Qt::MouseButtons pressedButtons() const { return m_pressedButtons; } |
| 48 | Qt::KeyboardModifiers modifiers() const { return m_pressedModifiers; } |
| 49 | QPointF pressPosition() const { return m_pressPosition; } |
| 50 | QPointF scenePressPosition() const { return m_scenePressPosition; } |
| 51 | QPointF sceneGrabPosition() const { return m_sceneGrabPosition; } |
| 52 | QPointF position() const { return m_position; } |
| 53 | QPointF scenePosition() const { return m_scenePosition; } |
| 54 | QVector2D velocity() const { return m_velocity; } |
| 55 | qreal rotation() const { return m_rotation; } |
| 56 | qreal pressure() const { return m_pressure; } |
| 57 | QSizeF ellipseDiameters() const { return m_ellipseDiameters; } |
| 58 | QPointingDeviceUniqueId uniqueId() const { return m_uniqueId; } |
| 59 | // non-const only because of QML engine limitations (similar to QTBUG-61749) |
| 60 | QPointingDevice *device() const { return const_cast<QPointingDevice *>(m_device); } |
| 61 | void localize(QQuickItem *item); |
| 62 | |
| 63 | void reset(); |
| 64 | void reset(const QPointerEvent *event, const QEventPoint &point); |
| 65 | void reset(const QVector<QQuickHandlerPoint> &points); |
| 66 | |
| 67 | private: |
| 68 | int m_id = -1; |
| 69 | const QPointingDevice *m_device = QPointingDevice::primaryPointingDevice(); |
| 70 | QPointingDeviceUniqueId m_uniqueId; |
| 71 | Qt::MouseButtons m_pressedButtons = Qt::NoButton; |
| 72 | Qt::KeyboardModifiers m_pressedModifiers = Qt::NoModifier; |
| 73 | QPointF m_position; |
| 74 | QPointF m_scenePosition; |
| 75 | QPointF m_pressPosition; |
| 76 | QPointF m_scenePressPosition; |
| 77 | QPointF m_sceneGrabPosition; |
| 78 | QVector2D m_velocity; |
| 79 | qreal m_rotation = 0; |
| 80 | qreal m_pressure = 0; |
| 81 | QSizeF m_ellipseDiameters; |
| 82 | friend class QQuickMultiPointHandler; |
| 83 | friend class QQuickSinglePointHandler; |
| 84 | }; |
| 85 | |
| 86 | QT_END_NAMESPACE |
| 87 | |
| 88 | #endif // QQUICKHANDLERPOINT_H |
| 89 |
