Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickflickable_p_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
4#ifndef QQUICKFLICKABLE_P_P_H
5#define QQUICKFLICKABLE_P_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qquickflickable_p.h"
19#include "qquickitem_p.h"
21
22#include <QtQml/qqml.h>
23#include <QtCore/qdatetime.h>
24#include "qplatformdefs.h"
25
26#include <private/qquicktimeline_p_p.h>
27#include <private/qquickanimation_p_p.h>
28#include <private/qquicktransitionmanager_p_p.h>
29#include <private/qpodvector_p.h>
30
32
36
38{
39 Q_DECLARE_PUBLIC(QQuickFlickable)
40
41public:
42 static inline QQuickFlickablePrivate *get(QQuickFlickable *o) { return o->d_func(); }
43
45 void init();
46
48 {
51 void setValue(qreal v) override {
52 if (v != value()) {
54 parent->updateVelocity();
55 }
56 }
58 };
59
60 enum MovementReason { Other, SetIndex, Mouse };
61
62 struct AxisData {
64 : move(fp, func)
65 , transitionToBounds(nullptr)
66 , viewSize(-1), lastPos(0), previousDragDelta(0), velocity(0), startMargin(0), endMargin(0)
67 , origin(0), overshoot(0)
68 , transitionTo(0)
69 , continuousFlickVelocity(0), velocityTime(), vTime(0)
70 , smoothVelocity(fp), atEnd(false), atBeginning(true)
71 , transitionToSet(false)
72 , fixingUp(false), inOvershoot(false), inRebound(false), moving(false), flicking(false)
73 , flickingWhenDragBegan(false), dragging(false), extentsChanged(false)
74 , explicitValue(false), minExtentDirty(true), maxExtentDirty(true)
75 , contentPositionChangedExternallyDuringDrag(false)
76 , unused(0)
77 {}
78
79 ~AxisData();
80
81 void reset() {
82 velocityBuffer.clear();
83 dragStartOffset = 0;
84 fixingUp = false;
85 inOvershoot = false;
86 contentPositionChangedExternallyDuringDrag = false;
87 }
88
90 minExtentDirty = true;
91 maxExtentDirty = true;
92 extentsChanged = true;
93 }
94
96 transitionTo = 0;
97 transitionToSet = false;
98 }
99
100 void addVelocitySample(qreal v, qreal maxVelocity);
101 void updateVelocity();
102
103 QQuickTimeLineValueProxy<QQuickFlickablePrivate> move;
121 int vTime;
123 QPODVector<qreal,10> velocityBuffer;
136 mutable uint minExtentDirty : 1;
137 mutable uint maxExtentDirty : 1;
140 };
141
142 bool flickX(QEvent::Type eventType, qreal velocity);
143 bool flickY(QEvent::Type eventType, qreal velocity);
144 virtual bool flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
146 QEvent::Type eventType, qreal velocity);
147 void flickingStarted(bool flickingH, bool flickingV);
148
149 void fixupX();
150 void fixupY();
151 virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
152 void adjustContentPos(AxisData &data, qreal toPos);
153 void resetTimeline(AxisData &data);
154 void clearTimeline();
155
156 void updateBeginningEnd();
157
158 bool isInnermostPressDelay(QQuickItem *item) const;
159 void captureDelayedPress(QQuickItem *item, QPointerEvent *event);
160 void clearDelayedPress();
161 void replayDelayedPress();
162
163 void setViewportX(qreal x);
164 void setViewportY(qreal y);
165
166 qreal overShootDistance(qreal velocity) const;
167
168 void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override;
169
170 void draggingStarting();
171 void draggingEnding();
172
173 bool isViewMoving() const;
174
175 void cancelInteraction();
176
177 void addPointerHandler(QQuickPointerHandler *h) override;
178
179 virtual bool wantsPointerEvent(const QPointerEvent *) { return true; }
180
181public:
183
186
187 MovementReason moveReason = Other;
188
190 bool hMoved : 1;
191 bool vMoved : 1;
192 bool stealMouse : 1;
193 bool pressed : 1;
195 bool interactive : 1;
196 bool calcVelocity : 1;
197 bool pixelAligned : 1;
198 bool syncDrag : 1;
214
215 enum FixupMode { Normal, Immediate, ExtentChanged };
217
218 static void fixupY_callback(void *);
219 static void fixupX_callback(void *);
220
221 void updateVelocity();
222 int vTime;
226 QQuickFlickable::BoundsBehavior boundsBehavior;
229
230 void viewportAxisMoved(AxisData &data, qreal minExtent, qreal maxExtent,
232
233 void handlePressEvent(QPointerEvent *);
234 void handleMoveEvent(QPointerEvent *);
235 void handleReleaseEvent(QPointerEvent *);
236
237 void maybeBeginDrag(qint64 currentTimestamp, const QPointF &pressPosn,
238 Qt::MouseButtons buttons = Qt::NoButton);
239 void drag(qint64 currentTimestamp, QEvent::Type eventType, const QPointF &localPos,
240 const QVector2D &deltas, bool overThreshold, bool momentum,
241 bool velocitySensitiveOverBounds, const QVector2D &velocity);
242
243 QVector2D firstPointLocalVelocity(QPointerEvent *event);
244 qint64 computeCurrentTime(QInputEvent *event) const;
245 qreal devicePixelRatio() const;
246
247 // flickableData property
248 static void data_append(QQmlListProperty<QObject> *, QObject *);
249 static qsizetype data_count(QQmlListProperty<QObject> *);
250 static QObject *data_at(QQmlListProperty<QObject> *, qsizetype);
251 static void data_clear(QQmlListProperty<QObject> *);
252};
253
254class Q_QUICK_EXPORT QQuickFlickableVisibleArea : public QObject
255{
257
258 Q_PROPERTY(qreal xPosition READ xPosition NOTIFY xPositionChanged FINAL)
259 Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged FINAL)
260 Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged FINAL)
261 Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged FINAL)
264
265public:
267
268 qreal xPosition() const;
269 qreal widthRatio() const;
270 qreal yPosition() const;
271 qreal heightRatio() const;
272
273 void updateVisible();
274
276 void xPositionChanged(qreal xPosition);
277 void yPositionChanged(qreal yPosition);
278 void widthRatioChanged(qreal widthRatio);
279 void heightRatioChanged(qreal heightRatio);
280
281private:
282 QQuickFlickable *flickable;
283 qreal m_xPosition;
284 qreal m_widthRatio;
285 qreal m_yPosition;
286 qreal m_heightRatio;
287};
288
290
291#endif // QQUICKFLICKABLE_P_P_H
\inmodule QtCore
Definition qbasictimer.h:18
\inmodule QtCore
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
\inmodule QtGui
Definition qevent.h:49
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
A base class for pointer events.
Definition qevent.h:73
virtual bool wantsPointerEvent(const QPointerEvent *)
QQuickFlickable::BoundsMovement boundsMovement
static QQuickFlickablePrivate * get(QQuickFlickable *o)
QQuickFlickable::FlickableDirection flickableDirection
QPointerEvent * delayedPressEvent
QQuickFlickableVisibleArea * visibleArea
QQuickFlickable::BoundsBehavior boundsBehavior
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
The QQuickTimeLineValue class provides a value that can be modified by QQuickTimeLine.
virtual void setValue(qreal v)
Set the current value.
The QQuickTimeLine class provides a timeline for controlling animations.
\inmodule QtCore\reentrant
Definition qrect.h:484
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
Combined button and popup list for selecting options.
@ NoButton
Definition qnamespace.h:57
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint y
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLenum func
Definition qopenglext.h:663
GLfloat GLfloat p
[1]
#define QML_ANONYMOUS
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define fp
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SIGNALS
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
QObject::connect nullptr
QGraphicsItem * item
AxisData(QQuickFlickablePrivate *fp, void(QQuickFlickablePrivate::*func)(qreal))
QQuickFlickableReboundTransition * transitionToBounds
QPODVector< qreal, 10 > velocityBuffer
QQuickFlickablePrivate::Velocity smoothVelocity
QQuickTimeLineValueProxy< QQuickFlickablePrivate > move
void setValue(qreal v) override
Set the current value.
Velocity(QQuickFlickablePrivate *p)