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,
84 public QSafeQuickItemChangeListener<QQuickScrollBarAttachedPrivate>
85{
86public:
87 static QQuickScrollBarAttachedPrivate *get(QQuickScrollBarAttached *attached)
88 {
89 return attached->d_func();
90 }
91
92 void setFlickable(QQuickFlickable *flickable);
93
94 void initHorizontal();
95 void initVertical();
96 void cleanupHorizontal();
97 void cleanupVertical();
98 void activateHorizontal();
99 void activateVertical();
100 void scrollHorizontal();
101 void scrollVertical();
102 void mirrorVertical();
103
104 void layoutHorizontal(bool move = true);
105 void layoutVertical(bool move = true);
106
107 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
108 void itemImplicitWidthChanged(QQuickItem *item) override;
109 void itemImplicitHeightChanged(QQuickItem *item) override;
110 void itemDestroyed(QQuickItem *item) override;
111
112 QQuickFlickable *flickable = nullptr;
113 QQuickScrollBar *horizontal = nullptr;
114 QQuickScrollBar *vertical = nullptr;
115};
116
117QT_END_NAMESPACE
118
119#endif // QQUICKSCROLLBAR_P_P_H
120

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