1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEPINCHAREA_H
43 #define QDECLARATIVEPINCHAREA_H
45 #include <qdeclarativeitem.h>
51 QT_MODULE(Declarative)
53 class Q_AUTOTEST_EXPORT QDeclarativePinch : public QObject
58 Q_PROPERTY(QGraphicsObject *target READ target WRITE setTarget RESET resetTarget)
59 Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged)
60 Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged)
61 Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged)
62 Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged)
63 Q_PROPERTY(Axis dragAxis READ axis WRITE setAxis NOTIFY dragAxisChanged)
64 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
65 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
66 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
67 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
68 Q_PROPERTY(bool active READ active NOTIFY activeChanged)
73 QGraphicsObject *target() const { return m_target; }
74 void setTarget(QGraphicsObject *target) {
75 if (target == m_target)
87 qreal minimumScale() const { return m_minScale; }
88 void setMinimumScale(qreal s) {
92 emit minimumScaleChanged();
94 qreal maximumScale() const { return m_maxScale; }
95 void setMaximumScale(qreal s) {
99 emit maximumScaleChanged();
102 qreal minimumRotation() const { return m_minRotation; }
103 void setMinimumRotation(qreal r) {
104 if (r == m_minRotation)
107 emit minimumRotationChanged();
109 qreal maximumRotation() const { return m_maxRotation; }
110 void setMaximumRotation(qreal r) {
111 if (r == m_maxRotation)
114 emit maximumRotationChanged();
117 enum Axis { NoDrag=0x00, XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
118 Axis axis() const { return m_axis; }
119 void setAxis(Axis a) {
123 emit dragAxisChanged();
126 qreal xmin() const { return m_xmin; }
127 void setXmin(qreal x) {
131 emit minimumXChanged();
133 qreal xmax() const { return m_xmax; }
134 void setXmax(qreal x) {
138 emit maximumXChanged();
140 qreal ymin() const { return m_ymin; }
141 void setYmin(qreal y) {
145 emit minimumYChanged();
147 qreal ymax() const { return m_ymax; }
148 void setYmax(qreal y) {
152 emit maximumYChanged();
155 bool active() const { return m_active; }
156 void setActive(bool a) {
160 emit activeChanged();
164 void targetChanged();
165 void minimumScaleChanged();
166 void maximumScaleChanged();
167 void minimumRotationChanged();
168 void maximumRotationChanged();
169 void dragAxisChanged();
170 void minimumXChanged();
171 void maximumXChanged();
172 void minimumYChanged();
173 void maximumYChanged();
174 void activeChanged();
177 QGraphicsObject *m_target;
190 class Q_AUTOTEST_EXPORT QDeclarativePinchEvent : public QObject
194 Q_PROPERTY(QPointF center READ center)
195 Q_PROPERTY(QPointF startCenter READ startCenter)
196 Q_PROPERTY(QPointF previousCenter READ previousCenter)
197 Q_PROPERTY(qreal scale READ scale)
198 Q_PROPERTY(qreal previousScale READ previousScale)
199 Q_PROPERTY(qreal angle READ angle)
200 Q_PROPERTY(qreal previousAngle READ previousAngle)
201 Q_PROPERTY(qreal rotation READ rotation)
202 Q_PROPERTY(QPointF point1 READ point1)
203 Q_PROPERTY(QPointF startPoint1 READ startPoint1)
204 Q_PROPERTY(QPointF point2 READ point2)
205 Q_PROPERTY(QPointF startPoint2 READ startPoint2)
206 Q_PROPERTY(int pointCount READ pointCount)
207 Q_PROPERTY(bool accepted READ accepted WRITE setAccepted)
210 QDeclarativePinchEvent(QPointF c, qreal s, qreal a, qreal r)
211 : QObject(), m_center(c), m_scale(s), m_angle(a), m_rotation(r)
212 , m_pointCount(0), m_accepted(true) {}
214 QPointF center() const { return m_center; }
215 QPointF startCenter() const { return m_startCenter; }
216 void setStartCenter(QPointF c) { m_startCenter = c; }
217 QPointF previousCenter() const { return m_lastCenter; }
218 void setPreviousCenter(QPointF c) { m_lastCenter = c; }
219 qreal scale() const { return m_scale; }
220 qreal previousScale() const { return m_lastScale; }
221 void setPreviousScale(qreal s) { m_lastScale = s; }
222 qreal angle() const { return m_angle; }
223 qreal previousAngle() const { return m_lastAngle; }
224 void setPreviousAngle(qreal a) { m_lastAngle = a; }
225 qreal rotation() const { return m_rotation; }
226 QPointF point1() const { return m_point1; }
227 void setPoint1(QPointF p) { m_point1 = p; }
228 QPointF startPoint1() const { return m_startPoint1; }
229 void setStartPoint1(QPointF p) { m_startPoint1 = p; }
230 QPointF point2() const { return m_point2; }
231 void setPoint2(QPointF p) { m_point2 = p; }
232 QPointF startPoint2() const { return m_startPoint2; }
233 void setStartPoint2(QPointF p) { m_startPoint2 = p; }
234 int pointCount() const { return m_pointCount; }
235 void setPointCount(int count) { m_pointCount = count; }
237 bool accepted() const { return m_accepted; }
238 void setAccepted(bool a) { m_accepted = a; }
242 QPointF m_startCenter;
243 QPointF m_lastCenter;
251 QPointF m_startPoint1;
252 QPointF m_startPoint2;
258 class QDeclarativeMouseEvent;
259 class QDeclarativePinchAreaPrivate;
260 class Q_AUTOTEST_EXPORT QDeclarativePinchArea : public QDeclarativeItem
264 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
265 Q_PROPERTY(QDeclarativePinch *pinch READ pinch CONSTANT)
268 QDeclarativePinchArea(QDeclarativeItem *parent=0);
269 ~QDeclarativePinchArea();
271 bool isEnabled() const;
272 void setEnabled(bool);
274 QDeclarativePinch *pinch();
277 void enabledChanged();
278 void pinchStarted(QDeclarativePinchEvent *pinch);
279 void pinchUpdated(QDeclarativePinchEvent *pinch);
280 void pinchFinished(QDeclarativePinchEvent *pinch);
283 void mousePressEvent(QGraphicsSceneMouseEvent *event);
284 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
285 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
286 bool sceneEvent(QEvent *);
287 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
288 bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
289 bool event(QEvent *);
291 virtual void geometryChanged(const QRectF &newGeometry,
292 const QRectF &oldGeometry);
293 virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
298 void handleRelease();
301 Q_DISABLE_COPY(QDeclarativePinchArea)
302 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativePinchArea)
307 QML_DECLARE_TYPE(QDeclarativePinch)
308 QML_DECLARE_TYPE(QDeclarativePinchEvent)
309 QML_DECLARE_TYPE(QDeclarativePinchArea)
313 #endif // QDECLARATIVEPINCHAREA_H