1// Copyright (C) 2017 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 QQUICKSCROLLBAR_P_P_H
5#define QQUICKSCROLLBAR_P_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 <QtQuickTemplates2/private/qquickscrollbar_p.h>
19#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
20#include <QtQuick/private/qquickitemchangelistener_p.h>
21
22QT_BEGIN_NAMESPACE
23
24class QQuickFlickable;
25class QQuickIndicatorButton;
26
27class QQuickScrollBarPrivate : public QQuickControlPrivate
28{
29 Q_DECLARE_PUBLIC(QQuickScrollBar)
30
31public:
32 static QQuickScrollBarPrivate *get(QQuickScrollBar *bar)
33 {
34 return bar->d_func();
35 }
36
37 struct VisualArea
38 {
39 VisualArea(qreal pos, qreal sz)
40 : position(pos), size(sz) { }
41 qreal position = 0;
42 qreal size = 0;
43 };
44 VisualArea visualArea() const;
45
46 qreal logicalPosition(qreal position) const;
47
48 void setPosition(qreal position, bool notifyVisualChange = true);
49 qreal snapPosition(qreal position) const;
50 qreal positionAt(const QPointF &point) const;
51 void setInteractive(bool interactive);
52 void updateActive();
53 void resizeContent() override;
54 void itemImplicitWidthChanged(QQuickItem *item) override;
55 void itemImplicitHeightChanged(QQuickItem *item) override;
56
57 bool handlePress(const QPointF &point, ulong timestamp) override;
58 bool handleMove(const QPointF &point, ulong timestamp) override;
59 bool handleRelease(const QPointF &point, ulong timestamp) override;
60 void handleUngrab() override;
61
62 void visualAreaChange(const VisualArea &newVisualArea, const VisualArea &oldVisualArea);
63
64 void updateHover(const QPointF &pos, std::optional<bool> newHoverState = {});
65
66 QQuickIndicatorButton *decreaseVisual = nullptr;
67 QQuickIndicatorButton *increaseVisual = nullptr;
68 qreal size = 0;
69 qreal position = 0;
70 qreal stepSize = 0;
71 qreal offset = 0;
72 qreal minimumSize = 0;
73 bool active = false;
74 bool pressed = false;
75 bool moving = false;
76 bool interactive = true;
77 bool explicitInteractive = false;
78 Qt::Orientation orientation = Qt::Vertical;
79 QQuickScrollBar::SnapMode snapMode = QQuickScrollBar::NoSnap;
80 QQuickScrollBar::Policy policy = QQuickScrollBar::AsNeeded;
81};
82
83class QQuickScrollBarAttachedPrivate : public QObjectPrivate, public QQuickItemChangeListener
84{
85public:
86 static QQuickScrollBarAttachedPrivate *get(QQuickScrollBarAttached *attached)
87 {
88 return attached->d_func();
89 }
90
91 void setFlickable(QQuickFlickable *flickable);
92
93 void initHorizontal();
94 void initVertical();
95 void cleanupHorizontal();
96 void cleanupVertical();
97 void activateHorizontal();
98 void activateVertical();
99 void scrollHorizontal();
100 void scrollVertical();
101 void mirrorVertical();
102
103 void layoutHorizontal(bool move = true);
104 void layoutVertical(bool move = true);
105
106 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
107 void itemImplicitWidthChanged(QQuickItem *item) override;
108 void itemImplicitHeightChanged(QQuickItem *item) override;
109 void itemDestroyed(QQuickItem *item) override;
110
111 QQuickFlickable *flickable = nullptr;
112 QQuickScrollBar *horizontal = nullptr;
113 QQuickScrollBar *vertical = nullptr;
114};
115
116QT_END_NAMESPACE
117
118#endif // QQUICKSCROLLBAR_P_P_H
119

source code of qtdeclarative/src/quicktemplates/qquickscrollbar_p_p.h