1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtSG module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
42 #ifndef QQUICKPINCHAREA_H
43 #define QQUICKPINCHAREA_H
45 #include "qquickitem.h"
51 class Q_AUTOTEST_EXPORT QQuickPinch : public QObject
56 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget RESET resetTarget)
57 Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged)
58 Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged)
59 Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
60 Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
61 Q_PROPERTY(Axis dragAxis READ axis WRITE setAxis NOTIFY dragAxisChanged)
62 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
63 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
64 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
65 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
66 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
71 QQuickItem *target() const { return m_target; }
72 void setTarget(QQuickItem *target) {
73 if (target == m_target)
85 qreal minimumScale() const { return m_minScale; }
86 void setMinimumScale(qreal s) {
90 emit minimumScaleChanged();
92 qreal maximumScale() const { return m_maxScale; }
93 void setMaximumScale(qreal s) {
97 emit maximumScaleChanged();
100 qreal minimumRotation() const { return m_minRotation; }
101 void setMinimumRotation(qreal r) {
102 if (r == m_minRotation)
105 emit minimumRotationChanged();
107 qreal maximumRotation() const { return m_maxRotation; }
108 void setMaximumRotation(qreal r) {
109 if (r == m_maxRotation)
112 emit maximumRotationChanged();
115 enum Axis { NoDrag=0x00, XAxis=0x01, YAxis=0x02, XAndYAxis=0x03, XandYAxis=XAndYAxis };
116 Axis axis() const { return m_axis; }
117 void setAxis(Axis a) {
121 emit dragAxisChanged();
124 qreal xmin() const { return m_xmin; }
125 void setXmin(qreal x) {
129 emit minimumXChanged();
131 qreal xmax() const { return m_xmax; }
132 void setXmax(qreal x) {
136 emit maximumXChanged();
138 qreal ymin() const { return m_ymin; }
139 void setYmin(qreal y) {
143 emit minimumYChanged();
145 qreal ymax() const { return m_ymax; }
146 void setYmax(qreal y) {
150 emit maximumYChanged();
153 bool active() const { return m_active; }
154 void setActive(bool a) {
158 emit activeChanged();
162 void targetChanged();
163 void minimumScaleChanged();
164 void maximumScaleChanged();
165 void minimumRotationChanged();
166 void maximumRotationChanged();
167 void dragAxisChanged();
168 void minimumXChanged();
169 void maximumXChanged();
170 void minimumYChanged();
171 void maximumYChanged();
172 void activeChanged();
175 QQuickItem *m_target;
188 class Q_AUTOTEST_EXPORT QQuickPinchEvent : public QObject
192 Q_PROPERTY(QPointF center READ center)
193 Q_PROPERTY(QPointF startCenter READ startCenter)
194 Q_PROPERTY(QPointF previousCenter READ previousCenter)
195 Q_PROPERTY(qreal scale READ scale)
196 Q_PROPERTY(qreal previousScale READ previousScale)
197 Q_PROPERTY(qreal angle READ angle)
198 Q_PROPERTY(qreal previousAngle READ previousAngle)
199 Q_PROPERTY(qreal rotation READ rotation)
200 Q_PROPERTY(QPointF point1 READ point1)
201 Q_PROPERTY(QPointF startPoint1 READ startPoint1)
202 Q_PROPERTY(QPointF point2 READ point2)
203 Q_PROPERTY(QPointF startPoint2 READ startPoint2)
204 Q_PROPERTY(int pointCount READ pointCount)
205 Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
208 QQuickPinchEvent(QPointF c, qreal s, qreal a, qreal r)
209 : QObject(), m_center(c), m_scale(s), m_angle(a), m_rotation(r)
210 , m_pointCount(0), m_accepted(true) {}
212 QPointF center() const { return m_center; }
213 QPointF startCenter() const { return m_startCenter; }
214 void setStartCenter(QPointF c) { m_startCenter = c; }
215 QPointF previousCenter() const { return m_lastCenter; }
216 void setPreviousCenter(QPointF c) { m_lastCenter = c; }
217 qreal scale() const { return m_scale; }
218 qreal previousScale() const { return m_lastScale; }
219 void setPreviousScale(qreal s) { m_lastScale = s; }
220 qreal angle() const { return m_angle; }
221 qreal previousAngle() const { return m_lastAngle; }
222 void setPreviousAngle(qreal a) { m_lastAngle = a; }
223 qreal rotation() const { return m_rotation; }
224 QPointF point1() const { return m_point1; }
225 void setPoint1(QPointF p) { m_point1 = p; }
226 QPointF startPoint1() const { return m_startPoint1; }
227 void setStartPoint1(QPointF p) { m_startPoint1 = p; }
228 QPointF point2() const { return m_point2; }
229 void setPoint2(QPointF p) { m_point2 = p; }
230 QPointF startPoint2() const { return m_startPoint2; }
231 void setStartPoint2(QPointF p) { m_startPoint2 = p; }
232 int pointCount() const { return m_pointCount; }
233 void setPointCount(int count) { m_pointCount = count; }
235 bool accepted() const { return m_accepted; }
236 void setAccepted(bool a) { m_accepted = a; }
240 QPointF m_startCenter;
241 QPointF m_lastCenter;
249 QPointF m_startPoint1;
250 QPointF m_startPoint2;
256 class QQuickMouseEvent;
257 class QQuickPinchAreaPrivate;
258 class Q_AUTOTEST_EXPORT QQuickPinchArea : public QQuickItem
262 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
263 Q_PROPERTY(QQuickPinch *pinch READ pinch CONSTANT)
266 QQuickPinchArea(QQuickItem *parent=0);
269 bool isEnabled() const;
270 void setEnabled(bool);
272 QQuickPinch *pinch();
275 void enabledChanged();
276 void pinchStarted(QQuickPinchEvent *pinch);
277 void pinchUpdated(QQuickPinchEvent *pinch);
278 void pinchFinished(QQuickPinchEvent *pinch);
281 virtual bool childMouseEventFilter(QQuickItem *i, QEvent *e);
282 virtual void touchEvent(QTouchEvent *event);
284 virtual void geometryChanged(const QRectF &newGeometry,
285 const QRectF &oldGeometry);
286 virtual void itemChange(ItemChange change, const ItemChangeData& value);
291 void handleRelease();
294 Q_DISABLE_COPY(QQuickPinchArea)
295 Q_DECLARE_PRIVATE(QQuickPinchArea)
300 QML_DECLARE_TYPE(QQuickPinch)
301 QML_DECLARE_TYPE(QQuickPinchEvent)
302 QML_DECLARE_TYPE(QQuickPinchArea)
306 #endif // QQUICKPINCHAREA_H