diff --git a/apps/shared/Makefile b/apps/shared/Makefile index 5034a0580..bcd225770 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -21,6 +21,7 @@ app_objs += $(addprefix apps/shared/,\ function_expression_cell.o\ function_title_cell.o\ go_to_parameter_controller.o\ + hideable_even_odd_editable_text_cell.o\ initialisation_parameter_controller.o\ interactive_curve_view_controller.o\ interactive_curve_view_range.o\ diff --git a/apps/shared/hideable_even_odd_editable_text_cell.cpp b/apps/shared/hideable_even_odd_editable_text_cell.cpp new file mode 100644 index 000000000..c9f5b1ed1 --- /dev/null +++ b/apps/shared/hideable_even_odd_editable_text_cell.cpp @@ -0,0 +1,20 @@ +#include "hideable_even_odd_editable_text_cell.h" + +namespace Shared { + +KDColor HideableEvenOddEditableTextCell::backgroundColor() const { + if (m_hide) { + return Palette::WallScreenDark; + } + return EvenOddEditableTextCell::backgroundColor(); +} + +void HideableEvenOddEditableTextCell::setHide(bool hide) { + if (m_hide != hide) { + m_hide = hide; + editableTextCell()->textField()->setBackgroundColor(backgroundColor()); + reloadCell(); + } +} + +} diff --git a/apps/shared/hideable_even_odd_editable_text_cell.h b/apps/shared/hideable_even_odd_editable_text_cell.h new file mode 100644 index 000000000..0103a9e85 --- /dev/null +++ b/apps/shared/hideable_even_odd_editable_text_cell.h @@ -0,0 +1,22 @@ +#ifndef APPS_SHARED_HIDEABLE_EVEN_ODD_EDITABLE_TEXT_CELL_H +#define APPS_SHARED_HIDEABLE_EVEN_ODD_EDITABLE_TEXT_CELL_H + +#include + +namespace Shared { + +class HideableEvenOddEditableTextCell : public EvenOddEditableTextCell { +public: + HideableEvenOddEditableTextCell(Responder * parentResponder = nullptr, TextFieldDelegate * delegate = nullptr, char * draftTextBuffer = nullptr) : + EvenOddEditableTextCell(parentResponder, delegate, draftTextBuffer), + m_hide(false) + {} + KDColor backgroundColor() const override; + void setHide(bool hide); +private: + bool m_hide; +}; + +} + +#endif diff --git a/apps/shared/store_controller.cpp b/apps/shared/store_controller.cpp index c57e01137..58f8cc9eb 100644 --- a/apps/shared/store_controller.cpp +++ b/apps/shared/store_controller.cpp @@ -79,12 +79,20 @@ int StoreController::typeAtLocation(int i, int j) { void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { // Handle empty cells - if (j > 0 && j > m_store->numberOfPairsOfSeries(seriesAtColumn(i)) && j < numberOfRows() - 1) { - ((EvenOddCell *)cell)->setEven(j%2 == 0); - assert(cellAtLocationIsEditable(i, j)); - ((EvenOddEditableTextCell *)cell)->editableTextCell()->textField()->setText(""); + if (j > 0 && j > m_store->numberOfPairsOfSeries(seriesAtColumn(i)) && j < numberOfRows()) { + HideableEvenOddEditableTextCell * myCell = static_cast(cell); + myCell->editableTextCell()->textField()->setText(""); + if (cellShouldBeTransparent(i,j)) { + myCell->setHide(true); + } else { + myCell->setEven(j%2 == 0); + myCell->setHide(false); + } return; } + if (cellAtLocationIsEditable(i, j)) { + static_cast(cell)->setHide(false); + } willDisplayCellAtLocationWithDisplayMode(cell, i, j, PrintFloat::Mode::Decimal); } @@ -161,7 +169,7 @@ int StoreController::maxNumberOfElements() const { View * StoreController::loadView() { SelectableTableView * tableView = (SelectableTableView*)EditableCellTableViewController::loadView(); for (int i = 0; i < k_maxNumberOfEditableCells; i++) { - m_editableCells[i] = new EvenOddEditableTextCell(tableView, this, m_draftTextBuffer); + m_editableCells[i] = new HideableEvenOddEditableTextCell(tableView, this, m_draftTextBuffer); } tableView->setMargins(k_margin); return tableView; @@ -175,4 +183,9 @@ void StoreController::unloadView(View * view) { EditableCellTableViewController::unloadView(view); } +bool StoreController::cellShouldBeTransparent(int i, int j) { + int seriesIndex = i/k_numberOfColumnsPerSeries; + return j > 1 + m_store->numberOfPairsOfSeries(seriesIndex); +} + } diff --git a/apps/shared/store_controller.h b/apps/shared/store_controller.h index a5ae3d19b..5354ba614 100644 --- a/apps/shared/store_controller.h +++ b/apps/shared/store_controller.h @@ -3,6 +3,7 @@ #include #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" @@ -52,9 +53,11 @@ protected: virtual HighlightCell * titleCells(int index) = 0; char m_draftTextBuffer[TextField::maxBufferSize()]; int seriesAtColumn(int column) const { return column / k_numberOfColumnsPerSeries; } - EvenOddEditableTextCell * m_editableCells[k_maxNumberOfEditableCells]; + HideableEvenOddEditableTextCell * m_editableCells[k_maxNumberOfEditableCells]; FloatPairStore * m_store; StoreParameterController m_storeParameterController; +private: + bool cellShouldBeTransparent(int i, int j); }; } diff --git a/apps/statistics/store_controller.cpp b/apps/statistics/store_controller.cpp index ec0410e92..934ae72ee 100644 --- a/apps/statistics/store_controller.cpp +++ b/apps/statistics/store_controller.cpp @@ -17,13 +17,13 @@ StoreController::StoreController(Responder * parentResponder, Store * store, But } void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { - ::StoreController::willDisplayCellAtLocation(cell, i, j); + Shared::StoreController::willDisplayCellAtLocation(cell, i, j); if (cellAtLocationIsEditable(i, j)) { return; } Shared::BufferFunctionTitleCell * mytitleCell = (Shared::BufferFunctionTitleCell *)cell; - bool valuesColumn = i%k_numberOfColumnsPerSeries == 0; int seriesIndex = i/k_numberOfColumnsPerSeries; + bool valuesColumn = i%k_numberOfColumnsPerSeries == 0; assert(seriesIndex >= 0 && seriesIndex < FloatPairStore::k_numberOfSeries); if (valuesColumn) { I18n::Message valuesMessages[] = {I18n::Message::Values1, I18n::Message::Values2, I18n::Message::Values3}; diff --git a/escher/src/even_odd_cell.cpp b/escher/src/even_odd_cell.cpp index 3b6671f8a..4e6b0bb9f 100644 --- a/escher/src/even_odd_cell.cpp +++ b/escher/src/even_odd_cell.cpp @@ -9,8 +9,8 @@ EvenOddCell::EvenOddCell() : void EvenOddCell::setEven(bool even) { if (even != m_even) { - m_even = even; - reloadCell(); + m_even = even; + reloadCell(); } }