diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index ebf9d27c2..154380314 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -29,6 +29,7 @@ ValuesController::ValuesController(Responder * parentResponder, InputEventHandle m_functionTitleCells[i].setFont(KDFont::SmallFont); } setupAbscissaCellsAndTitleCells(inputEventHandlerDelegate); + m_selectableTableView.setDelegate(this); } void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { @@ -101,6 +102,15 @@ I18n::Message ValuesController::emptyMessage() { return I18n::Message::NoActivatedFunction; } +void ValuesController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection) { + const int i = selectedColumn(); + const int j = selectedRow(); + const int numberOfElementsInCol = numberOfElementsInColumn(i); + if (j > 1 + numberOfElementsInCol) { + selectCellAtLocation(i, 1 + numberOfElementsInCol); + } +} + Ion::Storage::Record ValuesController::recordAtColumn(int i) { bool isDerivative = false; return recordAtColumn(i, &isDerivative); diff --git a/apps/graph/values/values_controller.h b/apps/graph/values/values_controller.h index 6146cf859..2bd9717f7 100644 --- a/apps/graph/values/values_controller.h +++ b/apps/graph/values/values_controller.h @@ -14,7 +14,7 @@ namespace Graph { -class ValuesController : public Shared::ValuesController { +class ValuesController : public Shared::ValuesController, public SelectableTableViewDelegate { public: ValuesController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header); Button * buttonAtIndex(int index, ButtonRowController::Position position) const override { @@ -29,6 +29,7 @@ public: IntervalParameterSelectorController * intervalParameterSelectorController() { return &m_intervalParameterSelectorController; } + void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) override; private: constexpr static int k_maxNumberOfFunctions = 5; constexpr static int k_maxNumberOfAbscissaCells = Shared::CartesianFunction::k_numberOfPlotTypes * k_maxNumberOfRows; diff --git a/apps/shared/store_selectable_table_view.h b/apps/shared/store_selectable_table_view.h index 8bca451aa..e8592d831 100644 --- a/apps/shared/store_selectable_table_view.h +++ b/apps/shared/store_selectable_table_view.h @@ -7,6 +7,7 @@ namespace Shared { class StoreSelectableTableView : public SelectableTableView { +// TODO Put this behavior in the SelectableTableView delegate public: StoreSelectableTableView(DoublePairStore * store, Responder * parentResponder, TableViewDataSource * dataSource, SelectableTableViewDataSource * selectionDataSource = nullptr, SelectableTableViewDelegate * delegate = nullptr); bool handleEvent(Ion::Events::Event event) override; diff --git a/apps/shared/values_controller.h b/apps/shared/values_controller.h index 23b6bc45d..99968a641 100644 --- a/apps/shared/values_controller.h +++ b/apps/shared/values_controller.h @@ -56,11 +56,12 @@ protected: virtual FunctionStore * functionStore() const; virtual Ion::Storage::Record recordAtColumn(int i); int numberOfElementsInColumn(int columnIndex) override; + SelectableTableView * selectableTableView() override { return &m_selectableTableView; } int m_numberOfColumns; bool m_numberOfColumnsNeedUpdate; + SelectableTableView m_selectableTableView; private: Responder * tabController() const override; - SelectableTableView * selectableTableView() override { return &m_selectableTableView; } bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override; double dataAtLocation(int columnIndex, int rowIndex) override; virtual Interval * intervalAtColumn(int columnIndex) = 0; @@ -70,7 +71,6 @@ private: virtual double evaluationOfAbscissaAtColumn(double abscissa, int columnIndex); virtual int maxNumberOfCells() = 0; virtual int maxNumberOfFunctions() = 0; - SelectableTableView m_selectableTableView; virtual FunctionTitleCell * functionTitleCells(int j) = 0; virtual EvenOddBufferTextCell * floatCells(int j) = 0; virtual int abscissaCellsCount() const = 0;