Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickmultipointtoucharea_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QQUICKMULTIPOINTTOUCHAREA_H
5#define QQUICKMULTIPOINTTOUCHAREA_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 <private/qtquickglobal_p.h>
19
20#include <QtQuick/qquickitem.h>
21
22#include <QtGui/qevent.h>
23#include <QtGui/qguiapplication.h>
24#include <QtGui/qstylehints.h>
25
26#include <QtCore/qlist.h>
27#include <QtCore/qmap.h>
28#include <QtCore/qpointer.h>
29
31
33class Q_QUICK_EXPORT QQuickTouchPoint : public QObject
34{
36 Q_PROPERTY(int pointId READ pointId NOTIFY pointIdChanged)
37 Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId NOTIFY uniqueIdChanged REVISION(2, 9))
38 Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
39 Q_PROPERTY(qreal x READ x NOTIFY xChanged)
40 Q_PROPERTY(qreal y READ y NOTIFY yChanged)
41 Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters NOTIFY ellipseDiametersChanged REVISION(2, 9))
42 Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged)
43 Q_PROPERTY(qreal rotation READ rotation NOTIFY rotationChanged REVISION(2, 9))
44 Q_PROPERTY(QVector2D velocity READ velocity NOTIFY velocityChanged)
45 Q_PROPERTY(QRectF area READ area NOTIFY areaChanged)
46
47 Q_PROPERTY(qreal startX READ startX NOTIFY startXChanged)
48 Q_PROPERTY(qreal startY READ startY NOTIFY startYChanged)
49 Q_PROPERTY(qreal previousX READ previousX NOTIFY previousXChanged)
50 Q_PROPERTY(qreal previousY READ previousY NOTIFY previousYChanged)
51 Q_PROPERTY(qreal sceneX READ sceneX NOTIFY sceneXChanged)
52 Q_PROPERTY(qreal sceneY READ sceneY NOTIFY sceneYChanged)
53 QML_NAMED_ELEMENT(TouchPoint)
55
56public:
57 QQuickTouchPoint(bool qmlDefined = true)
58 : _qmlDefined(qmlDefined)
59 {}
60
61 int pointId() const { return _id; }
62 void setPointId(int id);
63
64 QPointingDeviceUniqueId uniqueId() const { return _uniqueId; }
65 void setUniqueId(const QPointingDeviceUniqueId &id);
66
67 qreal x() const { return _x; }
68 qreal y() const { return _y; }
70
71 QSizeF ellipseDiameters() const { return _ellipseDiameters; }
72 void setEllipseDiameters(const QSizeF &d);
73
74 qreal pressure() const { return _pressure; }
75 void setPressure(qreal pressure);
76
77 qreal rotation() const { return _rotation; }
78 void setRotation(qreal r);
79
80 QVector2D velocity() const { return _velocity; }
81 void setVelocity(const QVector2D &velocity);
82
83 QRectF area() const { return _area; }
84 void setArea(const QRectF &area);
85
86 bool isQmlDefined() const { return _qmlDefined; }
87
88 bool inUse() const { return _inUse; }
89 void setInUse(bool inUse) { _inUse = inUse; }
90
91 bool pressed() const { return _pressed; }
92 void setPressed(bool pressed);
93
94 qreal startX() const { return _startX; }
95 void setStartX(qreal startX);
96
97 qreal startY() const { return _startY; }
98 void setStartY(qreal startY);
99
100 qreal previousX() const { return _previousX; }
101 void setPreviousX(qreal previousX);
102
103 qreal previousY() const { return _previousY; }
104 void setPreviousY(qreal previousY);
105
106 qreal sceneX() const { return _sceneX; }
107 void setSceneX(qreal sceneX);
108
109 qreal sceneY() const { return _sceneY; }
110 void setSceneY(qreal sceneY);
111
115 Q_REVISION(2, 9) void uniqueIdChanged();
116 void xChanged();
117 void yChanged();
118 Q_REVISION(2, 9) void ellipseDiametersChanged();
119 void pressureChanged();
120 Q_REVISION(2, 9) void rotationChanged();
121 void velocityChanged();
122 void areaChanged();
123 void startXChanged();
124 void startYChanged();
125 void previousXChanged();
126 void previousYChanged();
127 void sceneXChanged();
128 void sceneYChanged();
129
130private:
132 int _id = 0;
133 qreal _x = 0.0;
134 qreal _y = 0.0;
135 qreal _pressure = 0.0;
136 qreal _rotation = 0;
137 QSizeF _ellipseDiameters;
138 QVector2D _velocity;
139 QRectF _area;
140 bool _qmlDefined;
141 bool _inUse = false; //whether the point is currently in use (only valid when _qmlDefined == true)
142 bool _pressed = false;
143 qreal _startX = 0.0;
144 qreal _startY = 0.0;
145 qreal _previousX = 0.0;
146 qreal _previousY = 0.0;
147 qreal _sceneX = 0.0;
148 qreal _sceneY = 0.0;
149 QPointingDeviceUniqueId _uniqueId;
150};
151
153{
155 Q_PROPERTY(QQmlListProperty<QObject> touchPoints READ touchPoints CONSTANT FINAL)
156 Q_PROPERTY(qreal dragThreshold READ dragThreshold CONSTANT FINAL)
157 QML_NAMED_ELEMENT(GestureEvent)
159 QML_UNCREATABLE("GestureEvent is only available in the context of handling the gestureStarted signal from MultiPointTouchArea.")
160
161public:
162 QQuickGrabGestureEvent() : _dragThreshold(QGuiApplication::styleHints()->startDragDistance()) {}
163
164 Q_INVOKABLE void grab() { _grab = true; }
165 bool wantsGrab() const { return _grab; }
166
167 QQmlListProperty<QObject> touchPoints() {
168 return QQmlListProperty<QObject>(this, &_touchPoints);
169 }
170 qreal dragThreshold() const { return _dragThreshold; }
171
172private:
174 bool _grab = false;
175 qreal _dragThreshold;
176 QList<QObject*> _touchPoints;
177};
178
179class Q_QUICK_EXPORT QQuickMultiPointTouchArea : public QQuickItem
180{
182 Q_DISABLE_COPY_MOVE(QQuickMultiPointTouchArea)
183
184 Q_PROPERTY(QQmlListProperty<QQuickTouchPoint> touchPoints READ touchPoints CONSTANT)
185 Q_PROPERTY(int minimumTouchPoints READ minimumTouchPoints WRITE setMinimumTouchPoints NOTIFY minimumTouchPointsChanged)
186 Q_PROPERTY(int maximumTouchPoints READ maximumTouchPoints WRITE setMaximumTouchPoints NOTIFY maximumTouchPointsChanged)
187 Q_PROPERTY(bool mouseEnabled READ mouseEnabled WRITE setMouseEnabled NOTIFY mouseEnabledChanged)
188 QML_NAMED_ELEMENT(MultiPointTouchArea)
190
191public:
192 QQuickMultiPointTouchArea(QQuickItem *parent=nullptr);
194
195 int minimumTouchPoints() const;
196 void setMinimumTouchPoints(int num);
197 int maximumTouchPoints() const;
198 void setMaximumTouchPoints(int num);
199 bool mouseEnabled() const { return _mouseEnabled; }
200 void setMouseEnabled(bool arg);
201
202 QQmlListProperty<QQuickTouchPoint> touchPoints() {
204 }
205
206 static void touchPoint_append(QQmlListProperty<QQuickTouchPoint> *list, QQuickTouchPoint* touch) {
208 q->addTouchPrototype(touch);
209 }
210
211 static qsizetype touchPoint_count(QQmlListProperty<QQuickTouchPoint> *list) {
213 return q->_touchPrototypes.size();
214 }
215
216 static QQuickTouchPoint* touchPoint_at(QQmlListProperty<QQuickTouchPoint> *list, qsizetype index) {
218 return q->_touchPrototypes.value(index);
219 }
220
222#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
223 void pressed(const QList<QObject*> &touchPoints);
224 void updated(const QList<QObject*> &touchPoints);
225 void released(const QList<QObject*> &touchPoints);
226 void canceled(const QList<QObject*> &touchPoints);
227#else
228 void pressed(const QList<QObject*> &points);
229 void updated(const QList<QObject*> &points);
230 void released(const QList<QObject*> &points);
231 void canceled(const QList<QObject*> &points);
232#endif
234#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
235 void touchUpdated(const QList<QObject*> &touchPoints);
236#else
237 void touchUpdated(const QList<QObject*> &points);
238#endif
242
243protected:
244 void touchEvent(QTouchEvent *) override;
245 bool childMouseEventFilter(QQuickItem *receiver, QEvent *event) override;
246 void mousePressEvent(QMouseEvent *event) override;
247 void mouseReleaseEvent(QMouseEvent *event) override;
248 void mouseMoveEvent(QMouseEvent *event) override;
249 void mouseUngrabEvent() override;
250 void touchUngrabEvent() override;
251
252 void addTouchPrototype(QQuickTouchPoint* prototype);
253 void addTouchPoint(const QEventPoint *p);
254 void addTouchPoint(const QMouseEvent *e);
255 void clearTouchLists();
256
257 void updateTouchPoint(QQuickTouchPoint*, const QEventPoint*);
258 void updateTouchPoint(QQuickTouchPoint *dtp, const QMouseEvent *e);
259 enum class RemapEventPoints { No, ToLocal };
260 void updateTouchData(QEvent*, RemapEventPoints remap = RemapEventPoints::No);
261
262 bool sendMouseEvent(QMouseEvent *event);
263 bool shouldFilter(QEvent *event);
264 void grabGesture(QPointingDevice *dev);
265 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
266#ifdef Q_OS_MACOS
267 void hoverEnterEvent(QHoverEvent *event) override;
268 void hoverLeaveEvent(QHoverEvent *event) override;
269 void setTouchEventsEnabled(bool enable);
270 void itemChange(ItemChange change, const ItemChangeData &data) override;
271#endif
272
273private:
274 void ungrab(bool normalRelease = false);
275 QMap<int,QQuickTouchPoint*> _touchPrototypes; //TouchPoints defined in QML
276 QMap<int,QObject*> _touchPoints; //All current touch points
277 QList<QObject*> _releasedTouchPoints;
278 QList<QObject*> _pressedTouchPoints;
279 QList<QObject*> _movedTouchPoints;
280 int _minimumTouchPoints;
281 int _maximumTouchPoints;
282 QVector<int> _lastFilterableTouchPointIds;
283 QPointer<QQuickTouchPoint> _mouseTouchPoint; // exists when mouse button is down and _mouseEnabled is true; null otherwise
284 QEventPoint _mouseQpaTouchPoint; // synthetic QPA touch point to hold state and position of the mouse
285 const QPointingDevice *_touchMouseDevice;
286 QPointF _mousePos;
287 bool _stealMouse;
288 bool _mouseEnabled;
289};
290
292
293#endif // QQUICKMULTIPOINTTOUCHAREA_H
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
\inmodule QtCore
Definition qcoreevent.h:45
\macro qGuiApp
\inmodule QtGui
Definition qevent.h:246
T value(const Key &key, const T &defaultValue=T()) const
Definition qmap.h:357
size_type size() const
Definition qmap.h:267
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
QPointingDeviceUniqueId identifies a unique object, such as a tagged token or stylus,...
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
QQmlListProperty< QObject > touchPoints()
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
static void touchPoint_append(QQmlListProperty< QQuickTouchPoint > *list, QQuickTouchPoint *touch)
void canceled(const QList< QObject * > &points)
QQmlListProperty< QQuickTouchPoint > touchPoints()
static QQuickTouchPoint * touchPoint_at(QQmlListProperty< QQuickTouchPoint > *list, qsizetype index)
static qsizetype touchPoint_count(QQmlListProperty< QQuickTouchPoint > *list)
void addTouchPrototype(QQuickTouchPoint *prototype)
void gestureStarted(QQuickGrabGestureEvent *gesture)
void updated(const QList< QObject * > &points)
void released(const QList< QObject * > &points)
void pressed(const QList< QObject * > &points)
void touchUpdated(const QList< QObject * > &points)
QPointingDeviceUniqueId uniqueId() const
Q_REVISION(2, 9) void uniqueIdChanged()
\inmodule QtCore\reentrant
Definition qrect.h:484
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
\inmodule QtCore
Definition qsize.h:208
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
auto signal
Combined button and popup list for selecting options.
static void * context
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
static int area(const QSize &s)
Definition qicon.cpp:153
n void setPosition(void) \n\
GLint GLint GLint GLint GLint x
[0]
GLuint index
[2]
GLboolean r
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLboolean enable
GLint y
struct _cl_event * event
GLfixed GLfixed GLint GLint GLfixed points
GLuint in
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLfloat GLfloat p
[1]
GLuint num
#define QML_UNCREATABLE(REASON)
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
SSL_CTX int void * arg
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_INVOKABLE
#define Q_SIGNALS
ptrdiff_t qsizetype
Definition qtypes.h:165
double qreal
Definition qtypes.h:187
QList< int > list
[14]