3#include "qml_material/control/control.hpp"
5#include "qml_material/anim/size_transition.hpp"
7#include "qml_material/control/page_motion.hpp"
8#include "qml_material/input/input_host.hpp"
9#include <QQmlComponent>
13class PageStackAttached;
14class QML_MATERIAL_API PageStack :
public Control {
16 QML_NAMED_ELEMENT(PageStackBase)
17 QML_ATTACHED(PageStackAttached)
18 Q_PROPERTY(
int depth READ depth NOTIFY depthChanged FINAL)
19 Q_PROPERTY(
bool empty READ empty NOTIFY depthChanged FINAL)
20 Q_PROPERTY(
bool busy READ busy NOTIFY busyChanged FINAL)
21 Q_PROPERTY(SizeTransition* sizeTransition READ sizeTransition WRITE setSizeTransition NOTIFY
22 sizeTransitionChanged FINAL)
24 QQmlComponent* pushMotion READ pushMotion WRITE setPushMotion NOTIFY motionsChanged FINAL)
26 QQmlComponent* popMotion READ popMotion WRITE setPopMotion NOTIFY motionsChanged FINAL)
27 Q_PROPERTY(QQmlComponent* replaceMotion READ replaceMotion WRITE setReplaceMotion NOTIFY
29 Q_PROPERTY(PageMotion* currentMotion READ currentMotion NOTIFY currentMotionChanged FINAL)
30 Q_PROPERTY(
bool preview READ preview NOTIFY previewChanged FINAL)
31 Q_PROPERTY(
bool settling READ settling NOTIFY previewChanged FINAL)
32 Q_PROPERTY(
bool backGestureEnabled READ backGestureEnabled WRITE setBackGestureEnabled NOTIFY
33 backGestureEnabledChanged FINAL)
34 Q_PROPERTY(QSizeF destinationSize READ destinationSize NOTIFY destinationSizeChanged FINAL)
35 Q_PROPERTY(QQuickItem* currentItem READ currentItem NOTIFY currentItemChanged FINAL)
36 Q_PROPERTY(QQuickItem* initialItem READ initialItem WRITE setInitialItem NOTIFY
37 initialItemChanged FINAL)
52 Q_ENUM(TransitionMode)
53 explicit PageStack(QQuickItem* parent =
nullptr);
54 ~PageStack()
override;
55 static PageStackAttached* qmlAttachedProperties(QObject*);
57 bool empty()
const {
return depth() == 0; }
59 SizeTransition* sizeTransition()
const;
60 void setSizeTransition(SizeTransition*);
61 Q_SIGNAL
void sizeTransitionChanged();
62 QQmlComponent* pushMotion()
const;
63 QQmlComponent* popMotion()
const;
64 QQmlComponent* replaceMotion()
const;
65 void setPushMotion(QQmlComponent*);
66 void setPopMotion(QQmlComponent*);
67 void setReplaceMotion(QQmlComponent*);
68 PageMotion* currentMotion()
const;
70 bool settling()
const;
71 bool backGestureEnabled()
const;
72 void setBackGestureEnabled(
bool);
73 QSizeF destinationSize()
const;
74 Q_INVOKABLE QString beginPopPreview();
75 Q_INVOKABLE
bool updatePopPreview(QString
id, qreal progress);
76 Q_INVOKABLE
bool commitPopPreview(QString
id, qreal velocity = 0);
77 Q_INVOKABLE
bool cancelPopPreview(QString
id, qreal velocity = 0);
78 Q_INVOKABLE
void abortPreview();
79 Q_INVOKABLE
void completeTransition();
80 Q_SIGNAL
void busyChanged();
81 Q_SIGNAL
void motionsChanged();
82 Q_SIGNAL
void currentMotionChanged();
83 Q_SIGNAL
void previewChanged();
84 Q_SIGNAL
void backGestureEnabledChanged();
85 Q_SIGNAL
void destinationSizeChanged();
86 QQuickItem* currentItem()
const;
87 QQuickItem* initialItem()
const;
88 void setInitialItem(QQuickItem*);
89 Q_INVOKABLE
bool pushItem(QQuickItem*, TransitionMode mode = Animated);
90 Q_INVOKABLE
bool replaceCurrentItem(QQuickItem*, TransitionMode mode = Animated);
91 Q_INVOKABLE
bool popCurrentItem(TransitionMode mode = Animated);
92 Q_INVOKABLE
bool clear(TransitionMode mode = Animated);
93 Q_INVOKABLE QQuickItem* itemAt(
int index)
const;
94 Q_SIGNAL
void depthChanged();
95 Q_SIGNAL
void currentItemChanged();
96 Q_SIGNAL
void initialItemChanged();
97 Q_SIGNAL
void entryRemoved(quint64
id);
98 Q_SIGNAL
void entryAdded(quint64
id, QQuickItem* item);
101 void enableDefaultMotion();
102 void componentComplete()
override;
103 void geometryChange(
const QRectF&,
const QRectF&)
override;
104 bool childMouseEventFilter(QQuickItem*, QEvent*)
override;
105 QSizeF measureImplicitContent()
const override;
109 std::shared_ptr<State> m_state;
110 bool navigate(
int operation, QQuickItem*, TransitionMode);
113 void removePage(quint64);
114 void startTransition(quint64);
116 bool settlePreview(QString,
bool, qreal);
117 void tryFinishTransition();
121 QPointF m_gesturePoint;
122 qreal m_gestureFraction = 0;
125class QML_MATERIAL_API MaterialPageStack :
public PageStack {
127 QML_NAMED_ELEMENT(PageStack)
128 QML_ATTACHED(PageStackAttached)
130 explicit MaterialPageStack(QQuickItem* parent =
nullptr);
133class QML_MATERIAL_API PageStackAttached :
public QObject {
135 Q_PROPERTY(PageStack* view READ view NOTIFY changed FINAL)
136 Q_PROPERTY(
int index READ index NOTIFY changed FINAL)
137 Q_PROPERTY(PageStack::Status status READ status NOTIFY statusChanged FINAL)
139 using Status = PageStack::Status;
140 explicit PageStackAttached(QObject* parent): QObject(parent) {}
141 PageStack* view()
const {
return m_view; }
142 int index()
const {
return m_index; }
143 Status status()
const {
return m_status; }
144 Q_SIGNAL
void changed();
145 Q_SIGNAL
void statusChanged();
146 Q_SIGNAL
void removed();
149 friend class PageStack;
150 void update(PageStack*,
int, Status);
151 QPointer<PageStack> m_view;
153 Status m_status = PageStack::Inactive;
154 bool m_removing =
false;
157QML_DECLARE_TYPEINFO(qml_material::PageStack, QML_HAS_ATTACHED_PROPERTIES)
158QML_DECLARE_TYPEINFO(qml_material::MaterialPageStack, QML_HAS_ATTACHED_PROPERTIES)