1 // Commit: 1bcddaaf318fc37c71c5191913f3487c49444ec6
2 /****************************************************************************
4 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this
15 ** file. Please review the following information to ensure the GNU Lesser
16 ** General Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
23 ** GNU General Public License Usage
24 ** Alternatively, this file may be used under the terms of the GNU General
25 ** Public License version 3.0 as published by the Free Software Foundation
26 ** and appearing in the file LICENSE.GPL included in the packaging of this
27 ** file. Please review the following information to ensure the GNU General
28 ** Public License version 3.0 requirements will be met:
29 ** http://www.gnu.org/copyleft/gpl.html.
32 ** Alternatively, this file may be used in accordance with the terms and
33 ** conditions contained in a signed written agreement between you and Nokia.
41 ****************************************************************************/
43 #ifndef QSGFLICKABLE_P_H
44 #define QSGFLICKABLE_P_H
52 QT_MODULE(Declarative)
54 class QSGFlickablePrivate;
55 class QSGFlickableVisibleArea;
56 class Q_AUTOTEST_EXPORT QSGFlickable : public QSGItem
60 Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
61 Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
62 Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
63 Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
64 Q_PROPERTY(QSGItem *contentItem READ contentItem CONSTANT)
66 Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
67 Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
69 Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
70 Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
71 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
72 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
73 Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
74 Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
75 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
76 Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
77 Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
78 Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
80 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
81 Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
83 Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
84 Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
85 Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
86 Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
88 Q_PROPERTY(QSGFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
90 Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
91 Q_PROPERTY(QDeclarativeListProperty<QSGItem> flickableChildren READ flickableChildren)
92 Q_CLASSINFO("DefaultProperty", "flickableData")
94 Q_ENUMS(FlickableDirection)
95 Q_ENUMS(BoundsBehavior)
98 QSGFlickable(QSGItem *parent=0);
101 QDeclarativeListProperty<QObject> flickableData();
102 QDeclarativeListProperty<QSGItem> flickableChildren();
104 enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
105 BoundsBehavior boundsBehavior() const;
106 void setBoundsBehavior(BoundsBehavior);
108 qreal contentWidth() const;
109 void setContentWidth(qreal);
111 qreal contentHeight() const;
112 void setContentHeight(qreal);
114 qreal contentX() const;
115 virtual void setContentX(qreal pos);
117 qreal contentY() const;
118 virtual void setContentY(qreal pos);
120 bool isMoving() const;
121 bool isMovingHorizontally() const;
122 bool isMovingVertically() const;
123 bool isFlicking() const;
124 bool isFlickingHorizontally() const;
125 bool isFlickingVertically() const;
127 int pressDelay() const;
128 void setPressDelay(int delay);
130 qreal maximumFlickVelocity() const;
131 void setMaximumFlickVelocity(qreal);
133 qreal flickDeceleration() const;
134 void setFlickDeceleration(qreal);
136 bool isInteractive() const;
137 void setInteractive(bool);
139 qreal horizontalVelocity() const;
140 qreal verticalVelocity() const;
142 bool isAtXEnd() const;
143 bool isAtXBeginning() const;
144 bool isAtYEnd() const;
145 bool isAtYBeginning() const;
147 QSGItem *contentItem();
149 enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
150 FlickableDirection flickableDirection() const;
151 void setFlickableDirection(FlickableDirection);
153 Q_INVOKABLE void resizeContent(qreal w, qreal h, QPointF center);
154 Q_INVOKABLE void returnToBounds();
157 void contentWidthChanged();
158 void contentHeightChanged();
159 void contentXChanged();
160 void contentYChanged();
161 void movingChanged();
162 void movingHorizontallyChanged();
163 void movingVerticallyChanged();
164 void flickingChanged();
165 void flickingHorizontallyChanged();
166 void flickingVerticallyChanged();
167 void horizontalVelocityChanged();
168 void verticalVelocityChanged();
169 void isAtBoundaryChanged();
170 void flickableDirectionChanged();
171 void interactiveChanged();
172 void boundsBehaviorChanged();
173 void maximumFlickVelocityChanged();
174 void flickDecelerationChanged();
175 void pressDelayChanged();
176 void movementStarted();
177 void movementEnded();
182 virtual bool childMouseEventFilter(QSGItem *, QEvent *);
183 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
184 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
185 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
186 virtual void wheelEvent(QWheelEvent *event);
187 virtual void timerEvent(QTimerEvent *event);
189 QSGFlickableVisibleArea *visibleArea();
192 virtual void ticked();
193 void movementStarting();
194 void movementEnding();
197 void movementXEnding();
198 void movementYEnding();
199 virtual qreal minXExtent() const;
200 virtual qreal minYExtent() const;
201 virtual qreal maxXExtent() const;
202 virtual qreal maxYExtent() const;
203 qreal vWidth() const;
204 qreal vHeight() const;
205 virtual void viewportMoved();
206 virtual void geometryChanged(const QRectF &newGeometry,
207 const QRectF &oldGeometry);
208 void mouseUngrabEvent();
209 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
216 QSGFlickable(QSGFlickablePrivate &dd, QSGItem *parent);
219 Q_DISABLE_COPY(QSGFlickable)
220 Q_DECLARE_PRIVATE(QSGFlickable)
221 friend class QSGFlickableVisibleArea;
226 QML_DECLARE_TYPE(QSGFlickable)
230 #endif // QSGFLICKABLE_P_H