Numworks Epsilon  1.4.1
Graphing Calculator Operating System
stack_view_controller.h
Go to the documentation of this file.
1 #ifndef ESCHER_STACK_VIEW_CONTROLLER_H
2 #define ESCHER_STACK_VIEW_CONTROLLER_H
3 
5 #include <escher/stack_view.h>
6 #include <escher/palette.h>
7 
8 constexpr uint8_t kMaxNumberOfStacks = 4;
9 
11 public:
13  KDColor textColor = Palette::SubTab, KDColor backgroundColor = KDColorWhite, KDColor separatorColor = Palette::GreyBright);
14 
15  /* Push creates a new StackView and adds it */
16  void push(ViewController * vc, KDColor textColor = Palette::SubTab, KDColor backgroundColor = KDColorWhite, KDColor separatorColor = Palette::GreyBright);
17  void pop();
18 
19  int depth();
20  View * view() override;
21  const char * title() override;
22  bool handleEvent(Ion::Events::Event event) override;
23  void didBecomeFirstResponder() override;
24  void viewWillAppear() override;
25  void viewDidDisappear() override;
26 private:
27  class Frame {
28  public:
29  Frame(ViewController * viewController = nullptr, KDColor textColor = Palette::SubTab, KDColor backgroundColor = KDColorWhite, KDColor separatorColor = Palette::GreyBright) :
30  m_viewController(viewController),
31  m_textColor(textColor),
32  m_backgroundColor(backgroundColor),
33  m_separatorColor(separatorColor) {}
34  ViewController * viewController() { return m_viewController; }
35  KDColor textColor() { return m_textColor; }
36  KDColor backgroundColor() { return m_backgroundColor; }
37  KDColor separatorColor() { return m_separatorColor; }
38  private:
39  ViewController * m_viewController;
40  KDColor m_textColor;
41  KDColor m_backgroundColor;
42  KDColor m_separatorColor;
43  };
44  class ControllerView : public View {
45  public:
46  ControllerView();
47  void shouldDisplayStackHearders(bool shouldDisplay);
48  int8_t numberOfStacks() const { return m_numberOfStacks; }
49  void setContentView(View * view);
50  void pushStack(Frame frame);
51  void popStack();
52  protected:
53 #if ESCHER_VIEW_LOGGING
54  const char * className() const override;
55 #endif
56  private:
57  int numberOfSubviews() const override;
58  View * subviewAtIndex(int index) override;
59  void layoutSubviews() override;
60 
61  StackView m_stackViews[kMaxNumberOfStacks];
62  View * m_contentView;
63  int8_t m_numberOfStacks;
64  bool m_displayStackHeaders;
65  };
66  ControllerView m_view;
67  void pushModel(Frame frame);
68  void setupActiveViewController();
69  static constexpr uint8_t k_maxNumberOfChildren = 4;
70  Frame m_childrenFrame[k_maxNumberOfChildren];
71  uint8_t m_numberOfChildren;
72  bool m_isVisible;
73 };
74 
75 #endif
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)
Responder * parentResponder() const
Definition: responder.cpp:12
const char * title() override
unsigned char uint8_t
Definition: stdint.h:4
void viewDidDisappear() override
constexpr KDColor KDColorWhite
Definition: color.h:42
static constexpr KDColor SubTab
Definition: palette.h:21
bool handleEvent(Ion::Events::Event event) override
constexpr uint8_t kMaxNumberOfStacks
signed char int8_t
Definition: stdint.h:9
Definition: color.h:6
void didBecomeFirstResponder() override
Definition: view.h:23
static constexpr KDColor GreyBright
Definition: palette.h:13