1 | // Copyright (C) 2020 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 QEVENTPOINT_H |
5 | #define QEVENTPOINT_H |
6 | |
7 | #include <QtGui/qtguiglobal.h> |
8 | #include <QtGui/qvector2d.h> |
9 | #include <QtGui/qpointingdevice.h> |
10 | #include <QtCore/qshareddata.h> |
11 | #include <QtCore/qmetatype.h> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class QEventPointPrivate; |
16 | QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QEventPointPrivate, Q_GUI_EXPORT) |
17 | class QMutableEventPoint; |
18 | |
19 | class Q_GUI_EXPORT QEventPoint |
20 | { |
21 | Q_GADGET |
22 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) |
23 | QDOC_PROPERTY(QPointingDevice *device READ device CONSTANT) // qdoc doesn't know const |
24 | Q_PROPERTY(const QPointingDevice *device READ device CONSTANT) |
25 | Q_PROPERTY(int id READ id CONSTANT) |
26 | Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId CONSTANT) |
27 | Q_PROPERTY(State state READ state CONSTANT) |
28 | Q_PROPERTY(ulong timestamp READ timestamp CONSTANT) |
29 | Q_PROPERTY(ulong pressTimestamp READ pressTimestamp CONSTANT) |
30 | Q_PROPERTY(ulong lastTimestamp READ lastTimestamp CONSTANT) |
31 | Q_PROPERTY(qreal timeHeld READ timeHeld CONSTANT) |
32 | Q_PROPERTY(qreal pressure READ pressure CONSTANT) |
33 | Q_PROPERTY(qreal rotation READ rotation CONSTANT) |
34 | Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters CONSTANT) |
35 | Q_PROPERTY(QVector2D velocity READ velocity CONSTANT) |
36 | Q_PROPERTY(QPointF position READ position CONSTANT) |
37 | Q_PROPERTY(QPointF pressPosition READ pressPosition CONSTANT) |
38 | Q_PROPERTY(QPointF grabPosition READ grabPosition CONSTANT) |
39 | Q_PROPERTY(QPointF lastPosition READ lastPosition CONSTANT) |
40 | Q_PROPERTY(QPointF scenePosition READ scenePosition CONSTANT) |
41 | Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition CONSTANT) |
42 | Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition CONSTANT) |
43 | Q_PROPERTY(QPointF sceneLastPosition READ sceneLastPosition CONSTANT) |
44 | Q_PROPERTY(QPointF globalPosition READ globalPosition CONSTANT) |
45 | Q_PROPERTY(QPointF globalPressPosition READ globalPressPosition CONSTANT) |
46 | Q_PROPERTY(QPointF globalGrabPosition READ globalGrabPosition CONSTANT) |
47 | Q_PROPERTY(QPointF globalLastPosition READ globalLastPosition CONSTANT) |
48 | public: |
49 | enum State : quint8 { |
50 | Unknown = Qt::TouchPointUnknownState, |
51 | Stationary = Qt::TouchPointStationary, |
52 | Pressed = Qt::TouchPointPressed, |
53 | Updated = Qt::TouchPointMoved, |
54 | Released = Qt::TouchPointReleased |
55 | }; |
56 | Q_DECLARE_FLAGS(States, State) |
57 | Q_FLAG(States) |
58 | |
59 | explicit QEventPoint(int id = -1, const QPointingDevice *device = nullptr); |
60 | QEventPoint(int pointId, State state, const QPointF &scenePosition, const QPointF &globalPosition); |
61 | QEventPoint(const QEventPoint &other) noexcept; |
62 | QEventPoint &operator=(const QEventPoint &other) noexcept; |
63 | QEventPoint(QEventPoint && other) noexcept = default; |
64 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QEventPoint) |
65 | bool operator==(const QEventPoint &other) const noexcept; |
66 | bool operator!=(const QEventPoint &other) const noexcept { return !operator==(other); } |
67 | ~QEventPoint(); |
68 | inline void swap(QEventPoint &other) noexcept |
69 | { d.swap(other&: other.d); } |
70 | |
71 | QPointF position() const; |
72 | QPointF pressPosition() const; |
73 | QPointF grabPosition() const; |
74 | QPointF lastPosition() const; |
75 | QPointF scenePosition() const; |
76 | QPointF scenePressPosition() const; |
77 | QPointF sceneGrabPosition() const; |
78 | QPointF sceneLastPosition() const; |
79 | QPointF globalPosition() const; |
80 | QPointF globalPressPosition() const; |
81 | QPointF globalGrabPosition() const; |
82 | QPointF globalLastPosition() const; |
83 | QPointF normalizedPosition() const; |
84 | |
85 | #if QT_DEPRECATED_SINCE(6, 0) |
86 | // QEventPoint replaces QTouchEvent::TouchPoint, so we need all its old accessors, for now |
87 | QT_DEPRECATED_VERSION_X_6_0("Use position()" ) |
88 | QPointF pos() const { return position(); } |
89 | QT_DEPRECATED_VERSION_X_6_0("Use pressPosition()" ) |
90 | QPointF startPos() const { return pressPosition(); } |
91 | QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()" ) |
92 | QPointF scenePos() const { return scenePosition(); } |
93 | QT_DEPRECATED_VERSION_X_6_0("Use scenePressPosition()" ) |
94 | QPointF startScenePos() const { return scenePressPosition(); } |
95 | QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()" ) |
96 | QPointF screenPos() const { return globalPosition(); } |
97 | QT_DEPRECATED_VERSION_X_6_0("Use globalPressPosition()" ) |
98 | QPointF startScreenPos() const { return globalPressPosition(); } |
99 | QT_DEPRECATED_VERSION_X_6_0("Use globalPressPosition()" ) |
100 | QPointF startNormalizedPos() const; |
101 | QT_DEPRECATED_VERSION_X_6_0("Use normalizedPosition()" ) |
102 | QPointF normalizedPos() const { return normalizedPosition(); } |
103 | QT_DEPRECATED_VERSION_X_6_0("Use lastPosition()" ) |
104 | QPointF lastPos() const { return lastPosition(); } |
105 | QT_DEPRECATED_VERSION_X_6_0("Use sceneLastPosition()" ) |
106 | QPointF lastScenePos() const { return sceneLastPosition(); } |
107 | QT_DEPRECATED_VERSION_X_6_0("Use globalLastPosition()" ) |
108 | QPointF lastScreenPos() const { return globalLastPosition(); } |
109 | QT_DEPRECATED_VERSION_X_6_0("Use globalLastPosition()" ) |
110 | QPointF lastNormalizedPos() const; |
111 | #endif // QT_DEPRECATED_SINCE(6, 0) |
112 | QVector2D velocity() const; |
113 | State state() const; |
114 | const QPointingDevice *device() const; |
115 | int id() const; |
116 | QPointingDeviceUniqueId uniqueId() const; |
117 | ulong timestamp() const; |
118 | ulong lastTimestamp() const; |
119 | ulong pressTimestamp() const; |
120 | qreal timeHeld() const; |
121 | qreal pressure() const; |
122 | qreal rotation() const; |
123 | QSizeF ellipseDiameters() const; |
124 | |
125 | bool isAccepted() const; |
126 | void setAccepted(bool accepted = true); |
127 | |
128 | private: |
129 | QExplicitlySharedDataPointer<QEventPointPrivate> d; |
130 | friend class QMutableEventPoint; |
131 | friend class QPointerEvent; |
132 | }; |
133 | |
134 | #ifndef QT_NO_DEBUG_STREAM |
135 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QEventPoint *); |
136 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QEventPoint &); |
137 | #endif |
138 | |
139 | Q_DECLARE_SHARED(QEventPoint) |
140 | |
141 | QT_END_NAMESPACE |
142 | |
143 | #endif // QEVENTPOINT_H |
144 | |