12 m_sequenceStore(sequenceStore),
13 m_sequenceTitleCells{},
15 m_parameterController(
this, sequenceStore),
27 int recurrenceDepth = -1;
28 int sequenceDefinition = sequenceDefinitionForRow(
selectedRow());
30 if (sequenceDefinition == 0) {
31 recurrenceDepth =
sequence->numberOfElements()-1;
34 return &m_sequenceToolbox;
60 if (sequenceDefinitionForRow(j) == 1) {
61 layout =
sequence->firstInitialConditionLayout();
63 if (sequenceDefinitionForRow(j) == 2) {
64 layout =
sequence->secondInitialConditionLayout();
66 if (layout ==
nullptr) {
76 myCell->
setEven(functionIndexForRow(j)%2 == 0);
86 char * initialText =
nullptr;
89 switch (sequenceDefinition) {
91 strlcpy(initialTextContent,
sequence->text(),
sizeof(initialTextContent));
94 strlcpy(initialTextContent,
sequence->firstInitialConditionText(),
sizeof(initialTextContent));
97 strlcpy(initialTextContent,
sequence->secondInitialConditionText(),
sizeof(initialTextContent));
100 initialText = initialTextContent;
105 static_cast<App *
>(
app())->localContext()->resetCache();
106 switch (sequenceDefinition) {
108 inputController->
edit(
this, event,
sequence, initialText,
109 [](
void * context,
void * sender){
112 const char * textBody = myInputViewController->
textBody();
113 mySequence->setContent(textBody);
115 [](
void * context,
void * sender){
119 inputController->
edit(
this, event,
sequence, initialText,
120 [](
void * context,
void * sender){
123 const char * textBody = myInputViewController->
textBody();
124 mySequence->setFirstInitialConditionContent(textBody);
126 [](
void * context,
void * sender){
130 inputController->
edit(
this, event,
sequence, initialText,
131 [](
void * context,
void * sender){
134 const char * textBody = myInputViewController->
textBody();
135 mySequence->setSecondInitialConditionContent(textBody);
137 [](
void * context,
void * sender){
142 bool ListController::removeFunctionRow(
Function *
function) {
145 static_cast<App *
>(
app())->localContext()->resetCache();
150 return &m_parameterController;
153 int ListController::maxNumberOfRows() {
154 return k_maxNumberOfRows;
158 assert(index >= 0 && index < k_maxNumberOfRows);
159 return m_sequenceTitleCells[index];
163 assert(index >= 0 && index < k_maxNumberOfRows);
164 return m_expressionCells[index];
168 void ListController::willDisplayTitleCellAtIndex(
HighlightCell * cell,
int j) {
169 SequenceTitleCell * myCell = (SequenceTitleCell *)cell;
171 if (sequenceDefinitionForRow(j) == 0) {
172 myCell->setExpression(
sequence->definitionName());
174 if (sequenceDefinitionForRow(j) == 1) {
175 myCell->setExpression(
sequence->firstInitialConditionName());
177 if (sequenceDefinitionForRow(j) == 2) {
178 myCell->setExpression(
sequence->secondInitialConditionName());
181 myCell->setColor(nameColor);
184 void ListController::willDisplayExpressionCellAtIndex(
HighlightCell * cell,
int j) {
187 if (sequenceDefinitionForRow(j) == 0) {
190 if (sequenceDefinitionForRow(j) == 1) {
193 if (sequenceDefinitionForRow(j) == 2) {
201 int ListController::functionIndexForRow(
int j) {
207 return functionIndexForRow(j-1)+1;
210 int sequenceIndex = -1;
214 rowIndex +=
sequence->numberOfElements();
215 }
while (rowIndex <= j);
216 return sequenceIndex;
219 const char * ListController::textForRow(
int j) {
221 switch (sequenceDefinitionForRow(j)) {
225 return sequence->firstInitialConditionText();
227 return sequence->secondInitialConditionText();
234 int ListController::sequenceDefinitionForRow(
int j) {
243 int sequenceIndex = -1;
248 rowIndex +=
sequence->numberOfElements();
249 }
while (rowIndex <= j);
250 return sequence->numberOfElements()-rowIndex+j;
253 void ListController::addEmptyFunction() {
264 static_cast<App *
>(
app())->localContext()->resetCache();
271 sequence->setFirstInitialConditionContent(
"");
277 sequence->setSecondInitialConditionContent(
"");
289 View * ListController::loadView() {
290 for (
int i = 0; i < k_maxNumberOfRows; i++) {
291 m_sequenceTitleCells[i] =
new SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator);
297 void ListController::unloadView(
View * view) {
298 for (
int i = 0; i < k_maxNumberOfRows; i++) {
299 delete m_sequenceTitleCells[i];
300 m_sequenceTitleCells[i] =
nullptr;
301 delete m_expressionCells[i];
302 m_expressionCells[i] =
nullptr;
static constexpr KDCoordinate StoreRowHeight
static constexpr KDCoordinate ModalTopMargin
void displayModalViewController(ViewController *vc, float verticalAlignment, float horizontalAlignment, KDCoordinate topMargin=0, KDCoordinate leftMargin=0, KDCoordinate bottomMargin=0, KDCoordinate rightMargin=0)
static constexpr int maxBufferSize()
virtual void setEven(bool even)
static constexpr KDCoordinate CommonRightMargin
static constexpr KDCoordinate TabHeight
static constexpr KDColor GreyDark
int numberOfRows() override
Sequence * functionAtIndex(int i) override
int maxNumberOfFunctions() override
size_t strlcpy(char *dst, const char *src, size_t len)
static constexpr KDCoordinate ModalBottomMargin
void willDisplayCellAtLocation(HighlightCell *cell, int i, int j) override
FunctionStore * m_functionStore
virtual Function * functionAtIndex(int i)=0
void reloadData(bool setFirstResponder=true)
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
void selectPreviousNewSequenceCell()
constexpr KDColor KDColorWhite
size_t strlen(const char *s)
View * loadView() override
static constexpr KDColor PurpleDark
void willDisplayCellAtLocation(HighlightCell *cell, int i, int j) override
constexpr KDColor KDColorBlack
void setTextColor(KDColor color)
virtual KDCoordinate rowHeight(int j) override
static constexpr KDCoordinate CommonLeftMargin
ListController(Responder *parentResponder, FunctionStore *functionStore, ButtonRowController *header, ButtonRowController *footer, I18n::Message text)
void unloadView(View *view) override
const char * title() override
SelectableTableView * selectableTableView()
static constexpr KDSize charSize(FontSize size=FontSize::Large)
void setExpression(Poincare::ExpressionLayout *expressionLayout)
void selectCellAtLocation(int i, int j)
Toolbox * toolboxForTextInput(TextInput *textInput) override
virtual void removeFunction(Function *f)=0
constexpr KDCoordinate height() const