Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickflickable_p.h
Go to the documentation of this file.
1
2// Copyright (C) 2019 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6#ifndef QQUICKFLICKABLE_P_H
7#define QQUICKFLICKABLE_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include "qquickitem.h"
21#include <private/qtquickglobal_p.h>
22#include <QtCore/qpoint.h>
23
25
26class QQuickFlickablePrivate;
27class QQuickFlickableVisibleArea;
28class QPointerEvent;
29class Q_QUICK_EXPORT QQuickFlickable : public QQuickItem
30{
31 Q_OBJECT
32
33 Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged VIRTUAL)
34 Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged VIRTUAL)
35 Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
36 Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
37 Q_PROPERTY(QQuickItem *contentItem READ contentItem CONSTANT)
38
39 Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
40 Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
41 Q_PROPERTY(qreal originY READ originY NOTIFY originYChanged)
42
43 Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
44 Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
45 Q_PROPERTY(qreal originX READ originX NOTIFY originXChanged)
46
47 Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
48 Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
49
50 Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
51 Q_PROPERTY(BoundsMovement boundsMovement READ boundsMovement WRITE setBoundsMovement NOTIFY boundsMovementChanged REVISION(2, 10))
52 Q_PROPERTY(QQuickTransition *rebound READ rebound WRITE setRebound NOTIFY reboundChanged)
53 Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
54 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
55 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
56 Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
57 Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
58 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
59 Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
60 Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
61 Q_PROPERTY(bool dragging READ isDragging NOTIFY draggingChanged)
62 Q_PROPERTY(bool draggingHorizontally READ isDraggingHorizontally NOTIFY draggingHorizontallyChanged)
63 Q_PROPERTY(bool draggingVertically READ isDraggingVertically NOTIFY draggingVerticallyChanged)
64 Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
65
66 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
67 Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
68
69 Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY atXEndChanged)
70 Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY atYEndChanged)
71 Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY atXBeginningChanged)
72 Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY atYBeginningChanged)
73
74 Q_PROPERTY(QQuickFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
75
76 Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY pixelAlignedChanged)
77 Q_PROPERTY(bool synchronousDrag READ synchronousDrag WRITE setSynchronousDrag NOTIFY synchronousDragChanged REVISION(2, 12))
78
79 Q_PROPERTY(qreal horizontalOvershoot READ horizontalOvershoot NOTIFY horizontalOvershootChanged REVISION(2, 9))
80 Q_PROPERTY(qreal verticalOvershoot READ verticalOvershoot NOTIFY verticalOvershootChanged REVISION(2, 9))
81
82 Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged REVISION(6, 9) FINAL)
83
84 Q_PROPERTY(QQmlListProperty<QObject> flickableData READ flickableData)
85 Q_PROPERTY(QQmlListProperty<QQuickItem> flickableChildren READ flickableChildren)
86 Q_CLASSINFO("DefaultProperty", "flickableData")
87 QML_NAMED_ELEMENT(Flickable)
88 QML_ADDED_IN_VERSION(2, 0)
89
90public:
91 QQuickFlickable(QQuickItem *parent=nullptr);
92 ~QQuickFlickable() override;
93
94 QQmlListProperty<QObject> flickableData();
95 QQmlListProperty<QQuickItem> flickableChildren();
96
97 enum BoundsBehaviorFlag {
98 StopAtBounds = 0x0,
99 DragOverBounds = 0x1,
100 OvershootBounds = 0x2,
101 DragAndOvershootBounds = DragOverBounds | OvershootBounds
102 };
103 Q_DECLARE_FLAGS(BoundsBehavior, BoundsBehaviorFlag)
104 Q_FLAG(BoundsBehavior)
105
106 BoundsBehavior boundsBehavior() const;
107 void setBoundsBehavior(BoundsBehavior);
108
109 enum BoundsMovement {
110 // StopAtBounds = 0x0,
111 FollowBoundsBehavior = 0x1
112 };
113 Q_ENUM(BoundsMovement)
114
115 BoundsMovement boundsMovement() const;
116 void setBoundsMovement(BoundsMovement movement);
117
118 QQuickTransition *rebound() const;
119 void setRebound(QQuickTransition *transition);
120
121 qreal contentWidth() const;
122 void setContentWidth(qreal);
123
124 qreal contentHeight() const;
125 void setContentHeight(qreal);
126
127 qreal contentX() const;
128 virtual void setContentX(qreal pos);
129
130 qreal contentY() const;
131 virtual void setContentY(qreal pos);
132
133 qreal topMargin() const;
134 void setTopMargin(qreal m);
135
136 qreal bottomMargin() const;
137 void setBottomMargin(qreal m);
138
139 qreal leftMargin() const;
140 void setLeftMargin(qreal m);
141
142 qreal rightMargin() const;
143 void setRightMargin(qreal m);
144
145 virtual qreal originY() const;
146 virtual qreal originX() const;
147
148 bool isMoving() const;
149 bool isMovingHorizontally() const;
150 bool isMovingVertically() const;
151 bool isFlicking() const;
152 bool isFlickingHorizontally() const;
153 bool isFlickingVertically() const;
154 bool isDragging() const;
155 bool isDraggingHorizontally() const;
156 bool isDraggingVertically() const;
157
158 int pressDelay() const;
159 void setPressDelay(int delay);
160
161 qreal maximumFlickVelocity() const;
162 void setMaximumFlickVelocity(qreal);
163
164 qreal flickDeceleration() const;
165 void setFlickDeceleration(qreal);
166
167 bool isInteractive() const;
168 void setInteractive(bool);
169
170 qreal horizontalVelocity() const;
171 qreal verticalVelocity() const;
172
173 bool isAtXEnd() const;
174 bool isAtXBeginning() const;
175 bool isAtYEnd() const;
176 bool isAtYBeginning() const;
177
178 QQuickItem *contentItem() const;
179
180 enum FlickableDirection { AutoFlickDirection=0x0, HorizontalFlick=0x1, VerticalFlick=0x2, HorizontalAndVerticalFlick=0x3,
181 AutoFlickIfNeeded=0xc };
182 Q_ENUM(FlickableDirection)
183 FlickableDirection flickableDirection() const;
184 void setFlickableDirection(FlickableDirection);
185
186 bool pixelAligned() const;
187 void setPixelAligned(bool align);
188
189 bool synchronousDrag() const;
190 void setSynchronousDrag(bool v);
191
192 Qt::MouseButtons acceptedButtons() const;
193 void setAcceptedButtons(Qt::MouseButtons buttons);
194
195 qreal horizontalOvershoot() const;
196 qreal verticalOvershoot() const;
197
198 enum PositionModeFlag {
199 AlignLeft = Qt::AlignLeft,
200 AlignRight = Qt::AlignRight,
201 AlignHCenter = Qt::AlignHCenter,
202 AlignTop = Qt::AlignTop,
203 AlignBottom = Qt::AlignBottom,
204 AlignVCenter = Qt::AlignVCenter,
205 AlignCenter = AlignVCenter | AlignHCenter,
206 Visible = 0x01000,
207 Contain = 0x02000
208 };
209 Q_DECLARE_FLAGS(PositionMode, PositionModeFlag)
210 Q_FLAG(PositionMode)
211
212 Q_INVOKABLE void resizeContent(qreal w, qreal h, QPointF center);
213 Q_INVOKABLE void returnToBounds();
214 Q_INVOKABLE void flick(qreal xVelocity, qreal yVelocity);
215 Q_INVOKABLE void cancelFlick();
216 Q_REVISION(6, 11) Q_INVOKABLE void positionViewAtChild(QQuickItem *child, PositionMode mode, const QPointF &offset = QPointF());
217 Q_REVISION(6, 11) Q_INVOKABLE void flickToChild(QQuickItem *child, PositionMode mode, const QPointF &offset = QPointF());
218 Q_REVISION(6, 11) Q_INVOKABLE void flickTo(const QPointF &position);
219
220Q_SIGNALS:
221 void contentWidthChanged();
222 void contentHeightChanged();
223 void contentXChanged();
224 void contentYChanged();
225 void topMarginChanged();
226 void bottomMarginChanged();
227 void leftMarginChanged();
228 void rightMarginChanged();
229 void originYChanged();
230 void originXChanged();
231 void movingChanged();
232 void movingHorizontallyChanged();
233 void movingVerticallyChanged();
234 void flickingChanged();
235 void flickingHorizontallyChanged();
236 void flickingVerticallyChanged();
237 void draggingChanged();
238 void draggingHorizontallyChanged();
239 void draggingVerticallyChanged();
240 void horizontalVelocityChanged();
241 void verticalVelocityChanged();
242 void isAtBoundaryChanged();
243 void flickableDirectionChanged();
244 void interactiveChanged();
245 void boundsBehaviorChanged();
246 Q_REVISION(2, 10) void boundsMovementChanged();
247 void reboundChanged();
248 void maximumFlickVelocityChanged();
249 void flickDecelerationChanged();
250 void pressDelayChanged();
251 void movementStarted();
252 void movementEnded();
253 void flickStarted();
254 void flickEnded();
255 void dragStarted();
256 void dragEnded();
257 void pixelAlignedChanged();
258 Q_REVISION(2, 12) void synchronousDragChanged();
259 Q_REVISION(2, 9) void horizontalOvershootChanged();
260 Q_REVISION(2, 9) void verticalOvershootChanged();
261
262 // The next four signals should be marked as Q_REVISION(2, 12). See QTBUG-71243
263 void atXEndChanged();
264 void atYEndChanged();
265 void atXBeginningChanged();
266 void atYBeginningChanged();
267
268 Q_REVISION(6, 9) void acceptedButtonsChanged();
269
270protected:
271 bool childMouseEventFilter(QQuickItem *, QEvent *) override;
272 void mousePressEvent(QMouseEvent *event) override;
273 void mouseMoveEvent(QMouseEvent *event) override;
274 void mouseReleaseEvent(QMouseEvent *event) override;
275 void touchEvent(QTouchEvent *event) override;
276#if QT_CONFIG(wheelevent)
277 void wheelEvent(QWheelEvent *event) override;
278#endif
279 void timerEvent(QTimerEvent *event) override;
280
281 QQuickFlickableVisibleArea *visibleArea();
282
283protected Q_SLOTS:
284 void movementStarting();
285 void movementEnding();
286 void movementEnding(bool hMovementEnding, bool vMovementEnding);
287 void velocityTimelineCompleted();
288 void timelineCompleted();
289
290protected:
291 virtual qreal minXExtent() const;
292 virtual qreal minYExtent() const;
293 virtual qreal maxXExtent() const;
294 virtual qreal maxYExtent() const;
295 qreal vWidth() const;
296 qreal vHeight() const;
297 void componentComplete() override;
298 virtual void viewportMoved(Qt::Orientations orient);
299 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
300 void mouseUngrabEvent() override;
301 bool filterPointerEvent(QQuickItem *receiver, QPointerEvent *event);
302
303 bool xflick() const;
304 bool yflick() const;
305
306 QPointF computePosition(QPointF currentPosition, QRectF itemRect, PositionMode mode,
307 const QPointF &offset = QPointF()) const;
308
309protected:
310 QQuickFlickable(QQuickFlickablePrivate &dd, QQuickItem *parent);
311
312private:
313 Q_DISABLE_COPY(QQuickFlickable)
314 Q_DECLARE_PRIVATE(QQuickFlickable)
315 friend class QQuickFlickableVisibleArea;
316 friend class QQuickFlickableReboundTransition;
317};
318
319QT_END_NAMESPACE
320
321#endif // QQUICKFLICKABLE_P_H
bool contains(const QPointF &point) const override
QQuickFlickableContentItem(QQuickItem *parent=nullptr)
bool startTransition(QQuickFlickablePrivate::AxisData *data, qreal toPos)
QQuickFlickableReboundTransition(QQuickFlickable *f, const QString &name)
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
static bool fuzzyLessThanOrEqualTo(qreal a, qreal b)
static qreal EaseOvershoot(qreal t)
#define QML_FLICK_SAMPLEBUFFER
#define QML_FLICK_OVERSHOOT
#define QML_FLICK_MULTIFLICK_MAXBOOST
#define QML_FLICK_MULTIFLICK_THRESHOLD
#define QML_FLICK_OVERSHOOTFRICTION
#define QML_FLICK_DISCARDSAMPLES
#define QML_FLICK_MULTIFLICK_RATIO