mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/graph/values] replace float table view cell by text table view
cell Change-Id: I8d4fd55dc472239905164ae1a36c1b0cbee3fc42
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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\
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include <escher/buffer_text_view.h>
|
||||
#include <escher/button.h>
|
||||
#include <escher/container.h>
|
||||
#include <escher/float_table_view_cell.h>
|
||||
#include <escher/float_view.h>
|
||||
#include <escher/header_view_controller.h>
|
||||
#include <escher/image.h>
|
||||
#include <escher/image_view.h>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef ESCHER_FLOAT_TABLE_VIEW_CELL_H
|
||||
#define ESCHER_FLOAT_TABLE_VIEW_CELL_H
|
||||
|
||||
#include <escher/table_view_cell.h>
|
||||
#include <escher/float_view.h>
|
||||
|
||||
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
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef ESCHER_FLOAT_VIEW_H
|
||||
#define ESCHER_FLOAT_VIEW_H
|
||||
|
||||
#include <escher/childless_view.h>
|
||||
#include <poincare.h>
|
||||
|
||||
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
|
||||
@@ -1,26 +0,0 @@
|
||||
#include <escher/float_table_view_cell.h>
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#include <escher/float_view.h>
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user