mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher] Move apps/settings/menu_cell to escher to be used by sequence
app and settings app Change-Id: Ia7812d9e83f5f54af4670fd5da73ba371678cd15
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
app_objs += $(addprefix apps/settings/,\
|
||||
app.o\
|
||||
main_controller.o\
|
||||
menu_cell.o\
|
||||
settings_node.o\
|
||||
sub_controller.o\
|
||||
)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <escher.h>
|
||||
#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;
|
||||
|
||||
@@ -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\
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <escher/buffer_text_view.h>
|
||||
#include <escher/button.h>
|
||||
#include <escher/chevron_menu_list_cell.h>
|
||||
#include <escher/chevron_text_menu_list_cell.h>
|
||||
#include <escher/chevron_view.h>
|
||||
#include <escher/container.h>
|
||||
#include <escher/editable_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 <escher.h>
|
||||
#include <escher/chevron_menu_list_cell.h>
|
||||
|
||||
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
|
||||
@@ -1,37 +1,35 @@
|
||||
#include "menu_cell.h"
|
||||
#include <escher/chevron_text_menu_list_cell.h>
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user