3#include "qml_material/control/control.hpp"
9class ScrollIndicatorAttached;
13class QML_MATERIAL_API ScrollIndicator :
public Control {
15 QML_NAMED_ELEMENT(ScrollIndicator)
16 QML_ATTACHED(ScrollIndicatorAttached)
17 Q_PROPERTY(qreal size READ size WRITE setSize NOTIFY sizeChanged FINAL)
18 Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged FINAL)
20 qreal minimumSize READ minimumSize WRITE setMinimumSize NOTIFY minimumSizeChanged FINAL)
21 Q_PROPERTY(qreal visualSize READ visualSize NOTIFY visualSizeChanged FINAL)
22 Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL)
23 Q_PROPERTY(
bool active READ active WRITE setActive NOTIFY activeChanged FINAL)
24 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY
25 orientationChanged FINAL)
26 Q_PROPERTY(
bool horizontal READ horizontal NOTIFY orientationChanged FINAL)
27 Q_PROPERTY(
bool vertical READ vertical NOTIFY orientationChanged FINAL)
29 explicit ScrollIndicator(QQuickItem* parent =
nullptr);
30 static ScrollIndicatorAttached* qmlAttachedProperties(QObject*);
31 qreal size()
const {
return m_size; }
32 qreal position()
const {
return m_position; }
33 qreal minimumSize()
const {
return m_minimum_size; }
34 qreal visualSize()
const;
35 qreal visualPosition()
const;
36 bool active()
const {
return m_active; }
37 Qt::Orientation orientation()
const {
return m_orientation; }
38 bool horizontal()
const {
return m_orientation == Qt::Horizontal; }
39 bool vertical()
const {
return m_orientation == Qt::Vertical; }
40 Q_SLOT
void setSize(qreal);
41 Q_SLOT
void setPosition(qreal);
42 void setMinimumSize(qreal);
44 void setOrientation(Qt::Orientation);
45 Q_SIGNAL
void sizeChanged();
46 Q_SIGNAL
void positionChanged();
47 Q_SIGNAL
void minimumSizeChanged();
48 Q_SIGNAL
void visualSizeChanged();
49 Q_SIGNAL
void visualPositionChanged();
50 Q_SIGNAL
void activeChanged();
51 Q_SIGNAL
void orientationChanged();
54 QRectF contentRect()
const override;
55 virtual void setMoving(
bool value) { setActive(value); }
56 virtual void disconnectFlickable() {}
59 friend class ScrollIndicatorAttached;
60 QPointF visualArea()
const;
61 void updateVisualArea(
const QPointF& old);
64 qreal m_minimum_size = 0;
65 bool m_active =
false;
66 Qt::Orientation m_orientation = Qt::Vertical;
67 QPointer<ScrollIndicatorAttached> m_attachment;
70class QML_MATERIAL_API ScrollIndicatorAttached :
public QObject {
72 Q_PROPERTY(ScrollIndicator* horizontal READ horizontal WRITE setHorizontal NOTIFY
73 horizontalChanged FINAL)
75 ScrollIndicator* vertical READ vertical WRITE setVertical NOTIFY verticalChanged FINAL)
77 explicit ScrollIndicatorAttached(QObject* parent);
78 ScrollIndicatorAttached(QObject* target, QObject* parent,
bool bidirectional);
79 ~ScrollIndicatorAttached()
override;
80 ScrollIndicator* horizontal()
const {
return m_horizontal.item; }
81 ScrollIndicator* vertical()
const {
return m_vertical.item; }
82 void setHorizontal(ScrollIndicator*);
83 void setVertical(ScrollIndicator*);
84 Q_SIGNAL
void horizontalChanged();
85 Q_SIGNAL
void verticalChanged();
89 QPointer<ScrollIndicator> item;
90 QList<QMetaObject::Connection> connections;
92 bool layingOut =
false;
94 bool syncPending =
false;
96 void attach(Axis&, ScrollIndicator*,
bool horizontal);
98 void layout(Axis&,
bool horizontal,
bool force =
false);
99 void activate(Axis&,
bool horizontal);
100 void sync(Axis&,
bool horizontal);
101 void scroll(Axis&,
bool horizontal);
102 Q_SLOT
void syncHorizontal();
103 Q_SLOT
void syncVertical();
104 std::unique_ptr<ScrollViewport> m_viewport;
105 QPointer<QQuickItem> m_flickable;
106 bool m_bidirectional =
false;
107 Axis m_horizontal, m_vertical;
112QML_DECLARE_TYPEINFO(qml_material::ScrollIndicator, QML_HAS_ATTACHED_PROPERTIES)