Numworks Epsilon  1.4.1
Graphing Calculator Operating System
interactive_curve_view_controller.cpp
Go to the documentation of this file.
3 #include <cmath>
4 #include <assert.h>
5 
6 using namespace Poincare;
7 
8 namespace Shared {
9 
10 InteractiveCurveViewController::InteractiveCurveViewController(Responder * parentResponder, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, uint32_t * modelVersion, uint32_t * rangeVersion) :
11  SimpleInteractiveCurveViewController(parentResponder, interactiveRange, curveView, cursor),
12  ButtonRowDelegate(header, nullptr),
13  m_modelVersion(modelVersion),
14  m_rangeVersion(rangeVersion),
15  m_rangeParameterController(this, interactiveRange),
16  m_zoomParameterController(this, interactiveRange, curveView),
17  m_rangeButton(this, I18n::Message::Axis, Invocation([](void * context, void * sender) {
18  InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context;
19  StackViewController * stack = graphController->stackController();
20  stack->push(graphController->rangeParameterController());
21  }, this), KDText::FontSize::Small),
22  m_zoomButton(this, I18n::Message::Zoom, Invocation([](void * context, void * sender) {
23  InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context;
24  StackViewController * stack = graphController->stackController();
25  stack->push(graphController->zoomParameterController());
26  }, this), KDText::FontSize::Small),
27  m_defaultInitialisationButton(this, I18n::Message::Initialization, Invocation([](void * context, void * sender) {
28  InteractiveCurveViewController * graphController = (InteractiveCurveViewController *) context;
29  StackViewController * stack = graphController->stackController();
30  stack->push(graphController->initialisationParameterController());
31  }, this), KDText::FontSize::Small)
32 {
33 }
34 
36  return I18n::translate(I18n::Message::GraphTab);
37 }
38 
40  if (!curveView()->isMainViewSelected()) {
41  if (event == Ion::Events::Down) {
43  curveView()->selectMainView(true);
44  app()->setFirstResponder(this);
46  curveView()->reload();
47  return true;
48  }
49  if (event == Ion::Events::Up) {
52  return true;
53  }
54  return false;
55  }
57  return true;
58  }
59  if (event == Ion::Events::Down || event == Ion::Events::Up) {
60  int direction = event == Ion::Events::Down ? -1 : 1;
61  if (moveCursorVertically(direction)) {
63  curveView()->reload();
64  return true;
65  }
66  if (event == Ion::Events::Down) {
67  return false;
68  }
69  curveView()->selectMainView(false);
71  return true;
72  }
73  return false;
74 }
75 
77  if (!curveView()->isMainViewSelected()) {
79  }
80 }
81 
83  return &m_rangeParameterController;
84 }
85 
87  return &m_zoomParameterController;
88 }
89 
91  if (isEmpty()) {
92  return 0;
93  }
94  return 3;
95 }
96 
98  const Button * buttons[3] = {&m_rangeButton, &m_zoomButton, &m_defaultInitialisationButton};
99  return (Button *)buttons[index];
100 }
101 
103  return tabController();
104 }
105 
107  uint32_t newModelVersion = modelVersion();
108  if (*m_modelVersion != newModelVersion) {
109  *m_modelVersion = newModelVersion;
111  /* Warning: init cursor parameter before reloading banner view. Indeed,
112  * reloading banner view needs an updated cursor to load the right data. */
114  }
115  uint32_t newRangeVersion = rangeVersion();
116  if (*m_rangeVersion != newRangeVersion) {
117  *m_rangeVersion = newRangeVersion;
118  if (!isCursorVisible()) {
120  }
121  }
123  if (!curveView()->isMainViewSelected()) {
124  curveView()->selectMainView(true);
125  header()->setSelectedButton(-1);
126  }
128  curveView()->reload();
129 }
130 
132  *m_rangeVersion = rangeVersion();
133 }
134 
137  curveView()->reload();
138 }
139 
141  if (nextFirstResponder == nullptr || nextFirstResponder == tabController()) {
142  curveView()->selectMainView(false);
143  header()->setSelectedButton(-1);
144  curveView()->reload();
145  }
146 }
147 
149  return (stackController()->parentResponder());
150 }
151 
154 }
155 
156 }
virtual StackViewController * stackController() const
Definition: i18n.h:6
int numberOfButtons(ButtonRowController::Position position) const override
void push(ViewController *vc, KDColor textColor=Palette::SubTab, KDColor backgroundColor=KDColorWhite, KDColor separatorColor=Palette::GreyBright)
Responder * parentResponder() const
Definition: responder.cpp:12
constexpr Event Up
Definition: events.h:62
constexpr Event Down
Definition: events.h:63
void setOkView(View *okView)
Definition: curve_view.cpp:77
Button * buttonAtIndex(int index, ButtonRowController::Position position) const override
void didEnterResponderChain(Responder *previousFirstResponder) override
void willExitResponderChain(Responder *nextFirstResponder) override
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
Definition: i18n.cpp:5
ButtonRowController * header()
virtual bool isEmpty() const =0
unsigned int uint32_t
Definition: stdint.h:6
virtual bool moveCursorVertically(int direction)=0
bool setSelectedButton(int selectedButton)
void setFirstResponder(Responder *responder)
Definition: app.cpp:62
bool handleEvent(Ion::Events::Event event) override
virtual void reload()
Definition: curve_view.cpp:25
void selectMainView(bool mainViewSelected)
Definition: curve_view.cpp:46
App * app()
Definition: responder.cpp:77
Definition: button.h:10