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 QtQml 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 QQUICKFLICKABLE_P_H
43 #define QQUICKFLICKABLE_P_H
45 #include "qquickitem.h"
46 #include <private/qtquickglobal_p.h>
52 class QQuickFlickablePrivate;
53 class QQuickFlickableVisibleArea;
54 class Q_QUICK_PRIVATE_EXPORT QQuickFlickable : public QQuickItem
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(QQuickItem *contentItem READ contentItem CONSTANT)
64 Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
65 Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
66 Q_PROPERTY(qreal originY READ originY NOTIFY originYChanged)
68 Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
69 Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
70 Q_PROPERTY(qreal originX READ originX NOTIFY originXChanged)
72 Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
73 Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
75 Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
76 Q_PROPERTY(QQuickTransition *rebound READ rebound WRITE setRebound NOTIFY reboundChanged)
77 Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
78 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
79 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
80 Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
81 Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
82 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
83 Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
84 Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
85 Q_PROPERTY(bool dragging READ isDragging NOTIFY draggingChanged)
86 Q_PROPERTY(bool draggingHorizontally READ isDraggingHorizontally NOTIFY draggingHorizontallyChanged)
87 Q_PROPERTY(bool draggingVertically READ isDraggingVertically NOTIFY draggingVerticallyChanged)
88 Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
90 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
91 Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
93 Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
94 Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
95 Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
96 Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
98 Q_PROPERTY(QQuickFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
100 Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY pixelAlignedChanged)
102 Q_PROPERTY(QQmlListProperty<QObject> flickableData READ flickableData)
103 Q_PROPERTY(QQmlListProperty<QQuickItem> flickableChildren READ flickableChildren)
104 Q_CLASSINFO("DefaultProperty", "flickableData")
106 Q_ENUMS(FlickableDirection)
107 Q_ENUMS(BoundsBehavior)
110 QQuickFlickable(QQuickItem *parent=0);
113 QQmlListProperty<QObject> flickableData();
114 QQmlListProperty<QQuickItem> flickableChildren();
116 enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
117 BoundsBehavior boundsBehavior() const;
118 void setBoundsBehavior(BoundsBehavior);
120 QQuickTransition *rebound() const;
121 void setRebound(QQuickTransition *transition);
123 qreal contentWidth() const;
124 void setContentWidth(qreal);
126 qreal contentHeight() const;
127 void setContentHeight(qreal);
129 qreal contentX() const;
130 virtual void setContentX(qreal pos);
132 qreal contentY() const;
133 virtual void setContentY(qreal pos);
135 qreal topMargin() const;
136 void setTopMargin(qreal m);
138 qreal bottomMargin() const;
139 void setBottomMargin(qreal m);
141 qreal leftMargin() const;
142 void setLeftMargin(qreal m);
144 qreal rightMargin() const;
145 void setRightMargin(qreal m);
147 virtual qreal originY() const;
148 virtual qreal originX() const;
150 bool isMoving() const;
151 bool isMovingHorizontally() const;
152 bool isMovingVertically() const;
153 bool isFlicking() const;
154 bool isFlickingHorizontally() const;
155 bool isFlickingVertically() const;
156 bool isDragging() const;
157 bool isDraggingHorizontally() const;
158 bool isDraggingVertically() const;
160 int pressDelay() const;
161 void setPressDelay(int delay);
163 qreal maximumFlickVelocity() const;
164 void setMaximumFlickVelocity(qreal);
166 qreal flickDeceleration() const;
167 void setFlickDeceleration(qreal);
169 bool isInteractive() const;
170 void setInteractive(bool);
172 qreal horizontalVelocity() const;
173 qreal verticalVelocity() const;
175 bool isAtXEnd() const;
176 bool isAtXBeginning() const;
177 bool isAtYEnd() const;
178 bool isAtYBeginning() const;
180 QQuickItem *contentItem();
182 enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
183 FlickableDirection flickableDirection() const;
184 void setFlickableDirection(FlickableDirection);
186 bool pixelAligned() const;
187 void setPixelAligned(bool align);
189 Q_INVOKABLE void resizeContent(qreal w, qreal h, QPointF center);
190 Q_INVOKABLE void returnToBounds();
191 Q_INVOKABLE void flick(qreal xVelocity, qreal yVelocity);
192 Q_INVOKABLE void cancelFlick();
195 void contentWidthChanged();
196 void contentHeightChanged();
197 void contentXChanged();
198 void contentYChanged();
199 void topMarginChanged();
200 void bottomMarginChanged();
201 void leftMarginChanged();
202 void rightMarginChanged();
203 void originYChanged();
204 void originXChanged();
205 void movingChanged();
206 void movingHorizontallyChanged();
207 void movingVerticallyChanged();
208 void flickingChanged();
209 void flickingHorizontallyChanged();
210 void flickingVerticallyChanged();
211 void draggingChanged();
212 void draggingHorizontallyChanged();
213 void draggingVerticallyChanged();
214 void horizontalVelocityChanged();
215 void verticalVelocityChanged();
216 void isAtBoundaryChanged();
217 void flickableDirectionChanged();
218 void interactiveChanged();
219 void boundsBehaviorChanged();
220 void reboundChanged();
221 void maximumFlickVelocityChanged();
222 void flickDecelerationChanged();
223 void pressDelayChanged();
224 void movementStarted();
225 void movementEnded();
230 void pixelAlignedChanged();
233 virtual bool childMouseEventFilter(QQuickItem *, QEvent *);
234 virtual void mousePressEvent(QMouseEvent *event);
235 virtual void mouseMoveEvent(QMouseEvent *event);
236 virtual void mouseReleaseEvent(QMouseEvent *event);
237 virtual void wheelEvent(QWheelEvent *event);
238 virtual void timerEvent(QTimerEvent *event);
240 QQuickFlickableVisibleArea *visibleArea();
243 void movementStarting();
244 void movementEnding();
245 void movementEnding(bool hMovementEnding, bool vMovementEnding);
246 void timelineCompleted();
249 virtual qreal minXExtent() const;
250 virtual qreal minYExtent() const;
251 virtual qreal maxXExtent() const;
252 virtual qreal maxYExtent() const;
253 qreal vWidth() const;
254 qreal vHeight() const;
255 virtual void componentComplete();
256 virtual void viewportMoved(Qt::Orientations orient);
257 virtual void geometryChanged(const QRectF &newGeometry,
258 const QRectF &oldGeometry);
259 void mouseUngrabEvent();
260 bool sendMouseEvent(QMouseEvent *event);
266 QQuickFlickable(QQuickFlickablePrivate &dd, QQuickItem *parent);
269 Q_DISABLE_COPY(QQuickFlickable)
270 Q_DECLARE_PRIVATE(QQuickFlickable)
271 friend class QQuickFlickableVisibleArea;
272 friend class QQuickFlickableReboundTransition;
277 QML_DECLARE_TYPE(QQuickFlickable)
281 #endif // QQUICKFLICKABLE_P_H