diff --git a/apps/graph/list/parameter_controller.cpp b/apps/graph/list/parameter_controller.cpp index fef33f7c9..eb3188921 100644 --- a/apps/graph/list/parameter_controller.cpp +++ b/apps/graph/list/parameter_controller.cpp @@ -5,9 +5,9 @@ namespace Graph { ParameterController::ParameterController(Responder * parentResponder, FunctionStore * functionStore) : ViewController(parentResponder), - m_colorCell(TableViewCell((char*)"Couleur de la fonction")), - m_enableCell(SwitchTableViewCell((char*)"Activer/Desactiver")), - m_deleteCell(TableViewCell((char*)"Supprimer la fonction")), + m_colorCell(ListViewCell((char*)"Couleur de la fonction")), + m_enableCell(SwitchListViewCell((char*)"Activer/Desactiver")), + m_deleteCell(ListViewCell((char*)"Supprimer la fonction")), m_listView(ListView(this,Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_activeCell(0), @@ -38,12 +38,12 @@ void ParameterController::setActiveCell(int index) { if (index < 0 || index >= k_totalNumberOfCell) { return; } - TableViewCell * previousCell = (TableViewCell *)(m_listView.cellAtIndex(m_activeCell)); + ListViewCell * previousCell = (ListViewCell *)(m_listView.cellAtIndex(m_activeCell)); previousCell->setHighlighted(false); m_activeCell = index; m_listView.scrollToRow(index); - TableViewCell * cell = (TableViewCell *)(m_listView.cellAtIndex(index)); + ListViewCell * cell = (ListViewCell *)(m_listView.cellAtIndex(index)); cell->setHighlighted(true); } diff --git a/apps/graph/list/parameter_controller.h b/apps/graph/list/parameter_controller.h index 5e8661e4d..1c7cbea84 100644 --- a/apps/graph/list/parameter_controller.h +++ b/apps/graph/list/parameter_controller.h @@ -26,9 +26,9 @@ public: private: bool handleEnter(); constexpr static int k_totalNumberOfCell = 3; - TableViewCell m_colorCell; - SwitchTableViewCell m_enableCell; - TableViewCell m_deleteCell; + ListViewCell m_colorCell; + SwitchListViewCell m_enableCell; + ListViewCell m_deleteCell; ListView m_listView; int m_activeCell; Function * m_function; diff --git a/apps/graph/values/values_parameter_controller.cpp b/apps/graph/values/values_parameter_controller.cpp index 834cf97d1..3518ca1be 100644 --- a/apps/graph/values/values_parameter_controller.cpp +++ b/apps/graph/values/values_parameter_controller.cpp @@ -7,9 +7,9 @@ namespace Graph { ValuesParameterController::ValuesParameterController(Responder * parentResponder, Interval * interval) : ViewController(parentResponder), m_interval(interval), - m_intervalStartCell(TextTableViewCell((char*)"X Debut")), - m_intervalEndCell(TextTableViewCell((char*)"X Fin")), - m_intervalStepCell(TextTableViewCell((char*)"Pas")), + m_intervalStartCell(TextListViewCell((char*)"X Debut")), + m_intervalEndCell(TextListViewCell((char*)"X Fin")), + m_intervalStepCell(TextListViewCell((char*)"Pas")), m_listView(ListView(this,Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_activeCell(0) @@ -24,7 +24,7 @@ View * ValuesParameterController::view() { return &m_listView; } -TextTableViewCell * ValuesParameterController::tableViewCellAtIndex(int index) { +TextListViewCell * ValuesParameterController::ListViewCellAtIndex(int index) { switch(index) { case 0: return &m_intervalStartCell; @@ -51,7 +51,7 @@ int ValuesParameterController::activeCell() { } void ValuesParameterController::willDisplayCellForIndex(View * cell, int index) { - TextTableViewCell * myCell = (TextTableViewCell *) cell; + TextListViewCell * myCell = (TextListViewCell *) cell; char buffer[14]; switch (index) { case 0: @@ -76,12 +76,12 @@ void ValuesParameterController::setActiveCell(int index) { if (index < 0 || index >= k_totalNumberOfCell) { return; } - TextTableViewCell * previousCell = (TextTableViewCell *)(m_listView.cellAtIndex(m_activeCell)); + TextListViewCell * previousCell = (TextListViewCell *)(m_listView.cellAtIndex(m_activeCell)); previousCell->setHighlighted(false); m_activeCell = index; m_listView.scrollToRow(index); - TextTableViewCell * cell = (TextTableViewCell *)(m_listView.cellAtIndex(index)); + TextListViewCell * cell = (TextListViewCell *)(m_listView.cellAtIndex(index)); cell->setHighlighted(true); } @@ -121,14 +121,14 @@ void ValuesParameterController::editParameterInterval() { /* This code assumes that the active cell remains the one which is edited * until the invocation is performed. This could lead to concurrency issue in * other cases. */ - const char * initialTextContent = tableViewCellAtIndex(m_activeCell)->textContent(); + const char * initialTextContent = ListViewCellAtIndex(m_activeCell)->textContent(); App * myApp = (App *)app(); InputViewController * inputController = myApp->inputViewController(); inputController->edit(this, initialTextContent, this, [](void * context, void * sender){ ValuesParameterController * valuesParameterController = (ValuesParameterController *)context; int activeCell = valuesParameterController->activeCell(); - TextTableViewCell * cell = valuesParameterController->tableViewCellAtIndex(activeCell); + TextListViewCell * cell = valuesParameterController->ListViewCellAtIndex(activeCell); InputViewController * myInputViewController = (InputViewController *)sender; const char * textBody = myInputViewController->textBody(); App * myApp = (App *)valuesParameterController->app(); diff --git a/apps/graph/values/values_parameter_controller.h b/apps/graph/values/values_parameter_controller.h index a12538174..56df38c75 100644 --- a/apps/graph/values/values_parameter_controller.h +++ b/apps/graph/values/values_parameter_controller.h @@ -9,7 +9,7 @@ class ValuesParameterController : public ViewController, public ListViewDataSour public: ValuesParameterController(Responder * parentResponder, Interval * interval); Interval * interval(); - TextTableViewCell * tableViewCellAtIndex(int index); + TextListViewCell * ListViewCellAtIndex(int index); int activeCell(); void editParameterInterval(); void setIntervalParameterAtIndex(int parameterIndex, float f); @@ -28,9 +28,9 @@ public: private: constexpr static int k_totalNumberOfCell = 3; Interval * m_interval; - TextTableViewCell m_intervalStartCell; - TextTableViewCell m_intervalEndCell; - TextTableViewCell m_intervalStepCell; + TextListViewCell m_intervalStartCell; + TextListViewCell m_intervalEndCell; + TextListViewCell m_intervalStepCell; ListView m_listView; int m_activeCell; }; diff --git a/apps/probability/law/law_controller.cpp b/apps/probability/law/law_controller.cpp index dba7450fa..b5a26d9eb 100644 --- a/apps/probability/law/law_controller.cpp +++ b/apps/probability/law/law_controller.cpp @@ -37,12 +37,12 @@ void Probability::LawController::setActiveCell(int index) { if (index < 0 || index >= k_totalNumberOfModels) { return; } - TableViewCell * previousCell = (TableViewCell *)(m_listView.cellAtIndex(m_activeCell)); + ListViewCell * previousCell = (ListViewCell *)(m_listView.cellAtIndex(m_activeCell)); previousCell->setHighlighted(false); m_activeCell = index; m_listView.scrollToRow(index); - TableViewCell * cell = (TableViewCell *)(m_listView.cellAtIndex(index)); + ListViewCell * cell = (ListViewCell *)(m_listView.cellAtIndex(index)); cell->setHighlighted(true); } @@ -77,7 +77,7 @@ int Probability::LawController::reusableCellCount() { } void Probability::LawController::willDisplayCellForIndex(View * cell, int index) { - TableViewCell * myCell = (TableViewCell *)cell; + ListViewCell * myCell = (ListViewCell *)cell; myCell->textView()->setText(m_messages[index]); if (m_activeCell == index) { myCell->textView()->setBackgroundColor(Palette::FocusCellBackgroundColor); diff --git a/apps/probability/law/law_controller.h b/apps/probability/law/law_controller.h index 117aa2d3f..e5f136ff8 100644 --- a/apps/probability/law/law_controller.h +++ b/apps/probability/law/law_controller.h @@ -26,7 +26,7 @@ private: constexpr static int k_maxNumberOfCells = 10; // !!! CAUTION: The order here is important // The cells should be initialized *before* the listview! - TableViewCell m_cells[k_maxNumberOfCells]; + ListViewCell m_cells[k_maxNumberOfCells]; ListView m_listView; const char ** m_messages; int m_activeCell; diff --git a/escher/Makefile b/escher/Makefile index 6cc73a0a6..b689051c6 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -20,16 +20,16 @@ objs += $(addprefix escher/src/,\ solid_color_view.o\ stack_view.o\ stack_view_controller.o\ - switch_table_view_cell.o\ + switch_list_view_cell.o\ switch_view.o\ tab_view.o\ tab_view_cell.o\ tab_view_controller.o\ table_view.o\ - table_view_cell.o\ + list_view_cell.o\ table_view_data_source.o\ text_field.o\ - text_table_view_cell.o\ + text_list_view_cell.o\ text_view.o\ tiled_view.o\ view.o\ diff --git a/escher/include/escher.h b/escher/include/escher.h index 258c023bd..25e98679d 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -21,13 +21,13 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include -#include +#include #include #include #include diff --git a/escher/include/escher/table_view_cell.h b/escher/include/escher/list_view_cell.h similarity index 80% rename from escher/include/escher/table_view_cell.h rename to escher/include/escher/list_view_cell.h index 2bab9c388..01c0c88b1 100644 --- a/escher/include/escher/table_view_cell.h +++ b/escher/include/escher/list_view_cell.h @@ -1,5 +1,5 @@ -#ifndef ESCHER_TABLE_VIEW_CELL_H -#define ESCHER_TABLE_VIEW_CELL_H +#ifndef ESCHER_LIST_VIEW_CELL_H +#define ESCHER_LIST_VIEW_CELL_H #include #include @@ -7,9 +7,9 @@ #include -class TableViewCell : public View { +class ListViewCell : public View { public: - TableViewCell(char * label = nullptr); + ListViewCell(char * label = nullptr); PointerTextView * textView(); virtual View * contentView() const; bool isHighlighted() const; diff --git a/escher/include/escher/switch_list_view_cell.h b/escher/include/escher/switch_list_view_cell.h new file mode 100644 index 000000000..469aca959 --- /dev/null +++ b/escher/include/escher/switch_list_view_cell.h @@ -0,0 +1,15 @@ +#ifndef ESCHER_SWITCH_LIST_VIEW_CELL_H +#define ESCHER_SWITCH_LIST_VIEW_CELL_H + +#include +#include + +class SwitchListViewCell : public ListViewCell { +public: + SwitchListViewCell(char * label); + View * contentView() const override; +private: + SwitchView m_contentView; +}; + +#endif diff --git a/escher/include/escher/switch_table_view_cell.h b/escher/include/escher/switch_table_view_cell.h deleted file mode 100644 index 234e6821f..000000000 --- a/escher/include/escher/switch_table_view_cell.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ESCHER_SWITCH_TABLE_VIEW_CELL_H -#define ESCHER_SWITCH_TABLE_VIEW_CELL_H - -#include -#include - -class SwitchTableViewCell : public TableViewCell { -public: - SwitchTableViewCell(char * label); - View * contentView() const override; -private: - SwitchView m_contentView; -}; - -#endif diff --git a/escher/include/escher/text_table_view_cell.h b/escher/include/escher/text_list_view_cell.h similarity index 55% rename from escher/include/escher/text_table_view_cell.h rename to escher/include/escher/text_list_view_cell.h index 037a57195..0a0b7cde0 100644 --- a/escher/include/escher/text_table_view_cell.h +++ b/escher/include/escher/text_list_view_cell.h @@ -1,12 +1,12 @@ -#ifndef ESCHER_TEXT_TABLE_VIEW_CELL_H -#define ESCHER_TEXT_TABLE_VIEW_CELL_H +#ifndef ESCHER_TEXT_LIST_VIEW_CELL_H +#define ESCHER_TEXT_LIST_VIEW_CELL_H -#include +#include #include -class TextTableViewCell : public TableViewCell { +class TextListViewCell : public ListViewCell { public: - TextTableViewCell(char * label); + TextListViewCell(char * label); View * contentView() const override; void setHighlighted(bool highlight); void setText(const char * textBody); diff --git a/escher/src/table_view_cell.cpp b/escher/src/list_view_cell.cpp similarity index 77% rename from escher/src/table_view_cell.cpp rename to escher/src/list_view_cell.cpp index 23953c0dd..dfb8a4bc5 100644 --- a/escher/src/table_view_cell.cpp +++ b/escher/src/list_view_cell.cpp @@ -1,23 +1,23 @@ -#include +#include #include -constexpr KDCoordinate TableViewCell::k_separatorThickness; +constexpr KDCoordinate ListViewCell::k_separatorThickness; -TableViewCell::TableViewCell(char * label) : +ListViewCell::ListViewCell(char * label) : View(), m_highlighted(false), m_pointerTextView(PointerTextView(label, 0, 0.5, KDColorBlack, Palette::CellBackgroundColor)) { } -int TableViewCell::numberOfSubviews() const { +int ListViewCell::numberOfSubviews() const { if (contentView() == nullptr) { return 1; } return 2; } -View * TableViewCell::subviewAtIndex(int index) { +View * ListViewCell::subviewAtIndex(int index) { if (index == 0) { return &m_pointerTextView; } @@ -25,7 +25,7 @@ View * TableViewCell::subviewAtIndex(int index) { return contentView(); } -void TableViewCell::layoutSubviews() { +void ListViewCell::layoutSubviews() { KDCoordinate width = bounds().width(); KDCoordinate height = bounds().height(); m_pointerTextView.setFrame(KDRect(k_separatorThickness, k_separatorThickness, 3*width/4 - 2*k_separatorThickness, height - 2*k_separatorThickness)); @@ -35,26 +35,26 @@ void TableViewCell::layoutSubviews() { } } -PointerTextView * TableViewCell::textView() { +PointerTextView * ListViewCell::textView() { return &m_pointerTextView; } -View * TableViewCell::contentView() const { +View * ListViewCell::contentView() const { return nullptr; } -bool TableViewCell::isHighlighted() const { +bool ListViewCell::isHighlighted() const { return m_highlighted; } -void TableViewCell::setHighlighted(bool highlight) { +void ListViewCell::setHighlighted(bool highlight) { m_highlighted = highlight; KDColor backgroundColor = highlight? Palette::FocusCellBackgroundColor : Palette::CellBackgroundColor; m_pointerTextView.setBackgroundColor(backgroundColor); markRectAsDirty(bounds()); } -void TableViewCell::drawRect(KDContext * ctx, KDRect rect) const { +void ListViewCell::drawRect(KDContext * ctx, KDRect rect) const { KDCoordinate width = bounds().width(); KDCoordinate height = bounds().height(); KDColor backgroundColor = (m_highlighted ? Palette::FocusCellBackgroundColor : Palette::CellBackgroundColor); diff --git a/escher/src/switch_list_view_cell.cpp b/escher/src/switch_list_view_cell.cpp new file mode 100644 index 000000000..a31bd6b7a --- /dev/null +++ b/escher/src/switch_list_view_cell.cpp @@ -0,0 +1,11 @@ +#include + +SwitchListViewCell::SwitchListViewCell(char * label) : + ListViewCell(label), + m_contentView(SwitchView()) +{ +} + +View * SwitchListViewCell::contentView() const { + return (View *)&m_contentView; +} diff --git a/escher/src/switch_table_view_cell.cpp b/escher/src/switch_table_view_cell.cpp deleted file mode 100644 index 52490c9c6..000000000 --- a/escher/src/switch_table_view_cell.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -SwitchTableViewCell::SwitchTableViewCell(char * label) : - TableViewCell(label), - m_contentView(SwitchView()) -{ -} - -View * SwitchTableViewCell::contentView() const { - return (View *)&m_contentView; -} diff --git a/escher/src/text_list_view_cell.cpp b/escher/src/text_list_view_cell.cpp new file mode 100644 index 000000000..616518f40 --- /dev/null +++ b/escher/src/text_list_view_cell.cpp @@ -0,0 +1,25 @@ +#include + +TextListViewCell::TextListViewCell(char * label) : + ListViewCell(label), + m_contentView(BufferTextView(1.0f, 0.5f)) +{ +} + +void TextListViewCell::setText(const char * textBody) { + m_contentView.setText(textBody); +} + +const char * TextListViewCell::textContent() { + return m_contentView.text(); +} + +View * TextListViewCell::contentView() const { + return (View *)&m_contentView; +} + +void TextListViewCell::setHighlighted(bool highlight) { + ListViewCell::setHighlighted(highlight); + KDColor backgroundColor = highlight? Palette::FocusCellBackgroundColor : Palette::CellBackgroundColor; + m_contentView.setBackgroundColor(backgroundColor); +} \ No newline at end of file diff --git a/escher/src/text_table_view_cell.cpp b/escher/src/text_table_view_cell.cpp deleted file mode 100644 index a4ad8e066..000000000 --- a/escher/src/text_table_view_cell.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include - -TextTableViewCell::TextTableViewCell(char * label) : - TableViewCell(label), - m_contentView(BufferTextView(1.0f, 0.5f)) -{ -} - -void TextTableViewCell::setText(const char * textBody) { - m_contentView.setText(textBody); -} - -const char * TextTableViewCell::textContent() { - return m_contentView.text(); -} - -View * TextTableViewCell::contentView() const { - return (View *)&m_contentView; -} - -void TextTableViewCell::setHighlighted(bool highlight) { - TableViewCell::setHighlighted(highlight); - KDColor backgroundColor = highlight? Palette::FocusCellBackgroundColor : Palette::CellBackgroundColor; - m_contentView.setBackgroundColor(backgroundColor); -} \ No newline at end of file