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
qscroller_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QSCROLLER_P_H
6#define QSCROLLER_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 <QtWidgets/private/qtwidgetsglobal_p.h>
20#include <QObject>
21#include <QPointer>
22#include <QQueue>
23#include <QSet>
24#include <QEasingCurve>
25#include <QElapsedTimer>
26#include <QSizeF>
27#include <QPointF>
28#include <QRectF>
29#include <qscroller.h>
30#include <qscrollerproperties.h>
31#include <private/qscrollerproperties_p.h>
32#if QT_CONFIG(animation)
33#include <QAbstractAnimation>
34#endif
35
36QT_BEGIN_NAMESPACE
37
38#ifndef QT_NO_GESTURES
39class QFlickGestureRecognizer;
40#endif
41
42#if QT_CONFIG(animation)
43class QScrollTimer;
44#endif
46{
47 Q_OBJECT
48 Q_DECLARE_PUBLIC(QScroller)
49
50public:
52 void init();
53
54 void sendEvent(QObject *o, QEvent *e);
55
56 void setState(QScroller::State s);
57
63
74
75 bool pressWhileInactive(const QPointF &position, qint64 timestamp);
76 bool moveWhilePressed(const QPointF &position, qint64 timestamp);
77 bool releaseWhilePressed(const QPointF &position, qint64 timestamp);
78 bool moveWhileDragging(const QPointF &position, qint64 timestamp);
79 bool releaseWhileDragging(const QPointF &position, qint64 timestamp);
80 bool pressWhileScrolling(const QPointF &position, qint64 timestamp);
81
82 void timerTick();
85
86 bool prepareScrolling(const QPointF &position);
87 void handleDrag(const QPointF &position, qint64 timestamp);
88
89 QPointF dpi() const;
90 void setDpi(const QPointF &dpi);
91 void setDpiFromWidget(QWidget *widget);
92
93 void updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime);
94 void pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation);
95 void recalcScrollingSegments(bool forceRecalc = false);
96 qreal scrollingSegmentsEndPos(Qt::Orientation orientation) const;
97 bool scrollingSegmentsValid(Qt::Orientation orientation) const;
98 void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type);
99 void createScrollingSegments(qreal v, qreal startPos,
100 qreal deltaTime, qreal deltaPos,
101 Qt::Orientation orientation);
102 void createScrollingSegments(const QPointF &v, const QPointF &startPos, const QPointF &ppm);
103
104 void setContentPositionHelperDragging(const QPointF &deltaPos);
106
107 qreal nextSnapPos(qreal p, int dir, Qt::Orientation orientation) const;
108 static qreal nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos);
109
110 inline int frameRateSkip() const { return properties.d.data()->frameRate; }
111
112 static const char *stateName(QScroller::State state);
113 static const char *inputName(QScroller::Input input);
114
115public slots:
116 void targetDestroyed();
117
118public:
119 // non static
121 QScrollerProperties properties;
122#ifndef QT_NO_GESTURES
125#endif
126
127 // scroller state:
128
129 // QPointer<QObject> scrollTarget;
133 QPointF overshootPosition; // the number of pixels we are overshooting (before overshootDragResistanceFactor)
134
135 // state
136
139 bool firstScroll; // true if we haven't already send a scroll event
140
141 QPointF oldVelocity; // the release velocity of the last drag
142
147
148 QPointF dragDistance; // the distance we should move during the next drag timer event
149
152
153 // snap positions
160
162
164
165 QPointF releaseVelocity; // the starting velocity of the scrolling state
166#if QT_CONFIG(animation)
168#endif
169
170 QScroller *q_ptr;
171};
172template <>
175
176
177QT_END_NAMESPACE
178
179#endif // QSCROLLER_P_H
friend class QWidget
Definition qpainter.h:431
QPointF pixelPerMeter
QFlickGestureRecognizer * recognizer
qreal scrollingSegmentsEndPos(Qt::Orientation orientation) const
QQueue< ScrollSegment > ySegments
QScrollerProperties properties
QPointF pressPosition
bool moveWhilePressed(const QPointF &position, qint64 timestamp)
void setContentPositionHelperScrolling()
QList< qreal > snapPositionsY
bool pressWhileInactive(const QPointF &position, qint64 timestamp)
void setState(QScroller::State s)
qreal nextSnapPos(qreal p, int dir, Qt::Orientation orientation) const
QScroller::State state
bool pressWhileScrolling(const QPointF &position, qint64 timestamp)
QPointF contentPosition
void setDpi(const QPointF &dpi)
void recalcScrollingSegments(bool forceRecalc=false)
void setDpiFromWidget(QWidget *widget)
void createScrollingSegments(const QPointF &v, const QPointF &startPos, const QPointF &ppm)
bool scrollingSegmentsValid(Qt::Orientation orientation) const
QElapsedTimer monotonicTimer
static const char * inputName(QScroller::Input input)
void createScrollingSegments(qreal v, qreal startPos, qreal deltaTime, qreal deltaPos, Qt::Orientation orientation)
void setContentPositionHelperDragging(const QPointF &deltaPos)
int frameRateSkip() const
void pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation)
QPointF dpi() const
QList< qreal > snapPositionsX
QScroller * q_ptr
bool moveWhileDragging(const QPointF &position, qint64 timestamp)
QQueue< ScrollSegment > xSegments
void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type)
bool prepareScrolling(const QPointF &position)
QPointF releaseVelocity
QPointF overshootPosition
void handleDrag(const QPointF &position, qint64 timestamp)
void sendEvent(QObject *o, QEvent *e)
bool releaseWhilePressed(const QPointF &position, qint64 timestamp)
void timerEventWhileScrolling()
void timerEventWhileDragging()
static qreal nextSegmentPosition(QQueue< ScrollSegment > &segments, qint64 now, qreal oldPos)
bool releaseWhileDragging(const QPointF &position, qint64 timestamp)
void updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime)
Qt::GestureType recognizerType
static const char * stateName(QScroller::State state)