diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index 044a4c882..062792908 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -2,17 +2,14 @@ #include ValuesController::ValuesController(Responder * parentResponder, Graph::FunctionStore * functionStore) : - ViewController(parentResponder), + HeaderViewController(parentResponder, &m_tableView), m_tableView(TableView(this, k_topMargin, k_rightMargin, k_bottomMargin, k_leftMargin)), m_activeCellX(0), m_activeCellY(-1), m_functionStore(functionStore), m_interval(Graph::Interval(-1.0f, 1.0f, 0.25f)) { -} - -View * ValuesController::view() { - return &m_tableView; + setButtonTitles("Regler l'intervalle", nullptr, nullptr); } const char * ValuesController::title() const { @@ -111,26 +108,40 @@ void ValuesController::didBecomeFirstResponder() { } bool ValuesController::handleEvent(Ion::Events::Event event) { - switch (event) { - case Ion::Events::Event::DOWN_ARROW: - setActiveCell(m_activeCellX, m_activeCellY+1); - return true; - case Ion::Events::Event::UP_ARROW: - setActiveCell(m_activeCellX, m_activeCellY-1); - if (m_activeCellY == -1) { + if (m_activeCellY == -1) { + switch (event) { + case Ion::Events::Event::DOWN_ARROW: + setSelectedButton(-1); + setActiveCell(m_activeCellX, m_activeCellY+1); + return true; + case Ion::Events::Event::UP_ARROW: + setSelectedButton(-1); app()->setFirstResponder(tabController()); - } - return true; - case Ion::Events::Event::LEFT_ARROW: - setActiveCell(m_activeCellX-1, m_activeCellY); - return true; - case Ion::Events::Event::RIGHT_ARROW: - setActiveCell(m_activeCellX+1, m_activeCellY); - return true; - case Ion::Events::Event::ENTER: - return false; - default: - return false; + default: + return HeaderViewController::handleEvent(event); + } + } else { + switch (event) { + case Ion::Events::Event::DOWN_ARROW: + setActiveCell(m_activeCellX, m_activeCellY+1); + return true; + case Ion::Events::Event::UP_ARROW: + setActiveCell(m_activeCellX, m_activeCellY-1); + if (m_activeCellY == -1) { + setSelectedButton(0); + } + return true; + case Ion::Events::Event::LEFT_ARROW: + setActiveCell(m_activeCellX-1, m_activeCellY); + return true; + case Ion::Events::Event::RIGHT_ARROW: + setActiveCell(m_activeCellX+1, m_activeCellY); + return true; + case Ion::Events::Event::ENTER: + return true; + default: + return false; + } } } diff --git a/apps/graph/values/values_controller.h b/apps/graph/values/values_controller.h index 7eb4fcc53..81f9a835c 100644 --- a/apps/graph/values/values_controller.h +++ b/apps/graph/values/values_controller.h @@ -7,13 +7,12 @@ #include "title_cell.h" #include "interval.h" -class ValuesController : public ViewController, public TableViewDataSource { +class ValuesController : public HeaderViewController, public TableViewDataSource { public: ValuesController(Responder * parentResponder, Graph::FunctionStore * functionStore); void setActiveCell(int i, int j); - View * view() override; const char * title() const override; bool handleEvent(Ion::Events::Event event) override; void didBecomeFirstResponder() override;