39 public QSafeQuickItemChangeListener<QQuickFlickablePrivate>
41 Q_DECLARE_PUBLIC(QQuickFlickable)
44 static inline QQuickFlickablePrivate *get(QQuickFlickable *o) {
return o->d_func(); }
46 QQuickFlickablePrivate();
49 struct Velocity :
public QQuickTimeLineValue
51 Velocity(QQuickFlickablePrivate *p)
53 void setValue(qreal v) override {
55 QQuickTimeLineValue::setValue(v);
56 parent->updateVelocity();
59 QQuickFlickablePrivate *parent;
62 enum MovementReason { Other, SetIndex, Mouse };
65 AxisData(QQuickFlickablePrivate *fp,
void (QQuickFlickablePrivate::*func)(qreal))
67 , smoothVelocity(fp), atEnd(
false), atBeginning(
true)
68 , transitionToSet(
false)
69 , fixingUp(
false), inOvershoot(
false), inRebound(
false), moving(
false), flicking(
false)
70 , flickingWhenDragBegan(
false), dragging(
false), extentsChanged(
false)
71 , explicitValue(
false), contentPositionChangedExternallyDuringDrag(
false)
72 , minExtentDirty(
true), maxExtentDirty(
true)
78 velocityBuffer.clear();
82 contentPositionChangedExternallyDuringDrag =
false;
85 void markExtentsDirty() {
86 minExtentDirty =
true;
87 maxExtentDirty =
true;
88 extentsChanged =
true;
91 void resetTransitionTo() {
93 transitionToSet =
false;
96 void addVelocitySample(qreal v, qreal maxVelocity);
97 void updateVelocity();
99 QQuickTimeLineValueProxy<QQuickFlickablePrivate> move;
100 QQuickFlickableReboundTransition *transitionToBounds =
nullptr;
104 qreal dragStartOffset = 0;
105 qreal dragMinBound = 0;
106 qreal dragMaxBound = 0;
107 qreal previousDragDelta = 0;
109 qreal flickTarget = 0;
110 qreal startMargin = 0;
114 qreal transitionTo = 0;
115 qreal continuousFlickVelocity = 0;
116 QElapsedTimer velocityTime;
118 QQuickFlickablePrivate::Velocity smoothVelocity;
119 QPODVector<qreal,10> velocityBuffer;
122 uint atBeginning : 1;
123 uint transitionToSet : 1;
125 uint inOvershoot : 1;
129 uint flickingWhenDragBegan : 1;
131 uint extentsChanged : 1;
132 uint explicitValue : 1;
133 uint contentPositionChangedExternallyDuringDrag : 1;
135 mutable uint minExtentDirty : 1;
136 mutable uint maxExtentDirty : 1;
140 bool flickX(QEvent::Type eventType, qreal velocity);
141 bool flickY(QEvent::Type eventType, qreal velocity);
142 virtual bool flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
143 QQuickTimeLineCallback::Callback fixupCallback,
144 QEvent::Type eventType, qreal velocity);
145 void flickingStarted(
bool flickingH,
bool flickingV);
149 virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
150 void adjustContentPos(AxisData &data, qreal toPos);
151 void resetTimeline(AxisData &data);
152 void clearTimeline();
154 void updateBeginningEnd();
156 bool isInnermostPressDelay(QQuickItem *item)
const;
157 void captureDelayedPress(QQuickItem *item, QPointerEvent *event);
158 void clearDelayedPress();
159 void replayDelayedPress();
161 void setViewportX(qreal x);
162 void setViewportY(qreal y);
164 qreal overShootDistance(qreal velocity)
const;
166 void itemGeometryChanged(QQuickItem *, QQuickGeometryChange,
const QRectF &) override;
168 void draggingStarting();
169 void draggingEnding();
171 bool isViewMoving()
const;
173 void cancelInteraction();
175 void addPointerHandler(QQuickPointerHandler *h) override;
177 virtual bool wantsPointerEvent(
const QPointerEvent *) {
return true; }
180 QQuickItem *contentItem;
185 MovementReason moveReason = Other;
187 QQuickTimeLine timeline;
192 bool scrollingPhase : 1;
193 bool interactive : 1;
194 bool calcVelocity : 1;
195 bool pixelAligned : 1;
197 Qt::MouseButtons acceptedButtons = Qt::LeftButton;
200 qint64 lastPressTime;
203 QVector2D accumulatedWheelPixelDelta;
205 qreal wheelDeceleration;
207 QPointerEvent *delayedPressEvent;
208 QBasicTimer delayedPressTimer;
212 qreal initialWheelFlickDistance;
214 enum FixupMode { Normal, Immediate, ExtentChanged };
217 static void fixupY_callback(
void *);
218 static void fixupX_callback(
void *);
220 void updateVelocity();
222 QQuickTimeLine velocityTimeline;
223 QQuickFlickableVisibleArea *visibleArea;
224 QQuickFlickable::FlickableDirection flickableDirection;
225 QQuickFlickable::BoundsBehavior boundsBehavior;
226 QQuickFlickable::BoundsMovement boundsMovement;
227 QQuickTransition *rebound;
229 void viewportAxisMoved(AxisData &data, qreal minExtent, qreal maxExtent,
230 QQuickTimeLineCallback::Callback fixupCallback);
232 void handlePressEvent(QPointerEvent *);
233 void handleMoveEvent(QPointerEvent *);
234 void handleReleaseEvent(QPointerEvent *);
235 bool buttonsAccepted(
const QSinglePointEvent *event);
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);
243 QVector2D firstPointLocalVelocity(QPointerEvent *event);
244 qint64 computeCurrentTime(QInputEvent *event)
const;
247 static void data_append(QQmlListProperty<QObject> *, QObject *);
248 static qsizetype data_count(QQmlListProperty<QObject> *);
249 static QObject *data_at(QQmlListProperty<QObject> *, qsizetype);
250 static void data_clear(QQmlListProperty<QObject> *);
257 Q_PROPERTY(qreal xPosition READ xPosition NOTIFY xPositionChanged FINAL)
258 Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged FINAL)
259 Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged FINAL)
260 Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged FINAL)
262 QML_ADDED_IN_VERSION(2, 0)
265 QQuickFlickableVisibleArea(QQuickFlickable *parent=
nullptr);
267 qreal xPosition()
const;
268 qreal widthRatio()
const;
269 qreal yPosition()
const;
270 qreal heightRatio()
const;
272 void updateVisible();
275 void xPositionChanged(qreal xPosition);
276 void yPositionChanged(qreal yPosition);
277 void widthRatioChanged(qreal widthRatio);
278 void heightRatioChanged(qreal heightRatio);
281 QQuickFlickable *flickable;
bool contains(const QPointF &point) const override