8 StackViewController::ControllerView::ControllerView() :
10 m_contentView(nullptr),
12 m_displayStackHeaders(
true)
16 void StackViewController::ControllerView::shouldDisplayStackHearders(
bool shouldDisplay) {
17 m_displayStackHeaders = shouldDisplay;
20 void StackViewController::ControllerView::setContentView(
View * view) {
23 markRectAsDirty(bounds());
26 void StackViewController::ControllerView::pushStack(Frame frame) {
27 m_stackViews[m_numberOfStacks].setNamedController(frame.viewController());
28 m_stackViews[m_numberOfStacks].setTextColor(frame.textColor());
29 m_stackViews[m_numberOfStacks].setBackgroundColor(frame.backgroundColor());
30 m_stackViews[m_numberOfStacks].setSeparatorColor(frame.separatorColor());
34 void StackViewController::ControllerView::popStack() {
35 assert(m_numberOfStacks > 0);
39 void StackViewController::ControllerView::layoutSubviews() {
41 if (m_displayStackHeaders) {
42 for (
int i=0; i<m_numberOfStacks; i++) {
47 KDCoordinate separatorHeight = m_numberOfStacks > 0 ? 1 : 0;
52 m_contentView->setFrame(contentViewFrame);
56 int StackViewController::ControllerView::numberOfSubviews()
const {
57 return (m_displayStackHeaders ? m_numberOfStacks : 0) + (m_contentView ==
nullptr ? 0 : 1);
60 View * StackViewController::ControllerView::subviewAtIndex(
int index) {
61 if (!m_displayStackHeaders) {
65 if (index < m_numberOfStacks) {
67 return &m_stackViews[index];
69 assert(index == m_numberOfStacks);
74 #if ESCHER_VIEW_LOGGING 75 const char * StackViewController::ControllerView::className()
const {
76 return "StackViewController::ControllerView";
83 m_numberOfChildren(0),
86 pushModel(Frame(rootViewController, textColor, backgroundColor, separatorColor));
96 Frame frame = Frame(vc, textColor, backgroundColor, separatorColor);
104 m_view.pushStack(frame);
106 setupActiveViewController();
107 if (m_numberOfChildren > 1) {
108 m_childrenFrame[m_numberOfChildren-2].viewController()->viewDidDisappear();
113 assert(m_numberOfChildren > 0);
114 ViewController * vc = m_childrenFrame[m_numberOfChildren-1].viewController();
118 m_numberOfChildren--;
119 setupActiveViewController();
125 return m_numberOfChildren;
128 void StackViewController::pushModel(Frame frame) {
129 m_childrenFrame[m_numberOfChildren++] = frame;
132 void StackViewController::setupActiveViewController() {
133 ViewController * vc = m_childrenFrame[m_numberOfChildren-1].viewController();
136 m_view.setContentView(vc->
view());
143 ViewController * vc = m_childrenFrame[m_numberOfChildren-1].viewController();
161 for (
int i = 0; i < m_numberOfChildren; i++) {
162 ViewController * childrenVC = m_childrenFrame[i].viewController();
164 m_view.pushStack(m_childrenFrame[i]);
168 ViewController * vc = m_childrenFrame[m_numberOfChildren-1].viewController();
169 if (m_numberOfChildren > 0 && vc) {
170 m_view.setContentView(vc->
view());
178 ViewController * vc = m_childrenFrame[m_numberOfChildren-1].viewController();
179 if (m_numberOfChildren > 0 && vc) {
182 for (
int i = 0; i < m_view.numberOfStacks(); i++) {
static constexpr KDCoordinate StackTitleHeight
StackViewController(Responder *parentResponder, ViewController *rootViewController, KDColor textColor=Palette::SubTab, KDColor backgroundColor=KDColorWhite, KDColor separatorColor=Palette::GreyBright)
void push(ViewController *vc, KDColor textColor=Palette::SubTab, KDColor backgroundColor=KDColorWhite, KDColor separatorColor=Palette::GreyBright)
const char * title() override
void viewDidDisappear() override
void setParentResponder(Responder *responder)
bool handleEvent(Ion::Events::Event event) override
virtual void viewWillAppear()
void viewWillAppear() override
void didBecomeFirstResponder() override
virtual const char * title()
void setFirstResponder(Responder *responder)
virtual void viewDidDisappear()
virtual DisplayParameter displayParameter()