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