From 2e1636510089f711916314da8da993f452640873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Fri, 17 Feb 2017 10:56:21 +0100 Subject: [PATCH] [escher] Reorganize all cells'name and factorize their layouts Change-Id: I69900ee98ff6a6868f96d70a0e335a589ef16c3f --- apps/Makefile | 1 - apps/calculation/history_controller.cpp | 4 +- apps/calculation/history_controller.h | 4 +- apps/calculation/selectable_table_view.cpp | 4 +- .../graph/curve_parameter_controller.cpp | 12 +-- apps/graph/graph/curve_parameter_controller.h | 10 +- .../graph/graph/goto_parameter_controller.cpp | 4 +- apps/graph/graph/goto_parameter_controller.h | 6 +- .../initialisation_parameter_controller.cpp | 6 +- .../initialisation_parameter_controller.h | 6 +- apps/graph/list/list_controller.cpp | 8 +- apps/graph/list/list_controller.h | 8 +- .../values/abscissa_parameter_controller.cpp | 10 +- .../values/abscissa_parameter_controller.h | 8 +- .../derivative_parameter_controller.cpp | 8 +- .../values/derivative_parameter_controller.h | 6 +- .../values/function_parameter_controller.cpp | 10 +- .../values/function_parameter_controller.h | 8 +- .../values/interval_parameter_controller.cpp | 10 +- .../values/interval_parameter_controller.h | 10 +- apps/graph/values/values_controller.cpp | 4 +- apps/graph/values/values_controller.h | 4 +- apps/home/app_cell.cpp | 4 +- apps/home/app_cell.h | 2 +- apps/home/controller.cpp | 4 +- apps/home/controller.h | 4 +- apps/math_toolbox.cpp | 13 +-- apps/math_toolbox.h | 9 +- apps/probability/cell.cpp | 4 +- apps/probability/cell.h | 2 +- apps/probability/image_table_view.cpp | 8 +- apps/probability/image_table_view.h | 6 +- apps/probability/law_controller.cpp | 4 +- apps/probability/law_controller.h | 4 +- apps/probability/parameters_controller.cpp | 10 +- apps/probability/parameters_controller.h | 8 +- apps/regression/calculation_controller.cpp | 4 +- apps/regression/calculation_controller.h | 4 +- .../even_odd_double_buffer_text_cell.cpp | 2 +- .../regression/go_to_parameter_controller.cpp | 8 +- apps/regression/go_to_parameter_controller.h | 8 +- .../initialisation_parameter_controller.cpp | 6 +- .../initialisation_parameter_controller.h | 6 +- .../prediction_parameter_controller.cpp | 6 +- .../prediction_parameter_controller.h | 6 +- apps/regression/store_controller.cpp | 4 +- apps/regression/store_controller.h | 4 +- apps/sequence/list/list_controller.cpp | 12 +-- apps/sequence/list/list_controller.h | 10 +- .../list/list_parameter_controller.cpp | 8 +- .../sequence/list/list_parameter_controller.h | 6 +- apps/sequence/list/sequence_toolbox.cpp | 6 +- apps/sequence/list/sequence_toolbox.h | 6 +- .../list/type_parameter_controller.cpp | 16 ++-- .../sequence/list/type_parameter_controller.h | 14 +-- apps/settings/main_controller.cpp | 10 +- apps/settings/main_controller.h | 6 +- apps/settings/sub_controller.cpp | 10 +- apps/settings/sub_controller.h | 6 +- .../editable_cell_table_view_controller.cpp | 2 +- .../editable_cell_table_view_controller.h | 2 +- apps/shared/float_parameter_controller.cpp | 8 +- apps/shared/float_parameter_controller.h | 2 +- apps/shared/list_controller.cpp | 4 +- apps/shared/list_controller.h | 12 +-- apps/shared/list_parameter_controller.cpp | 12 +-- apps/shared/list_parameter_controller.h | 10 +- apps/shared/range_parameter_controller.cpp | 14 +-- apps/shared/range_parameter_controller.h | 10 +- apps/shared/store_controller.cpp | 4 +- apps/shared/store_controller.h | 6 +- apps/shared/store_parameter_controller.cpp | 10 +- apps/shared/store_parameter_controller.h | 8 +- apps/statistics/calculation_controller.cpp | 4 +- apps/statistics/calculation_controller.h | 4 +- .../histogram_parameter_controller.cpp | 6 +- .../histogram_parameter_controller.h | 8 +- apps/statistics/store_controller.cpp | 4 +- apps/statistics/store_controller.h | 4 +- apps/toolbox_leaf_cell.cpp | 53 ----------- apps/toolbox_leaf_cell.h | 21 ----- apps/variable_box_controller.cpp | 6 +- apps/variable_box_controller.h | 6 +- apps/variable_box_leaf_cell.cpp | 4 +- apps/variable_box_leaf_cell.h | 2 +- escher/Makefile | 22 +++-- escher/include/escher.h | 22 +++-- .../chevron_expression_menu_list_cell.h | 20 ---- .../include/escher/chevron_menu_list_cell.h | 16 ---- .../escher/chevron_text_menu_list_cell.h | 19 ---- escher/include/escher/chevron_view.h | 6 +- escher/include/escher/editable_text_cell.h | 5 +- escher/include/escher/even_odd_cell.h | 4 +- .../escher/expression_menu_list_cell.h | 25 ----- escher/include/escher/expression_table_cell.h | 17 ++++ .../expression_table_cell_with_pointer.h | 17 ++++ .../{table_view_cell.h => highlight_cell.h} | 10 +- escher/include/escher/list_view_data_source.h | 6 +- escher/include/escher/menu_list_cell.h | 27 ------ escher/include/escher/pointer_table_cell.h | 18 ++++ ...ell.h => pointer_table_cell_with_buffer.h} | 10 +- .../escher/pointer_table_cell_with_chevron.h | 16 ++++ ...r_table_cell_with_chevron_and_expression.h | 17 ++++ ...nter_table_cell_with_chevron_and_pointer.h | 16 ++++ ...> pointer_table_cell_with_editable_text.h} | 10 +- .../escher/pointer_table_cell_with_pointer.h | 19 ++++ .../escher/pointer_table_cell_with_switch.h | 15 +++ escher/include/escher/pointer_text_view.h | 1 - escher/include/escher/selectable_table_view.h | 2 +- .../escher/simple_list_view_data_source.h | 6 +- .../escher/simple_table_view_data_source.h | 6 +- escher/include/escher/switch_menu_list_cell.h | 15 --- escher/include/escher/switch_view.h | 1 + escher/include/escher/table_cell.h | 27 ++++++ escher/include/escher/table_view.h | 6 +- .../include/escher/table_view_data_source.h | 6 +- .../escher/text_expression_menu_list_cell.h | 19 ---- .../src/chevron_expression_menu_list_cell.cpp | 39 -------- escher/src/chevron_menu_list_cell.cpp | 16 ---- escher/src/chevron_text_menu_list_cell.cpp | 39 -------- escher/src/chevron_view.cpp | 7 +- escher/src/editable_text_cell.cpp | 7 +- escher/src/editable_text_menu_list_cell.cpp | 40 -------- escher/src/even_odd_cell.cpp | 2 +- escher/src/expression_menu_list_cell.cpp | 42 --------- escher/src/expression_table_cell.cpp | 24 +++++ .../expression_table_cell_with_pointer.cpp | 26 ++++++ escher/src/highlight_cell.cpp | 20 ++++ escher/src/list_view_data_source.cpp | 4 +- escher/src/menu_list_cell.cpp | 66 ------------- escher/src/pointer_table_cell.cpp | 28 ++++++ escher/src/pointer_table_cell_with_buffer.cpp | 32 +++++++ .../src/pointer_table_cell_with_chevron.cpp | 16 ++++ ...table_cell_with_chevron_and_expression.cpp | 24 +++++ ...er_table_cell_with_chevron_and_pointer.cpp | 24 +++++ .../pointer_table_cell_with_editable_text.cpp | 42 +++++++++ .../src/pointer_table_cell_with_pointer.cpp | 39 ++++++++ escher/src/pointer_table_cell_with_switch.cpp | 12 +++ escher/src/selectable_table_view.cpp | 8 +- escher/src/simple_list_view_data_source.cpp | 2 +- escher/src/simple_table_view_data_source.cpp | 2 +- escher/src/switch_menu_list_cell.cpp | 11 --- escher/src/switch_view.cpp | 4 + escher/src/table_cell.cpp | 92 +++++++++++++++++++ escher/src/table_view.cpp | 6 +- escher/src/table_view_cell.cpp | 20 ---- escher/src/table_view_data_source.cpp | 2 +- escher/src/text_expression_menu_list_cell.cpp | 37 -------- escher/src/text_menu_list_cell.cpp | 31 ------- 149 files changed, 903 insertions(+), 914 deletions(-) delete mode 100644 apps/toolbox_leaf_cell.cpp delete mode 100644 apps/toolbox_leaf_cell.h delete mode 100644 escher/include/escher/chevron_expression_menu_list_cell.h delete mode 100644 escher/include/escher/chevron_menu_list_cell.h delete mode 100644 escher/include/escher/chevron_text_menu_list_cell.h delete mode 100644 escher/include/escher/expression_menu_list_cell.h create mode 100644 escher/include/escher/expression_table_cell.h create mode 100644 escher/include/escher/expression_table_cell_with_pointer.h rename escher/include/escher/{table_view_cell.h => highlight_cell.h} (57%) delete mode 100644 escher/include/escher/menu_list_cell.h create mode 100644 escher/include/escher/pointer_table_cell.h rename escher/include/escher/{text_menu_list_cell.h => pointer_table_cell_with_buffer.h} (55%) create mode 100644 escher/include/escher/pointer_table_cell_with_chevron.h create mode 100644 escher/include/escher/pointer_table_cell_with_chevron_and_expression.h create mode 100644 escher/include/escher/pointer_table_cell_with_chevron_and_pointer.h rename escher/include/escher/{editable_text_menu_list_cell.h => pointer_table_cell_with_editable_text.h} (59%) create mode 100644 escher/include/escher/pointer_table_cell_with_pointer.h create mode 100644 escher/include/escher/pointer_table_cell_with_switch.h delete mode 100644 escher/include/escher/switch_menu_list_cell.h create mode 100644 escher/include/escher/table_cell.h delete mode 100644 escher/include/escher/text_expression_menu_list_cell.h delete mode 100644 escher/src/chevron_expression_menu_list_cell.cpp delete mode 100644 escher/src/chevron_menu_list_cell.cpp delete mode 100644 escher/src/chevron_text_menu_list_cell.cpp delete mode 100644 escher/src/editable_text_menu_list_cell.cpp delete mode 100644 escher/src/expression_menu_list_cell.cpp create mode 100644 escher/src/expression_table_cell.cpp create mode 100644 escher/src/expression_table_cell_with_pointer.cpp create mode 100644 escher/src/highlight_cell.cpp delete mode 100644 escher/src/menu_list_cell.cpp create mode 100644 escher/src/pointer_table_cell.cpp create mode 100644 escher/src/pointer_table_cell_with_buffer.cpp create mode 100644 escher/src/pointer_table_cell_with_chevron.cpp create mode 100644 escher/src/pointer_table_cell_with_chevron_and_expression.cpp create mode 100644 escher/src/pointer_table_cell_with_chevron_and_pointer.cpp create mode 100644 escher/src/pointer_table_cell_with_editable_text.cpp create mode 100644 escher/src/pointer_table_cell_with_pointer.cpp create mode 100644 escher/src/pointer_table_cell_with_switch.cpp delete mode 100644 escher/src/switch_menu_list_cell.cpp create mode 100644 escher/src/table_cell.cpp delete mode 100644 escher/src/table_view_cell.cpp delete mode 100644 escher/src/text_expression_menu_list_cell.cpp delete mode 100644 escher/src/text_menu_list_cell.cpp diff --git a/apps/Makefile b/apps/Makefile index 922ebc4cb..40e23ee5c 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -19,7 +19,6 @@ app_objs += $(addprefix apps/,\ math_toolbox.o\ node.o\ title_bar_view.o\ - toolbox_leaf_cell.o\ toolbox_node.o\ variable_box_controller.o\ variable_box_leaf_cell.o\ diff --git a/apps/calculation/history_controller.cpp b/apps/calculation/history_controller.cpp index fb80d2e0b..785049c17 100644 --- a/apps/calculation/history_controller.cpp +++ b/apps/calculation/history_controller.cpp @@ -131,7 +131,7 @@ int HistoryController::numberOfRows() { return m_calculationStore->numberOfCalculations(); }; -TableViewCell * HistoryController::reusableCell(int index, int type) { +HighlightCell * HistoryController::reusableCell(int index, int type) { assert(type == 0); assert(index >= 0); assert(index < k_maxNumberOfDisplayedRows); @@ -143,7 +143,7 @@ int HistoryController::reusableCellCount(int type) { return k_maxNumberOfDisplayedRows; } -void HistoryController::willDisplayCellForIndex(TableViewCell * cell, int index) { +void HistoryController::willDisplayCellForIndex(HighlightCell * cell, int index) { HistoryViewCell * myCell = (HistoryViewCell *)cell; myCell->setCalculation(m_calculationStore->calculationAtIndex(index)); myCell->setEven(index%2 == 0); diff --git a/apps/calculation/history_controller.h b/apps/calculation/history_controller.h index 2104d050b..5a58dc975 100644 --- a/apps/calculation/history_controller.h +++ b/apps/calculation/history_controller.h @@ -21,9 +21,9 @@ public: void didBecomeFirstResponder() override; void reload(); int numberOfRows() override; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; KDCoordinate rowHeight(int j) override; KDCoordinate cumulatedHeightFromIndex(int j) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; diff --git a/apps/calculation/selectable_table_view.cpp b/apps/calculation/selectable_table_view.cpp index 41c928b4b..d013d4fc7 100644 --- a/apps/calculation/selectable_table_view.cpp +++ b/apps/calculation/selectable_table_view.cpp @@ -42,7 +42,7 @@ void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(Histo /* As we scroll, the selected calculation does not use the same history view * cell, thus, we want to deselect the previous used history view cell. */ if (selectedRow() >= 0) { - TableViewCell * previousCell = cellAtLocation(selectedColumn(), selectedRow()); + HighlightCell * previousCell = cellAtLocation(selectedColumn(), selectedRow()); previousCell->setHighlighted(false); } /* Main part of the scroll */ @@ -61,7 +61,7 @@ void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(Histo * inform the delegate which history view cell is highlighted even if the * selected calculation has not changed. */ setContentOffset(KDPoint(contentOffsetX, contentOffsetY)); - TableViewCell * cell = cellAtLocation(i, j); + HighlightCell * cell = cellAtLocation(i, j); cell->setHighlighted(true); if (m_delegate) { m_delegate->tableViewDidChangeSelection(this, selectedColumn(), selectedRow()); diff --git a/apps/graph/graph/curve_parameter_controller.cpp b/apps/graph/graph/curve_parameter_controller.cpp index c6685be0d..36c620bd3 100644 --- a/apps/graph/graph/curve_parameter_controller.cpp +++ b/apps/graph/graph/curve_parameter_controller.cpp @@ -9,9 +9,9 @@ CurveParameterController::CurveParameterController(InteractiveCurveViewRange * g ViewController(nullptr), m_bannerView(bannerView), m_function(nullptr), - m_calculationCell(ChevronMenuListCell((char*)"Calculer")), - m_goToCell(ChevronMenuListCell((char*)"Aller a")), - m_derivativeCell(SwitchMenuListCell((char*)"Nombre derivee")), + m_calculationCell(PointerTableCellWithChevron((char*)"Calculer")), + m_goToCell(PointerTableCellWithChevron((char*)"Aller a")), + m_derivativeCell(PointerTableCellWithSwitch((char*)"Nombre derivee")), m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_goToParameterController(GoToParameterController(this, graphRange, cursor)) @@ -31,7 +31,7 @@ void CurveParameterController::didBecomeFirstResponder() { app()->setFirstResponder(&m_selectableTableView); } -void CurveParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { +void CurveParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (cell == &m_derivativeCell) { SwitchView * switchView = (SwitchView *)m_derivativeCell.accessoryView(); switchView->setState(m_bannerView->displayDerivative()); @@ -67,10 +67,10 @@ int CurveParameterController::numberOfRows() { return k_totalNumberOfCells; }; -TableViewCell * CurveParameterController::reusableCell(int index) { +HighlightCell * CurveParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCells); - TableViewCell * cells[] = {&m_calculationCell, &m_goToCell, &m_derivativeCell}; + HighlightCell * cells[] = {&m_calculationCell, &m_goToCell, &m_derivativeCell}; return cells[index]; } diff --git a/apps/graph/graph/curve_parameter_controller.h b/apps/graph/graph/curve_parameter_controller.h index dab6e3bbc..b7c376fea 100644 --- a/apps/graph/graph/curve_parameter_controller.h +++ b/apps/graph/graph/curve_parameter_controller.h @@ -20,17 +20,17 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; void setFunction(CartesianFunction * function); private: BannerView * m_bannerView; CartesianFunction * m_function; constexpr static int k_totalNumberOfCells = 3; - ChevronMenuListCell m_calculationCell; - ChevronMenuListCell m_goToCell; - SwitchMenuListCell m_derivativeCell; + PointerTableCellWithChevron m_calculationCell; + PointerTableCellWithChevron m_goToCell; + PointerTableCellWithSwitch m_derivativeCell; SelectableTableView m_selectableTableView; GoToParameterController m_goToParameterController; }; diff --git a/apps/graph/graph/goto_parameter_controller.cpp b/apps/graph/graph/goto_parameter_controller.cpp index 1382ed5da..decdadd2e 100644 --- a/apps/graph/graph/goto_parameter_controller.cpp +++ b/apps/graph/graph/goto_parameter_controller.cpp @@ -9,7 +9,7 @@ namespace Graph { GoToParameterController::GoToParameterController(Responder * parentResponder, InteractiveCurveViewRange * graphRange, CurveViewCursor * cursor) : FloatParameterController(parentResponder), - m_abscisseCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char*)"x")), + m_abscisseCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char*)"x")), m_graphRange(graphRange), m_cursor(cursor), m_function(nullptr) @@ -38,7 +38,7 @@ int GoToParameterController::numberOfRows() { return 1; }; -TableViewCell * GoToParameterController::reusableCell(int index) { +HighlightCell * GoToParameterController::reusableCell(int index) { assert(index == 0); return &m_abscisseCell; } diff --git a/apps/graph/graph/goto_parameter_controller.h b/apps/graph/graph/goto_parameter_controller.h index a5b3399b5..fa3c7651b 100644 --- a/apps/graph/graph/goto_parameter_controller.h +++ b/apps/graph/graph/goto_parameter_controller.h @@ -13,15 +13,15 @@ public: GoToParameterController(Responder * parentResponder, Shared::InteractiveCurveViewRange * graphRange, Shared::CurveViewCursor * cursor); const char * title() const override; int numberOfRows() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; void setFunction(CartesianFunction * function); bool textFieldDidFinishEditing(TextField * textField, const char * text) override; private: float parameterAtIndex(int index) override; void setParameterAtIndex(int parameterIndex, float f) override; - char m_draftTextBuffer[EditableTextMenuListCell::k_bufferLength]; - EditableTextMenuListCell m_abscisseCell; + char m_draftTextBuffer[PointerTableCellWithEditableText::k_bufferLength]; + PointerTableCellWithEditableText m_abscisseCell; Shared::InteractiveCurveViewRange * m_graphRange; Shared::CurveViewCursor * m_cursor; CartesianFunction * m_function; diff --git a/apps/graph/graph/initialisation_parameter_controller.cpp b/apps/graph/graph/initialisation_parameter_controller.cpp index 45394a416..4aa4a9f50 100644 --- a/apps/graph/graph/initialisation_parameter_controller.cpp +++ b/apps/graph/graph/initialisation_parameter_controller.cpp @@ -45,7 +45,7 @@ int InitialisationParameterController::numberOfRows() { }; -TableViewCell * InitialisationParameterController::reusableCell(int index) { +HighlightCell * InitialisationParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCells); return &m_cells[index]; @@ -59,8 +59,8 @@ KDCoordinate InitialisationParameterController::cellHeight() { return Metric::ParameterCellHeight; } -void InitialisationParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { - MenuListCell * myCell = (MenuListCell *)cell; +void InitialisationParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { + PointerTableCell * myCell = (PointerTableCell *)cell; const char * titles[4] = {"Trigonometrique", "Abscisses entieres", "Orthonorme", "Reglage de base"}; myCell->setText(titles[index]); } diff --git a/apps/graph/graph/initialisation_parameter_controller.h b/apps/graph/graph/initialisation_parameter_controller.h index 9a914587d..d33e62dd9 100644 --- a/apps/graph/graph/initialisation_parameter_controller.h +++ b/apps/graph/graph/initialisation_parameter_controller.h @@ -15,12 +15,12 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; private: constexpr static int k_totalNumberOfCells = 4; - MenuListCell m_cells[k_totalNumberOfCells]; + PointerTableCell m_cells[k_totalNumberOfCells]; SelectableTableView m_selectableTableView; Shared::InteractiveCurveViewRange * m_graphRange; }; diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index 0e6f34ed4..443f4592f 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -112,18 +112,18 @@ int ListController::maxNumberOfRows() { return k_maxNumberOfRows; } -TableViewCell * ListController::titleCells(int index) { +HighlightCell * ListController::titleCells(int index) { assert(index >= 0 && index < k_maxNumberOfRows); return &m_functionTitleCells[index]; } -TableViewCell * ListController::expressionCells(int index) { +HighlightCell * ListController::expressionCells(int index) { assert(index >= 0 && index < k_maxNumberOfRows); return &m_expressionCells[index]; } -void ListController::willDisplayTitleCellAtIndex(TableViewCell * cell, int j) { +void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) { FunctionTitleCell * myFunctionCell = (FunctionTitleCell *)cell; CartesianFunction * function = ((CartesianFunctionStore *)m_functionStore)->functionAtIndex(j); char bufferName[5] = {*function->name(),'(',function->symbol(),')', 0}; @@ -132,7 +132,7 @@ void ListController::willDisplayTitleCellAtIndex(TableViewCell * cell, int j) { myFunctionCell->setColor(functionNameColor); } -void ListController::willDisplayExpressionCellAtIndex(TableViewCell * cell, int j) { +void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) { FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell; Function * f = m_functionStore->functionAtIndex(j); myCell->setExpression(f->layout()); diff --git a/apps/graph/list/list_controller.h b/apps/graph/list/list_controller.h index 3969c191c..9fb0ed026 100644 --- a/apps/graph/list/list_controller.h +++ b/apps/graph/list/list_controller.h @@ -23,10 +23,10 @@ private: void editExpression(Shared::Function * function, Ion::Events::Event event); Shared::ListParameterController * parameterController() override; int maxNumberOfRows() override; - TableViewCell * titleCells(int index) override; - TableViewCell * expressionCells(int index) override; - void willDisplayTitleCellAtIndex(TableViewCell * cell, int j) override; - void willDisplayExpressionCellAtIndex(TableViewCell * cell, int j) override; + HighlightCell * titleCells(int index) override; + HighlightCell * expressionCells(int index) override; + void willDisplayTitleCellAtIndex(HighlightCell * cell, int j) override; + void willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) override; constexpr static int k_maxNumberOfRows = 5; FunctionTitleCell m_functionTitleCells[k_maxNumberOfRows]; Shared::FunctionExpressionCell m_expressionCells[k_maxNumberOfRows]; diff --git a/apps/graph/values/abscissa_parameter_controller.cpp b/apps/graph/values/abscissa_parameter_controller.cpp index 2f7d4b734..608e3ccf5 100644 --- a/apps/graph/values/abscissa_parameter_controller.cpp +++ b/apps/graph/values/abscissa_parameter_controller.cpp @@ -5,9 +5,9 @@ namespace Graph { AbscissaParameterController::AbscissaParameterController(Responder * parentResponder, IntervalParameterController * intervalParameterController) : ViewController(parentResponder), - m_deleteColumn(MenuListCell((char*)"Effacer la colonne")), - m_copyColumn(ChevronMenuListCell((char*)"Copier la colonne dans une liste")), - m_setInterval(ChevronMenuListCell((char*)"Regler l'intervalle")), + m_deleteColumn(PointerTableCell((char*)"Effacer la colonne")), + m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")), + m_setInterval(PointerTableCellWithChevron((char*)"Regler l'intervalle")), m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_intervalParameterController(intervalParameterController) @@ -60,10 +60,10 @@ int AbscissaParameterController::numberOfRows() { return k_totalNumberOfCell; }; -TableViewCell * AbscissaParameterController::reusableCell(int index) { +HighlightCell * AbscissaParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCell); - TableViewCell * cells[] = {&m_deleteColumn, &m_copyColumn, &m_setInterval}; + HighlightCell * cells[] = {&m_deleteColumn, &m_copyColumn, &m_setInterval}; return cells[index]; } diff --git a/apps/graph/values/abscissa_parameter_controller.h b/apps/graph/values/abscissa_parameter_controller.h index a76989070..935c11317 100644 --- a/apps/graph/values/abscissa_parameter_controller.h +++ b/apps/graph/values/abscissa_parameter_controller.h @@ -15,13 +15,13 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; private: constexpr static int k_totalNumberOfCell = 3; - MenuListCell m_deleteColumn; - ChevronMenuListCell m_copyColumn; - ChevronMenuListCell m_setInterval; + PointerTableCell m_deleteColumn; + PointerTableCellWithChevron m_copyColumn; + PointerTableCellWithChevron m_setInterval; SelectableTableView m_selectableTableView; IntervalParameterController * m_intervalParameterController; }; diff --git a/apps/graph/values/derivative_parameter_controller.cpp b/apps/graph/values/derivative_parameter_controller.cpp index 6c7bcf1d8..4d5fa68c7 100644 --- a/apps/graph/values/derivative_parameter_controller.cpp +++ b/apps/graph/values/derivative_parameter_controller.cpp @@ -7,8 +7,8 @@ namespace Graph { DerivativeParameterController::DerivativeParameterController(ValuesController * valuesController) : ViewController(valuesController), m_pageTitle{"Colonne f'(x)"}, - m_hideColumn(MenuListCell((char*)"Masquer la colonne de la derivee")), - m_copyColumn(ChevronMenuListCell((char*)"Copier la colonne dans une liste")), + m_hideColumn(PointerTableCell((char*)"Masquer la colonne de la derivee")), + m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")), m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_function(nullptr), @@ -65,10 +65,10 @@ int DerivativeParameterController::numberOfRows() { return k_totalNumberOfCell; }; -TableViewCell * DerivativeParameterController::reusableCell(int index) { +HighlightCell * DerivativeParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCell); - TableViewCell * cells[] = {&m_hideColumn, &m_copyColumn}; + HighlightCell * cells[] = {&m_hideColumn, &m_copyColumn}; return cells[index]; } diff --git a/apps/graph/values/derivative_parameter_controller.h b/apps/graph/values/derivative_parameter_controller.h index 13045ca4d..05fe0fee8 100644 --- a/apps/graph/values/derivative_parameter_controller.h +++ b/apps/graph/values/derivative_parameter_controller.h @@ -18,7 +18,7 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; void setFunction(CartesianFunction * function); @@ -26,8 +26,8 @@ private: constexpr static int k_totalNumberOfCell = 2; constexpr static int k_maxNumberOfCharsInTitle = 16; char m_pageTitle[k_maxNumberOfCharsInTitle]; - MenuListCell m_hideColumn; - ChevronMenuListCell m_copyColumn; + PointerTableCell m_hideColumn; + PointerTableCellWithChevron m_copyColumn; SelectableTableView m_selectableTableView; CartesianFunction * m_function; ValuesController * m_valuesController; diff --git a/apps/graph/values/function_parameter_controller.cpp b/apps/graph/values/function_parameter_controller.cpp index 23bef9252..84cd07132 100644 --- a/apps/graph/values/function_parameter_controller.cpp +++ b/apps/graph/values/function_parameter_controller.cpp @@ -7,8 +7,8 @@ namespace Graph { FunctionParameterController::FunctionParameterController(ValuesController * valuesController) : ViewController(nullptr), m_pageTitle{"Colonne f(x)"}, - m_displayDerivativeColumn(SwitchMenuListCell((char*)"Colonne de la fonction derivee")), - m_copyColumn(ChevronMenuListCell((char*)"Copier la colonne dans une liste")), + m_displayDerivativeColumn(PointerTableCellWithSwitch((char*)"Colonne de la fonction derivee")), + m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")), m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_function(nullptr), @@ -67,10 +67,10 @@ int FunctionParameterController::numberOfRows() { return k_totalNumberOfCell; }; -TableViewCell * FunctionParameterController::reusableCell(int index) { +HighlightCell * FunctionParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCell); - TableViewCell * cells[] = {&m_displayDerivativeColumn, &m_copyColumn}; + HighlightCell * cells[] = {&m_displayDerivativeColumn, &m_copyColumn}; return cells[index]; } @@ -82,7 +82,7 @@ KDCoordinate FunctionParameterController::cellHeight() { return Metric::ParameterCellHeight; } -void FunctionParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { +void FunctionParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (cell == &m_displayDerivativeColumn) { SwitchView * switchView = (SwitchView *)m_displayDerivativeColumn.accessoryView(); switchView->setState(m_function->displayDerivative()); diff --git a/apps/graph/values/function_parameter_controller.h b/apps/graph/values/function_parameter_controller.h index 6799b473f..a724e5ecd 100644 --- a/apps/graph/values/function_parameter_controller.h +++ b/apps/graph/values/function_parameter_controller.h @@ -18,17 +18,17 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; void setFunction(CartesianFunction * function); private: constexpr static int k_totalNumberOfCell = 2; constexpr static int k_maxNumberOfCharsInTitle = 16; char m_pageTitle[k_maxNumberOfCharsInTitle]; - SwitchMenuListCell m_displayDerivativeColumn; - ChevronMenuListCell m_copyColumn; + PointerTableCellWithSwitch m_displayDerivativeColumn; + PointerTableCellWithChevron m_copyColumn; SelectableTableView m_selectableTableView; CartesianFunction * m_function; ValuesController * m_valuesController; diff --git a/apps/graph/values/interval_parameter_controller.cpp b/apps/graph/values/interval_parameter_controller.cpp index 93ed53580..0ff5c8614 100644 --- a/apps/graph/values/interval_parameter_controller.cpp +++ b/apps/graph/values/interval_parameter_controller.cpp @@ -9,9 +9,9 @@ namespace Graph { IntervalParameterController::IntervalParameterController(Responder * parentResponder, Interval * interval) : FloatParameterController(parentResponder), m_interval(interval), - m_intervalStartCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char*)"X Debut")), - m_intervalEndCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char*)"X Fin")), - m_intervalStepCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Pas")) + m_intervalStartCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char*)"X Debut")), + m_intervalEndCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char*)"X Fin")), + m_intervalStepCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Pas")) { } @@ -37,10 +37,10 @@ int IntervalParameterController::numberOfRows() { return k_totalNumberOfCell; }; -TableViewCell * IntervalParameterController::reusableCell(int index) { +HighlightCell * IntervalParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCell); - TableViewCell * cells[] = {&m_intervalStartCell, &m_intervalEndCell, &m_intervalStepCell}; + HighlightCell * cells[] = {&m_intervalStartCell, &m_intervalEndCell, &m_intervalStepCell}; return cells[index]; } diff --git a/apps/graph/values/interval_parameter_controller.h b/apps/graph/values/interval_parameter_controller.h index 6e9323cdb..b498df6da 100644 --- a/apps/graph/values/interval_parameter_controller.h +++ b/apps/graph/values/interval_parameter_controller.h @@ -13,17 +13,17 @@ public: Interval * interval(); const char * title() const override; int numberOfRows() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; private: float parameterAtIndex(int index) override; void setParameterAtIndex(int parameterIndex, float f) override; constexpr static int k_totalNumberOfCell = 3; Interval * m_interval; - char m_draftTextBuffer[EditableTextMenuListCell::k_bufferLength]; - EditableTextMenuListCell m_intervalStartCell; - EditableTextMenuListCell m_intervalEndCell; - EditableTextMenuListCell m_intervalStepCell; + char m_draftTextBuffer[PointerTableCellWithEditableText::k_bufferLength]; + PointerTableCellWithEditableText m_intervalStartCell; + PointerTableCellWithEditableText m_intervalEndCell; + PointerTableCellWithEditableText m_intervalStepCell; }; } diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index a5e8ecab3..dd6462d14 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -124,7 +124,7 @@ int ValuesController::numberOfColumns() { return result; } -void ValuesController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { App * graphApp = (App *)app(); willDisplayCellAtLocationWithDisplayMode(cell, i, j, Expression::FloatDisplayMode::Default); if (cellAtLocationIsEditable(i, j)) { @@ -206,7 +206,7 @@ int ValuesController::indexFromCumulatedWidth(KDCoordinate offsetX) { } } -TableViewCell * ValuesController::reusableCell(int index, int type) { +HighlightCell * ValuesController::reusableCell(int index, int type) { assert(index >= 0); switch (type) { case 0: diff --git a/apps/graph/values/values_controller.h b/apps/graph/values/values_controller.h index c4e2550d5..20a8c96f8 100644 --- a/apps/graph/values/values_controller.h +++ b/apps/graph/values/values_controller.h @@ -24,11 +24,11 @@ public: int numberOfButtons() const override; Button * buttonAtIndex(int index) override; int numberOfColumns() override; - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; KDCoordinate columnWidth(int i) override; KDCoordinate cumulatedWidthFromIndex(int i) override; int indexFromCumulatedWidth(KDCoordinate offsetX) override; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; int typeAtLocation(int i, int j) override; bool isEmpty() const override; diff --git a/apps/home/app_cell.cpp b/apps/home/app_cell.cpp index acb0d62d9..cff8f2207 100644 --- a/apps/home/app_cell.cpp +++ b/apps/home/app_cell.cpp @@ -4,7 +4,7 @@ namespace Home { AppCell::AppCell() : - TableViewCell(), + HighlightCell(), m_nameView(PointerTextView(KDText::FontSize::Small, nullptr, 0.5f, 0.5f, KDColorBlack, KDColorWhite)), m_visible(true) { @@ -39,7 +39,7 @@ void AppCell::setVisible(bool visible) { } void AppCell::reloadCell() { - TableViewCell::reloadCell(); + HighlightCell::reloadCell(); m_nameView.setBackgroundColor(isHighlighted() ? Palette::YellowDark : KDColorWhite); } diff --git a/apps/home/app_cell.h b/apps/home/app_cell.h index 3e52e1434..1dfd65d2a 100644 --- a/apps/home/app_cell.h +++ b/apps/home/app_cell.h @@ -5,7 +5,7 @@ namespace Home { -class AppCell : public TableViewCell { +class AppCell : public HighlightCell { public: AppCell(); diff --git a/apps/home/controller.cpp b/apps/home/controller.cpp index cbf8fa47e..326d909ab 100644 --- a/apps/home/controller.cpp +++ b/apps/home/controller.cpp @@ -50,7 +50,7 @@ KDCoordinate Controller::cellWidth() { return k_cellWidth; } -TableViewCell * Controller::reusableCell(int index) { +HighlightCell * Controller::reusableCell(int index) { return &m_cells[index]; } @@ -58,7 +58,7 @@ int Controller::reusableCellCount() { return k_maxNumberOfCells; } -void Controller::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void Controller::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { AppCell * appCell = (AppCell *)cell; int appIndex = (j*k_numberOfColumns+i)+1; if (appIndex >= m_container->numberOfApps()) { diff --git a/apps/home/controller.h b/apps/home/controller.h index 0cab52a6d..cef9e77cb 100644 --- a/apps/home/controller.h +++ b/apps/home/controller.h @@ -21,9 +21,9 @@ public: virtual int numberOfColumns() override; virtual KDCoordinate cellHeight() override; virtual KDCoordinate cellWidth() override; - virtual TableViewCell * reusableCell(int index) override; + virtual HighlightCell * reusableCell(int index) override; virtual int reusableCellCount() override; - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) override; private: int numberOfIcons(); diff --git a/apps/math_toolbox.cpp b/apps/math_toolbox.cpp index 71c37b6ba..bd1a3f5f9 100644 --- a/apps/math_toolbox.cpp +++ b/apps/math_toolbox.cpp @@ -148,7 +148,7 @@ int MathToolbox::numberOfRows() { return m_nodeModel->numberOfChildren(); } -TableViewCell * MathToolbox::reusableCell(int index, int type) { +HighlightCell * MathToolbox::reusableCell(int index, int type) { assert(type < 2); assert(index >= 0); assert(index < k_maxNumberOfDisplayedRows); @@ -162,15 +162,16 @@ int MathToolbox::reusableCellCount(int type) { return k_maxNumberOfDisplayedRows; } -void MathToolbox::willDisplayCellForIndex(TableViewCell * cell, int index) { +void MathToolbox::willDisplayCellForIndex(HighlightCell * cell, int index) { ToolboxNode * node = (ToolboxNode *)m_nodeModel->children(index); if (node->numberOfChildren() == 0) { - ToolboxLeafCell * myCell = (ToolboxLeafCell *)cell; - myCell->setLabel(node->label()); - myCell->setSubtitle(node->text()); + PointerTableCellWithPointer * myCell = (PointerTableCellWithPointer *)cell; + myCell->setText(node->label()); + myCell->setAccessoryText(node->text()); + myCell->setAccessoryTextColor(Palette::GreyDark); return; } - MenuListCell * myCell = (MenuListCell *)cell; + PointerTableCell * myCell = (PointerTableCell *)cell; myCell->setText(node->label()); } diff --git a/apps/math_toolbox.h b/apps/math_toolbox.h index be270f376..f71b85ce5 100644 --- a/apps/math_toolbox.h +++ b/apps/math_toolbox.h @@ -3,7 +3,6 @@ #include #include "toolbox_node.h" -#include "toolbox_leaf_cell.h" /* m_nodeModel points at the node of the tree (describing the whole model) * where we are located. It enables to know which rows are leaves and which are @@ -16,9 +15,9 @@ public: bool handleEvent(Ion::Events::Event event) override; int numberOfRows() override; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; KDCoordinate rowHeight(int j) override; KDCoordinate cumulatedHeightFromIndex(int j) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; @@ -70,8 +69,8 @@ private: bool selectSubMenu(ToolboxNode * selectedNode); bool returnToPreviousMenu(); Stack m_stack; - ToolboxLeafCell m_leafCells[k_maxNumberOfDisplayedRows]; - ChevronMenuListCell m_nodeCells[k_maxNumberOfDisplayedRows]; + PointerTableCellWithPointer m_leafCells[k_maxNumberOfDisplayedRows]; + PointerTableCellWithChevron m_nodeCells[k_maxNumberOfDisplayedRows]; ListController m_listController; ToolboxNode * m_nodeModel; }; diff --git a/apps/probability/cell.cpp b/apps/probability/cell.cpp index a891a729d..66b36f7e7 100644 --- a/apps/probability/cell.cpp +++ b/apps/probability/cell.cpp @@ -4,7 +4,7 @@ namespace Probability { Cell::Cell() : - TableViewCell(), + HighlightCell(), m_labelView(PointerTextView(KDText::FontSize::Large, nullptr, 0, 0.5, KDColorBlack, KDColorWhite)) { } @@ -33,7 +33,7 @@ void Cell::layoutSubviews() { } void Cell::reloadCell() { - TableViewCell::reloadCell(); + HighlightCell::reloadCell(); KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; m_labelView.setBackgroundColor(backgroundColor); m_chevronView.setHighlighted(isHighlighted()); diff --git a/apps/probability/cell.h b/apps/probability/cell.h index 54516ab7a..91bf597fe 100644 --- a/apps/probability/cell.h +++ b/apps/probability/cell.h @@ -5,7 +5,7 @@ namespace Probability { -class Cell : public TableViewCell { +class Cell : public HighlightCell { public: Cell(); void reloadCell() override; diff --git a/apps/probability/image_table_view.cpp b/apps/probability/image_table_view.cpp index 44ddbbaf4..d8e16aad3 100644 --- a/apps/probability/image_table_view.cpp +++ b/apps/probability/image_table_view.cpp @@ -11,7 +11,7 @@ namespace Probability { ImageTableView::ImageCell::ImageCell() : - TableViewCell() + HighlightCell() { } @@ -29,7 +29,7 @@ void ImageTableView::ImageCell::layoutSubviews() { } void ImageTableView::ImageCell::reloadCell() { - TableViewCell::reloadCell(); + HighlightCell::reloadCell(); if (isHighlighted()) { m_iconView.setImage(m_focusedIcon); } else { @@ -108,7 +108,7 @@ int ImageTableView::numberOfRows() { return 1; } -TableViewCell * ImageTableView::reusableCell(int index) { +HighlightCell * ImageTableView::reusableCell(int index) { assert(index >= 0); assert(index < k_numberOfImages); return &m_imageCells[index]; @@ -118,7 +118,7 @@ int ImageTableView::reusableCellCount() { return k_numberOfImages; } -void ImageTableView::willDisplayCellForIndex(TableViewCell * cell, int index) { +void ImageTableView::willDisplayCellForIndex(HighlightCell * cell, int index) { ImageCell * myCell = (ImageCell *)cell; const Image * images[3] = {ImageStore::Calcul1Icon, ImageStore::Calcul2Icon, ImageStore::Calcul3Icon}; const Image * focusedImages[3] = {ImageStore::FocusedCalcul1Icon, ImageStore::FocusedCalcul2Icon, ImageStore::FocusedCalcul3Icon}; diff --git a/apps/probability/image_table_view.h b/apps/probability/image_table_view.h index c5c3735e4..6ad2d01bc 100644 --- a/apps/probability/image_table_view.h +++ b/apps/probability/image_table_view.h @@ -17,9 +17,9 @@ public: void select(bool select); void setHighlight(bool highlight); int numberOfRows() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; constexpr static KDCoordinate k_imageWidth = 35; constexpr static KDCoordinate k_imageHeight = 19; @@ -28,7 +28,7 @@ private: View * subviewAtIndex(int index) override; void layoutSubviews() override; void setCalculationAccordingToIndex(int index); - class ImageCell : public TableViewCell { + class ImageCell : public HighlightCell { public: ImageCell(); void reloadCell() override; diff --git a/apps/probability/law_controller.cpp b/apps/probability/law_controller.cpp index 915fd0cf2..f159a3be7 100644 --- a/apps/probability/law_controller.cpp +++ b/apps/probability/law_controller.cpp @@ -94,7 +94,7 @@ int Probability::LawController::numberOfRows() { return k_totalNumberOfModels; }; -TableViewCell * Probability::LawController::reusableCell(int index) { +HighlightCell * Probability::LawController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfModels); return &m_cells[index]; @@ -104,7 +104,7 @@ int Probability::LawController::reusableCellCount() { return k_totalNumberOfModels; } -void Probability::LawController::willDisplayCellForIndex(TableViewCell * cell, int index) { +void Probability::LawController::willDisplayCellForIndex(HighlightCell * cell, int index) { Cell * myCell = (Cell *)cell; myCell->setLabel(m_messages[index]); const Image * images[5] = {ImageStore::BinomialIcon, ImageStore::UniformIcon, ImageStore::ExponentialIcon, diff --git a/apps/probability/law_controller.h b/apps/probability/law_controller.h index 6ab933f52..5d070d836 100644 --- a/apps/probability/law_controller.h +++ b/apps/probability/law_controller.h @@ -16,9 +16,9 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; private: class ContentView : public View { diff --git a/apps/probability/parameters_controller.cpp b/apps/probability/parameters_controller.cpp index a90d05f86..d15cdf745 100644 --- a/apps/probability/parameters_controller.cpp +++ b/apps/probability/parameters_controller.cpp @@ -86,8 +86,8 @@ void ParametersController::ContentView::layoutSubviews() { ParametersController::ParametersController(Responder * parentResponder) : FloatParameterController(parentResponder), - m_menuListCell{EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer), - EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer)}, + m_menuListCell{PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer), + PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer)}, m_contentView(ContentView(this, &m_selectableTableView)), m_law(nullptr), m_buttonSelected(false), @@ -154,13 +154,13 @@ int ParametersController::numberOfRows() { return m_law->numberOfParameter(); }; -void ParametersController::willDisplayCellForIndex(TableViewCell * cell, int index) { - EditableTextMenuListCell * myCell = (EditableTextMenuListCell *) cell; +void ParametersController::willDisplayCellForIndex(HighlightCell * cell, int index) { + PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *) cell; myCell->setText(m_law->parameterNameAtIndex(index)); FloatParameterController::willDisplayCellForIndex(cell, index); } -TableViewCell * ParametersController::reusableCell(int index) { +HighlightCell * ParametersController::reusableCell(int index) { assert(index >= 0); assert(index < 2); return &m_menuListCell[index]; diff --git a/apps/probability/parameters_controller.h b/apps/probability/parameters_controller.h index ed8e8b761..933d3e3f2 100644 --- a/apps/probability/parameters_controller.h +++ b/apps/probability/parameters_controller.h @@ -19,8 +19,8 @@ public: StackViewController * stackController(); CalculationController * calculationController(); int numberOfRows() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; - TableViewCell * reusableCell(int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; private: float parameterAtIndex(int index) override; @@ -47,8 +47,8 @@ private: SelectableTableView * m_selectableTableView; }; constexpr static int k_maxNumberOfCells = 2; - char m_draftTextBuffer[EditableTextMenuListCell::k_bufferLength]; - EditableTextMenuListCell m_menuListCell[k_maxNumberOfCells]; + char m_draftTextBuffer[PointerTableCellWithEditableText::k_bufferLength]; + PointerTableCellWithEditableText m_menuListCell[k_maxNumberOfCells]; ContentView m_contentView; Law * m_law; bool m_buttonSelected; diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index 897ef5517..52730a8cd 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -105,7 +105,7 @@ int CalculationController::numberOfColumns() { return k_totalNumberOfColumns; } -void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { EvenOddCell * myCell = (EvenOddCell *)cell; myCell->setEven(j%2 == 0); myCell->setHighlighted(i == m_selectableTableView.selectedColumn() && j == m_selectableTableView.selectedRow()); @@ -176,7 +176,7 @@ int CalculationController::indexFromCumulatedHeight(KDCoordinate offsetY) { return (offsetY-1) / k_cellHeight; } -TableViewCell * CalculationController::reusableCell(int index, int type) { +HighlightCell * CalculationController::reusableCell(int index, int type) { if (type == 0) { assert(index < k_totalNumberOfRows + 2); return &m_titleCells[index]; diff --git a/apps/regression/calculation_controller.h b/apps/regression/calculation_controller.h index fcb4b66f4..39410402a 100644 --- a/apps/regression/calculation_controller.h +++ b/apps/regression/calculation_controller.h @@ -23,14 +23,14 @@ public: int numberOfRows() override; int numberOfColumns() override; - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; KDCoordinate columnWidth(int i) override; KDCoordinate rowHeight(int j) override; KDCoordinate cumulatedWidthFromIndex(int i) override; KDCoordinate cumulatedHeightFromIndex(int j) override; int indexFromCumulatedWidth(KDCoordinate offsetX) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; int typeAtLocation(int i, int j) override; void viewWillAppear() override; diff --git a/apps/regression/even_odd_double_buffer_text_cell.cpp b/apps/regression/even_odd_double_buffer_text_cell.cpp index 5eafc1551..c20efb160 100644 --- a/apps/regression/even_odd_double_buffer_text_cell.cpp +++ b/apps/regression/even_odd_double_buffer_text_cell.cpp @@ -29,7 +29,7 @@ void EvenOddDoubleBufferTextCell::reloadCell() { void EvenOddDoubleBufferTextCell::setHighlighted(bool highlight) { m_firstBufferTextView.setHighlighted(false); m_secondBufferTextView.setHighlighted(false); - TableViewCell::setHighlighted(highlight); + HighlightCell::setHighlighted(highlight); if (isHighlighted()) { if (m_firstTextSelected) { m_firstBufferTextView.setHighlighted(true); diff --git a/apps/regression/go_to_parameter_controller.cpp b/apps/regression/go_to_parameter_controller.cpp index 32b5924c4..08ddf2dde 100644 --- a/apps/regression/go_to_parameter_controller.cpp +++ b/apps/regression/go_to_parameter_controller.cpp @@ -7,7 +7,7 @@ namespace Regression { GoToParameterController::GoToParameterController(Responder * parentResponder, Store * store, CurveViewCursor * cursor) : FloatParameterController(parentResponder), - m_abscisseCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer)), + m_abscisseCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer)), m_store(store), m_cursor(cursor), m_xPrediction(true) @@ -52,7 +52,7 @@ int GoToParameterController::numberOfRows() { return 1; }; -TableViewCell * GoToParameterController::reusableCell(int index) { +HighlightCell * GoToParameterController::reusableCell(int index) { assert(index == 0); return &m_abscisseCell; } @@ -61,8 +61,8 @@ int GoToParameterController::reusableCellCount() { return 1; } -void GoToParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { - EditableTextMenuListCell * myCell = (EditableTextMenuListCell *) cell; +void GoToParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { + PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *) cell; if (m_xPrediction) { myCell->setText("x"); } else { diff --git a/apps/regression/go_to_parameter_controller.h b/apps/regression/go_to_parameter_controller.h index 265893a93..5695a4598 100644 --- a/apps/regression/go_to_parameter_controller.h +++ b/apps/regression/go_to_parameter_controller.h @@ -14,15 +14,15 @@ public: void setXPrediction(bool xPrediction); const char * title() const override; int numberOfRows() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; bool textFieldDidFinishEditing(TextField * textField, const char * text) override; private: float parameterAtIndex(int index) override; void setParameterAtIndex(int parameterIndex, float f) override; - char m_draftTextBuffer[EditableTextMenuListCell::k_bufferLength]; - EditableTextMenuListCell m_abscisseCell; + char m_draftTextBuffer[PointerTableCellWithEditableText::k_bufferLength]; + PointerTableCellWithEditableText m_abscisseCell; Store * m_store; Shared::CurveViewCursor * m_cursor; bool m_xPrediction; diff --git a/apps/regression/initialisation_parameter_controller.cpp b/apps/regression/initialisation_parameter_controller.cpp index 57405eb02..6e7499bfa 100644 --- a/apps/regression/initialisation_parameter_controller.cpp +++ b/apps/regression/initialisation_parameter_controller.cpp @@ -44,7 +44,7 @@ int InitialisationParameterController::numberOfRows() { }; -TableViewCell * InitialisationParameterController::reusableCell(int index) { +HighlightCell * InitialisationParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCells); return &m_cells[index]; @@ -58,8 +58,8 @@ KDCoordinate InitialisationParameterController::cellHeight() { return Metric::ParameterCellHeight; } -void InitialisationParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { - MenuListCell * myCell = (MenuListCell *)cell; +void InitialisationParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { + PointerTableCell * myCell = (PointerTableCell *)cell; const char * titles[3] = {"Abscisses entieres", "Orthonorme", "Reglage de base"}; myCell->setText(titles[index]); } diff --git a/apps/regression/initialisation_parameter_controller.h b/apps/regression/initialisation_parameter_controller.h index e0385ce5b..72f49b769 100644 --- a/apps/regression/initialisation_parameter_controller.h +++ b/apps/regression/initialisation_parameter_controller.h @@ -15,12 +15,12 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; private: constexpr static int k_totalNumberOfCells = 3; - MenuListCell m_cells[k_totalNumberOfCells]; + PointerTableCell m_cells[k_totalNumberOfCells]; SelectableTableView m_selectableTableView; Store * m_store; }; diff --git a/apps/regression/prediction_parameter_controller.cpp b/apps/regression/prediction_parameter_controller.cpp index 7fa503dea..9c5623eb4 100644 --- a/apps/regression/prediction_parameter_controller.cpp +++ b/apps/regression/prediction_parameter_controller.cpp @@ -40,7 +40,7 @@ int PredictionParameterController::numberOfRows() { return k_totalNumberOfCells; }; -TableViewCell * PredictionParameterController::reusableCell(int index) { +HighlightCell * PredictionParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCells); return &m_cells[index]; @@ -54,8 +54,8 @@ KDCoordinate PredictionParameterController::cellHeight() { return Metric::ParameterCellHeight; } -void PredictionParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { - ChevronMenuListCell * myCell = (ChevronMenuListCell *)cell; +void PredictionParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { + PointerTableCellWithChevron * myCell = (PointerTableCellWithChevron *)cell; const char * titles[3] = {"Prediction sachant x", "Prediction sachant y"}; myCell->setText(titles[index]); } diff --git a/apps/regression/prediction_parameter_controller.h b/apps/regression/prediction_parameter_controller.h index f490eb7a5..8699de7a0 100644 --- a/apps/regression/prediction_parameter_controller.h +++ b/apps/regression/prediction_parameter_controller.h @@ -17,12 +17,12 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; private: constexpr static int k_totalNumberOfCells = 2; - ChevronMenuListCell m_cells[2]; + PointerTableCellWithChevron m_cells[2]; SelectableTableView m_selectableTableView; GoToParameterController m_goToParameterController; }; diff --git a/apps/regression/store_controller.cpp b/apps/regression/store_controller.cpp index d53bc0c71..fee346a6d 100644 --- a/apps/regression/store_controller.cpp +++ b/apps/regression/store_controller.cpp @@ -19,7 +19,7 @@ StoreController::StoreController(Responder * parentResponder, Store * store, Hea m_titleLayout[1] = new BaselineRelativeLayout(new StringLayout("Y", 1, KDText::FontSize::Small), new StringLayout("i", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); } -void StoreController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { ::StoreController::willDisplayCellAtLocation(cell, i, j); if (cellAtLocationIsEditable(i, j)) { return; @@ -28,7 +28,7 @@ void StoreController::willDisplayCellAtLocation(TableViewCell * cell, int i, int mytitleCell->setExpression(m_titleLayout[i]); } -TableViewCell * StoreController::titleCells(int index) { +HighlightCell * StoreController::titleCells(int index) { assert(index >= 0 && index < k_numberOfTitleCells); return &m_titleCells[index]; } diff --git a/apps/regression/store_controller.h b/apps/regression/store_controller.h index b0edbfe05..dc6aa9f2a 100644 --- a/apps/regression/store_controller.h +++ b/apps/regression/store_controller.h @@ -10,9 +10,9 @@ namespace Regression { class StoreController : public Shared::StoreController { public: StoreController(Responder * parentResponder, Store * store, HeaderViewController * header); - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; private: - TableViewCell * titleCells(int index) override; + HighlightCell * titleCells(int index) override; EvenOddExpressionCell m_titleCells[k_numberOfTitleCells]; Poincare::ExpressionLayout * m_titleLayout[2]; }; diff --git a/apps/sequence/list/list_controller.cpp b/apps/sequence/list/list_controller.cpp index 546f07421..50294dfc2 100644 --- a/apps/sequence/list/list_controller.cpp +++ b/apps/sequence/list/list_controller.cpp @@ -14,7 +14,7 @@ ListController::ListController(Responder * parentResponder, SequenceStore * sequ SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator)}, m_parameterController(ListParameterController(this, sequenceStore)), - m_typeParameterController(this, sequenceStore), + m_typeParameterController(this, sequenceStore, TableCell::Layout::Vertical), m_typeStackController(StackViewController(nullptr, &m_typeParameterController, true, KDColorWhite, Palette::PurpleDark, Palette::PurpleDark)), m_sequenceToolbox(SequenceToolbox(m_sequenceStore)) { @@ -71,7 +71,7 @@ KDCoordinate ListController::rowHeight(int j) { return sequenceSize + defaultHeight - KDText::stringSize(" ").height(); } -void ListController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void ListController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { Shared::ListController::willDisplayCellAtLocation(cell, i, j); EvenOddCell * myCell = (EvenOddCell *)cell; myCell->setEven(sequenceIndexForRow(j)%2 == 0); @@ -176,18 +176,18 @@ int ListController::maxNumberOfRows() { return k_maxNumberOfRows; } -TableViewCell * ListController::titleCells(int index) { +HighlightCell * ListController::titleCells(int index) { assert(index >= 0 && index < k_maxNumberOfRows); return &m_sequenceTitleCells[index]; } -TableViewCell * ListController::expressionCells(int index) { +HighlightCell * ListController::expressionCells(int index) { assert(index >= 0 && index < k_maxNumberOfRows); return &m_expressionCells[index]; } -void ListController::willDisplayTitleCellAtIndex(TableViewCell * cell, int j) { +void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) { SequenceTitleCell * myCell = (SequenceTitleCell *)cell; Sequence * sequence = m_sequenceStore->functionAtIndex(sequenceIndexForRow(j)); if (sequenceDefinitionForRow(j) == 0) { @@ -203,7 +203,7 @@ void ListController::willDisplayTitleCellAtIndex(TableViewCell * cell, int j) { myCell->setColor(nameColor); } -void ListController::willDisplayExpressionCellAtIndex(TableViewCell * cell, int j) { +void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) { FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell; Sequence * sequence = m_sequenceStore->functionAtIndex(sequenceIndexForRow(j)); if (sequenceDefinitionForRow(j) == 0) { diff --git a/apps/sequence/list/list_controller.h b/apps/sequence/list/list_controller.h index 144249d66..ece4a97bd 100644 --- a/apps/sequence/list/list_controller.h +++ b/apps/sequence/list/list_controller.h @@ -20,7 +20,7 @@ public: const char * title() const override; int numberOfRows() override; virtual KDCoordinate rowHeight(int j) override; - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; bool handleEvent(Ion::Events::Event event) override; Toolbox * toolboxForTextField(TextField * textField) override; private: @@ -29,10 +29,10 @@ private: void editExpression(Sequence * sequence, int sequenceDefinitionIndex, Ion::Events::Event event); ListParameterController * parameterController() override; int maxNumberOfRows() override; - TableViewCell * titleCells(int index) override; - TableViewCell * expressionCells(int index) override; - void willDisplayTitleCellAtIndex(TableViewCell * cell, int j) override; - void willDisplayExpressionCellAtIndex(TableViewCell * cell, int j) override; + HighlightCell * titleCells(int index) override; + HighlightCell * expressionCells(int index) override; + void willDisplayTitleCellAtIndex(HighlightCell * cell, int j) override; + void willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) override; int sequenceIndexForRow(int j); int sequenceDefinitionForRow(int j); static constexpr KDCoordinate k_emptySubRowHeight = 30; diff --git a/apps/sequence/list/list_parameter_controller.cpp b/apps/sequence/list/list_parameter_controller.cpp index c72bd80b2..3682bca30 100644 --- a/apps/sequence/list/list_parameter_controller.cpp +++ b/apps/sequence/list/list_parameter_controller.cpp @@ -7,8 +7,8 @@ namespace Sequence { ListParameterController::ListParameterController(Responder * parentResponder, SequenceStore * sequenceStore) : Shared::ListParameterController(parentResponder, sequenceStore), - m_typeCell(ChevronExpressionMenuListCell((char *)"Type de suite")), - m_typeParameterController(TypeParameterController(this, sequenceStore, Metric::TopMargin, Metric::RightMargin, + m_typeCell(PointerTableCellWithChevronAndExpression((char *)"Type de suite")), + m_typeParameterController(TypeParameterController(this, sequenceStore, TableCell::Layout::Horizontal, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)) { } @@ -44,7 +44,7 @@ int ListParameterController::numberOfRows() { return k_totalNumberOfCell; }; -TableViewCell * ListParameterController::reusableCell(int index) { +HighlightCell * ListParameterController::reusableCell(int index) { if (index == 3) { return &m_typeCell; } @@ -55,7 +55,7 @@ int ListParameterController::reusableCellCount() { return k_totalNumberOfCell; } -void ListParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { +void ListParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { Shared::ListParameterController::willDisplayCellForIndex(cell, index); if (cell == &m_typeCell && m_sequence != nullptr) { m_typeCell.setExpression(m_sequence->definitionName()); diff --git a/apps/sequence/list/list_parameter_controller.h b/apps/sequence/list/list_parameter_controller.h index fcf0d3c41..8c2a5df3e 100644 --- a/apps/sequence/list/list_parameter_controller.h +++ b/apps/sequence/list/list_parameter_controller.h @@ -15,12 +15,12 @@ public: bool handleEvent(Ion::Events::Event event) override; void setFunction(Shared::Function * function) override; int numberOfRows() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; private: constexpr static int k_totalNumberOfCell = 4; - ChevronExpressionMenuListCell m_typeCell; + PointerTableCellWithChevronAndExpression m_typeCell; TypeParameterController m_typeParameterController; Sequence * m_sequence; }; diff --git a/apps/sequence/list/sequence_toolbox.cpp b/apps/sequence/list/sequence_toolbox.cpp index 38a5f8294..d1f451b0e 100644 --- a/apps/sequence/list/sequence_toolbox.cpp +++ b/apps/sequence/list/sequence_toolbox.cpp @@ -31,7 +31,7 @@ int SequenceToolbox::numberOfRows() { return MathToolbox::numberOfRows(); } -TableViewCell * SequenceToolbox::reusableCell(int index, int type) { +HighlightCell * SequenceToolbox::reusableCell(int index, int type) { assert(type < 3); assert(index >= 0); assert(index < k_maxNumberOfDisplayedRows); @@ -41,9 +41,9 @@ TableViewCell * SequenceToolbox::reusableCell(int index, int type) { return MathToolbox::reusableCell(index, type); } -void SequenceToolbox::willDisplayCellForIndex(TableViewCell * cell, int index) { +void SequenceToolbox::willDisplayCellForIndex(HighlightCell * cell, int index) { if (typeAtLocation(0, index) == 2) { - ExpressionMenuListCell * myCell = (ExpressionMenuListCell *)cell; + ExpressionTableCell * myCell = (ExpressionTableCell *)cell; myCell->setExpression(m_addedCellLayout[index]); return; } else { diff --git a/apps/sequence/list/sequence_toolbox.h b/apps/sequence/list/sequence_toolbox.h index 3f2305f49..767a5c4dc 100644 --- a/apps/sequence/list/sequence_toolbox.h +++ b/apps/sequence/list/sequence_toolbox.h @@ -11,15 +11,15 @@ public: SequenceToolbox(SequenceStore * sequenceStore); bool handleEvent(Ion::Events::Event event) override; int numberOfRows() override; - TableViewCell * reusableCell(int index, int type) override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + HighlightCell * reusableCell(int index, int type) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; KDCoordinate rowHeight(int j) override; int typeAtLocation(int i, int j) override; void addCells(int recurrenceDepth); private: bool selectAddedCell(int selectedRow); constexpr static KDCoordinate k_addedRowHeight = 20; - ExpressionMenuListCell m_addedCells[k_maxNumberOfDisplayedRows]; + ExpressionTableCell m_addedCells[k_maxNumberOfDisplayedRows]; Poincare::ExpressionLayout * m_addedCellLayout[k_maxNumberOfDisplayedRows]; int m_numberOfAddedCells; SequenceStore * m_sequenceStore; diff --git a/apps/sequence/list/type_parameter_controller.cpp b/apps/sequence/list/type_parameter_controller.cpp index 42ac01951..3895e4790 100644 --- a/apps/sequence/list/type_parameter_controller.cpp +++ b/apps/sequence/list/type_parameter_controller.cpp @@ -7,12 +7,12 @@ using namespace Poincare; namespace Sequence { -TypeParameterController::TypeParameterController(Responder * parentResponder, SequenceStore * sequenceStore, +TypeParameterController::TypeParameterController(Responder * parentResponder, SequenceStore * sequenceStore, TableCell::Layout cellLayout, KDCoordinate topMargin, KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin) : ViewController(parentResponder), - m_expliciteCell(TextExpressionMenuListCell((char*)"Explicite")), - m_singleRecurrenceCell(TextExpressionMenuListCell((char*)"Recurrence d'ordre 1")), - m_doubleRecurenceCell(TextExpressionMenuListCell((char*)"Recurrence d'ordre 2")), + m_expliciteCell(ExpressionTableCellWithPointer((char*)"Explicite", cellLayout)), + m_singleRecurrenceCell(ExpressionTableCellWithPointer((char*)"Recurrence d'ordre 1", cellLayout)), + m_doubleRecurenceCell(ExpressionTableCellWithPointer((char*)"Recurrence d'ordre 2", cellLayout)), m_selectableTableView(SelectableTableView(this, this, topMargin, rightMargin, bottomMargin, leftMargin)), m_sequenceStore(sequenceStore), m_sequence(nullptr) @@ -65,10 +65,10 @@ int TypeParameterController::numberOfRows() { return k_totalNumberOfCell; }; -TableViewCell * TypeParameterController::reusableCell(int index) { +HighlightCell * TypeParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCell); - TableViewCell * cells[] = {&m_expliciteCell, &m_singleRecurrenceCell, &m_doubleRecurenceCell}; + HighlightCell * cells[] = {&m_expliciteCell, &m_singleRecurrenceCell, &m_doubleRecurenceCell}; return cells[index]; } @@ -83,7 +83,7 @@ KDCoordinate TypeParameterController::cellHeight() { return 50; } -void TypeParameterController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void TypeParameterController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { const char * nextName = m_sequenceStore->firstAvailableName(); KDText::FontSize size = KDText::FontSize::Large; if (m_sequence) { @@ -96,7 +96,7 @@ void TypeParameterController::willDisplayCellAtLocation(TableViewCell * cell, in m_expressionLayouts[j] = nullptr; } m_expressionLayouts[j] = new BaselineRelativeLayout(new StringLayout(nextName, 1, size), new StringLayout(subscripts[j], strlen(subscripts[j]), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); - TextExpressionMenuListCell * myCell = (TextExpressionMenuListCell *)cell; + ExpressionTableCellWithPointer * myCell = (ExpressionTableCellWithPointer *)cell; myCell->setExpression(m_expressionLayouts[j]); } diff --git a/apps/sequence/list/type_parameter_controller.h b/apps/sequence/list/type_parameter_controller.h index 732ccb3d9..2af039f33 100644 --- a/apps/sequence/list/type_parameter_controller.h +++ b/apps/sequence/list/type_parameter_controller.h @@ -9,8 +9,8 @@ namespace Sequence { class TypeParameterController : public ViewController, public SimpleListViewDataSource { public: TypeParameterController(Responder * parentResponder, SequenceStore * sequenceStore, - KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0, KDCoordinate bottomMargin = 0, - KDCoordinate leftMargin = 0); + TableCell::Layout cellLayout, KDCoordinate topMargin = 0, KDCoordinate rightMargin = 0, + KDCoordinate bottomMargin = 0, KDCoordinate leftMargin = 0); ~TypeParameterController(); const char * title() const override; View * view() override; @@ -18,16 +18,16 @@ public: bool handleEvent(Ion::Events::Event event) override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; void setSequence(Sequence * sequence); private: StackViewController * stackController() const; constexpr static int k_totalNumberOfCell = 3; - TextExpressionMenuListCell m_expliciteCell; - TextExpressionMenuListCell m_singleRecurrenceCell; - TextExpressionMenuListCell m_doubleRecurenceCell; + ExpressionTableCellWithPointer m_expliciteCell; + ExpressionTableCellWithPointer m_singleRecurrenceCell; + ExpressionTableCellWithPointer m_doubleRecurenceCell; Poincare::ExpressionLayout * m_expressionLayouts[k_totalNumberOfCell]; SelectableTableView m_selectableTableView; SequenceStore * m_sequenceStore; diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp index 9f08fef18..3e16b1771 100644 --- a/apps/settings/main_controller.cpp +++ b/apps/settings/main_controller.cpp @@ -20,8 +20,8 @@ const SettingsNode model = SettingsNode("Parametres", menu, 5); MainController::MainController(Responder * parentResponder) : ViewController(parentResponder), - m_cells{ChevronTextMenuListCell(KDText::FontSize::Large), ChevronTextMenuListCell(KDText::FontSize::Large), ChevronTextMenuListCell(KDText::FontSize::Large), - ChevronTextMenuListCell(KDText::FontSize::Large), ChevronTextMenuListCell(KDText::FontSize::Large)}, + m_cells{PointerTableCellWithChevronAndPointer(KDText::FontSize::Large), PointerTableCellWithChevronAndPointer(KDText::FontSize::Large), PointerTableCellWithChevronAndPointer(KDText::FontSize::Large), + PointerTableCellWithChevronAndPointer(KDText::FontSize::Large), PointerTableCellWithChevronAndPointer(KDText::FontSize::Large)}, m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_nodeModel((Node *)&model), @@ -57,7 +57,7 @@ int MainController::numberOfRows() { return m_nodeModel->numberOfChildren(); }; -TableViewCell * MainController::reusableCell(int index) { +HighlightCell * MainController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCell); return &m_cells[index]; @@ -71,8 +71,8 @@ KDCoordinate MainController::cellHeight() { return Metric::ParameterCellHeight; } -void MainController::willDisplayCellForIndex(TableViewCell * cell, int index) { - ChevronTextMenuListCell * myCell = (ChevronTextMenuListCell *)cell; +void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) { + PointerTableCellWithChevronAndPointer * myCell = (PointerTableCellWithChevronAndPointer *)cell; myCell->setText(m_nodeModel->children(index)->label()); switch (index) { case 0: diff --git a/apps/settings/main_controller.h b/apps/settings/main_controller.h index ddaf6002f..8b9121d86 100644 --- a/apps/settings/main_controller.h +++ b/apps/settings/main_controller.h @@ -17,14 +17,14 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; void viewWillAppear() override; private: StackViewController * stackController() const; constexpr static int k_totalNumberOfCell = 5; - ChevronTextMenuListCell m_cells[k_totalNumberOfCell]; + PointerTableCellWithChevronAndPointer m_cells[k_totalNumberOfCell]; SelectableTableView m_selectableTableView; Node * m_nodeModel; SubController m_subController; diff --git a/apps/settings/sub_controller.cpp b/apps/settings/sub_controller.cpp index 72493e998..6f7926831 100644 --- a/apps/settings/sub_controller.cpp +++ b/apps/settings/sub_controller.cpp @@ -9,8 +9,8 @@ namespace Settings { SubController::SubController(Responder * parentResponder) : ViewController(parentResponder), - m_cells{MenuListCell(nullptr, KDText::FontSize::Large), MenuListCell(nullptr, KDText::FontSize::Large), - MenuListCell(nullptr, KDText::FontSize::Large)}, + m_cells{PointerTableCell(nullptr, KDText::FontSize::Large), PointerTableCell(nullptr, KDText::FontSize::Large), + PointerTableCell(nullptr, KDText::FontSize::Large)}, m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_nodeModel(nullptr), @@ -52,7 +52,7 @@ int SubController::numberOfRows() { return 0; } -TableViewCell * SubController::reusableCell(int index) { +HighlightCell * SubController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCell); return &m_cells[index]; @@ -66,8 +66,8 @@ KDCoordinate SubController::cellHeight() { return Metric::ParameterCellHeight; } -void SubController::willDisplayCellForIndex(TableViewCell * cell, int index) { - MenuListCell * myCell = (MenuListCell *)cell; +void SubController::willDisplayCellForIndex(HighlightCell * cell, int index) { + PointerTableCell * myCell = (PointerTableCell *)cell; myCell->setText(m_nodeModel->children(index)->label()); } diff --git a/apps/settings/sub_controller.h b/apps/settings/sub_controller.h index 733cf3258..9115a66bb 100644 --- a/apps/settings/sub_controller.h +++ b/apps/settings/sub_controller.h @@ -15,9 +15,9 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; void setNodeModel(const Node * nodeModel, int preferenceIndex); void viewWillAppear() override; private: @@ -25,7 +25,7 @@ private: void setPreferenceAtIndexWithValueIndex(int preferenceIndex, int valueIndex); int valueIndexAtPreferenceIndex(int preferenceIndex); constexpr static int k_totalNumberOfCell = 3; - MenuListCell m_cells[k_totalNumberOfCell]; + PointerTableCell m_cells[k_totalNumberOfCell]; SelectableTableView m_selectableTableView; Node * m_nodeModel; int m_preferenceIndex; diff --git a/apps/shared/editable_cell_table_view_controller.cpp b/apps/shared/editable_cell_table_view_controller.cpp index 679d74e13..7715cf867 100644 --- a/apps/shared/editable_cell_table_view_controller.cpp +++ b/apps/shared/editable_cell_table_view_controller.cpp @@ -62,7 +62,7 @@ int EditableCellTableViewController::indexFromCumulatedHeight(KDCoordinate offse return (offsetY-1) / k_cellHeight; } -void EditableCellTableViewController::willDisplayCellAtLocationWithDisplayMode(TableViewCell * cell, int i, int j, Expression::FloatDisplayMode floatDisplayMode) { +void EditableCellTableViewController::willDisplayCellAtLocationWithDisplayMode(HighlightCell * cell, int i, int j, Expression::FloatDisplayMode floatDisplayMode) { EvenOddCell * myCell = (EvenOddCell *)cell; myCell->setEven(j%2 == 0); // The cell is editable diff --git a/apps/shared/editable_cell_table_view_controller.h b/apps/shared/editable_cell_table_view_controller.h index 0980531c1..107d6498d 100644 --- a/apps/shared/editable_cell_table_view_controller.h +++ b/apps/shared/editable_cell_table_view_controller.h @@ -17,7 +17,7 @@ public: void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) override; int numberOfRows() override; - void willDisplayCellAtLocationWithDisplayMode(TableViewCell * cell, int i, int j, Poincare::Expression::FloatDisplayMode FloatDisplayMode); + void willDisplayCellAtLocationWithDisplayMode(HighlightCell * cell, int i, int j, Poincare::Expression::FloatDisplayMode FloatDisplayMode); KDCoordinate rowHeight(int j) override; KDCoordinate cumulatedHeightFromIndex(int j) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; diff --git a/apps/shared/float_parameter_controller.cpp b/apps/shared/float_parameter_controller.cpp index cd1ed67eb..95488b5eb 100644 --- a/apps/shared/float_parameter_controller.cpp +++ b/apps/shared/float_parameter_controller.cpp @@ -28,8 +28,8 @@ int FloatParameterController::activeCell() { return m_selectableTableView.selectedRow(); } -void FloatParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { - EditableTextMenuListCell * myCell = (EditableTextMenuListCell *) cell; +void FloatParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { + PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *) cell; char buffer[Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; Complex::convertFloatToText(parameterAtIndex(index), buffer, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::FloatDisplayMode::Decimal); myCell->setAccessoryText(buffer); @@ -46,9 +46,9 @@ bool FloatParameterController::textFieldDidFinishEditing(TextField * textField, } void FloatParameterController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) { - EditableTextMenuListCell * myCell = (EditableTextMenuListCell *)t->cellAtLocation(previousSelectedCellX, previousSelectedCellY); + PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *)t->cellAtLocation(previousSelectedCellX, previousSelectedCellY); myCell->setEditing(false); - EditableTextMenuListCell * myNewCell = (EditableTextMenuListCell *)t->cellAtLocation(t->selectedColumn(), t->selectedRow()); + PointerTableCellWithEditableText * myNewCell = (PointerTableCellWithEditableText *)t->cellAtLocation(t->selectedColumn(), t->selectedRow()); app()->setFirstResponder(myNewCell); } diff --git a/apps/shared/float_parameter_controller.h b/apps/shared/float_parameter_controller.h index 65d60ac91..5ac596e68 100644 --- a/apps/shared/float_parameter_controller.h +++ b/apps/shared/float_parameter_controller.h @@ -15,7 +15,7 @@ public: View * view() override; void didBecomeFirstResponder() override; KDCoordinate cellHeight() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; bool textFieldDidFinishEditing(TextField * textField, const char * text) override; void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) override; protected: diff --git a/apps/shared/list_controller.cpp b/apps/shared/list_controller.cpp index 01c83d3b4..4a86da756 100644 --- a/apps/shared/list_controller.cpp +++ b/apps/shared/list_controller.cpp @@ -83,7 +83,7 @@ int ListController::typeAtLocation(int i, int j) { return i; } -TableViewCell * ListController::reusableCell(int index, int type) { +HighlightCell * ListController::reusableCell(int index, int type) { assert(index >= 0); assert(index < maxNumberOfRows()); switch (type) { @@ -108,7 +108,7 @@ int ListController::reusableCellCount(int type) { return maxNumberOfRows(); } -void ListController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void ListController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { if (j < numberOfRows() - 1 || m_functionStore->numberOfFunctions() == m_functionStore->maxNumberOfFunctions()) { if (i == 0) { willDisplayTitleCellAtIndex(cell, j); diff --git a/apps/shared/list_controller.h b/apps/shared/list_controller.h index e500879c5..c9bc4577a 100644 --- a/apps/shared/list_controller.h +++ b/apps/shared/list_controller.h @@ -19,9 +19,9 @@ public: int indexFromCumulatedWidth(KDCoordinate offsetX) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; int typeAtLocation(int i, int j) override; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; void didBecomeFirstResponder() override; bool handleEvent(Ion::Events::Event event) override; void viewWillAppear() override; @@ -36,10 +36,10 @@ private: Responder * tabController() const; virtual ListParameterController * parameterController() = 0; virtual int maxNumberOfRows() = 0; - virtual TableViewCell * titleCells(int index) = 0; - virtual TableViewCell * expressionCells(int index) = 0; - virtual void willDisplayTitleCellAtIndex(TableViewCell * cell, int j) = 0; - virtual void willDisplayExpressionCellAtIndex(TableViewCell * cell, int j) = 0; + virtual HighlightCell * titleCells(int index) = 0; + virtual HighlightCell * expressionCells(int index) = 0; + virtual void willDisplayTitleCellAtIndex(HighlightCell * cell, int j) = 0; + virtual void willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) = 0; EvenOddCell m_emptyCell; NewFunctionCell m_addNewFunction; }; diff --git a/apps/shared/list_parameter_controller.cpp b/apps/shared/list_parameter_controller.cpp index 6d9507b96..44f8cca64 100644 --- a/apps/shared/list_parameter_controller.cpp +++ b/apps/shared/list_parameter_controller.cpp @@ -8,9 +8,9 @@ ListParameterController::ListParameterController(Responder * parentResponder, Fu m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_functionStore(functionStore), - m_colorCell(ChevronMenuListCell((char*)"Couleur de la fonction")), - m_enableCell(SwitchMenuListCell((char*)"Activer/Desactiver")), - m_deleteCell(MenuListCell((char*)"Supprimer la fonction")) + m_colorCell(PointerTableCellWithChevron((char*)"Couleur de la fonction")), + m_enableCell(PointerTableCellWithSwitch((char*)"Activer/Desactiver")), + m_deleteCell(PointerTableCell((char*)"Supprimer la fonction")) { } @@ -32,7 +32,7 @@ void ListParameterController::didBecomeFirstResponder() { app()->setFirstResponder(&m_selectableTableView); } -void ListParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { +void ListParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (cell == &m_enableCell) { SwitchView * switchView = (SwitchView *)m_enableCell.accessoryView(); switchView->setState(m_function->isActive()); @@ -83,10 +83,10 @@ int ListParameterController::numberOfRows() { return k_totalNumberOfCell; }; -TableViewCell * ListParameterController::reusableCell(int index) { +HighlightCell * ListParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCell); - TableViewCell * cells[] = {&m_colorCell, &m_enableCell, &m_deleteCell}; + HighlightCell * cells[] = {&m_colorCell, &m_enableCell, &m_deleteCell}; return cells[index]; } diff --git a/apps/shared/list_parameter_controller.h b/apps/shared/list_parameter_controller.h index d670c999b..0576082ee 100644 --- a/apps/shared/list_parameter_controller.h +++ b/apps/shared/list_parameter_controller.h @@ -18,18 +18,18 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; protected: SelectableTableView m_selectableTableView; FunctionStore * m_functionStore; Function * m_function; private: constexpr static int k_totalNumberOfCell = 3; - ChevronMenuListCell m_colorCell; - SwitchMenuListCell m_enableCell; - MenuListCell m_deleteCell; + PointerTableCellWithChevron m_colorCell; + PointerTableCellWithSwitch m_enableCell; + PointerTableCell m_deleteCell; }; } diff --git a/apps/shared/range_parameter_controller.cpp b/apps/shared/range_parameter_controller.cpp index 164913f44..e6dc80da6 100644 --- a/apps/shared/range_parameter_controller.cpp +++ b/apps/shared/range_parameter_controller.cpp @@ -10,9 +10,9 @@ namespace Shared { RangeParameterController::RangeParameterController(Responder * parentResponder, InteractiveCurveViewRange * interactiveRange) : FloatParameterController(parentResponder), m_interactiveRange(interactiveRange), - m_rangeCells{EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char *)"Xmin"), EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char *)"Xmax"), - EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char *)"Ymin"), EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char *)"Ymax")}, - m_yAutoCell(SwitchMenuListCell((char*)"Y auto")) + m_rangeCells{PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char *)"Xmin"), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char *)"Xmax"), + PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char *)"Ymin"), PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char *)"Ymax")}, + m_yAutoCell(PointerTableCellWithSwitch((char*)"Y auto")) { } @@ -20,7 +20,7 @@ const char * RangeParameterController::title() const { return "Axes"; } -void RangeParameterController::willDisplayCellForIndex(TableViewCell * cell, int index) { +void RangeParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (index == 2) { SwitchView * switchView = (SwitchView *)m_yAutoCell.accessoryView(); switchView->setState(m_interactiveRange->yAuto()); @@ -49,12 +49,12 @@ bool RangeParameterController::textFieldDidFinishEditing(TextField * textField, void RangeParameterController::tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) { if (previousSelectedCellX == 0 && previousSelectedCellY >= 0 && previousSelectedCellY !=2) { - EditableTextMenuListCell * myCell = (EditableTextMenuListCell *)t->cellAtLocation(previousSelectedCellX, previousSelectedCellY); + PointerTableCellWithEditableText * myCell = (PointerTableCellWithEditableText *)t->cellAtLocation(previousSelectedCellX, previousSelectedCellY); myCell->setEditing(false); app()->setFirstResponder(t); } if (t->selectedColumn() == 0 && t->selectedRow() >= 0 && t->selectedRow() !=2) { - EditableTextMenuListCell * myNewCell = (EditableTextMenuListCell *)t->cellAtLocation(t->selectedColumn(), t->selectedRow()); + PointerTableCellWithEditableText * myNewCell = (PointerTableCellWithEditableText *)t->cellAtLocation(t->selectedColumn(), t->selectedRow()); if ((t->selectedRow() == 0 || t->selectedRow() == 1) || !m_interactiveRange->yAuto()) { app()->setFirstResponder(myNewCell); } @@ -94,7 +94,7 @@ int RangeParameterController::numberOfRows() { return k_numberOfTextCell+1; }; -TableViewCell * RangeParameterController::reusableCell(int index) { +HighlightCell * RangeParameterController::reusableCell(int index) { if (index == 2) { return &m_yAutoCell; } diff --git a/apps/shared/range_parameter_controller.h b/apps/shared/range_parameter_controller.h index 32b452e04..3e8c83833 100644 --- a/apps/shared/range_parameter_controller.h +++ b/apps/shared/range_parameter_controller.h @@ -12,9 +12,9 @@ public: RangeParameterController(Responder * parentResponder, InteractiveCurveViewRange * interactiveCurveViewRange); const char * title() const override; int numberOfRows() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; bool textFieldDidFinishEditing(TextField * textField, const char * text) override; void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY) override; bool handleEvent(Ion::Events::Event event) override; @@ -23,9 +23,9 @@ private: void setParameterAtIndex(int parameterIndex, float f) override; constexpr static int k_numberOfTextCell = 4; InteractiveCurveViewRange * m_interactiveRange; - char m_draftTextBuffer[EditableTextMenuListCell::k_bufferLength]; - EditableTextMenuListCell m_rangeCells[k_numberOfTextCell]; - SwitchMenuListCell m_yAutoCell; + char m_draftTextBuffer[PointerTableCellWithEditableText::k_bufferLength]; + PointerTableCellWithEditableText m_rangeCells[k_numberOfTextCell]; + PointerTableCellWithSwitch m_yAutoCell; }; } diff --git a/apps/shared/store_controller.cpp b/apps/shared/store_controller.cpp index 75b940626..50620751e 100644 --- a/apps/shared/store_controller.cpp +++ b/apps/shared/store_controller.cpp @@ -40,7 +40,7 @@ int StoreController::indexFromCumulatedWidth(KDCoordinate offsetX) { return (offsetX-1) / k_cellWidth; } -TableViewCell * StoreController::reusableCell(int index, int type) { +HighlightCell * StoreController::reusableCell(int index, int type) { assert(index >= 0); switch (type) { case 0: @@ -66,7 +66,7 @@ int StoreController::typeAtLocation(int i, int j) { return j!=0; } -void StoreController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { willDisplayCellAtLocationWithDisplayMode(cell, i, j, Expression::FloatDisplayMode::Decimal); } diff --git a/apps/shared/store_controller.h b/apps/shared/store_controller.h index f04ce6791..37b703f0e 100644 --- a/apps/shared/store_controller.h +++ b/apps/shared/store_controller.h @@ -16,10 +16,10 @@ public: KDCoordinate columnWidth(int i) override; KDCoordinate cumulatedWidthFromIndex(int i) override; int indexFromCumulatedWidth(KDCoordinate offsetX) override; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; int typeAtLocation(int i, int j) override; - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; bool handleEvent(Ion::Events::Event event) override; protected: static constexpr KDCoordinate k_cellWidth = Ion::Display::Width/2 - Metric::RightMargin/2 - Metric::LeftMargin/2; @@ -31,7 +31,7 @@ protected: float dataAtLocation(int columnIndex, int rowIndex) override; int numberOfElements() override; int maxNumberOfElements() const override; - virtual TableViewCell * titleCells(int index) = 0; + virtual HighlightCell * titleCells(int index) = 0; char m_draftTextBuffer[EditableTextCell::k_bufferLength]; EvenOddEditableTextCell m_editableCells[k_maxNumberOfEditableCells]; FloatPairStore * m_store; diff --git a/apps/shared/store_parameter_controller.cpp b/apps/shared/store_parameter_controller.cpp index c5ec2279b..a6e78594a 100644 --- a/apps/shared/store_parameter_controller.cpp +++ b/apps/shared/store_parameter_controller.cpp @@ -5,9 +5,9 @@ namespace Shared { StoreParameterController::StoreParameterController(Responder * parentResponder, FloatPairStore * store) : ViewController(parentResponder), - m_deleteColumn(MenuListCell((char*)"Effacer la colonne")), - m_copyColumn(ChevronMenuListCell((char*)"Copier la colonne dans une liste")), - m_importList(ChevronMenuListCell((char*)"Importer une liste")), + m_deleteColumn(PointerTableCell((char*)"Effacer la colonne")), + m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")), + m_importList(PointerTableCellWithChevron((char*)"Importer une liste")), m_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_store(store), @@ -62,10 +62,10 @@ int StoreParameterController::numberOfRows() { return k_totalNumberOfCell; }; -TableViewCell * StoreParameterController::reusableCell(int index) { +HighlightCell * StoreParameterController::reusableCell(int index) { assert(index >= 0); assert(index < k_totalNumberOfCell); - TableViewCell * cells[] = {&m_deleteColumn, &m_copyColumn, &m_importList}; + HighlightCell * cells[] = {&m_deleteColumn, &m_copyColumn, &m_importList}; return cells[index]; } diff --git a/apps/shared/store_parameter_controller.h b/apps/shared/store_parameter_controller.h index 5c85c6dd5..def1a32ac 100644 --- a/apps/shared/store_parameter_controller.h +++ b/apps/shared/store_parameter_controller.h @@ -16,13 +16,13 @@ public: void didBecomeFirstResponder() override; int numberOfRows() override; KDCoordinate cellHeight() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; private: constexpr static int k_totalNumberOfCell = 3; - MenuListCell m_deleteColumn; - ChevronMenuListCell m_copyColumn; - ChevronMenuListCell m_importList; + PointerTableCell m_deleteColumn; + PointerTableCellWithChevron m_copyColumn; + PointerTableCellWithChevron m_importList; SelectableTableView m_selectableTableView; FloatPairStore * m_store; bool m_xColumnSelected; diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index f49d83e17..2540900f8 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -74,7 +74,7 @@ int CalculationController::numberOfColumns() { return 2; } -void CalculationController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { EvenOddCell * myCell = (EvenOddCell *)cell; myCell->setEven(j%2 == 0); myCell->setHighlighted(i == m_selectableTableView.selectedColumn() && j == m_selectableTableView.selectedRow()); @@ -120,7 +120,7 @@ int CalculationController::indexFromCumulatedHeight(KDCoordinate offsetY) { return (offsetY-1) / k_cellHeight; } -TableViewCell * CalculationController::reusableCell(int index, int type) { +HighlightCell * CalculationController::reusableCell(int index, int type) { assert(index < k_totalNumberOfRows); if (type == 0) { return &m_titleCells[index]; diff --git a/apps/statistics/calculation_controller.h b/apps/statistics/calculation_controller.h index fdb555697..80f879dd1 100644 --- a/apps/statistics/calculation_controller.h +++ b/apps/statistics/calculation_controller.h @@ -21,14 +21,14 @@ public: int numberOfRows() override; int numberOfColumns() override; - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; KDCoordinate columnWidth(int i) override; KDCoordinate rowHeight(int j) override; KDCoordinate cumulatedWidthFromIndex(int i) override; KDCoordinate cumulatedHeightFromIndex(int j) override; int indexFromCumulatedWidth(KDCoordinate offsetX) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; int typeAtLocation(int i, int j) override; void viewWillAppear() override; diff --git a/apps/statistics/histogram_parameter_controller.cpp b/apps/statistics/histogram_parameter_controller.cpp index 9e6bf304d..927f72646 100644 --- a/apps/statistics/histogram_parameter_controller.cpp +++ b/apps/statistics/histogram_parameter_controller.cpp @@ -8,8 +8,8 @@ namespace Statistics { HistogramParameterController::HistogramParameterController(Responder * parentResponder, Store * store) : FloatParameterController(parentResponder), - m_binWidthCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Largeur des rectanges : ")), - m_minValueCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Debut de la serie : ")), + m_binWidthCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Largeur des rectanges : ")), + m_minValueCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Debut de la serie : ")), m_store(store) { } @@ -43,7 +43,7 @@ int HistogramParameterController::numberOfRows() { return 2; }; -TableViewCell * HistogramParameterController::reusableCell(int index) { +HighlightCell * HistogramParameterController::reusableCell(int index) { assert(index >= 0 && index < 2); if (index == 0) { return &m_binWidthCell; diff --git a/apps/statistics/histogram_parameter_controller.h b/apps/statistics/histogram_parameter_controller.h index ae92cb6d2..a7e0713ab 100644 --- a/apps/statistics/histogram_parameter_controller.h +++ b/apps/statistics/histogram_parameter_controller.h @@ -12,14 +12,14 @@ public: HistogramParameterController(Responder * parentResponder, Store * store); const char * title() const override; int numberOfRows() override; - TableViewCell * reusableCell(int index) override; + HighlightCell * reusableCell(int index) override; int reusableCellCount() override; private: float parameterAtIndex(int index) override; void setParameterAtIndex(int parameterIndex, float f) override; - char m_draftTextBuffer[EditableTextMenuListCell::k_bufferLength]; - EditableTextMenuListCell m_binWidthCell; - EditableTextMenuListCell m_minValueCell; + char m_draftTextBuffer[PointerTableCellWithEditableText::k_bufferLength]; + PointerTableCellWithEditableText m_binWidthCell; + PointerTableCellWithEditableText m_minValueCell; Store * m_store; }; diff --git a/apps/statistics/store_controller.cpp b/apps/statistics/store_controller.cpp index 02262002f..cde235d5d 100644 --- a/apps/statistics/store_controller.cpp +++ b/apps/statistics/store_controller.cpp @@ -14,7 +14,7 @@ StoreController::StoreController(Responder * parentResponder, Store * store, Hea { } -void StoreController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { ::StoreController::willDisplayCellAtLocation(cell, i, j); if (cellAtLocationIsEditable(i, j)) { return; @@ -27,7 +27,7 @@ void StoreController::willDisplayCellAtLocation(TableViewCell * cell, int i, int mytitleCell->setText("Effectifs"); } -TableViewCell * StoreController::titleCells(int index) { +HighlightCell * StoreController::titleCells(int index) { assert(index >= 0 && index < k_numberOfTitleCells); return &m_titleCells[index]; } diff --git a/apps/statistics/store_controller.h b/apps/statistics/store_controller.h index 94e51462d..7a90738a5 100644 --- a/apps/statistics/store_controller.h +++ b/apps/statistics/store_controller.h @@ -10,9 +10,9 @@ namespace Statistics { class StoreController : public Shared::StoreController { public: StoreController(Responder * parentResponder, Store * store, HeaderViewController * header); - void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override; + void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override; private: - TableViewCell * titleCells(int index) override; + HighlightCell * titleCells(int index) override; EvenOddPointerTextCell m_titleCells[k_numberOfTitleCells]; }; diff --git a/apps/toolbox_leaf_cell.cpp b/apps/toolbox_leaf_cell.cpp deleted file mode 100644 index ae9705b56..000000000 --- a/apps/toolbox_leaf_cell.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "toolbox_leaf_cell.h" -#include - -ToolboxLeafCell::ToolboxLeafCell() : - TableViewCell(), - m_labelView(PointerTextView(KDText::FontSize::Small, nullptr, 0, 0.5, KDColorBlack, KDColorWhite)), - m_subtitleView(PointerTextView(KDText::FontSize::Small, nullptr, 0, 0.5, Palette::GreyDark, KDColorWhite)) -{ -} - -int ToolboxLeafCell::numberOfSubviews() const { - return 2; -} - -View * ToolboxLeafCell::subviewAtIndex(int index) { - assert(index == 0 || index == 1); - if (index == 0) { - return &m_labelView; - } - return &m_subtitleView; -} - -void ToolboxLeafCell::layoutSubviews() { - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - m_labelView.setFrame(KDRect(1, 1, width-2, height/2 - 1)); - m_subtitleView.setFrame(KDRect(1, height/2, width-2, height/2 - 1)); -} - -void ToolboxLeafCell::reloadCell() { - TableViewCell::reloadCell(); - KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; - m_labelView.setBackgroundColor(backgroundColor); - m_subtitleView.setBackgroundColor(backgroundColor); -} - -void ToolboxLeafCell::setLabel(const char * text) { - m_labelView.setText(text); -} - -void ToolboxLeafCell::setSubtitle(const char * text) { - m_subtitleView.setText(text); -} - -void ToolboxLeafCell::drawRect(KDContext * ctx, KDRect rect) const { - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - KDColor backgroundColor = isHighlighted() ? Palette::Select : KDColorWhite; - ctx->fillRect(KDRect(1, 0, width-2, height-1), backgroundColor); - ctx->fillRect(KDRect(0, height-1, width, 1), Palette::GreyBright); - ctx->fillRect(KDRect(0, 0, 1, height-1), Palette::GreyBright); - ctx->fillRect(KDRect(width-1, 0, 1, height-1), Palette::GreyBright); - } diff --git a/apps/toolbox_leaf_cell.h b/apps/toolbox_leaf_cell.h deleted file mode 100644 index 7c8e891d6..000000000 --- a/apps/toolbox_leaf_cell.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef APPS_TOOLBOX_LEAF_CELL_H -#define APPS_TOOLBOX_LEAF_CELL_H - -#include - -class ToolboxLeafCell : public TableViewCell { -public: - ToolboxLeafCell(); - void reloadCell() override; - void setLabel(const char * text); - void setSubtitle(const char * text); - void drawRect(KDContext * ctx, KDRect rect) const override; -private: - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - void layoutSubviews() override; - PointerTextView m_labelView; - PointerTextView m_subtitleView; -}; - -#endif diff --git a/apps/variable_box_controller.cpp b/apps/variable_box_controller.cpp index 0fb93b7f6..df8acb455 100644 --- a/apps/variable_box_controller.cpp +++ b/apps/variable_box_controller.cpp @@ -84,7 +84,7 @@ int VariableBoxController::ContentViewController::numberOfRows() { } } -TableViewCell * VariableBoxController::ContentViewController::reusableCell(int index, int type) { +HighlightCell * VariableBoxController::ContentViewController::reusableCell(int index, int type) { assert(type < 2); assert(index >= 0); if (type == 0) { @@ -103,10 +103,10 @@ int VariableBoxController::ContentViewController::reusableCellCount(int type) { return k_numberOfMenuRows; } -void VariableBoxController::ContentViewController::willDisplayCellForIndex(TableViewCell * cell, int index) { +void VariableBoxController::ContentViewController::willDisplayCellForIndex(HighlightCell * cell, int index) { if (m_currentPage == Page::RootMenu) { const char * label = nodeLabelAtIndex(index); - MenuListCell * myCell = (MenuListCell *)cell; + PointerTableCell * myCell = (PointerTableCell *)cell; myCell->setText(label); return; } diff --git a/apps/variable_box_controller.h b/apps/variable_box_controller.h index 026064254..bf469b867 100644 --- a/apps/variable_box_controller.h +++ b/apps/variable_box_controller.h @@ -20,9 +20,9 @@ private: void didBecomeFirstResponder() override; bool handleEvent(Ion::Events::Event event) override; int numberOfRows() override; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; - void willDisplayCellForIndex(TableViewCell * cell, int index) override; + void willDisplayCellForIndex(HighlightCell * cell, int index) override; KDCoordinate rowHeight(int j) override; KDCoordinate cumulatedHeightFromIndex(int j) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; @@ -51,7 +51,7 @@ private: int m_previousSelectedRow; Page m_currentPage; VariableBoxLeafCell m_leafCells[k_maxNumberOfDisplayedRows]; - ChevronMenuListCell m_nodeCells[k_numberOfMenuRows]; + PointerTableCellWithChevron m_nodeCells[k_numberOfMenuRows]; SelectableTableView m_selectableTableView; }; ContentViewController m_contentViewController; diff --git a/apps/variable_box_leaf_cell.cpp b/apps/variable_box_leaf_cell.cpp index 4874e772e..964e15666 100644 --- a/apps/variable_box_leaf_cell.cpp +++ b/apps/variable_box_leaf_cell.cpp @@ -4,7 +4,7 @@ using namespace Poincare; VariableBoxLeafCell::VariableBoxLeafCell() : - TableViewCell(), + HighlightCell(), m_labelView(BufferTextView(KDText::FontSize::Small, 0, 0.5, KDColorBlack, KDColorWhite)), m_subtitleView(BufferTextView(KDText::FontSize::Small, 0, 0.5, Palette::GreyDark, KDColorWhite)), m_displayExpression(false) @@ -50,7 +50,7 @@ void VariableBoxLeafCell::layoutSubviews() { } void VariableBoxLeafCell::reloadCell() { - TableViewCell::reloadCell(); + HighlightCell::reloadCell(); KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; m_labelView.setBackgroundColor(backgroundColor); m_subtitleView.setBackgroundColor(backgroundColor); diff --git a/apps/variable_box_leaf_cell.h b/apps/variable_box_leaf_cell.h index 4335e827e..8bb75247f 100644 --- a/apps/variable_box_leaf_cell.h +++ b/apps/variable_box_leaf_cell.h @@ -3,7 +3,7 @@ #include -class VariableBoxLeafCell : public TableViewCell { +class VariableBoxLeafCell : public HighlightCell { public: VariableBoxLeafCell(); void displayExpression(bool displayExpression); diff --git a/escher/Makefile b/escher/Makefile index 338484ac8..8348b3b16 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -5,30 +5,35 @@ objs += $(addprefix escher/src/,\ app.o\ buffer_text_view.o\ button.o\ - chevron_menu_list_cell.o\ - chevron_text_menu_list_cell.o\ - chevron_expression_menu_list_cell.o\ chevron_view.o\ container.o\ - editable_text_menu_list_cell.o\ editable_text_cell.o\ even_odd_cell.o\ even_odd_buffer_text_cell.o\ even_odd_editable_text_cell.o\ even_odd_expression_cell.o\ even_odd_pointer_text_cell.o\ - expression_menu_list_cell.o\ + expression_table_cell.o\ + expression_table_cell_with_pointer.o\ expression_view.o\ header_view_controller.o\ header_view_delegate.o\ + highlight_cell.o\ image_view.o\ invocation.o\ input_view_controller.o\ list_view_data_source.o\ - menu_list_cell.o\ metric.o\ modal_view_controller.o\ palette.o\ + pointer_table_cell.o\ + pointer_table_cell_with_buffer.o\ + pointer_table_cell_with_chevron.o\ + pointer_table_cell_with_chevron_and_pointer.o\ + pointer_table_cell_with_chevron_and_expression.o\ + pointer_table_cell_with_editable_text.o\ + pointer_table_cell_with_pointer.o\ + pointer_table_cell_with_switch.o\ pointer_text_view.o\ responder.o\ scroll_view.o\ @@ -39,17 +44,14 @@ objs += $(addprefix escher/src/,\ solid_color_view.o\ stack_view.o\ stack_view_controller.o\ - switch_menu_list_cell.o\ switch_view.o\ tab_view.o\ tab_view_cell.o\ tab_view_controller.o\ + table_cell.o\ table_view.o\ - table_view_cell.o\ table_view_data_source.o\ text_field.o\ - text_expression_menu_list_cell.o\ - text_menu_list_cell.o\ text_view.o\ tiled_view.o\ toolbox.o\ diff --git a/escher/include/escher.h b/escher/include/escher.h index 2f57c92ad..974ddc0cf 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -6,31 +6,36 @@ #include #include #include -#include -#include -#include #include #include -#include #include #include #include #include #include #include -#include +#include +#include #include #include #include +#include #include #include #include #include #include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -42,15 +47,12 @@ #include #include #include -#include #include #include -#include -#include #include #include +#include #include -#include #include #include #include diff --git a/escher/include/escher/chevron_expression_menu_list_cell.h b/escher/include/escher/chevron_expression_menu_list_cell.h deleted file mode 100644 index 43c4e2eb3..000000000 --- a/escher/include/escher/chevron_expression_menu_list_cell.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ESCHER_CHEVRON_EXPRESSION_MENU_LIST_CELL_H -#define ESCHER_CHEVRON_EXPRESSION_MENU_LIST_CELL_H - -#include -#include - -class ChevronExpressionMenuListCell : public ChevronMenuListCell { -public: - ChevronExpressionMenuListCell(char * label = nullptr); - void setHighlighted(bool highlight) override; - void setExpression(Poincare::ExpressionLayout * expressionLayout); -private: - static constexpr KDCoordinate k_margin = 8; - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - void layoutSubviews() override; - ExpressionView m_subtitleView; -}; - -#endif diff --git a/escher/include/escher/chevron_menu_list_cell.h b/escher/include/escher/chevron_menu_list_cell.h deleted file mode 100644 index 1abea3424..000000000 --- a/escher/include/escher/chevron_menu_list_cell.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef ESCHER_CHEVRON_MENU_LIST_CELL_H -#define ESCHER_CHEVRON_MENU_LIST_CELL_H - -#include -#include - -class ChevronMenuListCell : public MenuListCell { -public: - ChevronMenuListCell(char * label = nullptr, KDText::FontSize size = KDText::FontSize::Small); - View * accessoryView() const override; - void setHighlighted(bool highlight) override; -private: - ChevronView m_accessoryView; -}; - -#endif diff --git a/escher/include/escher/chevron_text_menu_list_cell.h b/escher/include/escher/chevron_text_menu_list_cell.h deleted file mode 100644 index 626706764..000000000 --- a/escher/include/escher/chevron_text_menu_list_cell.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ESCHER_CHEVRON_TEXT_MENU_LIST_CELL_H -#define ESCHER_CHEVRON_TEXT_MENU_LIST_CELL_H - -#include - -class ChevronTextMenuListCell : public ChevronMenuListCell { -public: - ChevronTextMenuListCell(KDText::FontSize size = KDText::FontSize::Small); - void setHighlighted(bool highlight) override; - void setSubtitle(const char * text); -private: - static constexpr KDCoordinate k_margin = 8; - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - void layoutSubviews() override; - PointerTextView m_subtitleView; -}; - -#endif diff --git a/escher/include/escher/chevron_view.h b/escher/include/escher/chevron_view.h index ebf17531c..2e345bbd8 100644 --- a/escher/include/escher/chevron_view.h +++ b/escher/include/escher/chevron_view.h @@ -1,20 +1,18 @@ #ifndef ESCHER_CHEVRON_VIEW_H #define ESCHER_CHEVRON_VIEW_H -#include +#include -class ChevronView : public View { +class ChevronView : public HighlightCell { public: ChevronView(); void drawRect(KDContext * ctx, KDRect rect) const override; - void setHighlighted(bool highlight); KDSize minimalSizeForOptimalDisplay() override; /* k_chevronHeight and k_chevronWidth are the dimensions of the chevron. */ constexpr static KDCoordinate k_chevronHeight = 16; constexpr static KDCoordinate k_chevronWidth = 8; private: constexpr static KDCoordinate k_chevronRightMargin = 20; - bool m_highlighted; }; #endif diff --git a/escher/include/escher/editable_text_cell.h b/escher/include/escher/editable_text_cell.h index e26b26a92..465630be9 100644 --- a/escher/include/escher/editable_text_cell.h +++ b/escher/include/escher/editable_text_cell.h @@ -2,11 +2,11 @@ #define ESCHER_EDITABLE_TEXT_CELL_H #include -#include +#include #include #include -class EditableTextCell : public TableViewCell, public Responder { +class EditableTextCell : public HighlightCell, public Responder { public: EditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, KDText::FontSize size = KDText::FontSize::Large, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor = KDColorWhite); @@ -20,6 +20,7 @@ public: void didBecomeFirstResponder() override; bool isEditing(); void setEditing(bool isEditing); + KDSize minimalSizeForOptimalDisplay() override; constexpr static int k_bufferLength = 255; private: constexpr static KDCoordinate k_textHeight = 12; diff --git a/escher/include/escher/even_odd_cell.h b/escher/include/escher/even_odd_cell.h index b49413631..0c6faaf84 100644 --- a/escher/include/escher/even_odd_cell.h +++ b/escher/include/escher/even_odd_cell.h @@ -1,9 +1,9 @@ #ifndef ESCHER_EVEN_ODD_CELL_H #define ESCHER_EVEN_ODD_CELL_H -#include +#include -class EvenOddCell : public TableViewCell { +class EvenOddCell : public HighlightCell { public: EvenOddCell(); virtual void setEven(bool even); diff --git a/escher/include/escher/expression_menu_list_cell.h b/escher/include/escher/expression_menu_list_cell.h deleted file mode 100644 index 390af3b25..000000000 --- a/escher/include/escher/expression_menu_list_cell.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ESCHER_EXPRESSION_MENU_LIST_CELL_H -#define ESCHER_EXPRESSION_MENU_LIST_CELL_H - -#include -#include -#include -#include -#include - -class ExpressionMenuListCell : public TableViewCell { -public: - ExpressionMenuListCell(); - void setHighlighted(bool highlight) override; - void setExpression(Poincare::ExpressionLayout * expressionLayout); - void drawRect(KDContext * ctx, KDRect rect) const override; -protected: - constexpr static KDCoordinate k_separatorThickness = 1; - ExpressionView m_labelExpressionView; -private: - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - void layoutSubviews() override; -}; - -#endif diff --git a/escher/include/escher/expression_table_cell.h b/escher/include/escher/expression_table_cell.h new file mode 100644 index 000000000..0bd233a33 --- /dev/null +++ b/escher/include/escher/expression_table_cell.h @@ -0,0 +1,17 @@ +#ifndef ESCHER_EXPRESSION_TABLE_CELL_H +#define ESCHER_EXPRESSION_TABLE_CELL_H + +#include +#include + +class ExpressionTableCell : public TableCell { +public: + ExpressionTableCell(Layout layout = Layout::Horizontal); + View * labelView() const override; + void setHighlighted(bool highlight) override; + void setExpression(Poincare::ExpressionLayout * expressionLayout); +private: + ExpressionView m_labelExpressionView; +}; + +#endif diff --git a/escher/include/escher/expression_table_cell_with_pointer.h b/escher/include/escher/expression_table_cell_with_pointer.h new file mode 100644 index 000000000..bfc13fcfa --- /dev/null +++ b/escher/include/escher/expression_table_cell_with_pointer.h @@ -0,0 +1,17 @@ +#ifndef ESCHER_EXPRESSION_TABLE_CELL_WITH_POINTER_H +#define ESCHER_EXPRESSION_TABLE_CELL_WITH_POINTER_H + +#include +#include + +class ExpressionTableCellWithPointer : public ExpressionTableCell { +public: + ExpressionTableCellWithPointer(char * accessoryText = nullptr, Layout layout = Layout::Horizontal); + View * accessoryView() const override; + void setHighlighted(bool highlight) override; + void setAccessoryText(const char * textBody); +private: + PointerTextView m_accessoryView; +}; + +#endif diff --git a/escher/include/escher/table_view_cell.h b/escher/include/escher/highlight_cell.h similarity index 57% rename from escher/include/escher/table_view_cell.h rename to escher/include/escher/highlight_cell.h index 5d11d54d4..61f939aef 100644 --- a/escher/include/escher/table_view_cell.h +++ b/escher/include/escher/highlight_cell.h @@ -1,15 +1,15 @@ -#ifndef ESCHER_TABLE_VIEW_CELL_H -#define ESCHER_TABLE_VIEW_CELL_H +#ifndef ESCHER_HIGHLIGHT_CELL_H +#define ESCHER_HIGHLIGHT_CELL_H #include -class TableViewCell : public View { +class HighlightCell : public View { public: - TableViewCell(); + HighlightCell(); virtual void setHighlighted(bool highlight); bool isHighlighted() const; virtual void reloadCell(); -private: +protected: bool m_highlighted; }; diff --git a/escher/include/escher/list_view_data_source.h b/escher/include/escher/list_view_data_source.h index 7ddb9388b..0a8feba3c 100644 --- a/escher/include/escher/list_view_data_source.h +++ b/escher/include/escher/list_view_data_source.h @@ -2,17 +2,17 @@ #define ESCHER_LIST_VIEW_DATA_SOURCE_H #include -#include +#include class ListViewDataSource : public TableViewDataSource { public: KDCoordinate cellWidth(); KDCoordinate columnWidth(int i) override; int numberOfColumns() override; - void willDisplayCellAtLocation(TableViewCell * cell, int x, int y) override; + void willDisplayCellAtLocation(HighlightCell * cell, int x, int y) override; int indexFromCumulatedWidth(KDCoordinate offsetX) override; KDCoordinate cumulatedWidthFromIndex(int i) override; - virtual void willDisplayCellForIndex(TableViewCell * cell, int index); + virtual void willDisplayCellForIndex(HighlightCell * cell, int index); }; #endif \ No newline at end of file diff --git a/escher/include/escher/menu_list_cell.h b/escher/include/escher/menu_list_cell.h deleted file mode 100644 index f026e5a42..000000000 --- a/escher/include/escher/menu_list_cell.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef ESCHER_MENU_LIST_CELL_H -#define ESCHER_MENU_LIST_CELL_H - -#include -#include -#include -#include -#include - -class MenuListCell : public TableViewCell { -public: - MenuListCell(char * label = nullptr, KDText::FontSize size = KDText::FontSize::Small); - virtual View * accessoryView() const; - void setText(const char * text); - virtual void setTextColor(KDColor color); - void drawRect(KDContext * ctx, KDRect rect) const override; - void setHighlighted(bool highlight) override; -protected: - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - void layoutSubviews() override; - constexpr static KDCoordinate k_separatorThickness = 1; -private: - PointerTextView m_pointerTextView; -}; - -#endif diff --git a/escher/include/escher/pointer_table_cell.h b/escher/include/escher/pointer_table_cell.h new file mode 100644 index 000000000..4691efdea --- /dev/null +++ b/escher/include/escher/pointer_table_cell.h @@ -0,0 +1,18 @@ +#ifndef ESCHER_POINTER_TABLE_CELL_H +#define ESCHER_POINTER_TABLE_CELL_H + +#include +#include + +class PointerTableCell : public TableCell { +public: + PointerTableCell(char * label = nullptr, KDText::FontSize size = KDText::FontSize::Small, Layout layout = Layout::Horizontal); + View * labelView() const override; + virtual void setHighlighted(bool highlight) override; + void setText(const char * text); + virtual void setTextColor(KDColor color); +private: + PointerTextView m_pointerTextView; +}; + +#endif diff --git a/escher/include/escher/text_menu_list_cell.h b/escher/include/escher/pointer_table_cell_with_buffer.h similarity index 55% rename from escher/include/escher/text_menu_list_cell.h rename to escher/include/escher/pointer_table_cell_with_buffer.h index 2283e35af..fdf5e4b91 100644 --- a/escher/include/escher/text_menu_list_cell.h +++ b/escher/include/escher/pointer_table_cell_with_buffer.h @@ -1,12 +1,12 @@ -#ifndef ESCHER_TEXT_MENU_LIST_CELL_H -#define ESCHER_TEXT_MENU_LIST_CELL_H +#ifndef ESCHER_POINTER_TABLE_CELL_WITH_BUFFER_H +#define ESCHER_POINTER_TABLE_CELL_WITH_BUFFER_H -#include +#include #include -class TextMenuListCell : public MenuListCell { +class PointerTableCellWithBuffer : public PointerTableCell { public: - TextMenuListCell(char * label = nullptr); + PointerTableCellWithBuffer(char * label = nullptr); View * accessoryView() const override; void setHighlighted(bool highlight) override; void setAccessoryText(const char * textBody); diff --git a/escher/include/escher/pointer_table_cell_with_chevron.h b/escher/include/escher/pointer_table_cell_with_chevron.h new file mode 100644 index 000000000..b20160ab4 --- /dev/null +++ b/escher/include/escher/pointer_table_cell_with_chevron.h @@ -0,0 +1,16 @@ +#ifndef ESCHER_POINTER_TABLE_CELL_WITH_CHEVRON_H +#define ESCHER_POINTER_TABLE_CELL_WITH_CHEVRON_H + +#include +#include + +class PointerTableCellWithChevron : public PointerTableCell { +public: + PointerTableCellWithChevron(char * label = nullptr, KDText::FontSize size = KDText::FontSize::Small); + View * accessoryView() const override; + void setHighlighted(bool highlight) override; +private: + ChevronView m_accessoryView; +}; + +#endif diff --git a/escher/include/escher/pointer_table_cell_with_chevron_and_expression.h b/escher/include/escher/pointer_table_cell_with_chevron_and_expression.h new file mode 100644 index 000000000..7a0a66364 --- /dev/null +++ b/escher/include/escher/pointer_table_cell_with_chevron_and_expression.h @@ -0,0 +1,17 @@ +#ifndef ESCHER_POINTER_TABLE_CELL_WITH_CHEVRON_AND_EXPRESSION_H +#define ESCHER_POINTER_TABLE_CELL_WITH_CHEVRON_AND_EXPRESSION_H + +#include +#include + +class PointerTableCellWithChevronAndExpression : public PointerTableCellWithChevron { +public: + PointerTableCellWithChevronAndExpression(char * label = nullptr); + View * subAccessoryView() const override; + void setHighlighted(bool highlight) override; + void setExpression(Poincare::ExpressionLayout * expressionLayout); +private: + ExpressionView m_subtitleView; +}; + +#endif diff --git a/escher/include/escher/pointer_table_cell_with_chevron_and_pointer.h b/escher/include/escher/pointer_table_cell_with_chevron_and_pointer.h new file mode 100644 index 000000000..f77916d62 --- /dev/null +++ b/escher/include/escher/pointer_table_cell_with_chevron_and_pointer.h @@ -0,0 +1,16 @@ +#ifndef ESCHER_POINTER_TABLE_CELL_WITH_CHEVRON_AND_POINTER_H +#define ESCHER_POINTER_TABLE_CELL_WITH_CHEVRON_AND_POINTER_H + +#include + +class PointerTableCellWithChevronAndPointer : public PointerTableCellWithChevron { +public: + PointerTableCellWithChevronAndPointer(KDText::FontSize size = KDText::FontSize::Small); + View * subAccessoryView() const override; + void setHighlighted(bool highlight) override; + void setSubtitle(const char * text); +private: + PointerTextView m_subtitleView; +}; + +#endif diff --git a/escher/include/escher/editable_text_menu_list_cell.h b/escher/include/escher/pointer_table_cell_with_editable_text.h similarity index 59% rename from escher/include/escher/editable_text_menu_list_cell.h rename to escher/include/escher/pointer_table_cell_with_editable_text.h index 093c13c95..0cf8b4495 100644 --- a/escher/include/escher/editable_text_menu_list_cell.h +++ b/escher/include/escher/pointer_table_cell_with_editable_text.h @@ -1,13 +1,13 @@ -#ifndef ESCHER_EDITABLE_TEXT_MENU_LIST_CELL_H -#define ESCHER_EDITABLE_TEXT_MENU_LIST_CELL_H +#ifndef ESCHER_POINTER_TABLE_CELL_WITH_EDITABLE_TEXT_H +#define ESCHER_POINTER_TABLE_CELL_WITH_EDITABLE_TEXT_H #include -#include +#include #include -class EditableTextMenuListCell : public Responder, public MenuListCell { +class PointerTableCellWithEditableText : public Responder, public PointerTableCell { public: - EditableTextMenuListCell(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, char * label = nullptr); + PointerTableCellWithEditableText(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, char * label = nullptr); View * accessoryView() const override; const char * editedText() const; void didBecomeFirstResponder() override; diff --git a/escher/include/escher/pointer_table_cell_with_pointer.h b/escher/include/escher/pointer_table_cell_with_pointer.h new file mode 100644 index 000000000..91113101d --- /dev/null +++ b/escher/include/escher/pointer_table_cell_with_pointer.h @@ -0,0 +1,19 @@ +#ifndef ESCHER_POINTER_TABLE_CELL_WITH_POINTER_H +#define ESCHER_POINTER_TABLE_CELL_WITH_POINTER_H + +#include + +class PointerTableCellWithPointer : public PointerTableCell { +public: + PointerTableCellWithPointer(char * label = nullptr, Layout layout = Layout::Vertical); + View * accessoryView() const override; + void setHighlighted(bool highlight) override; + void setAccessoryText(const char * textBody); + const char * accessoryText(); + void setTextColor(KDColor color) override; + void setAccessoryTextColor(KDColor color); +protected: + PointerTextView m_accessoryView; +}; + +#endif diff --git a/escher/include/escher/pointer_table_cell_with_switch.h b/escher/include/escher/pointer_table_cell_with_switch.h new file mode 100644 index 000000000..339d0c6f8 --- /dev/null +++ b/escher/include/escher/pointer_table_cell_with_switch.h @@ -0,0 +1,15 @@ +#ifndef ESCHER_POINTER_TABLE_CELL_WITH_SWITCH_H +#define ESCHER_POINTER_TABLE_CELL_WITH_SWITCH_H + +#include +#include + +class PointerTableCellWithSwitch : public PointerTableCell { +public: + PointerTableCellWithSwitch(char * label = nullptr); + View * accessoryView() const override; +private: + SwitchView m_accessoryView; +}; + +#endif diff --git a/escher/include/escher/pointer_text_view.h b/escher/include/escher/pointer_text_view.h index 0f2f2cf7f..ec0a709ef 100644 --- a/escher/include/escher/pointer_text_view.h +++ b/escher/include/escher/pointer_text_view.h @@ -8,7 +8,6 @@ public: PointerTextView(KDText::FontSize size = KDText::FontSize::Large, const char * text = nullptr, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); void setText(const char * text) override; -protected: const char * text() const override; private: const char * m_textPointer; diff --git a/escher/include/escher/selectable_table_view.h b/escher/include/escher/selectable_table_view.h index ee57315ac..eca9c558e 100644 --- a/escher/include/escher/selectable_table_view.h +++ b/escher/include/escher/selectable_table_view.h @@ -29,7 +29,7 @@ public: virtual void didBecomeFirstResponder() override; void deselectTable(); bool selectCellAtLocation(int i, int j); - TableViewCell * selectedCell(); + HighlightCell * selectedCell(); protected: SelectableTableViewDelegate * m_delegate; private: diff --git a/escher/include/escher/simple_list_view_data_source.h b/escher/include/escher/simple_list_view_data_source.h index 11f3b3a17..ed787b153 100644 --- a/escher/include/escher/simple_list_view_data_source.h +++ b/escher/include/escher/simple_list_view_data_source.h @@ -2,7 +2,7 @@ #define ESCHER_SIMPLE_LIST_VIEW_DATA_SOURCE_H #include -#include +#include class SimpleListViewDataSource : public ListViewDataSource { public: @@ -10,9 +10,9 @@ public: KDCoordinate rowHeight(int j) override; KDCoordinate cumulatedHeightFromIndex(int j) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; - virtual TableViewCell * reusableCell(int index) = 0; + virtual HighlightCell * reusableCell(int index) = 0; virtual int reusableCellCount() = 0; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; int typeAtLocation(int i, int j) override; }; diff --git a/escher/include/escher/simple_table_view_data_source.h b/escher/include/escher/simple_table_view_data_source.h index 932dd3b4b..e543a61f2 100644 --- a/escher/include/escher/simple_table_view_data_source.h +++ b/escher/include/escher/simple_table_view_data_source.h @@ -2,7 +2,7 @@ #define ESCHER_SIMPLE_TABLE_VIEW_DATA_SOURCE_H #include -#include +#include class SimpleTableViewDataSource : public TableViewDataSource { public: @@ -14,9 +14,9 @@ public: KDCoordinate cumulatedHeightFromIndex(int j) override; int indexFromCumulatedWidth(KDCoordinate offsetX) override; int indexFromCumulatedHeight(KDCoordinate offsetY) override; - virtual TableViewCell * reusableCell(int index) = 0; + virtual HighlightCell * reusableCell(int index) = 0; virtual int reusableCellCount() = 0; - TableViewCell * reusableCell(int index, int type) override; + HighlightCell * reusableCell(int index, int type) override; int reusableCellCount(int type) override; int typeAtLocation(int i, int j) override; }; diff --git a/escher/include/escher/switch_menu_list_cell.h b/escher/include/escher/switch_menu_list_cell.h deleted file mode 100644 index 59ea0370a..000000000 --- a/escher/include/escher/switch_menu_list_cell.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ESCHER_SWITCH_MENU_LIST_CELL_H -#define ESCHER_SWITCH_MENU_LIST_CELL_H - -#include -#include - -class SwitchMenuListCell : public MenuListCell { -public: - SwitchMenuListCell(char * label = nullptr); - View * accessoryView() const override; -private: - SwitchView m_accessoryView; -}; - -#endif diff --git a/escher/include/escher/switch_view.h b/escher/include/escher/switch_view.h index 5b3c7d8d1..a69b12b51 100644 --- a/escher/include/escher/switch_view.h +++ b/escher/include/escher/switch_view.h @@ -9,6 +9,7 @@ public: bool state(); void setState(bool state); void drawRect(KDContext * ctx, KDRect rect) const override; + KDSize minimalSizeForOptimalDisplay() override; private: /* k_switchHeight and k_switchWidth are the dimensions of the switch * (including the outline of the switch). The outline thickness is diff --git a/escher/include/escher/table_cell.h b/escher/include/escher/table_cell.h new file mode 100644 index 000000000..b14f59dcb --- /dev/null +++ b/escher/include/escher/table_cell.h @@ -0,0 +1,27 @@ +#ifndef ESCHER_TABLE_CELL_H +#define ESCHER_TABLE_CELL_H + +#include + +class TableCell : public HighlightCell { +public: + enum class Layout { + Vertical, + Horizontal + }; + TableCell(Layout layout = Layout::Horizontal); + virtual View * labelView() const; + virtual View * accessoryView() const; + virtual View * subAccessoryView() const; + void drawRect(KDContext * ctx, KDRect rect) const override; +protected: + int numberOfSubviews() const override; + View * subviewAtIndex(int index) override; + void layoutSubviews() override; + constexpr static KDCoordinate k_separatorThickness = 1; +private: + Layout m_layout; +}; + +#endif + diff --git a/escher/include/escher/table_view.h b/escher/include/escher/table_view.h index ae38753a1..2ea131a07 100644 --- a/escher/include/escher/table_view.h +++ b/escher/include/escher/table_view.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include class TableView : public ScrollView { @@ -15,7 +15,7 @@ public: KDColor backgroundIndicatorColor = Palette::GreyMiddle, KDCoordinate indicatorMargin = 14); virtual void scrollToCell(int i, int j); - TableViewCell * cellAtLocation(int i, int j); + HighlightCell * cellAtLocation(int i, int j); void reloadData(); KDSize size() const; protected: @@ -28,7 +28,7 @@ protected: ContentView(TableView * tableView, TableViewDataSource * dataSource); void scrollToCell(int i, int j) const; - TableViewCell * cellAtLocation(int i, int j); + HighlightCell * cellAtLocation(int i, int j); void resizeToFitContent(); TableViewDataSource * dataSource(); KDSize size() const; diff --git a/escher/include/escher/table_view_data_source.h b/escher/include/escher/table_view_data_source.h index 4ae620a27..12bc07faa 100644 --- a/escher/include/escher/table_view_data_source.h +++ b/escher/include/escher/table_view_data_source.h @@ -2,13 +2,13 @@ #define ESCHER_TABLE_VIEW_DATA_SOURCE_H #include -#include +#include class TableViewDataSource { public: virtual int numberOfRows() = 0; virtual int numberOfColumns() = 0; - virtual void willDisplayCellAtLocation(TableViewCell * cell, int i, int j); + virtual void willDisplayCellAtLocation(HighlightCell * cell, int i, int j); virtual KDCoordinate columnWidth(int i) = 0; virtual KDCoordinate rowHeight(int j) = 0; /* return the number of pixels to include in offset to display the column i at @@ -21,7 +21,7 @@ public: * returns n-1. */ virtual int indexFromCumulatedWidth(KDCoordinate offsetX) = 0; virtual int indexFromCumulatedHeight(KDCoordinate offsetY) = 0; - virtual TableViewCell * reusableCell(int index, int type) = 0; + virtual HighlightCell * reusableCell(int index, int type) = 0; virtual int reusableCellCount(int type) = 0; virtual int typeAtLocation(int i, int j) = 0; }; diff --git a/escher/include/escher/text_expression_menu_list_cell.h b/escher/include/escher/text_expression_menu_list_cell.h deleted file mode 100644 index d50463583..000000000 --- a/escher/include/escher/text_expression_menu_list_cell.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ESCHER_TEXT_EXPRESSION_MENU_LIST_CELL_H -#define ESCHER_TEXT_EXPRESSION_MENU_LIST_CELL_H - -#include -#include - -class TextExpressionMenuListCell : public ExpressionMenuListCell { -public: - TextExpressionMenuListCell(char * accessoryText = nullptr); - void setHighlighted(bool highlight) override; - void setAccessoryText(const char * textBody); -private: - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - void layoutSubviews() override; - PointerTextView m_accessoryView; -}; - -#endif diff --git a/escher/src/chevron_expression_menu_list_cell.cpp b/escher/src/chevron_expression_menu_list_cell.cpp deleted file mode 100644 index bd28aff7e..000000000 --- a/escher/src/chevron_expression_menu_list_cell.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include - -ChevronExpressionMenuListCell::ChevronExpressionMenuListCell(char * label) : - ChevronMenuListCell(label), - m_subtitleView(1.0f, 0.5f, Palette::GreyDark) -{ -} - -void ChevronExpressionMenuListCell::setHighlighted(bool highlight) { - ChevronMenuListCell::setHighlighted(highlight); - KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; - m_subtitleView.setBackgroundColor(backgroundColor); -} - -void ChevronExpressionMenuListCell::setExpression(Poincare::ExpressionLayout * expressionLayout) { - m_subtitleView.setExpression(expressionLayout); - markRectAsDirty(bounds()); - layoutSubviews(); -} - -int ChevronExpressionMenuListCell::numberOfSubviews() const { - return 3; -} - -View * ChevronExpressionMenuListCell::subviewAtIndex(int index) { - if (index == 0 || index == 1) { - return ChevronMenuListCell::subviewAtIndex(index); - } - return &m_subtitleView; -} - -void ChevronExpressionMenuListCell::layoutSubviews() { - ChevronMenuListCell::layoutSubviews(); - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - KDSize subtitleSize = m_subtitleView.minimalSizeForOptimalDisplay(); - KDSize chevronSize = accessoryView()->minimalSizeForOptimalDisplay(); - m_subtitleView.setFrame(KDRect(width-chevronSize.width()-subtitleSize.width()-k_margin, k_separatorThickness, subtitleSize.width(), height - 2*k_separatorThickness)); -} diff --git a/escher/src/chevron_menu_list_cell.cpp b/escher/src/chevron_menu_list_cell.cpp deleted file mode 100644 index ad0152114..000000000 --- a/escher/src/chevron_menu_list_cell.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include - -ChevronMenuListCell::ChevronMenuListCell(char * label, KDText::FontSize size) : - MenuListCell(label, size), - m_accessoryView(ChevronView()) -{ -} - -View * ChevronMenuListCell::accessoryView() const { - return (View *)&m_accessoryView; -} - -void ChevronMenuListCell::setHighlighted(bool highlight) { - MenuListCell::setHighlighted(highlight); - m_accessoryView.setHighlighted(isHighlighted()); -} diff --git a/escher/src/chevron_text_menu_list_cell.cpp b/escher/src/chevron_text_menu_list_cell.cpp deleted file mode 100644 index 7f43792ea..000000000 --- a/escher/src/chevron_text_menu_list_cell.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include - -ChevronTextMenuListCell::ChevronTextMenuListCell(KDText::FontSize size) : -ChevronMenuListCell(nullptr, size), - m_subtitleView(size, "", 1.0f, 0.5f, Palette::GreyDark) -{ -} - -void ChevronTextMenuListCell::setHighlighted(bool highlight) { - ChevronMenuListCell::setHighlighted(highlight); - KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; - m_subtitleView.setBackgroundColor(backgroundColor); -} - -void ChevronTextMenuListCell::setSubtitle(const char * text) { - m_subtitleView.setText(text); - markRectAsDirty(bounds()); - layoutSubviews(); -} - -int ChevronTextMenuListCell::numberOfSubviews() const { - return 3; -} - -View * ChevronTextMenuListCell::subviewAtIndex(int index) { - if (index == 0 || index == 1) { - return ChevronMenuListCell::subviewAtIndex(index); - } - return &m_subtitleView; -} - -void ChevronTextMenuListCell::layoutSubviews() { - ChevronMenuListCell::layoutSubviews(); - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - KDSize subtitleSize = m_subtitleView.minimalSizeForOptimalDisplay(); - KDSize chevronSize = accessoryView()->minimalSizeForOptimalDisplay(); - m_subtitleView.setFrame(KDRect(width-chevronSize.width()-subtitleSize.width()-k_margin, k_separatorThickness, subtitleSize.width(), height - 2*k_separatorThickness)); -} diff --git a/escher/src/chevron_view.cpp b/escher/src/chevron_view.cpp index 973c2cd59..88a1561a6 100644 --- a/escher/src/chevron_view.cpp +++ b/escher/src/chevron_view.cpp @@ -40,15 +40,10 @@ const KDColor highlightedChevronPixel[] = { }; ChevronView::ChevronView() : - m_highlighted(false) + HighlightCell() { } -void ChevronView::setHighlighted(bool highlight) { - m_highlighted = highlight; - markRectAsDirty(bounds()); -} - KDColor s_workingBuffer[ChevronView::k_chevronWidth*ChevronView::k_chevronHeight]; void ChevronView::drawRect(KDContext * ctx, KDRect rect) const { diff --git a/escher/src/editable_text_cell.cpp b/escher/src/editable_text_cell.cpp index d12efb59c..ea52f96c6 100644 --- a/escher/src/editable_text_cell.cpp +++ b/escher/src/editable_text_cell.cpp @@ -5,7 +5,7 @@ EditableTextCell::EditableTextCell(Responder * parentResponder, TextFieldDelegate * delegate, char * draftTextBuffer, KDText::FontSize size, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) : - TableViewCell(), + HighlightCell(), Responder(parentResponder), m_textField(TextField(this, m_textBody, draftTextBuffer, 255, delegate, size, horizontalAlignment, verticalAlignment, textColor, backgroundColor)) { @@ -16,7 +16,7 @@ TextField * EditableTextCell::textField() { } void EditableTextCell::setHighlighted(bool highlight) { - TableViewCell::setHighlighted(highlight); + HighlightCell::setHighlighted(highlight); KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; m_textField.setBackgroundColor(backgroundColor); } @@ -56,3 +56,6 @@ void EditableTextCell::setEditing(bool isEditing) { m_textField.setEditing(isEditing); } +KDSize EditableTextCell::minimalSizeForOptimalDisplay() { + return m_textField.minimalSizeForOptimalDisplay(); +} diff --git a/escher/src/editable_text_menu_list_cell.cpp b/escher/src/editable_text_menu_list_cell.cpp deleted file mode 100644 index a63425565..000000000 --- a/escher/src/editable_text_menu_list_cell.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - -EditableTextMenuListCell::EditableTextMenuListCell(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, char * label) : - Responder(parentResponder), - MenuListCell(label), - m_textField(TextField(this, m_textBody, draftTextBuffer, 255, textFieldDelegate, KDText::FontSize::Large, 1.0f, 0.5f)) -{ -} - -View * EditableTextMenuListCell::accessoryView() const { - return (View *)&m_textField; -} - -const char * EditableTextMenuListCell::editedText() const { - return m_textField.text(); -} - -void EditableTextMenuListCell::didBecomeFirstResponder() { - app()->setFirstResponder(&m_textField); -} - -void EditableTextMenuListCell::setEditing(bool isEditing) { - m_textField.setEditing(isEditing); -} - -void EditableTextMenuListCell::setHighlighted(bool highlight) { - MenuListCell::setHighlighted(highlight); - KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; - m_textField.setBackgroundColor(backgroundColor); -} - -void EditableTextMenuListCell::setAccessoryText(const char * text) { - m_textField.setText(text); -} - -void EditableTextMenuListCell::setTextColor(KDColor color) { - m_textField.setTextColor(color); - MenuListCell::setTextColor(color); -} diff --git a/escher/src/even_odd_cell.cpp b/escher/src/even_odd_cell.cpp index 01a071fb4..c8d90e582 100644 --- a/escher/src/even_odd_cell.cpp +++ b/escher/src/even_odd_cell.cpp @@ -2,7 +2,7 @@ #include EvenOddCell::EvenOddCell() : - TableViewCell(), + HighlightCell(), m_even(false) { } diff --git a/escher/src/expression_menu_list_cell.cpp b/escher/src/expression_menu_list_cell.cpp deleted file mode 100644 index a0c89453e..000000000 --- a/escher/src/expression_menu_list_cell.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -ExpressionMenuListCell::ExpressionMenuListCell() : - TableViewCell(), - m_labelExpressionView(ExpressionView(0.0f, 0.5f, KDColorBlack, KDColorWhite)) -{ -} - -void ExpressionMenuListCell::setHighlighted(bool highlight) { - TableViewCell::setHighlighted(highlight); - KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; - m_labelExpressionView.setBackgroundColor(backgroundColor); -} - -void ExpressionMenuListCell::setExpression(Poincare::ExpressionLayout * expressionLayout) { - m_labelExpressionView.setExpression(expressionLayout); -} - -void ExpressionMenuListCell::drawRect(KDContext * ctx, KDRect rect) const { - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - KDColor backgroundColor = isHighlighted() ? Palette::Select : KDColorWhite; - - ctx->fillRect(KDRect(k_separatorThickness, k_separatorThickness, width-2*k_separatorThickness, height-k_separatorThickness), backgroundColor); - ctx->fillRect(KDRect(0, 0, width, k_separatorThickness), Palette::GreyBright); - ctx->fillRect(KDRect(0, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); - ctx->fillRect(KDRect(width-k_separatorThickness, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); - } - -int ExpressionMenuListCell::numberOfSubviews() const { - return 1; -} - -View * ExpressionMenuListCell::subviewAtIndex(int index) { - assert(index == 0); - return &m_labelExpressionView; -} - -void ExpressionMenuListCell::layoutSubviews() { - m_labelExpressionView.setFrame(bounds()); -} diff --git a/escher/src/expression_table_cell.cpp b/escher/src/expression_table_cell.cpp new file mode 100644 index 000000000..f4775382f --- /dev/null +++ b/escher/src/expression_table_cell.cpp @@ -0,0 +1,24 @@ +#include +#include +#include + +ExpressionTableCell::ExpressionTableCell(Layout layout) : + TableCell(layout), + m_labelExpressionView(ExpressionView(0.0f, 0.5f, KDColorBlack, KDColorWhite)) +{ +} + +View * ExpressionTableCell::labelView() const { + return (View *)&m_labelExpressionView; +} + +void ExpressionTableCell::setHighlighted(bool highlight) { + TableCell::setHighlighted(highlight); + KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; + m_labelExpressionView.setBackgroundColor(backgroundColor); +} + +void ExpressionTableCell::setExpression(Poincare::ExpressionLayout * expressionLayout) { + m_labelExpressionView.setExpression(expressionLayout); + layoutSubviews(); +} diff --git a/escher/src/expression_table_cell_with_pointer.cpp b/escher/src/expression_table_cell_with_pointer.cpp new file mode 100644 index 000000000..623fde4f2 --- /dev/null +++ b/escher/src/expression_table_cell_with_pointer.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +ExpressionTableCellWithPointer::ExpressionTableCellWithPointer(char * accessoryText, Layout layout) : + ExpressionTableCell(layout), + m_accessoryView(PointerTextView(KDText::FontSize::Small, accessoryText, 0.0f, 0.5f, Palette::GreyDark, KDColorWhite)) +{ + if (layout == Layout::Horizontal) { + m_accessoryView.setAlignment(1.0f, 0.5f); + } +} + +View * ExpressionTableCellWithPointer::accessoryView() const { + return (View *)&m_accessoryView; +} + +void ExpressionTableCellWithPointer::setHighlighted(bool highlight) { + ExpressionTableCell::setHighlighted(highlight); + KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; + m_accessoryView.setBackgroundColor(backgroundColor); +} + +void ExpressionTableCellWithPointer::setAccessoryText(const char * text) { + m_accessoryView.setText(text); +} diff --git a/escher/src/highlight_cell.cpp b/escher/src/highlight_cell.cpp new file mode 100644 index 000000000..a897e6741 --- /dev/null +++ b/escher/src/highlight_cell.cpp @@ -0,0 +1,20 @@ +#include + +HighlightCell::HighlightCell() : + View(), + m_highlighted(false) +{ +} + +void HighlightCell::setHighlighted(bool highlight) { + m_highlighted = highlight; + reloadCell(); +} + +bool HighlightCell::isHighlighted() const { + return m_highlighted; +} + +void HighlightCell::reloadCell() { + markRectAsDirty(bounds()); +} diff --git a/escher/src/list_view_data_source.cpp b/escher/src/list_view_data_source.cpp index 62fea532d..e1992fd34 100644 --- a/escher/src/list_view_data_source.cpp +++ b/escher/src/list_view_data_source.cpp @@ -12,11 +12,11 @@ int ListViewDataSource::numberOfColumns() { return 1; } -void ListViewDataSource::willDisplayCellAtLocation(TableViewCell * cell, int x, int y) { +void ListViewDataSource::willDisplayCellAtLocation(HighlightCell * cell, int x, int y) { willDisplayCellForIndex(cell, y); } -void ListViewDataSource::willDisplayCellForIndex(TableViewCell * cell, int index) { +void ListViewDataSource::willDisplayCellForIndex(HighlightCell * cell, int index) { } KDCoordinate ListViewDataSource::cumulatedWidthFromIndex(int i) { diff --git a/escher/src/menu_list_cell.cpp b/escher/src/menu_list_cell.cpp deleted file mode 100644 index 19d6d0400..000000000 --- a/escher/src/menu_list_cell.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include - -constexpr KDCoordinate MenuListCell::k_separatorThickness; - -MenuListCell::MenuListCell(char * label, KDText::FontSize size) : - TableViewCell(), - m_pointerTextView(PointerTextView(size, label, 0, 0.5, KDColorBlack, KDColorWhite)) -{ -} - -int MenuListCell::numberOfSubviews() const { - if (accessoryView() == nullptr) { - return 1; - } - return 2; -} - -View * MenuListCell::subviewAtIndex(int index) { - if (index == 0) { - return &m_pointerTextView; - } - assert(numberOfSubviews() >= 2 && index == 1); - return accessoryView(); -} - -void MenuListCell::layoutSubviews() { - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - KDSize labelSize = m_pointerTextView.minimalSizeForOptimalDisplay(); - m_pointerTextView.setFrame(KDRect(k_separatorThickness, k_separatorThickness, labelSize.width(), height - 2*k_separatorThickness)); - View * accessory = accessoryView(); - if (accessory) { - accessory->setFrame(KDRect(k_separatorThickness + labelSize.width(), k_separatorThickness, width - labelSize.width()-2*k_separatorThickness, height-2*k_separatorThickness)); - } -} - -void MenuListCell::setHighlighted(bool highlight) { - TableViewCell::setHighlighted(highlight); - KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; - m_pointerTextView.setBackgroundColor(backgroundColor); -} - -void MenuListCell::setText(const char * text) { - m_pointerTextView.setText(text); - layoutSubviews(); -} - -void MenuListCell::setTextColor(KDColor color) { - m_pointerTextView.setTextColor(color); -} - -View * MenuListCell::accessoryView() const { - return nullptr; -} - -void MenuListCell::drawRect(KDContext * ctx, KDRect rect) const { - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - KDColor backgroundColor = isHighlighted() ? Palette::Select : KDColorWhite; - - ctx->fillRect(KDRect(k_separatorThickness, k_separatorThickness, width-2*k_separatorThickness, height-k_separatorThickness), backgroundColor); - ctx->fillRect(KDRect(0, 0, width, k_separatorThickness), Palette::GreyBright); - ctx->fillRect(KDRect(0, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); - ctx->fillRect(KDRect(width-k_separatorThickness, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); - } diff --git a/escher/src/pointer_table_cell.cpp b/escher/src/pointer_table_cell.cpp new file mode 100644 index 000000000..a4b92e81e --- /dev/null +++ b/escher/src/pointer_table_cell.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +PointerTableCell::PointerTableCell(char * label, KDText::FontSize size, Layout layout) : + TableCell(layout), + m_pointerTextView(PointerTextView(size, label, 0, 0.5, KDColorBlack, KDColorWhite)) +{ +} + +View * PointerTableCell::labelView() const { + return (View *)&m_pointerTextView; +} + +void PointerTableCell::setHighlighted(bool highlight) { + HighlightCell::setHighlighted(highlight); + KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; + m_pointerTextView.setBackgroundColor(backgroundColor); +} + +void PointerTableCell::setText(const char * text) { + m_pointerTextView.setText(text); + layoutSubviews(); +} + +void PointerTableCell::setTextColor(KDColor color) { + m_pointerTextView.setTextColor(color); +} diff --git a/escher/src/pointer_table_cell_with_buffer.cpp b/escher/src/pointer_table_cell_with_buffer.cpp new file mode 100644 index 000000000..4c933e0d8 --- /dev/null +++ b/escher/src/pointer_table_cell_with_buffer.cpp @@ -0,0 +1,32 @@ +#include +#include + +PointerTableCellWithBuffer::PointerTableCellWithBuffer(char * label) : + PointerTableCell(label), + m_accessoryView(BufferTextView(KDText::FontSize::Large, 1.0f, 0.5f)) +{ +} + +void PointerTableCellWithBuffer::setAccessoryText(const char * textBody) { + m_accessoryView.setText(textBody); + reloadCell(); +} + +const char * PointerTableCellWithBuffer::accessoryText() { + return m_accessoryView.text(); +} + +View * PointerTableCellWithBuffer::accessoryView() const { + return (View *)&m_accessoryView; +} + +void PointerTableCellWithBuffer::setHighlighted(bool highlight) { + PointerTableCell::setHighlighted(highlight); + KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; + m_accessoryView.setBackgroundColor(backgroundColor); +} + +void PointerTableCellWithBuffer::setTextColor(KDColor color) { + m_accessoryView.setTextColor(color); + PointerTableCell::setTextColor(color); +} diff --git a/escher/src/pointer_table_cell_with_chevron.cpp b/escher/src/pointer_table_cell_with_chevron.cpp new file mode 100644 index 000000000..5e9faeead --- /dev/null +++ b/escher/src/pointer_table_cell_with_chevron.cpp @@ -0,0 +1,16 @@ +#include + +PointerTableCellWithChevron::PointerTableCellWithChevron(char * label, KDText::FontSize size) : + PointerTableCell(label, size), + m_accessoryView(ChevronView()) +{ +} + +View * PointerTableCellWithChevron::accessoryView() const { + return (View *)&m_accessoryView; +} + +void PointerTableCellWithChevron::setHighlighted(bool highlight) { + PointerTableCell::setHighlighted(highlight); + m_accessoryView.setHighlighted(isHighlighted()); +} diff --git a/escher/src/pointer_table_cell_with_chevron_and_expression.cpp b/escher/src/pointer_table_cell_with_chevron_and_expression.cpp new file mode 100644 index 000000000..3f77087d8 --- /dev/null +++ b/escher/src/pointer_table_cell_with_chevron_and_expression.cpp @@ -0,0 +1,24 @@ +#include +#include + +PointerTableCellWithChevronAndExpression::PointerTableCellWithChevronAndExpression(char * label) : + PointerTableCellWithChevron(label), + m_subtitleView(1.0f, 0.5f, Palette::GreyDark) +{ +} + +View * PointerTableCellWithChevronAndExpression::subAccessoryView() const { + return (View *)&m_subtitleView; +} + +void PointerTableCellWithChevronAndExpression::setHighlighted(bool highlight) { + PointerTableCellWithChevron::setHighlighted(highlight); + KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; + m_subtitleView.setBackgroundColor(backgroundColor); +} + +void PointerTableCellWithChevronAndExpression::setExpression(Poincare::ExpressionLayout * expressionLayout) { + m_subtitleView.setExpression(expressionLayout); + reloadCell(); + layoutSubviews(); +} diff --git a/escher/src/pointer_table_cell_with_chevron_and_pointer.cpp b/escher/src/pointer_table_cell_with_chevron_and_pointer.cpp new file mode 100644 index 000000000..bfaad01b5 --- /dev/null +++ b/escher/src/pointer_table_cell_with_chevron_and_pointer.cpp @@ -0,0 +1,24 @@ +#include +#include + +PointerTableCellWithChevronAndPointer::PointerTableCellWithChevronAndPointer(KDText::FontSize size) : + PointerTableCellWithChevron(nullptr, size), + m_subtitleView(size, "", 1.0f, 0.5f, Palette::GreyDark) +{ +} + +View * PointerTableCellWithChevronAndPointer::subAccessoryView() const { + return (View *)&m_subtitleView; +} + +void PointerTableCellWithChevronAndPointer::setHighlighted(bool highlight) { + PointerTableCellWithChevron::setHighlighted(highlight); + KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; + m_subtitleView.setBackgroundColor(backgroundColor); +} + +void PointerTableCellWithChevronAndPointer::setSubtitle(const char * text) { + m_subtitleView.setText(text); + reloadCell(); + layoutSubviews(); +} diff --git a/escher/src/pointer_table_cell_with_editable_text.cpp b/escher/src/pointer_table_cell_with_editable_text.cpp new file mode 100644 index 000000000..33edd0a51 --- /dev/null +++ b/escher/src/pointer_table_cell_with_editable_text.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +PointerTableCellWithEditableText::PointerTableCellWithEditableText(Responder * parentResponder, TextFieldDelegate * textFieldDelegate, char * draftTextBuffer, char * label) : + Responder(parentResponder), + PointerTableCell(label), + m_textField(TextField(this, m_textBody, draftTextBuffer, 255, textFieldDelegate, KDText::FontSize::Large, 1.0f, 0.5f)) +{ +} + +View * PointerTableCellWithEditableText::accessoryView() const { + return (View *)&m_textField; +} + +const char * PointerTableCellWithEditableText::editedText() const { + return m_textField.text(); +} + +void PointerTableCellWithEditableText::didBecomeFirstResponder() { + app()->setFirstResponder(&m_textField); +} + +void PointerTableCellWithEditableText::setEditing(bool isEditing) { + m_textField.setEditing(isEditing); +} + +void PointerTableCellWithEditableText::setHighlighted(bool highlight) { + PointerTableCell::setHighlighted(highlight); + KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; + m_textField.setBackgroundColor(backgroundColor); +} + +void PointerTableCellWithEditableText::setAccessoryText(const char * text) { + m_textField.setText(text); + layoutSubviews(); +} + +void PointerTableCellWithEditableText::setTextColor(KDColor color) { + m_textField.setTextColor(color); + PointerTableCell::setTextColor(color); +} diff --git a/escher/src/pointer_table_cell_with_pointer.cpp b/escher/src/pointer_table_cell_with_pointer.cpp new file mode 100644 index 000000000..90a23f935 --- /dev/null +++ b/escher/src/pointer_table_cell_with_pointer.cpp @@ -0,0 +1,39 @@ +#include +#include + +PointerTableCellWithPointer::PointerTableCellWithPointer(char * label, Layout layout) : + PointerTableCell(label, KDText::FontSize::Small, layout), + m_accessoryView(PointerTextView(KDText::FontSize::Small, nullptr, 0.0f, 0.5f)) +{ + if (layout != Layout::Vertical) { + m_accessoryView.setAlignment(1.0f, 0.5f); + } +} + +void PointerTableCellWithPointer::setAccessoryText(const char * textBody) { + m_accessoryView.setText(textBody); + reloadCell(); +} + +const char * PointerTableCellWithPointer::accessoryText() { + return m_accessoryView.text(); +} + +View * PointerTableCellWithPointer::accessoryView() const { + return (View *)&m_accessoryView; +} + +void PointerTableCellWithPointer::setHighlighted(bool highlight) { + PointerTableCell::setHighlighted(highlight); + KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; + m_accessoryView.setBackgroundColor(backgroundColor); +} + +void PointerTableCellWithPointer::setTextColor(KDColor color) { + m_accessoryView.setTextColor(color); + PointerTableCell::setTextColor(color); +} + +void PointerTableCellWithPointer::setAccessoryTextColor(KDColor color) { + m_accessoryView.setTextColor(color); +} diff --git a/escher/src/pointer_table_cell_with_switch.cpp b/escher/src/pointer_table_cell_with_switch.cpp new file mode 100644 index 000000000..fadb2ac36 --- /dev/null +++ b/escher/src/pointer_table_cell_with_switch.cpp @@ -0,0 +1,12 @@ +#include +#include + +PointerTableCellWithSwitch::PointerTableCellWithSwitch(char * label) : + PointerTableCell(label), + m_accessoryView(SwitchView()) +{ +} + +View * PointerTableCellWithSwitch::accessoryView() const { + return (View *)&m_accessoryView; +} diff --git a/escher/src/selectable_table_view.cpp b/escher/src/selectable_table_view.cpp index a4f76cdff..d4c9c6b7f 100644 --- a/escher/src/selectable_table_view.cpp +++ b/escher/src/selectable_table_view.cpp @@ -34,7 +34,7 @@ void SelectableTableView::didBecomeFirstResponder() { void SelectableTableView::deselectTable() { if (m_selectedCellX >= 0 && m_selectedCellX < dataSource()->numberOfColumns() && m_selectedCellY >= 0 && m_selectedCellY < dataSource()->numberOfRows()) { - TableViewCell * previousCell = cellAtLocation(m_selectedCellX, m_selectedCellY); + HighlightCell * previousCell = cellAtLocation(m_selectedCellX, m_selectedCellY); previousCell->setHighlighted(false); } int previousSelectedCellX = m_selectedCellX; @@ -55,7 +55,7 @@ bool SelectableTableView::selectCellAtLocation(int i, int j) { } if (m_selectedCellX >= 0 && m_selectedCellX < dataSource()->numberOfColumns() && m_selectedCellY >= 0 && m_selectedCellY < dataSource()->numberOfRows()) { - TableViewCell * previousCell = cellAtLocation(m_selectedCellX, m_selectedCellY); + HighlightCell * previousCell = cellAtLocation(m_selectedCellX, m_selectedCellY); previousCell->setHighlighted(false); } int previousX = m_selectedCellX; @@ -64,7 +64,7 @@ bool SelectableTableView::selectCellAtLocation(int i, int j) { m_selectedCellY = j; if (m_selectedCellY >= 0) { scrollToCell(i, j); - TableViewCell * cell = cellAtLocation(i, j); + HighlightCell * cell = cellAtLocation(i, j); cell->setHighlighted(true); } if (m_delegate) { @@ -73,7 +73,7 @@ bool SelectableTableView::selectCellAtLocation(int i, int j) { return true; } -TableViewCell * SelectableTableView::selectedCell() { +HighlightCell * SelectableTableView::selectedCell() { return cellAtLocation(m_selectedCellX, m_selectedCellY); } diff --git a/escher/src/simple_list_view_data_source.cpp b/escher/src/simple_list_view_data_source.cpp index 365de19c7..e074c3428 100644 --- a/escher/src/simple_list_view_data_source.cpp +++ b/escher/src/simple_list_view_data_source.cpp @@ -17,7 +17,7 @@ int SimpleListViewDataSource::indexFromCumulatedHeight(KDCoordinate offsetY) { return (offsetY - 1) / height; } -TableViewCell * SimpleListViewDataSource::reusableCell(int index, int type) { +HighlightCell * SimpleListViewDataSource::reusableCell(int index, int type) { assert(type == 0); return reusableCell(index); } diff --git a/escher/src/simple_table_view_data_source.cpp b/escher/src/simple_table_view_data_source.cpp index 0c6b820cb..a82e544e0 100644 --- a/escher/src/simple_table_view_data_source.cpp +++ b/escher/src/simple_table_view_data_source.cpp @@ -37,7 +37,7 @@ int SimpleTableViewDataSource::indexFromCumulatedHeight(KDCoordinate offsetY) { return (offsetY - 1) / height; } -TableViewCell * SimpleTableViewDataSource::reusableCell(int index, int type) { +HighlightCell * SimpleTableViewDataSource::reusableCell(int index, int type) { assert(type == 0); return reusableCell(index); } diff --git a/escher/src/switch_menu_list_cell.cpp b/escher/src/switch_menu_list_cell.cpp deleted file mode 100644 index bcdf92686..000000000 --- a/escher/src/switch_menu_list_cell.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -SwitchMenuListCell::SwitchMenuListCell(char * label) : - MenuListCell(label), - m_accessoryView(SwitchView()) -{ -} - -View * SwitchMenuListCell::accessoryView() const { - return (View *)&m_accessoryView; -} diff --git a/escher/src/switch_view.cpp b/escher/src/switch_view.cpp index c49c3682f..6a1465024 100644 --- a/escher/src/switch_view.cpp +++ b/escher/src/switch_view.cpp @@ -40,3 +40,7 @@ void SwitchView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(KDRect(width - k_switchMargin - switchHalfWidth - k_separatorThickness, heightCenter-switchHalfHeight, switchHalfWidth, k_switchHeight), KDColorWhite); } } + +KDSize SwitchView::minimalSizeForOptimalDisplay() { + return KDSize(2*k_separatorThickness + k_switchMargin + k_switchWidth, k_switchHeight); +} diff --git a/escher/src/table_cell.cpp b/escher/src/table_cell.cpp new file mode 100644 index 000000000..57aa340ae --- /dev/null +++ b/escher/src/table_cell.cpp @@ -0,0 +1,92 @@ +#include +#include + +TableCell::TableCell(Layout layout) : + HighlightCell(), + m_layout(layout) +{ +} + +View * TableCell::labelView() const { + return nullptr; +} + +View * TableCell::accessoryView() const { + return nullptr; +} + +View * TableCell::subAccessoryView() const { + return nullptr; +} + +int TableCell::numberOfSubviews() const { + return (labelView() != nullptr) + (accessoryView()!= nullptr) + (subAccessoryView()!= nullptr); +} + +View * TableCell::subviewAtIndex(int index) { + if (index == 0) { + return labelView(); + } + if (index == 1) { + return accessoryView(); + } + return subAccessoryView(); +} + +void TableCell::layoutSubviews() { + KDCoordinate width = bounds().width(); + KDCoordinate height = bounds().height(); + View * label = labelView(); + if (label) { + KDSize labelSize = label->minimalSizeForOptimalDisplay(); + switch (m_layout) { + case Layout::Vertical: + label->setFrame(KDRect(k_separatorThickness, k_separatorThickness, width-2*k_separatorThickness, labelSize.height())); + break; + default: + label->setFrame(KDRect(k_separatorThickness, k_separatorThickness, labelSize.width(), height - 2*k_separatorThickness)); + break; + } + } + View * accessory = accessoryView(); + if (accessory) { + KDSize accessorySize = accessory->minimalSizeForOptimalDisplay(); + /* Handle textfield that has no defined width (as their width evolves with + * the length of edited text */ + if (accessorySize.width() == 0 && m_layout != Layout::Vertical) { + accessorySize = KDSize(width - 2*k_separatorThickness, accessorySize.height()); + if (label) { + KDSize labelSize = label->minimalSizeForOptimalDisplay(); + accessorySize = KDSize(width - 2*k_separatorThickness - labelSize.width(), accessorySize.height()); + } + } + switch (m_layout) { + case Layout::Vertical: + accessory->setFrame(KDRect(k_separatorThickness, height-k_separatorThickness-accessorySize.height(), + width-2*k_separatorThickness, accessorySize.height())); + break; + default: + accessory->setFrame(KDRect(width - accessorySize.width() - k_separatorThickness, k_separatorThickness, + accessorySize.width(), height-2*k_separatorThickness)); + break; + } + } + View * subAccessory = subAccessoryView(); + if (subAccessory && accessory) { + KDSize accessorySize = accessory->minimalSizeForOptimalDisplay(); + KDSize subAccessorySize = subAccessory->minimalSizeForOptimalDisplay(); + subAccessory->setFrame(KDRect(width-k_separatorThickness-accessorySize.width()-subAccessorySize.width(), k_separatorThickness, + subAccessorySize.width(), height-2*k_separatorThickness)); + } +} + +void TableCell::drawRect(KDContext * ctx, KDRect rect) const { + KDCoordinate width = bounds().width(); + KDCoordinate height = bounds().height(); + KDColor backgroundColor = isHighlighted() ? Palette::Select : KDColorWhite; + ctx->fillRect(KDRect(k_separatorThickness, k_separatorThickness, width-2*k_separatorThickness, height-k_separatorThickness), backgroundColor); + // Draw rectangle around cell + ctx->fillRect(KDRect(0, 0, width, k_separatorThickness), Palette::GreyBright); + ctx->fillRect(KDRect(0, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); + ctx->fillRect(KDRect(width-k_separatorThickness, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); + } diff --git a/escher/src/table_view.cpp b/escher/src/table_view.cpp index 0a387b7ef..f0ca68123 100644 --- a/escher/src/table_view.cpp +++ b/escher/src/table_view.cpp @@ -31,7 +31,7 @@ void TableView::scrollToCell(int i, int j) { m_contentView.scrollToCell(i, j); } -TableViewCell * TableView::cellAtLocation(int i, int j) { +HighlightCell * TableView::cellAtLocation(int i, int j) { return m_contentView.cellAtLocation(i, j); } @@ -131,7 +131,7 @@ int TableView::ContentView::typeIndexFromSubviewIndex(int index, int type) const return typeIndex; } -TableViewCell * TableView::ContentView::cellAtLocation(int x, int y) { +HighlightCell * TableView::ContentView::cellAtLocation(int x, int y) { int relativeX = x-columnsScrollingOffset(); int relativeY = y-rowsScrollingOffset(); int type = m_dataSource->typeAtLocation(x, y); @@ -187,7 +187,7 @@ void TableView::ContentView::layoutSubviews() { cell->setFrame(cellFrame); - m_dataSource->willDisplayCellAtLocation((TableViewCell *)cell, i, j); + m_dataSource->willDisplayCellAtLocation((HighlightCell *)cell, i, j); } } diff --git a/escher/src/table_view_cell.cpp b/escher/src/table_view_cell.cpp deleted file mode 100644 index e3d54edfe..000000000 --- a/escher/src/table_view_cell.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include - -TableViewCell::TableViewCell() : - View(), - m_highlighted(false) -{ -} - -void TableViewCell::setHighlighted(bool highlight) { - m_highlighted = highlight; - reloadCell(); -} - -bool TableViewCell::isHighlighted() const { - return m_highlighted; -} - -void TableViewCell::reloadCell() { - markRectAsDirty(bounds()); -} diff --git a/escher/src/table_view_data_source.cpp b/escher/src/table_view_data_source.cpp index c38f1a960..d92dccffb 100644 --- a/escher/src/table_view_data_source.cpp +++ b/escher/src/table_view_data_source.cpp @@ -1,4 +1,4 @@ #include -void TableViewDataSource::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { +void TableViewDataSource::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { } diff --git a/escher/src/text_expression_menu_list_cell.cpp b/escher/src/text_expression_menu_list_cell.cpp deleted file mode 100644 index 6b02e5d12..000000000 --- a/escher/src/text_expression_menu_list_cell.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -TextExpressionMenuListCell::TextExpressionMenuListCell(char * accessoryText) : - ExpressionMenuListCell(), - m_accessoryView(PointerTextView(KDText::FontSize::Small, accessoryText, 0.0f, 0.5f, Palette::GreyDark, KDColorWhite)) -{ -} - -void TextExpressionMenuListCell::setHighlighted(bool highlight) { - ExpressionMenuListCell::setHighlighted(highlight); - KDColor backgroundColor = highlight? Palette::Select : KDColorWhite; - m_accessoryView.setBackgroundColor(backgroundColor); -} - -void TextExpressionMenuListCell::setAccessoryText(const char * text) { - m_accessoryView.setText(text); -} - -int TextExpressionMenuListCell::numberOfSubviews() const { - return 2; -} - -View * TextExpressionMenuListCell::subviewAtIndex(int index) { - assert(index == 0 || index == 1); - if (index == 0) { - return &m_labelExpressionView; - } - return &m_accessoryView; -} - -void TextExpressionMenuListCell::layoutSubviews() { - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - m_labelExpressionView.setFrame(KDRect(k_separatorThickness, k_separatorThickness, width, height/2 - k_separatorThickness)); - m_accessoryView.setFrame(KDRect(k_separatorThickness, height/2, width, height/2 - k_separatorThickness)); -} diff --git a/escher/src/text_menu_list_cell.cpp b/escher/src/text_menu_list_cell.cpp deleted file mode 100644 index 1ab1994bd..000000000 --- a/escher/src/text_menu_list_cell.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include - -TextMenuListCell::TextMenuListCell(char * label) : - MenuListCell(label), - m_accessoryView(BufferTextView(KDText::FontSize::Large, 1.0f, 0.5f)) -{ -} - -void TextMenuListCell::setAccessoryText(const char * textBody) { - m_accessoryView.setText(textBody); - reloadCell(); -} - -const char * TextMenuListCell::accessoryText() { - return m_accessoryView.text(); -} - -View * TextMenuListCell::accessoryView() const { - return (View *)&m_accessoryView; -} - -void TextMenuListCell::setHighlighted(bool highlight) { - MenuListCell::setHighlighted(highlight); - KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; - m_accessoryView.setBackgroundColor(backgroundColor); -} - -void TextMenuListCell::setTextColor(KDColor color) { - m_accessoryView.setTextColor(color); - MenuListCell::setTextColor(color); -}