QtBase  v6.3.1
qeventpoint.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2020 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QEVENTPOINT_H
41 #define QEVENTPOINT_H
42 
43 #include <QtGui/qtguiglobal.h>
44 #include <QtGui/qvector2d.h>
45 #include <QtGui/qpointingdevice.h>
46 #include <QtCore/qshareddata.h>
47 #include <QtCore/qmetatype.h>
48 
50 
51 class QEventPointPrivate;
53 class QMutableEventPoint;
54 
55 class Q_GUI_EXPORT QEventPoint
56 {
58  Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
59  QDOC_PROPERTY(QPointingDevice *device READ device CONSTANT) // qdoc doesn't know const
60  Q_PROPERTY(const QPointingDevice *device READ device CONSTANT)
61  Q_PROPERTY(int id READ id CONSTANT)
62  Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId CONSTANT)
63  Q_PROPERTY(State state READ state CONSTANT)
64  Q_PROPERTY(ulong timestamp READ timestamp CONSTANT)
65  Q_PROPERTY(ulong pressTimestamp READ pressTimestamp CONSTANT)
66  Q_PROPERTY(ulong lastTimestamp READ lastTimestamp CONSTANT)
67  Q_PROPERTY(qreal timeHeld READ timeHeld CONSTANT)
68  Q_PROPERTY(qreal pressure READ pressure CONSTANT)
69  Q_PROPERTY(qreal rotation READ rotation CONSTANT)
70  Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters CONSTANT)
71  Q_PROPERTY(QVector2D velocity READ velocity CONSTANT)
72  Q_PROPERTY(QPointF position READ position CONSTANT)
73  Q_PROPERTY(QPointF pressPosition READ pressPosition CONSTANT)
74  Q_PROPERTY(QPointF grabPosition READ grabPosition CONSTANT)
75  Q_PROPERTY(QPointF lastPosition READ lastPosition CONSTANT)
76  Q_PROPERTY(QPointF scenePosition READ scenePosition CONSTANT)
77  Q_PROPERTY(QPointF scenePressPosition READ scenePressPosition CONSTANT)
78  Q_PROPERTY(QPointF sceneGrabPosition READ sceneGrabPosition CONSTANT)
79  Q_PROPERTY(QPointF sceneLastPosition READ sceneLastPosition CONSTANT)
80  Q_PROPERTY(QPointF globalPosition READ globalPosition CONSTANT)
81  Q_PROPERTY(QPointF globalPressPosition READ globalPressPosition CONSTANT)
82  Q_PROPERTY(QPointF globalGrabPosition READ globalGrabPosition CONSTANT)
83  Q_PROPERTY(QPointF globalLastPosition READ globalLastPosition CONSTANT)
84 public:
85  enum State : quint8 {
87  Stationary = Qt::TouchPointStationary,
88  Pressed = Qt::TouchPointPressed,
89  Updated = Qt::TouchPointMoved,
90  Released = Qt::TouchPointReleased
91  };
93  Q_FLAG(States)
94 
95  explicit QEventPoint(int id = -1, const QPointingDevice *device = nullptr);
96  QEventPoint(int pointId, State state, const QPointF &scenePosition, const QPointF &globalPosition);
97  QEventPoint(const QEventPoint &other) noexcept;
98  QEventPoint &operator=(const QEventPoint &other) noexcept;
99  QEventPoint(QEventPoint && other) noexcept = default;
101  bool operator==(const QEventPoint &other) const noexcept;
102  bool operator!=(const QEventPoint &other) const noexcept { return !operator==(other); }
103  ~QEventPoint();
104  inline void swap(QEventPoint &other) noexcept
105  { d.swap(other.d); }
106 
107  QPointF position() const;
108  QPointF pressPosition() const;
109  QPointF grabPosition() const;
110  QPointF lastPosition() const;
111  QPointF scenePosition() const;
112  QPointF scenePressPosition() const;
113  QPointF sceneGrabPosition() const;
114  QPointF sceneLastPosition() const;
115  QPointF globalPosition() const;
116  QPointF globalPressPosition() const;
117  QPointF globalGrabPosition() const;
118  QPointF globalLastPosition() const;
119  QPointF normalizedPosition() const;
120 
121 #if QT_DEPRECATED_SINCE(6, 0)
122  // QEventPoint replaces QTouchEvent::TouchPoint, so we need all its old accessors, for now
123  QT_DEPRECATED_VERSION_X_6_0("Use position()")
124  QPointF pos() const { return position(); }
125  QT_DEPRECATED_VERSION_X_6_0("Use pressPosition()")
126  QPointF startPos() const { return pressPosition(); }
127  QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()")
128  QPointF scenePos() const { return scenePosition(); }
129  QT_DEPRECATED_VERSION_X_6_0("Use scenePressPosition()")
130  QPointF startScenePos() const { return scenePressPosition(); }
131  QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
132  QPointF screenPos() const { return globalPosition(); }
133  QT_DEPRECATED_VERSION_X_6_0("Use globalPressPosition()")
134  QPointF startScreenPos() const { return globalPressPosition(); }
135  QT_DEPRECATED_VERSION_X_6_0("Use globalPressPosition()")
136  QPointF startNormalizedPos() const;
137  QT_DEPRECATED_VERSION_X_6_0("Use normalizedPosition()")
138  QPointF normalizedPos() const { return normalizedPosition(); }
139  QT_DEPRECATED_VERSION_X_6_0("Use lastPosition()")
140  QPointF lastPos() const { return lastPosition(); }
141  QT_DEPRECATED_VERSION_X_6_0("Use sceneLastPosition()")
142  QPointF lastScenePos() const { return sceneLastPosition(); }
143  QT_DEPRECATED_VERSION_X_6_0("Use globalLastPosition()")
144  QPointF lastScreenPos() const { return globalLastPosition(); }
145  QT_DEPRECATED_VERSION_X_6_0("Use globalLastPosition()")
146  QPointF lastNormalizedPos() const;
147 #endif // QT_DEPRECATED_SINCE(6, 0)
148  QVector2D velocity() const;
149  State state() const;
150  const QPointingDevice *device() const;
151  int id() const;
152  QPointingDeviceUniqueId uniqueId() const;
153  ulong timestamp() const;
154  ulong lastTimestamp() const;
155  ulong pressTimestamp() const;
156  qreal timeHeld() const;
157  qreal pressure() const;
158  qreal rotation() const;
159  QSizeF ellipseDiameters() const;
160 
161  bool isAccepted() const;
162  void setAccepted(bool accepted = true);
163 
164 private:
166  friend class QMutableEventPoint;
167  friend class QPointerEvent;
168 };
169 
170 #ifndef QT_NO_DEBUG_STREAM
171 Q_GUI_EXPORT QDebug operator<<(QDebug, const QEventPoint *);
172 Q_GUI_EXPORT QDebug operator<<(QDebug, const QEventPoint &);
173 #endif
174 
176 
178 
179 #endif // QEVENTPOINT_H
enum State_ State
operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
The QEventPoint class provides information about a point in a QPointerEvent.
Definition: qeventpoint.h:56
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:242
A base class for pointer events.
Definition: qevent.h:102
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
QPointingDeviceUniqueId identifies a unique object, such as a tagged token or stylus,...
The QSizeF class defines the size of a two-dimensional object using floating point precision.
Definition: qsize.h:235
The QVector2D class represents a vector or vertex in 2D space.
Definition: qvectornd.h:62
float rotation
else opt state
[0]
auto it unsigned count const
Definition: hb-iter.hh:848
QHighDpiScaling::Point position(T, QHighDpiScaling::Point::Kind)
@ TouchPointReleased
Definition: qnamespace.h:1625
@ TouchPointStationary
Definition: qnamespace.h:1624
@ TouchPointPressed
Definition: qnamespace.h:1622
@ TouchPointMoved
Definition: qnamespace.h:1623
@ TouchPointUnknownState
Definition: qnamespace.h:1621
constexpr bool operator!=(const timespec &t1, const timespec &t2)
Definition: qcore_unix_p.h:124
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition: qflags.h:210
unsigned long ulong
Definition: qglobal.h:335
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
#define QT_DEPRECATED_VERSION_X_6_0(text)
Definition: qglobal.h:444
unsigned char quint8
Definition: qglobal.h:284
#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(Class)
Definition: qglobal.h:563
bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two)
GLenum GLuint id
[6]
Definition: qopengl.h:270
#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro)
Definition: qshareddata.h:315
#define Q_PROPERTY(...)
Definition: qtmetamacros.h:92
#define Q_FLAG(x)
Definition: qtmetamacros.h:105
#define Q_GADGET
Definition: qtmetamacros.h:193
#define QDOC_PROPERTY(text)
Definition: qtmetamacros.h:98
#define Q_DECLARE_SHARED(TYPE)
Definition: qtypeinfo.h:197
QSharedPointer< T > other(t)
[5]
this swap(other)