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 QDECLARATIVEFLICKABLE_H
43 #define QDECLARATIVEFLICKABLE_H
45 #include "qdeclarativeitem.h"
52 class QDeclarative1FlickablePrivate;
53 class QDeclarative1FlickableVisibleArea;
54 class Q_AUTOTEST_EXPORT QDeclarative1Flickable : public QDeclarativeItem
58 Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
59 Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
60 Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
61 Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
62 Q_PROPERTY(QDeclarativeItem *contentItem READ contentItem CONSTANT)
64 Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
65 Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
67 Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
68 Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
69 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
70 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
71 Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
72 Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
73 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
74 Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
75 Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
76 Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
78 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
79 Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
81 Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
82 Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
83 Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
84 Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
86 Q_PROPERTY(QDeclarative1FlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
88 Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
89 Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> flickableChildren READ flickableChildren)
90 Q_CLASSINFO("DefaultProperty", "flickableData")
92 Q_ENUMS(FlickableDirection)
93 Q_ENUMS(BoundsBehavior)
96 QDeclarative1Flickable(QDeclarativeItem *parent=0);
97 ~QDeclarative1Flickable();
99 QDeclarativeListProperty<QObject> flickableData();
100 QDeclarativeListProperty<QGraphicsObject> flickableChildren();
102 enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
103 BoundsBehavior boundsBehavior() const;
104 void setBoundsBehavior(BoundsBehavior);
106 qreal contentWidth() const;
107 void setContentWidth(qreal);
109 qreal contentHeight() const;
110 void setContentHeight(qreal);
112 qreal contentX() const;
113 virtual void setContentX(qreal pos);
115 qreal contentY() const;
116 virtual void setContentY(qreal pos);
118 bool isMoving() const;
119 bool isMovingHorizontally() const;
120 bool isMovingVertically() const;
121 bool isFlicking() const;
122 bool isFlickingHorizontally() const;
123 bool isFlickingVertically() const;
125 int pressDelay() const;
126 void setPressDelay(int delay);
128 qreal maximumFlickVelocity() const;
129 void setMaximumFlickVelocity(qreal);
131 qreal flickDeceleration() const;
132 void setFlickDeceleration(qreal);
134 bool isInteractive() const;
135 void setInteractive(bool);
137 qreal horizontalVelocity() const;
138 qreal verticalVelocity() const;
140 bool isAtXEnd() const;
141 bool isAtXBeginning() const;
142 bool isAtYEnd() const;
143 bool isAtYBeginning() const;
145 QDeclarativeItem *contentItem();
147 enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
148 FlickableDirection flickableDirection() const;
149 void setFlickableDirection(FlickableDirection);
151 Q_INVOKABLE Q_REVISION(1) void resizeContent(qreal w, qreal h, QPointF center);
152 Q_INVOKABLE Q_REVISION(1) void returnToBounds();
155 void contentWidthChanged();
156 void contentHeightChanged();
157 void contentXChanged();
158 void contentYChanged();
159 void movingChanged();
160 void movingHorizontallyChanged();
161 void movingVerticallyChanged();
162 void flickingChanged();
163 void flickingHorizontallyChanged();
164 void flickingVerticallyChanged();
165 void horizontalVelocityChanged();
166 void verticalVelocityChanged();
167 void isAtBoundaryChanged();
168 void flickableDirectionChanged();
169 void interactiveChanged();
170 void boundsBehaviorChanged();
171 void maximumFlickVelocityChanged();
172 void flickDecelerationChanged();
173 void pressDelayChanged();
174 void movementStarted();
175 void movementEnded();
180 virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
181 void mousePressEvent(QGraphicsSceneMouseEvent *event);
182 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
183 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
184 void wheelEvent(QGraphicsSceneWheelEvent *event);
185 void timerEvent(QTimerEvent *event);
187 QDeclarative1FlickableVisibleArea *visibleArea();
190 virtual void ticked();
191 void movementStarting();
192 void movementEnding();
195 void movementXEnding();
196 void movementYEnding();
197 virtual qreal minXExtent() const;
198 virtual qreal minYExtent() const;
199 virtual qreal maxXExtent() const;
200 virtual qreal maxYExtent() const;
201 qreal vWidth() const;
202 qreal vHeight() const;
203 virtual void viewportMoved();
204 virtual void geometryChanged(const QRectF &newGeometry,
205 const QRectF &oldGeometry);
206 bool sceneEvent(QEvent *event);
207 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
214 QDeclarative1Flickable(QDeclarative1FlickablePrivate &dd, QDeclarativeItem *parent);
217 Q_DISABLE_COPY(QDeclarative1Flickable)
218 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flickable)
219 friend class QDeclarative1FlickableVisibleArea;
224 QML_DECLARE_TYPE(QDeclarative1Flickable)