3#include "qml_material/control/scroll_indicator.hpp"
4#include "qml_material/input/input_host.hpp"
8class ScrollBarAttached;
11class QML_MATERIAL_API ScrollBar :
public ScrollIndicator {
13 QML_NAMED_ELEMENT(ScrollBarBase)
14 QML_ATTACHED(ScrollBarAttached)
15 Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL)
16 Q_PROPERTY(InteractionSource* interactionSource READ interactionSource WRITE
17 setInteractionSource NOTIFY interactionSourceChanged FINAL)
18 Q_PROPERTY(qml_material::InteractionValues interactionValues READ interactionValues NOTIFY
19 interactionValuesChanged FINAL)
20 Q_PROPERTY(
bool interactive READ interactive WRITE setInteractive RESET resetInteractive NOTIFY
21 interactiveChanged FINAL)
22 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL)
23 Q_PROPERTY(Policy policy READ policy WRITE setPolicy NOTIFY policyChanged FINAL)
34 AsNeeded = Qt::ScrollBarAsNeeded,
35 AlwaysOff = Qt::ScrollBarAlwaysOff,
36 AlwaysOn = Qt::ScrollBarAlwaysOn
39 explicit ScrollBar(QQuickItem* parent =
nullptr);
40 ~ScrollBar()
override;
41 static ScrollBarAttached* qmlAttachedProperties(QObject*);
42 qreal stepSize()
const {
return m_step; }
43 InteractionSource* interactionSource() {
return m_input.source(); }
44 void setInteractionSource(InteractionSource* source) { m_input.setSource(source); }
45 InteractionValues interactionValues()
const {
return m_feedback.values(); }
46 bool interactive()
const {
return m_interactive; }
47 SnapMode snapMode()
const {
return m_snap; }
48 Policy policy()
const {
return m_policy; }
49 void setStepSize(qreal);
50 void setInteractive(
bool);
51 void resetInteractive();
52 void setSnapMode(SnapMode);
53 void setPolicy(Policy);
54 Q_INVOKABLE
void increase();
55 Q_INVOKABLE
void decrease();
56 Q_INVOKABLE
void requestPosition(qreal);
57 Q_SIGNAL
void stepSizeChanged();
58 Q_SIGNAL
void interactionSourceChanged();
59 Q_SIGNAL
void interactionValuesChanged();
60 Q_SIGNAL
void positionChangeRequested(qreal position);
61 Q_SIGNAL
void interactiveChanged();
62 Q_SIGNAL
void snapModeChanged();
63 Q_SIGNAL
void policyChanged();
66 void setMoving(
bool)
override;
67 void disconnectFlickable()
override;
68 bool event(QEvent*)
override;
69 void mouseUngrabEvent()
override;
70 void touchUngrabEvent()
override;
75 void begin(
const QPointF&);
76 void move(
const QPointF&,
bool release);
78 qreal logicalPosition(qreal)
const;
79 qreal positionAt(
const QPointF&)
const;
81 InteractionAccumulator m_feedback;
85 bool m_interactive =
true;
86 bool m_moving =
false;
87 SnapMode m_snap = NoSnap;
88 Policy m_policy = AsNeeded;
91class QML_MATERIAL_API ScrollBarAttached :
public QObject {
94 ScrollBar* horizontal READ horizontal WRITE setHorizontal NOTIFY horizontalChanged FINAL)
95 Q_PROPERTY(ScrollBar* vertical READ vertical WRITE setVertical NOTIFY verticalChanged FINAL)
97 explicit ScrollBarAttached(QObject* parent);
98 ScrollBar* horizontal()
const;
99 ScrollBar* vertical()
const;
100 void setHorizontal(ScrollBar*);
101 void setVertical(ScrollBar*);
102 Q_SIGNAL
void horizontalChanged();
103 Q_SIGNAL
void verticalChanged();
106 ScrollIndicatorAttached* m_attachment;
110QML_DECLARE_TYPEINFO(qml_material::ScrollBar, QML_HAS_ATTACHED_PROPERTIES)