diff --git a/apps/graph/values/values_parameter_controller.cpp b/apps/graph/values/values_parameter_controller.cpp index fcfab8a7e..834cf97d1 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(FloatTableViewCell((char*)"X Debut")), - m_intervalEndCell(FloatTableViewCell((char*)"X Fin")), - m_intervalStepCell(FloatTableViewCell((char*)"Pas")), + m_intervalStartCell(TextTableViewCell((char*)"X Debut")), + m_intervalEndCell(TextTableViewCell((char*)"X Fin")), + m_intervalStepCell(TextTableViewCell((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; } -FloatTableViewCell * ValuesParameterController::tableViewCellAtIndex(int index) { +TextTableViewCell * ValuesParameterController::tableViewCellAtIndex(int index) { switch(index) { case 0: return &m_intervalStartCell; @@ -51,16 +51,20 @@ int ValuesParameterController::activeCell() { } void ValuesParameterController::willDisplayCellForIndex(View * cell, int index) { - FloatTableViewCell * myCell = (FloatTableViewCell *) cell; + TextTableViewCell * myCell = (TextTableViewCell *) cell; + char buffer[14]; switch (index) { case 0: - myCell->setFloat(m_interval->start()); + Float(m_interval->start()).convertFloatToText(buffer, 14, 7); + myCell->setText(buffer); break; case 1: - myCell->setFloat(m_interval->end()); + Float(m_interval->end()).convertFloatToText(buffer, 14, 7); + myCell->setText(buffer); break; case 2: - myCell->setFloat(m_interval->step()); + Float(m_interval->step()).convertFloatToText(buffer, 14, 7); + myCell->setText(buffer); break; default: assert(false); @@ -72,12 +76,12 @@ void ValuesParameterController::setActiveCell(int index) { if (index < 0 || index >= k_totalNumberOfCell) { return; } - FloatTableViewCell * previousCell = (FloatTableViewCell *)(m_listView.cellAtIndex(m_activeCell)); + TextTableViewCell * previousCell = (TextTableViewCell *)(m_listView.cellAtIndex(m_activeCell)); previousCell->setHighlighted(false); m_activeCell = index; m_listView.scrollToRow(index); - FloatTableViewCell * cell = (FloatTableViewCell *)(m_listView.cellAtIndex(index)); + TextTableViewCell * cell = (TextTableViewCell *)(m_listView.cellAtIndex(index)); cell->setHighlighted(true); } @@ -117,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)->stringFromFloat(); + const char * initialTextContent = tableViewCellAtIndex(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(); - FloatTableViewCell * cell = valuesParameterController->tableViewCellAtIndex(activeCell); + TextTableViewCell * cell = valuesParameterController->tableViewCellAtIndex(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 8f2328c0b..a12538174 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(); - FloatTableViewCell * tableViewCellAtIndex(int index); + TextTableViewCell * tableViewCellAtIndex(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; - FloatTableViewCell m_intervalStartCell; - FloatTableViewCell m_intervalEndCell; - FloatTableViewCell m_intervalStepCell; + TextTableViewCell m_intervalStartCell; + TextTableViewCell m_intervalEndCell; + TextTableViewCell m_intervalStepCell; ListView m_listView; int m_activeCell; }; diff --git a/escher/Makefile b/escher/Makefile index 3863e6ea0..ceba1501f 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -6,8 +6,6 @@ objs += $(addprefix escher/src/,\ buffer_text_view.o\ button.o\ container.o\ - float_table_view_cell.o\ - float_view.o\ header_view_controller.o\ image_view.o\ invocation.o\ diff --git a/escher/include/escher.h b/escher/include/escher.h index 0ae8e50fc..258c023bd 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -5,8 +5,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/escher/include/escher/float_table_view_cell.h b/escher/include/escher/float_table_view_cell.h deleted file mode 100644 index 6bd63d245..000000000 --- a/escher/include/escher/float_table_view_cell.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ESCHER_FLOAT_TABLE_VIEW_CELL_H -#define ESCHER_FLOAT_TABLE_VIEW_CELL_H - -#include -#include - -class FloatTableViewCell : public TableViewCell { -public: - FloatTableViewCell(char * label); - View * contentView() const override; - void setHighlighted(bool highlight); - void setFloat(float f); - char * stringFromFloat(); -private: - FloatView m_contentView; -}; - -#endif diff --git a/escher/include/escher/float_view.h b/escher/include/escher/float_view.h deleted file mode 100644 index 7f57d345d..000000000 --- a/escher/include/escher/float_view.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ESCHER_FLOAT_VIEW_H -#define ESCHER_FLOAT_VIEW_H - -#include -#include - -class FloatView : public ChildlessView { -public: - FloatView(); - void drawRect(KDContext * ctx, KDRect rect) const override; - void setBackgroundColor(KDColor backgroundColor); - void setFloat(float f); - char * buffer(); -private: - Float m_float; - char m_buffer[14]; - KDColor m_backgroundColor; -}; - -#endif diff --git a/escher/src/float_table_view_cell.cpp b/escher/src/float_table_view_cell.cpp deleted file mode 100644 index f10eadb1e..000000000 --- a/escher/src/float_table_view_cell.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include - -FloatTableViewCell::FloatTableViewCell(char * label) : - TableViewCell(label), - m_contentView(FloatView()) -{ -} - -void FloatTableViewCell::setFloat(float f) { - m_contentView.setFloat(f); -} - -char * FloatTableViewCell::stringFromFloat() { - return m_contentView.buffer(); -} - - -View * FloatTableViewCell::contentView() const { - return (View *)&m_contentView; -} - -void FloatTableViewCell::setHighlighted(bool highlight) { - TableViewCell::setHighlighted(highlight); - KDColor backgroundColor = highlight? Palette::FocusCellBackgroundColor : Palette::CellBackgroundColor; - m_contentView.setBackgroundColor(backgroundColor); -} \ No newline at end of file diff --git a/escher/src/float_view.cpp b/escher/src/float_view.cpp deleted file mode 100644 index 62ffec0d0..000000000 --- a/escher/src/float_view.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -FloatView::FloatView() : -ChildlessView(), -m_float(Float(0.0f)), -m_backgroundColor(KDColorWhite) -{ -} - -void FloatView::setFloat(float f) { - m_float = Float(f); - m_float.convertFloatToText(m_buffer, 14, 7); -} - -char * FloatView::buffer() { - return m_buffer; -} - -void FloatView::setBackgroundColor(KDColor backgroundColor) { - m_backgroundColor = backgroundColor; - markRectAsDirty(bounds()); -} - -void FloatView::drawRect(KDContext * ctx, KDRect rect) const { - KDSize textSize = KDText::stringSize(m_buffer); - KDPoint origin(m_frame.width() - textSize.width(), 0.5f*(m_frame.height() - textSize.height())); - ctx->drawString(m_buffer, origin, KDColorBlack, m_backgroundColor); -}