From 9d1bab79ce1e2d3643d2fc6bf16bfee08d49fa7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 7 Feb 2017 11:35:21 +0100 Subject: [PATCH] [escher] Move apps/settings/menu_cell to escher to be used by sequence app and settings app Change-Id: Ia7812d9e83f5f54af4670fd5da73ba371678cd15 --- apps/settings/Makefile | 1 - apps/settings/main_controller.cpp | 4 +++- apps/settings/main_controller.h | 3 +-- escher/Makefile | 1 + escher/include/escher.h | 1 + .../escher/chevron_text_menu_list_cell.h | 14 +++++------- .../src/chevron_text_menu_list_cell.cpp | 22 ++++++++----------- 7 files changed, 20 insertions(+), 26 deletions(-) rename apps/settings/menu_cell.h => escher/include/escher/chevron_text_menu_list_cell.h (52%) rename apps/settings/menu_cell.cpp => escher/src/chevron_text_menu_list_cell.cpp (63%) diff --git a/apps/settings/Makefile b/apps/settings/Makefile index 2cd8547a7..2d0f7287e 100644 --- a/apps/settings/Makefile +++ b/apps/settings/Makefile @@ -1,7 +1,6 @@ app_objs += $(addprefix apps/settings/,\ app.o\ main_controller.o\ - menu_cell.o\ settings_node.o\ sub_controller.o\ ) diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp index 1539c6918..2e5dbac19 100644 --- a/apps/settings/main_controller.cpp +++ b/apps/settings/main_controller.cpp @@ -16,6 +16,8 @@ const SettingsNode model = SettingsNode("Parametres", menu, 5); MainController::MainController(Responder * parentResponder, Preferences * preferences) : 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_selectableTableView(SelectableTableView(this, this, Metric::TopMargin, Metric::RightMargin, Metric::BottomMargin, Metric::LeftMargin)), m_nodeModel((Node *)&model), @@ -69,7 +71,7 @@ KDCoordinate MainController::cellHeight() { } void MainController::willDisplayCellForIndex(TableViewCell * cell, int index) { - MenuCell * myCell = (MenuCell *)cell; + ChevronTextMenuListCell * myCell = (ChevronTextMenuListCell *)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 b421a52d0..5bf2e0621 100644 --- a/apps/settings/main_controller.h +++ b/apps/settings/main_controller.h @@ -4,7 +4,6 @@ #include #include "sub_controller.h" #include "settings_node.h" -#include "menu_cell.h" #include "../preferences.h" namespace Settings { @@ -25,7 +24,7 @@ public: private: StackViewController * stackController() const; constexpr static int k_totalNumberOfCell = 5; - MenuCell m_cells[k_totalNumberOfCell]; + ChevronTextMenuListCell m_cells[k_totalNumberOfCell]; SelectableTableView m_selectableTableView; Node * m_nodeModel; Preferences * m_preferences; diff --git a/escher/Makefile b/escher/Makefile index 0876a12e6..d14dc1c4d 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -6,6 +6,7 @@ objs += $(addprefix escher/src/,\ buffer_text_view.o\ button.o\ chevron_menu_list_cell.o\ + chevron_text_menu_list_cell.o\ chevron_view.o\ container.o\ editable_text_menu_list_cell.o\ diff --git a/escher/include/escher.h b/escher/include/escher.h index 7ef328d43..f6efbdc48 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/apps/settings/menu_cell.h b/escher/include/escher/chevron_text_menu_list_cell.h similarity index 52% rename from apps/settings/menu_cell.h rename to escher/include/escher/chevron_text_menu_list_cell.h index 0512219ef..51cb9efca 100644 --- a/apps/settings/menu_cell.h +++ b/escher/include/escher/chevron_text_menu_list_cell.h @@ -1,13 +1,11 @@ -#ifndef SETTINGS_MENU_CELL_H -#define SETTINGS_MENU_CELL_H +#ifndef ESCHER_CHEVRON_TEXT_MENU_LIST_CELL_H +#define ESCHER_CHEVRON_TEXT_MENU_LIST_CELL_H -#include +#include -namespace Settings { - -class MenuCell : public ChevronMenuListCell { +class ChevronTextMenuListCell : public ChevronMenuListCell { public: - MenuCell(); + ChevronTextMenuListCell(KDText::FontSize size = KDText::FontSize::Small); void reloadCell() override; void setSubtitle(const char * text); private: @@ -18,6 +16,4 @@ private: PointerTextView m_subtitleView; }; -} - #endif diff --git a/apps/settings/menu_cell.cpp b/escher/src/chevron_text_menu_list_cell.cpp similarity index 63% rename from apps/settings/menu_cell.cpp rename to escher/src/chevron_text_menu_list_cell.cpp index 17615d125..4345f4a83 100644 --- a/apps/settings/menu_cell.cpp +++ b/escher/src/chevron_text_menu_list_cell.cpp @@ -1,37 +1,35 @@ -#include "menu_cell.h" +#include -namespace Settings { - -MenuCell::MenuCell() : -ChevronMenuListCell(nullptr, KDText::FontSize::Large), - m_subtitleView(KDText::FontSize::Large, "", 1.0f, 0.5f, Palette::GreyDark) +ChevronTextMenuListCell::ChevronTextMenuListCell(KDText::FontSize size) : +ChevronMenuListCell(nullptr, size), + m_subtitleView(size, "", 1.0f, 0.5f, Palette::GreyDark) { } -void MenuCell::reloadCell() { +void ChevronTextMenuListCell::reloadCell() { ChevronMenuListCell::reloadCell(); KDColor backgroundColor = isHighlighted()? Palette::Select : KDColorWhite; m_subtitleView.setBackgroundColor(backgroundColor); } -void MenuCell::setSubtitle(const char * text) { +void ChevronTextMenuListCell::setSubtitle(const char * text) { m_subtitleView.setText(text); markRectAsDirty(bounds()); layoutSubviews(); } -int MenuCell::numberOfSubviews() const { +int ChevronTextMenuListCell::numberOfSubviews() const { return 3; } -View * MenuCell::subviewAtIndex(int index) { +View * ChevronTextMenuListCell::subviewAtIndex(int index) { if (index == 0 || index == 1) { return ChevronMenuListCell::subviewAtIndex(index); } return &m_subtitleView; } -void MenuCell::layoutSubviews() { +void ChevronTextMenuListCell::layoutSubviews() { ChevronMenuListCell::layoutSubviews(); KDCoordinate width = bounds().width(); KDCoordinate height = bounds().height(); @@ -39,5 +37,3 @@ void MenuCell::layoutSubviews() { KDSize chevronSize = accessoryView()->minimalSizeForOptimalDisplay(); m_subtitleView.setFrame(KDRect(width-chevronSize.width()-subtitleSize.width()-k_margin, k_separatorThickness, subtitleSize.width(), height - 2*k_separatorThickness)); } - -}