diff --git a/apps/shared/Makefile b/apps/shared/Makefile index bcd225770..52777d509 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -43,6 +43,7 @@ app_objs += $(addprefix apps/shared/,\ expression_layout_field_delegate.o\ store_controller.o\ store_parameter_controller.o\ + store_selectable_table_view.o\ sum_graph_controller.o\ tab_table_controller.o\ text_field_delegate.o\ diff --git a/apps/shared/store_controller.cpp b/apps/shared/store_controller.cpp index 65b252602..a24454b63 100644 --- a/apps/shared/store_controller.cpp +++ b/apps/shared/store_controller.cpp @@ -1,4 +1,5 @@ #include "store_controller.h" +#include "store_selectable_table_view.h" #include "../apps_container.h" #include "../constant.h" #include @@ -167,7 +168,10 @@ int StoreController::maxNumberOfElements() const { } View * StoreController::loadView() { - SelectableTableView * tableView = (SelectableTableView*)EditableCellTableViewController::loadView(); + StoreSelectableTableView * tableView = new StoreSelectableTableView(m_store, this, this, this); + tableView->setBackgroundColor(Palette::WallScreenDark); + tableView->setVerticalCellOverlap(0); + for (int i = 0; i < k_maxNumberOfEditableCells; i++) { m_editableCells[i] = new HideableEvenOddEditableTextCell(tableView, this, m_draftTextBuffer); } diff --git a/apps/shared/store_controller.h b/apps/shared/store_controller.h index 2e7187449..19cab4e36 100644 --- a/apps/shared/store_controller.h +++ b/apps/shared/store_controller.h @@ -2,10 +2,10 @@ #define SHARED_STORE_CONTROLLER_H #include +#include "editable_cell_table_view_controller.h" #include "float_pair_store.h" #include "hideable_even_odd_editable_text_cell.h" #include "store_parameter_controller.h" -#include "editable_cell_table_view_controller.h" namespace Shared { diff --git a/apps/shared/store_selectable_table_view.cpp b/apps/shared/store_selectable_table_view.cpp new file mode 100644 index 000000000..ec6adcf3d --- /dev/null +++ b/apps/shared/store_selectable_table_view.cpp @@ -0,0 +1,42 @@ +#include "store_selectable_table_view.h" + +namespace Shared { + +StoreSelectableTableView::StoreSelectableTableView(FloatPairStore * store, Responder * parentResponder, TableViewDataSource * dataSource, SelectableTableViewDataSource * selectionDataSource, SelectableTableViewDelegate * delegate) : + SelectableTableView(parentResponder, dataSource, selectionDataSource, delegate), + m_store(store) +{ +} + +bool StoreSelectableTableView::handleEvent(Ion::Events::Event event) { + if (event == Ion::Events::Down) { + return selecNonHiddenCellAtLocation(selectedColumn(), selectedRow()+1); + } + if (event == Ion::Events::Up) { + return selecNonHiddenCellAtLocation(selectedColumn(), selectedRow()-1); + } + if (event == Ion::Events::Left) { + return selecNonHiddenCellAtLocation(selectedColumn()-1, selectedRow()); + } + if (event == Ion::Events::Right) { + return selecNonHiddenCellAtLocation(selectedColumn()+1, selectedRow()); + } + return false; +} + +bool StoreSelectableTableView::selecNonHiddenCellAtLocation(int i, int j) { + if (i < 0 || i >= dataSource()->numberOfColumns()) { + return false; + } + if (j < 0 || j >= dataSource()->numberOfRows()) { + return false; + } + int seriesIndex = i/FloatPairStore::k_numberOfColumnsPerSeries; + int numberOfPairsOfCurrentSeries = m_store->numberOfPairsOfSeries(seriesIndex); + if (j > 1 + numberOfPairsOfCurrentSeries) { + return selectCellAtLocation(i, 1 + numberOfPairsOfCurrentSeries); + } + return selectCellAtLocation(i, j); +} + +} diff --git a/apps/shared/store_selectable_table_view.h b/apps/shared/store_selectable_table_view.h new file mode 100644 index 000000000..ca370b3ef --- /dev/null +++ b/apps/shared/store_selectable_table_view.h @@ -0,0 +1,20 @@ +#ifndef APPS_SHARED_STORE_SELECTABLE_TABLE_VIEW_H +#define APPS_SHARED_STORE_SELECTABLE_TABLE_VIEW_H + +#include +#include "float_pair_store.h" + +namespace Shared { + +class StoreSelectableTableView : public SelectableTableView { +public: + StoreSelectableTableView(FloatPairStore * store, Responder * parentResponder, TableViewDataSource * dataSource, SelectableTableViewDataSource * selectionDataSource = nullptr, SelectableTableViewDelegate * delegate = nullptr); + bool handleEvent(Ion::Events::Event event) override; +private: + bool selecNonHiddenCellAtLocation(int i, int j); + FloatPairStore * m_store; +}; + +} + +#endif