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
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
21#include <QtCore/qloggingcategory.h>
22#include <QtCore/qpointer.h>
23
25
28
29class QPointingDevice;
30
32{
33public:
36
37 QEventPointPrivate(int pointId, QEventPoint::State state, const QPointF &scenePosition, const QPointF &globalPosition)
38 : scenePos(scenePosition), globalPos(globalPosition), pointId(pointId), state(state)
39 {
41 pressure = 0;
42 }
43 inline bool operator==(const QEventPointPrivate &other) const
44 {
45 return device == other.device
46 && window == other.window
47 && target == other.target
48 && pos == other.pos
49 && scenePos == other.scenePos
50 && globalPos == other.globalPos
51 && globalPressPos == other.globalPressPos
52 && globalGrabPos == other.globalGrabPos
53 && globalLastPos == other.globalLastPos
54 && pressure == other.pressure
55 && rotation == other.rotation
56 && ellipseDiameters == other.ellipseDiameters
57 && velocity == other.velocity
58 && timestamp == other.timestamp
59 && lastTimestamp == other.lastTimestamp
60 && pressTimestamp == other.pressTimestamp
61 && uniqueId == other.uniqueId
62 && pointId == other.pointId
63 && state == other.state;
64 }
65
66 const QPointingDevice *device = nullptr;
67 QPointer<QWindow> window;
68 QPointer<QObject> target;
79 int pointId = -1;
81 bool accept = false;
82};
83
84// Private subclasses to allow accessing and modifying protected variables.
85// These should NOT hold any extra state.
86
88{
89public:
90 static QEventPoint withTimeStamp(ulong timestamp, int pointId, QEventPoint::State state,
91 QPointF position, QPointF scenePosition, QPointF globalPosition)
92 {
93 QEventPoint p(pointId, state, scenePosition, globalPosition);
94 p.d->timestamp = timestamp;
95 p.d->pos = position;
96 return p;
97 }
98
99 static Q_GUI_EXPORT void update(const QEventPoint &from, QEventPoint &to);
100
101 static Q_GUI_EXPORT void detach(QEventPoint &p);
102
103#define TRIVIAL_SETTER(type, field, Field) \
104 static void set##Field (QEventPoint &p, type arg) { p.d->field = std::move(arg); } \
105 /* end */
106
107 TRIVIAL_SETTER(int, pointId, Id)
108 TRIVIAL_SETTER(const QPointingDevice *, device, Device)
109
110 // not trivial:
111 static Q_GUI_EXPORT void setTimestamp(QEventPoint &p, ulong t);
112
113 TRIVIAL_SETTER(ulong, pressTimestamp, PressTimestamp)
115 TRIVIAL_SETTER(QPointingDeviceUniqueId, uniqueId, UniqueId)
116 TRIVIAL_SETTER(QPointF, pos, Position)
117 TRIVIAL_SETTER(QPointF, scenePos, ScenePosition)
118 TRIVIAL_SETTER(QPointF, globalPos, GlobalPosition)
119
120 TRIVIAL_SETTER(QPointF, globalPressPos, GlobalPressPosition)
121 TRIVIAL_SETTER(QPointF, globalGrabPos, GlobalGrabPosition)
122 TRIVIAL_SETTER(QPointF, globalLastPos, GlobalLastPosition)
123 TRIVIAL_SETTER(QSizeF, ellipseDiameters, EllipseDiameters)
124 TRIVIAL_SETTER(qreal, pressure, Pressure)
125 TRIVIAL_SETTER(qreal, rotation, Rotation)
126 TRIVIAL_SETTER(QVector2D, velocity, Velocity)
127
128 static QWindow *window(const QEventPoint &p) { return p.d->window.data(); }
129
131
132 static QObject *target(const QEventPoint &p) { return p.d->target.data(); }
133
135
136#undef TRIVIAL_SETTER
137};
138
140
141#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:48
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: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.
\inmodule QtCore
Definition qshareddata.h:19
\inmodule QtCore
Definition qsize.h:208
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:35
double qreal
Definition qtypes.h:187
QSharedPointer< T > other(t)
[5]
aWidget window() -> setWindowTitle("New Window Title")
[2]
Target
Definition tracegen.cpp:14