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)
40 Q_PROPERTY(qreal activeScale READ activeScale NOTIFY scaleChanged)
41 Q_PROPERTY(qreal persistentScale READ persistentScale WRITE setPersistentScale NOTIFY scaleChanged)
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)
49 Q_PROPERTY(qreal activeRotation READ activeRotation NOTIFY rotationChanged)
50 Q_PROPERTY(qreal persistentRotation READ persistentRotation WRITE setPersistentRotation NOTIFY rotationChanged)
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)
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))
60 QML_NAMED_ELEMENT(PinchHandler)
61 QML_ADDED_IN_VERSION(2, 12)
64 explicit QQuickPinchHandler(QQuickItem *parent =
nullptr);
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()); }
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);
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(); }
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);
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(); }
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);
102 void minimumScaleChanged();
103 void maximumScaleChanged();
104 void minimumRotationChanged();
105 void maximumRotationChanged();
107 void scaleChanged(qreal delta);
108 void rotationChanged(qreal delta);
109 void translationChanged(QVector2D delta);
112 bool wantsPointerEvent(QPointerEvent *event) override;
113 void onActiveChanged() override;
114 void handlePointerEventImpl(QPointerEvent *event) override;
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};
123 qreal m_startDistance = 0;
124 qreal m_accumulatedStartCentroidDistance = 0;
125 QPointF m_startTargetPos;
126 QVector<PointData> m_startAngles;
127 QQuickMatrix4x4 m_transform;