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 QSCROLLERPROPERTIES_H
5#define QSCROLLERPROPERTIES_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/QScopedPointer>
9#include <QtCore/QMetaType>
10#include <QtCore/QVariant>
11
12QT_REQUIRE_CONFIG(scroller);
13
14QT_BEGIN_NAMESPACE
15
16
17class QScroller;
18class QScrollerPrivate;
19class QScrollerPropertiesPrivate;
20
21class Q_WIDGETS_EXPORT QScrollerProperties
22{
23public:
24 QScrollerProperties();
25 QScrollerProperties(const QScrollerProperties &sp);
26 QScrollerProperties &operator=(const QScrollerProperties &sp);
27 virtual ~QScrollerProperties();
28
29 bool operator==(const QScrollerProperties &sp) const;
30 bool operator!=(const QScrollerProperties &sp) const;
31
32 static void setDefaultScrollerProperties(const QScrollerProperties &sp);
33 static void unsetDefaultScrollerProperties();
34
35 enum OvershootPolicy
36 {
37 OvershootWhenScrollable,
38 OvershootAlwaysOff,
39 OvershootAlwaysOn
40 };
41
42 enum FrameRates {
43 Standard,
44 Fps60,
45 Fps30,
46 Fps20
47 };
48
49 enum ScrollMetric
50 {
51 MousePressEventDelay, // qreal [s]
52 DragStartDistance, // qreal [m]
53 DragVelocitySmoothingFactor, // qreal [0..1/s] (complex calculation involving time) v = v_new* DASF + v_old * (1-DASF)
54 AxisLockThreshold, // qreal [0..1] atan(|min(dx,dy)|/|max(dx,dy)|)
55
56 ScrollingCurve, // QEasingCurve
57 DecelerationFactor, // slope of the curve
58
59 MinimumVelocity, // qreal [m/s]
60 MaximumVelocity, // qreal [m/s]
61 MaximumClickThroughVelocity, // qreal [m/s]
62
63 AcceleratingFlickMaximumTime, // qreal [s]
64 AcceleratingFlickSpeedupFactor, // qreal [1..]
65
66 SnapPositionRatio, // qreal [0..1]
67 SnapTime, // qreal [s]
68
69 OvershootDragResistanceFactor, // qreal [0..1]
70 OvershootDragDistanceFactor, // qreal [0..1]
71 OvershootScrollDistanceFactor, // qreal [0..1]
72 OvershootScrollTime, // qreal [s]
73
74 HorizontalOvershootPolicy, // enum OvershootPolicy
75 VerticalOvershootPolicy, // enum OvershootPolicy
76 FrameRate, // enum FrameRates
77
78 ScrollMetricCount
79 };
80
81 QVariant scrollMetric(ScrollMetric metric) const;
82 void setScrollMetric(ScrollMetric metric, const QVariant &value);
83
84protected:
85 QScopedPointer<QScrollerPropertiesPrivate> d;
86
87private:
88 QScrollerProperties(QScrollerPropertiesPrivate &dd);
89
90 friend class QScrollerPropertiesPrivate;
91 friend class QScroller;
92 friend class QScrollerPrivate;
93};
94
95QT_END_NAMESPACE
96
97QT_DECL_METATYPE_EXTERN_TAGGED(QScrollerProperties::OvershootPolicy,
98 QScrollerProperties__OvershootPolicy, Q_WIDGETS_EXPORT)
99QT_DECL_METATYPE_EXTERN_TAGGED(QScrollerProperties::FrameRates,
100 QScrollerProperties__FrameRates, Q_WIDGETS_EXPORT)
101
102#endif // QSCROLLERPROPERTIES_H
103

source code of qtbase/src/widgets/util/qscrollerproperties.h