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

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtbase/src/gui/kernel/qeventpoint.h