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
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
4#ifndef QSCROLLER_P_H
5#define QSCROLLER_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 <QtWidgets/private/qtwidgetsglobal_p.h>
19#include <QObject>
20#include <QPointer>
21#include <QQueue>
22#include <QSet>
23#include <QEasingCurve>
24#include <QElapsedTimer>
25#include <QSizeF>
26#include <QPointF>
27#include <QRectF>
28#include <qscroller.h>
29#include <qscrollerproperties.h>
30#include <private/qscrollerproperties_p.h>
31#if QT_CONFIG(animation)
32#include <QAbstractAnimation>
33#endif
34
36
37#ifndef QT_NO_GESTURES
39#endif
40
41#if QT_CONFIG(animation)
42class QScrollTimer;
43#endif
45{
47 Q_DECLARE_PUBLIC(QScroller)
48
49public:
51 void init();
52
53 void sendEvent(QObject *o, QEvent *e);
54
56
62
73
74 bool pressWhileInactive(const QPointF &position, qint64 timestamp);
75 bool moveWhilePressed(const QPointF &position, qint64 timestamp);
76 bool releaseWhilePressed(const QPointF &position, qint64 timestamp);
77 bool moveWhileDragging(const QPointF &position, qint64 timestamp);
78 bool releaseWhileDragging(const QPointF &position, qint64 timestamp);
79 bool pressWhileScrolling(const QPointF &position, qint64 timestamp);
80
81 void timerTick();
84
86 void handleDrag(const QPointF &position, qint64 timestamp);
87
88 QPointF dpi() const;
89 void setDpi(const QPointF &dpi);
91
92 void updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime);
93 void pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation);
94 void recalcScrollingSegments(bool forceRecalc = false);
96 bool scrollingSegmentsValid(Qt::Orientation orientation) const;
97 void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type);
98 void createScrollingSegments(qreal v, qreal startPos,
99 qreal deltaTime, qreal deltaPos,
100 Qt::Orientation orientation);
101 void createScrollingSegments(const QPointF &v, const QPointF &startPos, const QPointF &ppm);
102
103 void setContentPositionHelperDragging(const QPointF &deltaPos);
105
106 qreal nextSnapPos(qreal p, int dir, Qt::Orientation orientation) const;
107 static qreal nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos);
108
109 inline int frameRateSkip() const { return properties.d.data()->frameRate; }
110
111 static const char *stateName(QScroller::State state);
112 static const char *inputName(QScroller::Input input);
113
114public slots:
115 void targetDestroyed();
116
117public:
118 // non static
121#ifndef QT_NO_GESTURES
124#endif
125
126 // scroller state:
127
128 // QPointer<QObject> scrollTarget;
132 QPointF overshootPosition; // the number of pixels we are overshooting (before overshootDragResistanceFactor)
133
134 // state
135
138 bool firstScroll; // true if we haven't already send a scroll event
139
140 QPointF oldVelocity; // the release velocity of the last drag
141
146
147 QPointF dragDistance; // the distance we should move during the next drag timer event
148
149 QQueue<ScrollSegment> xSegments;
150 QQueue<ScrollSegment> ySegments;
151
152 // snap positions
153 QList<qreal> snapPositionsX;
156 QList<qreal> snapPositionsY;
159
161
163
164 QPointF releaseVelocity; // the starting velocity of the scrolling state
165#if QT_CONFIG(animation)
166 QScrollTimer *scrollTimer;
167#endif
168
170};
171template <>
172class QTypeInfo<QScrollerPrivate::ScrollSegment>
173 : public QTypeInfoMerger<QScrollerPrivate::ScrollSegment, QEasingCurve> {};
174
175
177
178#endif // QSCROLLER_P_H
179
\inmodule QtCore
Type
The type of easing curve.
\inmodule QtCore
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qrect.h:484
T * data() const noexcept
Returns the value of the pointer referenced by this object.
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)
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)
QScrollerPrivate(QScroller *q, QObject *target)
QScrollerProperties::FrameRates frameRate
The QScrollerProperties class stores the settings for a QScroller.
QScopedPointer< QScrollerPropertiesPrivate > d
The QScroller class enables kinetic scrolling for any scrolling widget or graphics item.
Definition qscroller.h:26
Input
This enum contains an input device agnostic view of input events that are relevant for QScroller.
Definition qscroller.h:51
State
This enum contains the different QScroller states.
Definition qscroller.h:34
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qtypeinfo.h:100
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QOpenGLWidget * widget
[1]
Combined button and popup list for selecting options.
Orientation
Definition qnamespace.h:98
GestureType
GLsizei const GLfloat * v
[13]
GLenum type
GLenum target
GLdouble s
[6]
Definition qopenglext.h:235
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint segments
GLfloat GLfloat p
[1]
GLenum GLenum GLenum input
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_OBJECT
#define slots
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
QString dir
[11]