From 7708b903c9613ad5b4618a7194f68532974777d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 23 Sep 2016 18:07:04 +0200 Subject: [PATCH] [apps/graph/list] keep the function of interest selected when going forth and back to the parameter page Change-Id: I0b73395d579d82e36b51e5fb3601e621445463c0 --- apps/graph/list/list_controller.cpp | 14 +++++++++++++- apps/graph/list/list_controller.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index 781567b23..aedfe2e71 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -12,7 +12,6 @@ ListController::ListController(Responder * parentResponder, Graph::FunctionStore } View * ListController::view() { - setActiveCell(0); return &m_tableView; } @@ -37,6 +36,19 @@ void ListController::setActiveCell(int index) { app()->setFirstResponder(cell); } +void ListController::didBecomeFirstResponder() { + if (m_activeCell == -1) { + setActiveCell(0); + } else { + if (m_activeCell < m_functionStore->numberOfFunctions()) { + setActiveCell(m_activeCell); + } else { + setActiveCell(m_functionStore->numberOfFunctions()-1); + } + } + assert(m_activeCell >= 0); +} + void ListController::configureFunction(Graph::Function * function) { StackViewController * stack = ((StackViewController *)parentResponder()); m_parameterController.setFunction(function); diff --git a/apps/graph/list/list_controller.h b/apps/graph/list/list_controller.h index 93c4d9b02..794cae6df 100644 --- a/apps/graph/list/list_controller.h +++ b/apps/graph/list/list_controller.h @@ -15,6 +15,7 @@ public: View * view() override; const char * title() const override; bool handleEvent(Ion::Events::Event event) override; + void didBecomeFirstResponder() override; int numberOfCells() override; void willDisplayCellForIndex(View * cell, int index) override;