[escher] Change name: table view cell -> list view cell

Change-Id: Ic224334f4311276da10fa09f9cb546361308e173
This commit is contained in:
Émilie Feral
2016-10-14 17:54:23 +02:00
parent 9eeb0abca1
commit cdf0d4fd84
17 changed files with 102 additions and 102 deletions

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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();

View File

@@ -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;
};

View File

@@ -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);

View File

@@ -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;

View File

@@ -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\

View File

@@ -21,13 +21,13 @@
#include <escher/solid_color_view.h>
#include <escher/stack_view_controller.h>
#include <escher/switch_view.h>
#include <escher/switch_table_view_cell.h>
#include <escher/switch_list_view_cell.h>
#include <escher/text_field.h>
#include <escher/text_table_view_cell.h>
#include <escher/text_list_view_cell.h>
#include <escher/text_view.h>
#include <escher/tab_view_controller.h>
#include <escher/table_view.h>
#include <escher/table_view_cell.h>
#include <escher/list_view_cell.h>
#include <escher/table_view_data_source.h>
#include <escher/tiled_view.h>
#include <escher/view.h>

View File

@@ -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 <escher/view.h>
#include <escher/pointer_text_view.h>
@@ -7,9 +7,9 @@
#include <escher/metric.h>
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;

View File

@@ -0,0 +1,15 @@
#ifndef ESCHER_SWITCH_LIST_VIEW_CELL_H
#define ESCHER_SWITCH_LIST_VIEW_CELL_H
#include <escher/list_view_cell.h>
#include <escher/switch_view.h>
class SwitchListViewCell : public ListViewCell {
public:
SwitchListViewCell(char * label);
View * contentView() const override;
private:
SwitchView m_contentView;
};
#endif

View File

@@ -1,15 +0,0 @@
#ifndef ESCHER_SWITCH_TABLE_VIEW_CELL_H
#define ESCHER_SWITCH_TABLE_VIEW_CELL_H
#include <escher/table_view_cell.h>
#include <escher/switch_view.h>
class SwitchTableViewCell : public TableViewCell {
public:
SwitchTableViewCell(char * label);
View * contentView() const override;
private:
SwitchView m_contentView;
};
#endif

View File

@@ -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 <escher/table_view_cell.h>
#include <escher/list_view_cell.h>
#include <escher/buffer_text_view.h>
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);

View File

@@ -1,23 +1,23 @@
#include <escher/table_view_cell.h>
#include <escher/list_view_cell.h>
#include <assert.h>
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);

View File

@@ -0,0 +1,11 @@
#include <escher/switch_list_view_cell.h>
SwitchListViewCell::SwitchListViewCell(char * label) :
ListViewCell(label),
m_contentView(SwitchView())
{
}
View * SwitchListViewCell::contentView() const {
return (View *)&m_contentView;
}

View File

@@ -1,11 +0,0 @@
#include <escher/switch_table_view_cell.h>
SwitchTableViewCell::SwitchTableViewCell(char * label) :
TableViewCell(label),
m_contentView(SwitchView())
{
}
View * SwitchTableViewCell::contentView() const {
return (View *)&m_contentView;
}

View File

@@ -0,0 +1,25 @@
#include <escher/text_list_view_cell.h>
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);
}

View File

@@ -1,25 +0,0 @@
#include <escher/text_table_view_cell.h>
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);
}