[apps/graph] Add margins in values

+ Fix parameter titles
This commit is contained in:
Léa Saviot
2019-09-03 17:01:40 +02:00
parent ed2a15dd03
commit ea586d1ac5
6 changed files with 85 additions and 57 deletions

View File

@@ -9,7 +9,7 @@ using namespace Poincare;
namespace Graph {
ValuesController::ValuesController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, Interval * interval, ButtonRowController * header) :
Shared::ValuesController(parentResponder, inputEventHandlerDelegate, header, interval),
Shared::ValuesController(parentResponder, header, interval),
m_functionTitleCells{},
m_floatCells{},
m_functionParameterController(this),
@@ -26,18 +26,18 @@ ValuesController::ValuesController(Responder * parentResponder, InputEventHandle
m_functionTitleCells[i].setOrientation(FunctionTitleCell::Orientation::HorizontalIndicator);
m_functionTitleCells[i].setFont(KDFont::SmallFont);
}
setupAbscissaCellsAndTitleCells(inputEventHandlerDelegate);
}
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
// The cell is the abscissa title cell:
if (typeAtLocation(i,j) == k_abscissaTitleCellType) {
int typeAtLoc = typeAtLocation(i,j);
if (typeAtLoc == k_abscissaTitleCellType) {
EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
mytitleCell->setMessage(I18n::Message::X);
mytitleCell->setMessage(I18n::Message::X); //TODO LEA
return;
}
// The cell is a function title cell:
if (typeAtLocation(i,j) == k_functionTitleCellType) {
if (typeAtLoc == k_functionTitleCellType) {
Shared::BufferFunctionTitleCell * myFunctionCell = (Shared::BufferFunctionTitleCell *)cell;
const size_t bufferNameSize = Shared::Function::k_maxNameWithArgumentSize + 1;
char bufferName[bufferNameSize];
@@ -51,6 +51,11 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
}
myFunctionCell->setText(bufferName);
myFunctionCell->setColor(function->color());
return;
}
if (typeAtLoc == k_editableValueCellType) {
StoreCell * storeCell = (StoreCell *)cell;
storeCell->setSeparatorLeft(i > 0);
}
}

View File

@@ -5,6 +5,7 @@
#include "../../shared/buffer_function_title_cell.h"
#include "../../shared/values_controller.h"
#include "../../shared/interval_parameter_controller.h"
#include "../../shared/store_cell.h"
#include "interval_parameter_selector_controller.h"
#include "derivative_parameter_controller.h"
#include "function_parameter_controller.h"
@@ -27,8 +28,10 @@ public:
return &m_intervalParameterSelectorController;
}
private:
constexpr static int k_maxNumberOfCells = 50;
constexpr static int k_maxNumberOfFunctions = 5;
constexpr static int k_maxNumberOfAbscissaCells = Shared::CartesianFunction::k_numberOfPlotTypes * k_maxNumberOfRows;
constexpr static int k_maxNumberOfCells = k_maxNumberOfFunctions * k_maxNumberOfRows;
void updateNumberOfColumns() override;
Ion::Storage::Record recordAtColumn(int i) override;
Ion::Storage::Record recordAtColumn(int i, bool * isDerivative);
@@ -39,12 +42,18 @@ private:
CartesianFunctionStore * functionStore() const override { return static_cast<CartesianFunctionStore *>(Shared::ValuesController::functionStore()); }
Shared::BufferFunctionTitleCell * functionTitleCells(int j) override;
EvenOddBufferTextCell * floatCells(int j) override;
int abscissaCellsCount() const override { return k_maxNumberOfAbscissaCells; }
EvenOddEditableTextCell * abscissaCells(int j) override { assert (j >= 0 && j < k_maxNumberOfAbscissaCells); return &m_abscissaCells[j]; }
int abscissaTitleCellsCount() const override { return Shared::CartesianFunction::k_numberOfPlotTypes; }
EvenOddMessageTextCell * abscissaTitleCells(int j) override { assert (j >= 0 && j < abscissaTitleCellsCount()); return &m_abscissaTitleCell[j]; }
ViewController * functionParameterController() override;
I18n::Message valuesParameterControllerPageTitle() const override;
int m_numberOfColumnsForType[Shared::CartesianFunction::k_numberOfPlotTypes];
Shared::BufferFunctionTitleCell m_functionTitleCells[k_maxNumberOfFunctions];
EvenOddBufferTextCell m_floatCells[k_maxNumberOfCells];
EvenOddMessageTextCell m_abscissaTitleCell[Shared::CartesianFunction::k_numberOfPlotTypes];
Shared::StoreCell m_abscissaCells[k_maxNumberOfAbscissaCells];
FunctionParameterController m_functionParameterController;
Shared::IntervalParameterController m_intervalParameterController;
IntervalParameterSelectorController m_intervalParameterSelectorController;

View File

@@ -7,9 +7,11 @@ using namespace Shared;
namespace Sequence {
ValuesController::ValuesController(Responder * parentResponder,InputEventHandlerDelegate * inputEventHandlerDelegate, Interval * interval, ButtonRowController * header) :
Shared::ValuesController(parentResponder, inputEventHandlerDelegate, header, interval),
Shared::ValuesController(parentResponder, header, interval),
m_sequenceTitleCells{},
m_floatCells{},
m_abscissaTitleCell(),
m_abscissaCells{},
#if COPY_COLUMN
m_sequenceParameterController('n'),
#endif
@@ -24,6 +26,7 @@ ValuesController::ValuesController(Responder * parentResponder,InputEventHandler
for (int i = 0; i < k_maxNumberOfSequences; i++) {
m_sequenceTitleCells[i].setOrientation(FunctionTitleCell::Orientation::HorizontalIndicator);
}
setupAbscissaCellsAndTitleCells(inputEventHandlerDelegate);
}
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
@@ -55,24 +58,6 @@ bool ValuesController::setDataAtLocation(double floatBody, int columnIndex, int
return Shared::ValuesController::setDataAtLocation(std::round(floatBody), columnIndex, rowIndex);
}
int ValuesController::maxNumberOfCells() {
return k_maxNumberOfCells;
}
int ValuesController::maxNumberOfFunctions() {
return k_maxNumberOfSequences;
}
SequenceTitleCell * ValuesController::functionTitleCells(int j) {
assert(j >= 0 && j < k_maxNumberOfSequences);
return &m_sequenceTitleCells[j];
}
EvenOddBufferTextCell * ValuesController::floatCells(int j) {
assert(j >= 0 && j < k_maxNumberOfCells);
return &m_floatCells[j];
}
ViewController * ValuesController::functionParameterController() {
#if COPY_COLUMN
m_sequenceParameterController.setRecord(recordAtColumn(selectedColumn()));

View File

@@ -21,17 +21,36 @@ public:
}
private:
bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override;
int maxNumberOfCells() override;
int maxNumberOfFunctions() override;
constexpr static int k_maxNumberOfCells = 30;
int maxNumberOfCells() override { return k_maxNumberOfCells; }
int maxNumberOfFunctions() override { return k_maxNumberOfSequences; }
constexpr static int k_maxNumberOfSequences = 3;
SequenceTitleCell m_sequenceTitleCells[k_maxNumberOfSequences];
SequenceTitleCell * functionTitleCells(int j) override;
EvenOddBufferTextCell m_floatCells[k_maxNumberOfCells];
EvenOddBufferTextCell * floatCells(int j) override;
constexpr static int k_maxNumberOfCells = k_maxNumberOfSequences * k_maxNumberOfRows;
SequenceStore * functionStore() const override { return static_cast<SequenceStore *>(Shared::ValuesController::functionStore()); }
ViewController * functionParameterController() override;
I18n::Message valuesParameterControllerPageTitle() const override;
int abscissaCellsCount() const override { return k_maxNumberOfRows; }
EvenOddEditableTextCell * abscissaCells(int j) override {
assert (j >= 0 && j < k_maxNumberOfRows);
return &m_abscissaCells[j];
}
int abscissaTitleCellsCount() const override { return 1; }
EvenOddMessageTextCell * abscissaTitleCells(int j) override {
assert (j >= 0 && j < abscissaTitleCellsCount());
return &m_abscissaTitleCell;
}
SequenceTitleCell * functionTitleCells(int j) override {
assert(j >= 0 && j < k_maxNumberOfSequences);
return &m_sequenceTitleCells[j];
}
EvenOddBufferTextCell * floatCells(int j) override {
assert(j >= 0 && j < k_maxNumberOfCells);
return &m_floatCells[j];
}
SequenceTitleCell m_sequenceTitleCells[k_maxNumberOfSequences];
EvenOddBufferTextCell m_floatCells[k_maxNumberOfCells];
EvenOddMessageTextCell m_abscissaTitleCell;
EvenOddEditableTextCell m_abscissaCells[k_maxNumberOfRows];
#if COPY_COLUMN
Shared::ValuesFunctionParameterController m_sequenceParameterController;
#endif

View File

@@ -8,15 +8,13 @@ using namespace Poincare;
namespace Shared {
ValuesController::ValuesController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Interval * interval) :
ValuesController::ValuesController(Responder * parentResponder, ButtonRowController * header, Interval * interval) :
EditableCellTableViewController(parentResponder),
ButtonRowDelegate(header, nullptr),
m_interval(interval),
m_numberOfColumns(0),
m_numberOfColumnsNeedUpdate(true),
m_selectableTableView(this),
m_abscissaTitleCell(),
m_abscissaCells{},
m_abscissaParameterController(this)
{
m_selectableTableView.setVerticalCellOverlap(0);
@@ -25,11 +23,20 @@ ValuesController::ValuesController(Responder * parentResponder, InputEventHandle
m_selectableTableView.setBottomMargin(k_bottomMargin);
m_selectableTableView.setLeftMargin(k_leftMargin);
m_selectableTableView.setBackgroundColor(Palette::WallScreenDark);
m_abscissaTitleCell.setMessageFont(k_font);
for (int i = 0; i < k_maxNumberOfAbscissaCells; i++) {
m_abscissaCells[i].setParentResponder(&m_selectableTableView);
m_abscissaCells[i].editableTextCell()->textField()->setDelegates(inputEventHandlerDelegate, this);
m_abscissaCells[i].editableTextCell()->textField()->setFont(k_font);
}
void ValuesController::setupAbscissaCellsAndTitleCells(InputEventHandlerDelegate * inputEventHandlerDelegate) {
int numberOfAbscissaCells = abscissaCellsCount();
for (int i = 0; i < numberOfAbscissaCells; i++) {
EvenOddEditableTextCell * c = abscissaCells(i);
c->setParentResponder(&m_selectableTableView);
c->editableTextCell()->textField()->setDelegates(inputEventHandlerDelegate, this);
c->editableTextCell()->textField()->setFont(k_font);
}
int numberOfAbscissaTitleCells = abscissaTitleCellsCount();
for (int i = 0; i < numberOfAbscissaTitleCells; i++) {
EvenOddMessageTextCell * c = abscissaTitleCells(i);
c->setMessageFont(k_font);
}
}
@@ -160,13 +167,13 @@ int ValuesController::indexFromCumulatedWidth(KDCoordinate offsetX) {
HighlightCell * ValuesController::reusableCell(int index, int type) {
assert(0 <= index && index < reusableCellCount(type));
switch (type) {
case 0:
return &m_abscissaTitleCell;
case 1:
case k_abscissaTitleCellType:
return abscissaTitleCells(index);
case k_functionTitleCellType:
return functionTitleCells(index);
case 2:
return &m_abscissaCells[index];
case 3:
case k_editableValueCellType:
return abscissaCells(index);
case k_notEditableValueCellType:
return floatCells(index);
default:
assert(false);
@@ -176,13 +183,13 @@ HighlightCell * ValuesController::reusableCell(int index, int type) {
int ValuesController::reusableCellCount(int type) {
switch (type) {
case 0:
return 3;
case 1:
case k_abscissaTitleCellType:
return abscissaTitleCellsCount();
case k_functionTitleCellType:
return maxNumberOfFunctions();
case 2:
return k_maxNumberOfAbscissaCells;
case 3:
case k_editableValueCellType:
return abscissaCellsCount();
case k_notEditableValueCellType:
return maxNumberOfCells();
default:
assert(false);

View File

@@ -15,7 +15,7 @@ namespace Shared {
class ValuesController : public EditableCellTableViewController, public ButtonRowDelegate, public AlternateEmptyViewDefaultDelegate {
public:
ValuesController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, Interval * interval);
ValuesController(Responder * parentResponder, ButtonRowController * header, Interval * interval);
const char * title() override;
int numberOfColumns() override;
virtual bool handleEvent(Ion::Events::Event event) override;
@@ -46,8 +46,10 @@ protected:
static constexpr int k_functionTitleCellType = 1;
static constexpr int k_editableValueCellType = 2;
static constexpr int k_notEditableValueCellType = 3;
constexpr static int k_maxNumberOfRows = 10;
static constexpr const KDFont * k_font = KDFont::SmallFont;
void setupAbscissaCellsAndTitleCells(InputEventHandlerDelegate * inputEventHandlerDelegate);
StackViewController * stackController() const;
bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override;
virtual void updateNumberOfColumns();
@@ -66,14 +68,15 @@ private:
return Interval::k_maxNumberOfElements;
};
virtual double evaluationOfAbscissaAtColumn(double abscissa, int columnIndex);
constexpr static int k_maxNumberOfAbscissaCells = 30;
virtual int maxNumberOfCells() = 0;
virtual int maxNumberOfFunctions() = 0;
SelectableTableView m_selectableTableView;
EvenOddMessageTextCell m_abscissaTitleCell;
virtual FunctionTitleCell * functionTitleCells(int j) = 0;
virtual EvenOddBufferTextCell * floatCells(int j) = 0;
EvenOddEditableTextCell m_abscissaCells[k_maxNumberOfAbscissaCells];
virtual int abscissaCellsCount() const = 0;
virtual EvenOddEditableTextCell * abscissaCells(int j) = 0;
virtual int abscissaTitleCellsCount() const = 0;
virtual EvenOddMessageTextCell * abscissaTitleCells(int j) = 0;
virtual ViewController * functionParameterController() = 0;
virtual I18n::Message valuesParameterControllerPageTitle() const = 0;
ValuesParameterController m_abscissaParameterController;