diff options
Diffstat (limited to 'src/quick/items/qquickflickable_p_p.h')
-rw-r--r-- | src/quick/items/qquickflickable_p_p.h | 115 |
1 files changed, 42 insertions, 73 deletions
diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h index 5f46c881b5..8d251ba9ff 100644 --- a/src/quick/items/qquickflickable_p_p.h +++ b/src/quick/items/qquickflickable_p_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQUICKFLICKABLE_P_P_H #define QQUICKFLICKABLE_P_P_H @@ -66,14 +30,11 @@ QT_BEGIN_NAMESPACE -// Really slow flicks can be annoying. -const qreal MinimumFlickVelocity = 75.0; - class QQuickFlickableVisibleArea; class QQuickTransition; class QQuickFlickableReboundTransition; -class Q_QUICK_PRIVATE_EXPORT QQuickFlickablePrivate : public QQuickItemPrivate, public QQuickItemChangeListener +class Q_QUICK_EXPORT QQuickFlickablePrivate : public QQuickItemPrivate, public QQuickItemChangeListener { Q_DECLARE_PUBLIC(QQuickFlickable) @@ -96,6 +57,8 @@ public: QQuickFlickablePrivate *parent; }; + enum MovementReason { Other, SetIndex, Mouse }; + struct AxisData { AxisData(QQuickFlickablePrivate *fp, void (QQuickFlickablePrivate::*func)(qreal)) : move(fp, func) @@ -107,8 +70,9 @@ public: , smoothVelocity(fp), atEnd(false), atBeginning(true) , transitionToSet(false) , fixingUp(false), inOvershoot(false), inRebound(false), moving(false), flicking(false) - , dragging(false), extentsChanged(false) + , flickingWhenDragBegan(false), dragging(false), extentsChanged(false) , explicitValue(false), minExtentDirty(true), maxExtentDirty(true) + , contentPositionChangedExternallyDuringDrag(false) , unused(0) {} @@ -119,6 +83,7 @@ public: dragStartOffset = 0; fixingUp = false; inOvershoot = false; + contentPositionChangedExternallyDuringDrag = false; } void markExtentsDirty() { @@ -156,26 +121,29 @@ public: int vTime; QQuickFlickablePrivate::Velocity smoothVelocity; QPODVector<qreal,10> velocityBuffer; - bool atEnd : 1; - bool atBeginning : 1; - bool transitionToSet : 1; - bool fixingUp : 1; - bool inOvershoot : 1; - bool inRebound : 1; - bool moving : 1; - bool flicking : 1; - bool dragging : 1; - bool extentsChanged : 1; - bool explicitValue : 1; - mutable bool minExtentDirty : 1; - mutable bool maxExtentDirty : 1; - uint unused : 19; + uint atEnd : 1; + uint atBeginning : 1; + uint transitionToSet : 1; + uint fixingUp : 1; + uint inOvershoot : 1; + uint inRebound : 1; + uint moving : 1; + uint flicking : 1; + uint flickingWhenDragBegan : 1; + uint dragging : 1; + uint extentsChanged : 1; + uint explicitValue : 1; + mutable uint minExtentDirty : 1; + mutable uint maxExtentDirty : 1; + uint contentPositionChangedExternallyDuringDrag : 1; + uint unused : 17; }; - bool flickX(qreal velocity); - bool flickY(qreal velocity); + bool flickX(QEvent::Type eventType, qreal velocity); + bool flickY(QEvent::Type eventType, qreal velocity); virtual bool flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QQuickTimeLineCallback::Callback fixupCallback, qreal velocity); + QQuickTimeLineCallback::Callback fixupCallback, + QEvent::Type eventType, qreal velocity); void flickingStarted(bool flickingH, bool flickingV); void fixupX(); @@ -195,7 +163,7 @@ public: void setViewportX(qreal x); void setViewportY(qreal y); - qreal overShootDistance(qreal size) const; + qreal overShootDistance(qreal velocity) const; void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override; @@ -216,6 +184,8 @@ public: AxisData hData; AxisData vData; + MovementReason moveReason = Other; + QQuickTimeLine timeline; bool hMoved : 1; bool vMoved : 1; @@ -233,13 +203,14 @@ public: QPointF pressPos; QVector2D accumulatedWheelPixelDelta; qreal deceleration; + qreal wheelDeceleration; qreal maxVelocity; - qreal reportedVelocitySmoothing; QPointerEvent *delayedPressEvent; QBasicTimer delayedPressTimer; int pressDelay; int fixupDuration; qreal flickBoost; + qreal initialWheelFlickDistance; enum FixupMode { Normal, Immediate, ExtentChanged }; FixupMode fixupMode; @@ -256,18 +227,20 @@ public: QQuickFlickable::BoundsMovement boundsMovement; QQuickTransition *rebound; - void viewportAxisMoved(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, + void viewportAxisMoved(AxisData &data, qreal minExtent, qreal maxExtent, QQuickTimeLineCallback::Callback fixupCallback); void handlePressEvent(QPointerEvent *); void handleMoveEvent(QPointerEvent *); void handleReleaseEvent(QPointerEvent *); - void maybeBeginDrag(qint64 currentTimestamp, const QPointF &pressPosn); + void maybeBeginDrag(qint64 currentTimestamp, const QPointF &pressPosn, + Qt::MouseButtons buttons = Qt::NoButton); void drag(qint64 currentTimestamp, QEvent::Type eventType, const QPointF &localPos, const QVector2D &deltas, bool overThreshold, bool momentum, bool velocitySensitiveOverBounds, const QVector2D &velocity); + QVector2D firstPointLocalVelocity(QPointerEvent *event); qint64 computeCurrentTime(QInputEvent *event) const; qreal devicePixelRatio() const; @@ -276,18 +249,16 @@ public: static qsizetype data_count(QQmlListProperty<QObject> *); static QObject *data_at(QQmlListProperty<QObject> *, qsizetype); static void data_clear(QQmlListProperty<QObject> *); - - static QVarLengthArray<const QPointingDevice *, 4> nonClickyWheelMice; }; -class QQuickFlickableVisibleArea : public QObject +class Q_QUICK_EXPORT QQuickFlickableVisibleArea : public QObject { Q_OBJECT - Q_PROPERTY(qreal xPosition READ xPosition NOTIFY xPositionChanged) - Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged) - Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged) - Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged) + Q_PROPERTY(qreal xPosition READ xPosition NOTIFY xPositionChanged FINAL) + Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged FINAL) + Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged FINAL) + Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged FINAL) QML_ANONYMOUS QML_ADDED_IN_VERSION(2, 0) @@ -317,6 +288,4 @@ private: QT_END_NAMESPACE -QML_DECLARE_TYPE(QQuickFlickableVisibleArea) - #endif // QQUICKFLICKABLE_P_P_H |