45 public QSafeQuickItemChangeListener<QQuickFlickablePrivate>
47 Q_DECLARE_PUBLIC(QQuickFlickable)
50 static inline QQuickFlickablePrivate *get(QQuickFlickable *o) {
return o->d_func(); }
52 QQuickFlickablePrivate();
55 struct Velocity :
public QQuickTimeLineValue
57 Velocity(QQuickFlickablePrivate *p)
59 void setValue(qreal v) override {
61 QQuickTimeLineValue::setValue(v);
62 parent->updateVelocity();
65 QQuickFlickablePrivate *parent;
68 enum MovementReason { Other, SetIndex, Mouse };
71 AxisData(QQuickFlickablePrivate *fp,
void (QQuickFlickablePrivate::*func)(qreal))
73 , smoothVelocity(fp), atEnd(
false), atBeginning(
true)
74 , transitionToSet(
false)
75 , fixingUp(
false), inOvershoot(
false), inRebound(
false), moving(
false), flicking(
false)
76 , flickingWhenDragBegan(
false), dragging(
false), extentsChanged(
false)
77 , explicitValue(
false), contentPositionChangedExternallyDuringDrag(
false)
78 , minExtentDirty(
true), maxExtentDirty(
true)
89 contentPositionChangedExternallyDuringDrag =
false;
92 void markExtentsDirty() {
93 minExtentDirty =
true;
94 maxExtentDirty =
true;
95 extentsChanged =
true;
98 void resetTransitionTo() {
100 transitionToSet =
false;
103 void addVelocitySample(qreal v, qreal maxVelocity);
104 void updateVelocity();
106 QQuickTimeLineValueProxy<QQuickFlickablePrivate> move;
107 QQuickFlickableReboundTransition *transitionToBounds =
nullptr;
111 qreal dragStartOffset = 0;
112 qreal dragMinBound = 0;
113 qreal dragMaxBound = 0;
114 qreal previousDragDelta = 0;
116 qreal flickTarget = 0;
117 qreal startMargin = 0;
121 qreal transitionTo = 0;
122 qreal continuousFlickVelocity = 0;
123 QElapsedTimer velocityTime;
125 QQuickFlickablePrivate::Velocity smoothVelocity;
127 int velocitySamples = 0;
128 int velocityWritePos = 0;
131 uint atBeginning : 1;
132 uint transitionToSet : 1;
134 uint inOvershoot : 1;
138 uint flickingWhenDragBegan : 1;
140 uint extentsChanged : 1;
141 uint explicitValue : 1;
142 uint contentPositionChangedExternallyDuringDrag : 1;
144 mutable uint minExtentDirty : 1;
145 mutable uint maxExtentDirty : 1;
149 bool flickX(QEvent::Type eventType, qreal velocity);
150 bool flickY(QEvent::Type eventType, qreal velocity);
151 virtual bool flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
152 QQuickTimeLineCallback::Callback fixupCallback,
153 QEvent::Type eventType, qreal velocity);
154 void flickingStarted(
bool flickingH,
bool flickingV);
158 virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
159 void adjustContentPos(AxisData &data, qreal toPos);
160 void resetTimeline(AxisData &data);
161 void clearTimeline();
163 void updateBeginningEnd();
165 bool isInnermostPressDelay(QQuickItem *item)
const;
166 void captureDelayedPress(QQuickItem *item, QPointerEvent *event);
167 void clearDelayedPress();
168 void replayDelayedPress();
170 void setViewportX(qreal x);
171 void setViewportY(qreal y);
173 qreal overShootDistance(qreal velocity)
const;
175 void itemGeometryChanged(QQuickItem *, QQuickGeometryChange,
const QRectF &) override;
177 void draggingStarting();
178 void draggingEnding();
180 bool isViewMoving()
const;
182 void cancelInteraction();
184 void addPointerHandler(QQuickPointerHandler *h) override;
186 virtual bool wantsPointerEvent(
const QPointerEvent *) {
return true; }
189 QQuickItem *contentItem;
194 MovementReason moveReason = Other;
196 QQuickTimeLine timeline;
201 bool scrollingPhase : 1;
202 bool interactive : 1;
203 bool calcVelocity : 1;
204 bool pixelAligned : 1;
206 Qt::MouseButtons acceptedButtons = Qt::LeftButton;
209 qint64 lastPressTime;
212 QVector2D accumulatedWheelPixelDelta;
214 qreal wheelDeceleration;
216 QPointerEvent *delayedPressEvent;
217 QBasicTimer delayedPressTimer;
221 qreal initialWheelFlickDistance;
223 enum FixupMode { Normal, Immediate, ExtentChanged };
226 static void fixupY_callback(
void *);
227 static void fixupX_callback(
void *);
229 void updateVelocity();
231 QQuickTimeLine velocityTimeline;
232 QQuickFlickableVisibleArea *visibleArea;
233 QQuickFlickable::FlickableDirection flickableDirection;
234 QQuickFlickable::BoundsBehavior boundsBehavior;
235 QQuickFlickable::BoundsMovement boundsMovement;
236 QQuickTransition *rebound;
238 void viewportAxisMoved(AxisData &data, qreal minExtent, qreal maxExtent,
239 QQuickTimeLineCallback::Callback fixupCallback);
241 void handlePressEvent(QPointerEvent *);
242 void handleMoveEvent(QPointerEvent *);
243 void handleReleaseEvent(QPointerEvent *);
244 bool buttonsAccepted(
const QSinglePointEvent *event);
246 void maybeBeginDrag(qint64 currentTimestamp,
const QPointF &pressPosn,
247 Qt::MouseButtons buttons = Qt::NoButton);
248 void drag(qint64 currentTimestamp, QEvent::Type eventType,
const QPointF &localPos,
249 const QVector2D &deltas,
bool overThreshold,
bool momentum,
250 bool velocitySensitiveOverBounds,
const QVector2D &velocity);
252 QVector2D firstPointLocalVelocity(QPointerEvent *event);
253 qint64 computeCurrentTime(QInputEvent *event)
const;
256 static void data_append(QQmlListProperty<QObject> *, QObject *);
257 static qsizetype data_count(QQmlListProperty<QObject> *);
258 static QObject *data_at(QQmlListProperty<QObject> *, qsizetype);
259 static void data_clear(QQmlListProperty<QObject> *);
261#if QT_CONFIG(accessibility)
263 QElapsedTimer m_scrollEventTimer;
271 Q_PROPERTY(qreal xPosition READ xPosition NOTIFY xPositionChanged FINAL)
272 Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged FINAL)
273 Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged FINAL)
274 Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged FINAL)
276 QML_ADDED_IN_VERSION(2, 0)
279 QQuickFlickableVisibleArea(QQuickFlickable *parent=
nullptr);
281 qreal xPosition()
const;
282 qreal widthRatio()
const;
283 qreal yPosition()
const;
284 qreal heightRatio()
const;
286 void updateVisible();
289 void xPositionChanged(qreal xPosition);
290 void yPositionChanged(qreal yPosition);
291 void widthRatioChanged(qreal widthRatio);
292 void heightRatioChanged(qreal heightRatio);
295 QQuickFlickable *flickable;
bool contains(const QPointF &point) const override
QQuickFlickableContentItem(QQuickItem *parent=nullptr)