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
qquickpincharea_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 QQUICKPINCHAREA_H
5#define QQUICKPINCHAREA_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 "qquickitem.h"
21
23
24class Q_QUICK_EXPORT QQuickPinch : public QObject
25{
27
28 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget RESET resetTarget NOTIFY targetChanged)
29 Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged)
30 Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged)
31 Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
32 Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
33 Q_PROPERTY(Axis dragAxis READ axis WRITE setAxis NOTIFY dragAxisChanged)
34 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
35 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
36 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
37 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
38 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
41
42public:
44
45 QQuickItem *target() const { return m_target; }
47 if (target == m_target)
48 return;
49 m_target = target;
50 Q_EMIT targetChanged();
51 }
52 void resetTarget() {
53 if (!m_target)
54 return;
55 m_target = nullptr;
56 Q_EMIT targetChanged();
57 }
58
59 qreal minimumScale() const { return m_minScale; }
61 if (s == m_minScale)
62 return;
63 m_minScale = s;
64 Q_EMIT minimumScaleChanged();
65 }
66 qreal maximumScale() const { return m_maxScale; }
68 if (s == m_maxScale)
69 return;
70 m_maxScale = s;
71 Q_EMIT maximumScaleChanged();
72 }
73
74 qreal minimumRotation() const { return m_minRotation; }
76 if (r == m_minRotation)
77 return;
78 m_minRotation = r;
79 Q_EMIT minimumRotationChanged();
80 }
81 qreal maximumRotation() const { return m_maxRotation; }
83 if (r == m_maxRotation)
84 return;
85 m_maxRotation = r;
86 Q_EMIT maximumRotationChanged();
87 }
88
89 enum Axis { NoDrag=0x00, XAxis=0x01, YAxis=0x02, XAndYAxis=0x03, XandYAxis=XAndYAxis };
90 Q_ENUM(Axis)
91 Axis axis() const { return m_axis; }
92 void setAxis(Axis a) {
93 if (a == m_axis)
94 return;
95 m_axis = a;
96 Q_EMIT dragAxisChanged();
97 }
98
99 qreal xmin() const { return m_xmin; }
101 if (x == m_xmin)
102 return;
103 m_xmin = x;
104 Q_EMIT minimumXChanged();
105 }
106 qreal xmax() const { return m_xmax; }
108 if (x == m_xmax)
109 return;
110 m_xmax = x;
111 Q_EMIT maximumXChanged();
112 }
113 qreal ymin() const { return m_ymin; }
115 if (y == m_ymin)
116 return;
117 m_ymin = y;
118 Q_EMIT minimumYChanged();
119 }
120 qreal ymax() const { return m_ymax; }
122 if (y == m_ymax)
123 return;
124 m_ymax = y;
125 Q_EMIT maximumYChanged();
126 }
127
128 bool active() const { return m_active; }
129 void setActive(bool a) {
130 if (a == m_active)
131 return;
132 m_active = a;
133 Q_EMIT activeChanged();
134 }
135
148
149private:
150 QQuickItem *m_target;
151 qreal m_minScale;
152 qreal m_maxScale;
153 qreal m_minRotation;
154 qreal m_maxRotation;
155 Axis m_axis;
156 qreal m_xmin;
157 qreal m_xmax;
158 qreal m_ymin;
159 qreal m_ymax;
160 bool m_active;
161};
162
163class Q_QUICK_EXPORT QQuickPinchEvent : public QObject
164{
166
167 Q_PROPERTY(QPointF center READ center FINAL)
168 Q_PROPERTY(QPointF startCenter READ startCenter FINAL)
169 Q_PROPERTY(QPointF previousCenter READ previousCenter FINAL)
171 Q_PROPERTY(qreal previousScale READ previousScale FINAL)
173 Q_PROPERTY(qreal previousAngle READ previousAngle FINAL)
174 Q_PROPERTY(qreal rotation READ rotation FINAL)
175 Q_PROPERTY(QPointF point1 READ point1 FINAL)
176 Q_PROPERTY(QPointF startPoint1 READ startPoint1 FINAL)
177 Q_PROPERTY(QPointF point2 READ point2 FINAL)
178 Q_PROPERTY(QPointF startPoint2 READ startPoint2 FINAL)
179 Q_PROPERTY(int pointCount READ pointCount FINAL)
180 Q_PROPERTY(bool accepted READ accepted WRITE setAccepted FINAL)
183
184public:
186 : QObject(), m_center(c), m_scale(s), m_angle(a), m_rotation(r)
187 , m_pointCount(0), m_accepted(true) {}
188
189 QPointF center() const { return m_center; }
190 QPointF startCenter() const { return m_startCenter; }
191 void setStartCenter(QPointF c) { m_startCenter = c; }
192 QPointF previousCenter() const { return m_lastCenter; }
193 void setPreviousCenter(QPointF c) { m_lastCenter = c; }
194 qreal scale() const { return m_scale; }
195 qreal previousScale() const { return m_lastScale; }
196 void setPreviousScale(qreal s) { m_lastScale = s; }
197 qreal angle() const { return m_angle; }
198 qreal previousAngle() const { return m_lastAngle; }
199 void setPreviousAngle(qreal a) { m_lastAngle = a; }
200 qreal rotation() const { return m_rotation; }
201 QPointF point1() const { return m_point1; }
202 void setPoint1(QPointF p) { m_point1 = p; }
203 QPointF startPoint1() const { return m_startPoint1; }
204 void setStartPoint1(QPointF p) { m_startPoint1 = p; }
205 QPointF point2() const { return m_point2; }
206 void setPoint2(QPointF p) { m_point2 = p; }
207 QPointF startPoint2() const { return m_startPoint2; }
208 void setStartPoint2(QPointF p) { m_startPoint2 = p; }
209 int pointCount() const { return m_pointCount; }
210 void setPointCount(int count) { m_pointCount = count; }
211
212 bool accepted() const { return m_accepted; }
213 void setAccepted(bool a) { m_accepted = a; }
214
215private:
216 QPointF m_center;
217 QPointF m_startCenter;
218 QPointF m_lastCenter;
219 qreal m_scale;
220 qreal m_lastScale;
221 qreal m_angle;
222 qreal m_lastAngle;
223 qreal m_rotation;
224 QPointF m_point1;
225 QPointF m_point2;
226 QPointF m_startPoint1;
227 QPointF m_startPoint2;
228 int m_pointCount;
229 bool m_accepted;
230};
231
232
234class Q_QUICK_EXPORT QQuickPinchArea : public QQuickItem
235{
237
238 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
239 Q_PROPERTY(QQuickPinch *pinch READ pinch CONSTANT)
240 QML_NAMED_ELEMENT(PinchArea)
242
243public:
244 QQuickPinchArea(QQuickItem *parent=nullptr);
246
247 bool isEnabled() const;
248 void setEnabled(bool);
249
250 QQuickPinch *pinch();
251
253 void enabledChanged();
254 void pinchStarted(QQuickPinchEvent *pinch);
255 void pinchUpdated(QQuickPinchEvent *pinch);
256 void pinchFinished(QQuickPinchEvent *pinch);
257 Q_REVISION(2, 5) void smartZoom(QQuickPinchEvent *pinch);
258
259protected:
260 bool childMouseEventFilter(QQuickItem *i, QEvent *e) override;
261 void touchEvent(QTouchEvent *event) override;
262
263 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
264 void itemChange(ItemChange change, const ItemChangeData& value) override;
265 bool event(QEvent *) override;
266
267private:
268 void clearPinch(QTouchEvent *event);
269 void cancelPinch(QTouchEvent *event);
270 void updatePinch(QTouchEvent *event, bool filtering);
271 void updatePinchTarget();
272
273private:
274 Q_DISABLE_COPY(QQuickPinchArea)
275 Q_DECLARE_PRIVATE(QQuickPinchArea)
276};
277
279
280#endif // QQUICKPINCHAREA_H
281
bool m_active
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:144
void setPreviousCenter(QPointF c)
void setPreviousScale(qreal s)
void setStartPoint2(QPointF p)
void setStartPoint1(QPointF p)
void setPoint1(QPointF p)
void setStartCenter(QPointF c)
void setPoint2(QPointF p)
qreal previousScale() const
qreal previousAngle() const
qreal rotation() const
void setPointCount(int count)
QPointF point2() const
QPointF previousCenter() const
void setPreviousAngle(qreal a)
QPointF startPoint2() const
QPointF point1() const
QPointF startCenter() const
void setAccepted(bool a)
QPointF startPoint1() const
QPointF center() const
void maximumXChanged()
qreal minimumRotation() const
qreal maximumRotation() const
void setXmax(qreal x)
qreal maximumScale() const
void setMinimumScale(qreal s)
void minimumScaleChanged()
qreal ymin() const
void dragAxisChanged()
void maximumYChanged()
void activeChanged()
void setXmin(qreal x)
void minimumYChanged()
void setYmin(qreal y)
void maximumScaleChanged()
void minimumRotationChanged()
void setMaximumScale(qreal s)
qreal xmin() const
void minimumXChanged()
void setTarget(QQuickItem *target)
qreal xmax() const
void setAxis(Axis a)
bool active() const
void maximumRotationChanged()
qreal minimumScale() const
void targetChanged()
void setActive(bool a)
void setMaximumRotation(qreal r)
void setMinimumRotation(qreal r)
void setYmax(qreal y)
qreal ymax() const
\inmodule QtCore\reentrant
Definition qrect.h:484
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLboolean r
[2]
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat angle
GLenum target
GLint y
struct _cl_event * event
GLdouble s
[6]
Definition qopenglext.h:235
const GLubyte * c
GLfloat GLfloat p
[1]
GLenum GLenum GLenum GLenum GLenum scale
#define QML_ANONYMOUS
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_REVISION(...)
#define Q_EMIT
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
\inmodule QtQuick
Definition qquickitem.h:159