Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKPINCHHANDLER_H
6#define QQUICKPINCHHANDLER_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/qevent.h>
20#include <QtQuick/qquickitem.h>
21
23#include <private/qquicktranslate_p.h>
25
27
28using namespace Qt::StringLiterals;
29
30class Q_QUICK_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler
31{
32 Q_OBJECT
33
34 Q_PROPERTY(QQuickDragAxis *scaleAxis READ scaleAxis CONSTANT)
35#if QT_DEPRECATED_SINCE(6, 5)
36 Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged)
37 Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged)
38 Q_PROPERTY(qreal scale READ scale NOTIFY updated)
39#endif
40 Q_PROPERTY(qreal activeScale READ activeScale NOTIFY scaleChanged)
41 Q_PROPERTY(qreal persistentScale READ persistentScale WRITE setPersistentScale NOTIFY scaleChanged)
42
43 Q_PROPERTY(QQuickDragAxis *rotationAxis READ rotationAxis CONSTANT)
44#if QT_DEPRECATED_SINCE(6, 5)
45 Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
46 Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
47 Q_PROPERTY(qreal rotation READ rotation NOTIFY updated)
48#endif
49 Q_PROPERTY(qreal activeRotation READ activeRotation NOTIFY rotationChanged)
50 Q_PROPERTY(qreal persistentRotation READ persistentRotation WRITE setPersistentRotation NOTIFY rotationChanged)
51
52 Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT)
53 Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT)
54#if QT_DEPRECATED_SINCE(6, 5)
55 Q_PROPERTY(QVector2D translation READ translation NOTIFY updated)
56#endif
57 Q_PROPERTY(QPointF activeTranslation READ activeTranslation NOTIFY translationChanged REVISION(6, 5))
58 Q_PROPERTY(QPointF persistentTranslation READ persistentTranslation WRITE setPersistentTranslation NOTIFY translationChanged REVISION(6, 5))
59
60 QML_NAMED_ELEMENT(PinchHandler)
61 QML_ADDED_IN_VERSION(2, 12)
62
63public:
64 explicit QQuickPinchHandler(QQuickItem *parent = nullptr);
65
66 QQuickDragAxis *xAxis() { return &m_xAxis; }
67 QQuickDragAxis *yAxis() { return &m_yAxis; }
68#if QT_DEPRECATED_SINCE(6, 5)
69 QVector2D translation() const { return QVector2D(activeTranslation()); }
70#endif
71 QPointF activeTranslation() const { return QPointF(m_xAxis.activeValue(), m_yAxis.activeValue()); }
72 QPointF persistentTranslation() const { return QPointF(m_xAxis.persistentValue(), m_yAxis.persistentValue()); }
73 void setPersistentTranslation(const QPointF &trans);
74
75 QQuickDragAxis *scaleAxis() { return &m_scaleAxis; }
76#if QT_DEPRECATED_SINCE(6, 5)
77 qreal minimumScale() const { return m_scaleAxis.minimum(); }
78 void setMinimumScale(qreal minimumScale);
79 qreal maximumScale() const { return m_scaleAxis.maximum(); }
80 void setMaximumScale(qreal maximumScale);
81 qreal scale() const { return persistentScale(); }
82#endif
83 qreal activeScale() const { return m_scaleAxis.activeValue(); }
84 void setActiveScale(qreal scale);
85 qreal persistentScale() const { return m_scaleAxis.persistentValue(); }
86 void setPersistentScale(qreal scale);
87
88 QQuickDragAxis *rotationAxis() { return &m_rotationAxis; }
89#if QT_DEPRECATED_SINCE(6, 5)
90 qreal minimumRotation() const { return m_rotationAxis.minimum(); }
91 void setMinimumRotation(qreal minimumRotation);
92 qreal maximumRotation() const { return m_rotationAxis.maximum(); }
93 void setMaximumRotation(qreal maximumRotation);
94 qreal rotation() const { return activeRotation(); }
95#endif
96 qreal activeRotation() const { return m_rotationAxis.activeValue(); }
97 void setActiveRotation(qreal rot);
98 qreal persistentRotation() const { return m_rotationAxis.persistentValue(); }
99 void setPersistentRotation(qreal rot);
100
101Q_SIGNALS:
102 void minimumScaleChanged();
103 void maximumScaleChanged();
104 void minimumRotationChanged();
105 void maximumRotationChanged();
106 void updated();
107 void scaleChanged(qreal delta);
108 void rotationChanged(qreal delta);
109 void translationChanged(QVector2D delta);
110
111protected:
112 bool wantsPointerEvent(QPointerEvent *event) override;
113 void onActiveChanged() override;
114 void handlePointerEventImpl(QPointerEvent *event) override;
115
116private:
117 QQuickDragAxis m_xAxis = {this, u"x"_s};
118 QQuickDragAxis m_yAxis = {this, u"y"_s};
119 QQuickDragAxis m_scaleAxis = {this, u"scale"_s, 1};
120 QQuickDragAxis m_rotationAxis = {this, u"rotation"_s};
121
122 // internal
123 qreal m_startDistance = 0;
124 qreal m_accumulatedStartCentroidDistance = 0;
125 QPointF m_startTargetPos;
126 QVector<PointData> m_startAngles;
127 QQuickMatrix4x4 m_transform;
128};
129
130QT_END_NAMESPACE
131
132#endif // QQUICKPINCHHANDLER_H
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")