[apps/sequence] Create a values tab

Change-Id: I37ffc57bdce85c74f46d9966a4ba4db8233e6053
This commit is contained in:
Émilie Feral
2017-02-24 16:58:22 +01:00
parent 4596602080
commit eef5f8dacb
9 changed files with 101 additions and 51 deletions

View File

@@ -6,7 +6,7 @@ using namespace Shared;
namespace Graph {
ValuesController::ValuesController(Responder * parentResponder, CartesianFunctionStore * functionStore, HeaderViewController * header) :
Shared::ValuesController(parentResponder, header),
Shared::ValuesController(parentResponder, header, 'x'),
m_functionTitleCells{FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small),
FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small), FunctionTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small)},
m_functionStore(functionStore),

View File

@@ -1,7 +1,7 @@
#include "sequence.h"
#include "local_context.h"
#include "../../poincare/src/layout/baseline_relative_layout.h"
#include "../../poincare/src/layout/string_layout.h"
#include "../../poincare/src/layout/baseline_relative_layout.h"
#include <string.h>
using namespace Shared;
@@ -18,6 +18,7 @@ Sequence::Sequence(const char * text, KDColor color) :
m_secondInitialConditionExpression(nullptr),
m_firstInitialConditionLayout(nullptr),
m_secondInitialConditionLayout(nullptr),
m_nameLayout(nullptr),
m_definitionName(nullptr),
m_firstInitialConditionName(nullptr),
m_secondInitialConditionName(nullptr)
@@ -42,6 +43,10 @@ Sequence::~Sequence() {
delete m_secondInitialConditionExpression;
m_secondInitialConditionExpression = nullptr;
}
if (m_nameLayout != nullptr) {
delete m_nameLayout;
m_nameLayout = nullptr;
}
if (m_definitionName != nullptr) {
delete m_definitionName;
m_definitionName = nullptr;
@@ -70,6 +75,10 @@ Sequence::Type Sequence::type() {
void Sequence::setType(Type type) {
m_type = type;
if (m_nameLayout != nullptr) {
delete m_nameLayout;
m_nameLayout = nullptr;
}
if (m_definitionName != nullptr) {
delete m_definitionName;
m_definitionName = nullptr;
@@ -82,6 +91,7 @@ void Sequence::setType(Type type) {
delete m_secondInitialConditionName;
m_secondInitialConditionName = nullptr;
}
m_nameLayout = new BaselineRelativeLayout(new StringLayout(name(), 1), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
if (m_type == Type::Explicite) {
m_definitionName = new BaselineRelativeLayout(new StringLayout(name(), 1), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
}
@@ -150,6 +160,10 @@ int Sequence::numberOfElements() {
return (int)m_type + 1;
}
Poincare::ExpressionLayout * Sequence::nameLayout() {
return m_nameLayout;
}
Poincare::ExpressionLayout * Sequence::definitionName() {
return m_definitionName;
}

View File

@@ -25,6 +25,7 @@ public:
void setFirstInitialConditionContent(const char * c);
void setSecondInitialConditionContent(const char * c);
int numberOfElements();
Poincare::ExpressionLayout * nameLayout();
Poincare::ExpressionLayout * definitionName();
Poincare::ExpressionLayout * firstInitialConditionName();
Poincare::ExpressionLayout * secondInitialConditionName();
@@ -40,6 +41,7 @@ private:
Poincare::Expression * m_secondInitialConditionExpression;
Poincare::ExpressionLayout * m_firstInitialConditionLayout;
Poincare::ExpressionLayout * m_secondInitialConditionLayout;
Poincare::ExpressionLayout * m_nameLayout;
Poincare::ExpressionLayout * m_definitionName;
Poincare::ExpressionLayout * m_firstInitialConditionName;
Poincare::ExpressionLayout * m_secondInitialConditionName;

View File

@@ -1,52 +1,71 @@
#include "values_controller.h"
#include <assert.h>
using namespace Shared;
namespace Sequence {
ValuesController::ValuesController(Responder * parentResponder, SequenceStore * sequenceStore,
HeaderViewController * header) :
ViewController(parentResponder),
HeaderViewDelegate(header),
m_view(SolidColorView(KDColorRed)),
m_sequenceStore(sequenceStore)
ValuesController::ValuesController(Responder * parentResponder, SequenceStore * sequenceStore, HeaderViewController * header) :
Shared::ValuesController(parentResponder, header, 'n'),
m_sequenceTitleCells{SequenceTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator),
SequenceTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator)},
m_sequenceStore(sequenceStore),
m_sequenceParameterController(Shared::ValuesFunctionParameterController('n'))
{
}
const char * ValuesController::title() const {
return "Valeurs";
int ValuesController::numberOfColumns() {
return m_sequenceStore->numberOfActiveFunctions()+1;
}
View * ValuesController::view() {
return &m_view;
}
void ValuesController::didBecomeFirstResponder() {
headerViewController()->setSelectedButton(-1);
}
int ValuesController::numberOfButtons() const {
return 0;
}
Button * ValuesController::buttonAtIndex(int index) {
return nullptr;
}
bool ValuesController::isEmpty() const {
if (m_sequenceStore->numberOfActiveFunctions() == 0) {
return true;
void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
Shared::ValuesController::willDisplayCellAtLocation(cell, i, j);
// The cell is the abscissa title cell:
if (j == 0 && i == 0) {
EvenOddPointerTextCell * mytitleCell = (EvenOddPointerTextCell *)cell;
mytitleCell->setText("n");
return;
}
// The cell is a function title cell:
if (j == 0 && i > 0) {
SequenceTitleCell * myCell = (SequenceTitleCell *)cell;
Sequence * sequence = m_sequenceStore->activeFunctionAtIndex(i-1);
myCell->setExpression(sequence->nameLayout());
myCell->setColor(sequence->color());
}
return false;
}
const char * ValuesController::emptyMessage() {
if (m_sequenceStore->numberOfDefinedFunctions() == 0) {
return "Aucune fonction";
return "Aucune suite";
}
return "Aucune fonction selectionnee";
return "Aucune suite selectionnee";
}
Responder * ValuesController::defaultController() {
return (parentResponder()->parentResponder()->parentResponder()->parentResponder());
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];
}
SequenceStore * ValuesController::functionStore() const {
return m_sequenceStore;
}
Shared::ValuesFunctionParameterController * ValuesController::functionParameterController() {
return &m_sequenceParameterController;
}
}

View File

@@ -1,25 +1,31 @@
#ifndef SEQUENCE_VALUES_CONTROLLER_H
#define SEQUENCE_VALUES_CONTROLLER_H
#include <escher.h>
#include "../sequence_store.h"
#include "../sequence_title_cell.h"
#include "../../shared/values_controller.h"
namespace Sequence {
class ValuesController : public ViewController, public HeaderViewDelegate, public AlternateEmptyViewDelegate {
class ValuesController : public Shared::ValuesController {
public:
ValuesController(Responder * parentResponder, SequenceStore * sequenceStore, HeaderViewController * header);
const char * title() const override;
View * view() override;
void didBecomeFirstResponder() override;
int numberOfButtons() const override;
Button * buttonAtIndex(int index) override;
bool isEmpty() const override;
int numberOfColumns() override;
void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override;
const char * emptyMessage() override;
Responder * defaultController() override;
private:
SolidColorView m_view;
int maxNumberOfCells() override;
int maxNumberOfFunctions() override;
constexpr static int k_maxNumberOfCells = 30;
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;
SequenceStore * m_sequenceStore;
SequenceStore * functionStore() const override;
Shared::ValuesFunctionParameterController m_sequenceParameterController;
Shared::ValuesFunctionParameterController * functionParameterController() override;
};
}

View File

@@ -8,7 +8,7 @@ using namespace Poincare;
namespace Shared {
ValuesController::ValuesController(Responder * parentResponder, HeaderViewController * header) :
ValuesController::ValuesController(Responder * parentResponder, HeaderViewController * header, char symbol) :
EditableCellTableViewController(parentResponder, k_topMargin, k_rightMargin, k_bottomMargin, k_leftMargin),
HeaderViewDelegate(header),
m_abscissaTitleCell(EvenOddPointerTextCell(KDText::FontSize::Small)),
@@ -16,7 +16,7 @@ ValuesController::ValuesController(Responder * parentResponder, HeaderViewContro
EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small),
EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small), EvenOddEditableTextCell(&m_selectableTableView, this, m_draftTextBuffer, KDText::FontSize::Small)},
m_intervalParameterController(IntervalParameterController(this, &m_interval)),
m_abscissaParameterController(ValuesParameterController(this, &m_intervalParameterController)),
m_abscissaParameterController(ValuesParameterController(this, &m_intervalParameterController, symbol)),
m_setIntervalButton(Button(this, "Regler l'intervalle",Invocation([](void * context, void * sender) {
ValuesController * valuesController = (ValuesController *) context;
StackViewController * stack = ((StackViewController *)valuesController->stackController());

View File

@@ -14,7 +14,7 @@ namespace Shared {
class ValuesController : public EditableCellTableViewController, public HeaderViewDelegate, public AlternateEmptyViewDelegate {
public:
ValuesController(Responder * parentResponder, HeaderViewController * header);
ValuesController(Responder * parentResponder, HeaderViewController * header, char symbol);
const char * title() const override;
Interval * interval();
virtual bool handleEvent(Ion::Events::Event event) override;

View File

@@ -3,8 +3,9 @@
namespace Shared {
ValuesParameterController::ValuesParameterController(Responder * parentResponder, IntervalParameterController * intervalParameterController) :
ValuesParameterController::ValuesParameterController(Responder * parentResponder, IntervalParameterController * intervalParameterController, char symbol) :
ViewController(parentResponder),
m_pageTitle("Colonne 0"),
m_deleteColumn(PointerTableCell((char*)"Effacer la colonne")),
m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")),
m_setInterval(PointerTableCellWithChevron((char*)"Regler l'intervalle")),
@@ -12,10 +13,16 @@ ValuesParameterController::ValuesParameterController(Responder * parentResponder
Metric::CommonBottomMargin, Metric::CommonLeftMargin)),
m_intervalParameterController(intervalParameterController)
{
for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) {
if (m_pageTitle[currentChar] == ' ') {
m_pageTitle[currentChar+1] = symbol;
return;
}
}
}
const char * ValuesParameterController::title() const {
return "Colonne x";
return m_pageTitle;
}
View * ValuesParameterController::view() {

View File

@@ -7,7 +7,7 @@
namespace Shared {
class ValuesParameterController : public ViewController, public SimpleListViewDataSource {
public:
ValuesParameterController(Responder * parentResponder, IntervalParameterController * intervalParameterController);
ValuesParameterController(Responder * parentResponder, IntervalParameterController * intervalParameterController, char symbol);
View * view() override;
const char * title() const override;
@@ -19,6 +19,8 @@ public:
int reusableCellCount() override;
private:
constexpr static int k_totalNumberOfCell = 3;
constexpr static int k_maxNumberOfCharsInTitle = 10;
char m_pageTitle[10];
PointerTableCell m_deleteColumn;
PointerTableCellWithChevron m_copyColumn;
PointerTableCellWithChevron m_setInterval;