Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qeventpoint_p.h
Go to the documentation of this file.
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_P_H
5#define QEVENTPOINT_P_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 for the convenience
12// of other Qt classes. 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 <QtGui/private/qtguiglobal_p.h>
19#include <QtGui/qevent.h>
20#include <QtCore/qloggingcategory.h>
21
23
26
27class QPointingDevice;
28
30{
31public:
33 : device(device), pointId(id) { }
34
35 QEventPointPrivate(int pointId, QEventPoint::State state, const QPointF &scenePosition, const QPointF &globalPosition)
36 : scenePos(scenePosition), globalPos(globalPosition), pointId(pointId), state(state)
37 {
39 pressure = 0;
40 }
41 inline bool operator==(const QEventPointPrivate &other) const
42 {
43 return device == other.device
44 && window == other.window
45 && target == other.target
46 && pos == other.pos
47 && scenePos == other.scenePos
48 && globalPos == other.globalPos
49 && globalPressPos == other.globalPressPos
50 && globalGrabPos == other.globalGrabPos
51 && globalLastPos == other.globalLastPos
52 && pressure == other.pressure
53 && rotation == other.rotation
54 && ellipseDiameters == other.ellipseDiameters
55 && velocity == other.velocity
56 && timestamp == other.timestamp
57 && lastTimestamp == other.lastTimestamp
58 && pressTimestamp == other.pressTimestamp
59 && uniqueId == other.uniqueId
60 && pointId == other.pointId
61 && state == other.state;
62 }
63
64 const QPointingDevice *device = nullptr;
77 int pointId = -1;
79 bool accept = false;
80};
81
82// Private subclasses to allow accessing and modifying protected variables.
83// These should NOT hold any extra state.
84
86{
87public:
88 static QEventPoint withTimeStamp(ulong timestamp, int pointId, QEventPoint::State state,
89 QPointF position, QPointF scenePosition, QPointF globalPosition)
90 {
91 QEventPoint p(pointId, state, scenePosition, globalPosition);
92 p.d->timestamp = timestamp;
93 p.d->pos = position;
94 return p;
95 }
96
97 static Q_GUI_EXPORT void update(const QEventPoint &from, QEventPoint &to);
98
99 static Q_GUI_EXPORT void detach(QEventPoint &p);
100
101#define TRIVIAL_SETTER(type, field, Field) \
102 static void set##Field (QEventPoint &p, type arg) { p.d->field = std::move(arg); } \
103 /* end */
104
105 TRIVIAL_SETTER(int, pointId, Id)
106 TRIVIAL_SETTER(const QPointingDevice *, device, Device)
107
108 // not trivial:
109 static Q_GUI_EXPORT void setTimestamp(QEventPoint &p, ulong t);
110
111 TRIVIAL_SETTER(ulong, pressTimestamp, PressTimestamp)
113 TRIVIAL_SETTER(QPointingDeviceUniqueId, uniqueId, UniqueId)
114 TRIVIAL_SETTER(QPointF, pos, Position)
115 TRIVIAL_SETTER(QPointF, scenePos, ScenePosition)
116 TRIVIAL_SETTER(QPointF, globalPos, GlobalPosition)
117
118 TRIVIAL_SETTER(QPointF, globalPressPos, GlobalPressPosition)
119 TRIVIAL_SETTER(QPointF, globalGrabPos, GlobalGrabPosition)
120 TRIVIAL_SETTER(QPointF, globalLastPos, GlobalLastPosition)
121 TRIVIAL_SETTER(QSizeF, ellipseDiameters, EllipseDiameters)
122 TRIVIAL_SETTER(qreal, pressure, Pressure)
123 TRIVIAL_SETTER(qreal, rotation, Rotation)
124 TRIVIAL_SETTER(QVector2D, velocity, Velocity)
125
126 static QWindow *window(const QEventPoint &p) { return p.d->window.data(); }
127
129
130 static QObject *target(const QEventPoint &p) { return p.d->target.data(); }
131
133
134#undef TRIVIAL_SETTER
135};
136
138
139#endif // QEVENTPOINT_P_H
IOBluetoothDevice * device
QEventPointPrivate(int id, const QPointingDevice *device)
QEventPointPrivate(int pointId, QEventPoint::State state, const QPointF &scenePosition, const QPointF &globalPosition)
QPointer< QObject > target
QEventPoint::State state
QPointer< QWindow > window
QPointingDeviceUniqueId uniqueId
const QPointingDevice * device
bool operator==(const QEventPointPrivate &other) const
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
State
Specifies the state of this event point.
Definition qeventpoint.h:49
static Q_GUI_EXPORT void detach(QEventPoint &p)
static Q_GUI_EXPORT void update(const QEventPoint &from, QEventPoint &to)
static QEventPoint withTimeStamp(ulong timestamp, int pointId, QEventPoint::State state, QPointF position, QPointF scenePosition, QPointF globalPosition)
static Q_GUI_EXPORT void setTimestamp(QEventPoint &p, ulong t)
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore\reentrant
Definition qpoint.h:214
\inmodule QtCore
Definition qpointer.h:18
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.
\inmodule QtCore
Definition qshareddata.h:19
\inmodule QtCore
Definition qsize.h:207
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
\inmodule QtGui
Definition qwindow.h:63
[Window class with invokable method]
Definition window.h:11
else opt state
[0]
Combined button and popup list for selecting options.
#define TRIVIAL_SETTER(type, field, Field)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLenum GLuint id
[7]
GLenum target
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat p
[1]
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
unsigned long ulong
Definition qtypes.h:30
double qreal
Definition qtypes.h:92
QSharedPointer< T > other(t)
[5]
aWidget window() -> setWindowTitle("New Window Title")
[2]
Target
Definition tracegen.cpp:14