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
qquickpinchhandler_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 QQUICKPINCHHANDLER_H
5#define QQUICKPINCHHANDLER_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 <QtGui/qevent.h>
19#include <QtQuick/qquickitem.h>
20
22#include <private/qquicktranslate_p.h>
23#include "qquickdragaxis_p.h"
24
26
27using namespace Qt::StringLiterals;
28
29class Q_QUICK_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler
30{
32
33 Q_PROPERTY(QQuickDragAxis *scaleAxis READ scaleAxis CONSTANT)
34#if QT_DEPRECATED_SINCE(6, 5)
35 Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged)
36 Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged)
37 Q_PROPERTY(qreal scale READ scale NOTIFY updated)
38#endif
39 Q_PROPERTY(qreal activeScale READ activeScale NOTIFY scaleChanged)
40 Q_PROPERTY(qreal persistentScale READ persistentScale WRITE setPersistentScale NOTIFY scaleChanged)
41
42 Q_PROPERTY(QQuickDragAxis *rotationAxis READ rotationAxis CONSTANT)
43#if QT_DEPRECATED_SINCE(6, 5)
44 Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
45 Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
46 Q_PROPERTY(qreal rotation READ rotation NOTIFY updated)
47#endif
48 Q_PROPERTY(qreal activeRotation READ activeRotation NOTIFY rotationChanged)
49 Q_PROPERTY(qreal persistentRotation READ persistentRotation WRITE setPersistentRotation NOTIFY rotationChanged)
50
51 Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT)
52 Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT)
53#if QT_DEPRECATED_SINCE(6, 5)
54 Q_PROPERTY(QVector2D translation READ translation NOTIFY updated)
55#endif
56 Q_PROPERTY(QPointF activeTranslation READ activeTranslation NOTIFY translationChanged REVISION(6, 5))
57 Q_PROPERTY(QPointF persistentTranslation READ persistentTranslation WRITE setPersistentTranslation NOTIFY translationChanged REVISION(6, 5))
58
59 QML_NAMED_ELEMENT(PinchHandler)
61
62public:
63 explicit QQuickPinchHandler(QQuickItem *parent = nullptr);
64
65 QQuickDragAxis *xAxis() { return &m_xAxis; }
66 QQuickDragAxis *yAxis() { return &m_yAxis; }
67#if QT_DEPRECATED_SINCE(6, 5)
68 QVector2D translation() const { return QVector2D(activeTranslation()); }
69#endif
70 QPointF activeTranslation() const { return QPointF(m_xAxis.activeValue(), m_yAxis.activeValue()); }
71 QPointF persistentTranslation() const { return QPointF(m_xAxis.persistentValue(), m_yAxis.persistentValue()); }
72 void setPersistentTranslation(const QPointF &trans);
73
74 QQuickDragAxis *scaleAxis() { return &m_scaleAxis; }
75#if QT_DEPRECATED_SINCE(6, 5)
76 qreal minimumScale() const { return m_scaleAxis.minimum(); }
77 void setMinimumScale(qreal minimumScale);
78 qreal maximumScale() const { return m_scaleAxis.maximum(); }
79 void setMaximumScale(qreal maximumScale);
80 qreal scale() const { return persistentScale(); }
81#endif
82 qreal activeScale() const { return m_scaleAxis.activeValue(); }
83 void setActiveScale(qreal scale);
84 qreal persistentScale() const { return m_scaleAxis.persistentValue(); }
85 void setPersistentScale(qreal scale);
86
87 QQuickDragAxis *rotationAxis() { return &m_rotationAxis; }
88#if QT_DEPRECATED_SINCE(6, 5)
89 qreal minimumRotation() const { return m_rotationAxis.minimum(); }
90 void setMinimumRotation(qreal minimumRotation);
91 qreal maximumRotation() const { return m_rotationAxis.maximum(); }
92 void setMaximumRotation(qreal maximumRotation);
93 qreal rotation() const { return activeRotation(); }
94#endif
95 qreal activeRotation() const { return m_rotationAxis.activeValue(); }
96 void setActiveRotation(qreal rot);
97 qreal persistentRotation() const { return m_rotationAxis.persistentValue(); }
98 void setPersistentRotation(qreal rot);
99
105 void updated();
106 void scaleChanged(qreal delta);
109
110protected:
111 bool wantsPointerEvent(QPointerEvent *event) override;
112 void onActiveChanged() override;
113 void handlePointerEventImpl(QPointerEvent *event) override;
114
115private:
116 QQuickDragAxis m_xAxis = {this, u"x"_s};
117 QQuickDragAxis m_yAxis = {this, u"y"_s};
118 QQuickDragAxis m_scaleAxis = {this, u"scale"_s, 1};
119 QQuickDragAxis m_rotationAxis = {this, u"rotation"_s};
120
121 // internal
122 qreal m_startDistance = 0;
123 qreal m_accumulatedStartCentroidDistance = 0;
124 QPointF m_startTargetPos;
125 QVector<PointData> m_startAngles;
126 QQuickMatrix4x4 m_transform;
127};
128
130
131#endif // QQUICKPINCHHANDLER_H
\inmodule QtCore\reentrant
Definition qpoint.h:217
A base class for pointer events.
Definition qevent.h:73
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
void rotationChanged(qreal delta)
void minimumScaleChanged()
qreal persistentRotation() const
QQuickDragAxis * scaleAxis()
QQuickDragAxis * rotationAxis()
void scaleChanged(qreal delta)
QQuickDragAxis * yAxis()
void maximumRotationChanged()
QPointF persistentTranslation() const
qreal persistentScale() const
void translationChanged(QVector2D delta)
void minimumRotationChanged()
void maximumScaleChanged()
QPointF activeTranslation() const
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
Combined button and popup list for selecting options.
struct _cl_event * event
GLenum GLenum GLenum GLenum GLenum scale
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
#define explicit