1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEPINCHAREA_H
43 #define QDECLARATIVEPINCHAREA_H
45 #include <qdeclarativeitem.h>
52 class Q_AUTOTEST_EXPORT QDeclarative1Pinch : public QObject
57 Q_PROPERTY(QGraphicsObject *target READ target WRITE setTarget RESET resetTarget)
58 Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged)
59 Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged)
60 Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
61 Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
62 Q_PROPERTY(Axis dragAxis READ axis WRITE setAxis NOTIFY dragAxisChanged)
63 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
64 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
65 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
66 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
67 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
72 QGraphicsObject *target() const { return m_target; }
73 void setTarget(QGraphicsObject *target) {
74 if (target == m_target)
86 qreal minimumScale() const { return m_minScale; }
87 void setMinimumScale(qreal s) {
91 emit minimumScaleChanged();
93 qreal maximumScale() const { return m_maxScale; }
94 void setMaximumScale(qreal s) {
98 emit maximumScaleChanged();
101 qreal minimumRotation() const { return m_minRotation; }
102 void setMinimumRotation(qreal r) {
103 if (r == m_minRotation)
106 emit minimumRotationChanged();
108 qreal maximumRotation() const { return m_maxRotation; }
109 void setMaximumRotation(qreal r) {
110 if (r == m_maxRotation)
113 emit maximumRotationChanged();
116 enum Axis { NoDrag=0x00, XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
117 Axis axis() const { return m_axis; }
118 void setAxis(Axis a) {
122 emit dragAxisChanged();
125 qreal xmin() const { return m_xmin; }
126 void setXmin(qreal x) {
130 emit minimumXChanged();
132 qreal xmax() const { return m_xmax; }
133 void setXmax(qreal x) {
137 emit maximumXChanged();
139 qreal ymin() const { return m_ymin; }
140 void setYmin(qreal y) {
144 emit minimumYChanged();
146 qreal ymax() const { return m_ymax; }
147 void setYmax(qreal y) {
151 emit maximumYChanged();
154 bool active() const { return m_active; }
155 void setActive(bool a) {
159 emit activeChanged();
163 void targetChanged();
164 void minimumScaleChanged();
165 void maximumScaleChanged();
166 void minimumRotationChanged();
167 void maximumRotationChanged();
168 void dragAxisChanged();
169 void minimumXChanged();
170 void maximumXChanged();
171 void minimumYChanged();
172 void maximumYChanged();
173 void activeChanged();
176 QGraphicsObject *m_target;
189 class Q_AUTOTEST_EXPORT QDeclarative1PinchEvent : public QObject
193 Q_PROPERTY(QPointF center READ center)
194 Q_PROPERTY(QPointF startCenter READ startCenter)
195 Q_PROPERTY(QPointF previousCenter READ previousCenter)
196 Q_PROPERTY(qreal scale READ scale)
197 Q_PROPERTY(qreal previousScale READ previousScale)
198 Q_PROPERTY(qreal angle READ angle)
199 Q_PROPERTY(qreal previousAngle READ previousAngle)
200 Q_PROPERTY(qreal rotation READ rotation)
201 Q_PROPERTY(QPointF point1 READ point1)
202 Q_PROPERTY(QPointF startPoint1 READ startPoint1)
203 Q_PROPERTY(QPointF point2 READ point2)
204 Q_PROPERTY(QPointF startPoint2 READ startPoint2)
205 Q_PROPERTY(int pointCount READ pointCount)
206 Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
209 QDeclarative1PinchEvent(QPointF c, qreal s, qreal a, qreal r)
210 : QObject(), m_center(c), m_scale(s), m_angle(a), m_rotation(r)
211 , m_pointCount(0), m_accepted(true) {}
213 QPointF center() const { return m_center; }
214 QPointF startCenter() const { return m_startCenter; }
215 void setStartCenter(QPointF c) { m_startCenter = c; }
216 QPointF previousCenter() const { return m_lastCenter; }
217 void setPreviousCenter(QPointF c) { m_lastCenter = c; }
218 qreal scale() const { return m_scale; }
219 qreal previousScale() const { return m_lastScale; }
220 void setPreviousScale(qreal s) { m_lastScale = s; }
221 qreal angle() const { return m_angle; }
222 qreal previousAngle() const { return m_lastAngle; }
223 void setPreviousAngle(qreal a) { m_lastAngle = a; }
224 qreal rotation() const { return m_rotation; }
225 QPointF point1() const { return m_point1; }
226 void setPoint1(QPointF p) { m_point1 = p; }
227 QPointF startPoint1() const { return m_startPoint1; }
228 void setStartPoint1(QPointF p) { m_startPoint1 = p; }
229 QPointF point2() const { return m_point2; }
230 void setPoint2(QPointF p) { m_point2 = p; }
231 QPointF startPoint2() const { return m_startPoint2; }
232 void setStartPoint2(QPointF p) { m_startPoint2 = p; }
233 int pointCount() const { return m_pointCount; }
234 void setPointCount(int count) { m_pointCount = count; }
236 bool accepted() const { return m_accepted; }
237 void setAccepted(bool a) { m_accepted = a; }
241 QPointF m_startCenter;
242 QPointF m_lastCenter;
250 QPointF m_startPoint1;
251 QPointF m_startPoint2;
257 class QDeclarative1MouseEvent;
258 class QDeclarative1PinchAreaPrivate;
259 class Q_AUTOTEST_EXPORT QDeclarative1PinchArea : public QDeclarativeItem
263 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
264 Q_PROPERTY(QDeclarative1Pinch *pinch READ pinch CONSTANT)
267 QDeclarative1PinchArea(QDeclarativeItem *parent=0);
268 ~QDeclarative1PinchArea();
270 bool isEnabled() const;
271 void setEnabled(bool);
273 QDeclarative1Pinch *pinch();
276 void enabledChanged();
277 void pinchStarted(QDeclarative1PinchEvent *pinch);
278 void pinchUpdated(QDeclarative1PinchEvent *pinch);
279 void pinchFinished(QDeclarative1PinchEvent *pinch);
282 void mousePressEvent(QGraphicsSceneMouseEvent *event);
283 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
284 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
285 bool sceneEvent(QEvent *);
286 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
287 bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
288 bool event(QEvent *);
290 virtual void geometryChanged(const QRectF &newGeometry,
291 const QRectF &oldGeometry);
292 virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
297 void handleRelease();
300 Q_DISABLE_COPY(QDeclarative1PinchArea)
301 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1PinchArea)
306 QML_DECLARE_TYPE(QDeclarative1Pinch)
307 QML_DECLARE_TYPE(QDeclarative1PinchEvent)
308 QML_DECLARE_TYPE(QDeclarative1PinchArea)
312 #endif // QDECLARATIVEPINCHAREA_H