mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 09:10:48 +01:00
[apps] Sequence: add other sequence shortcuts in toolbox call from the
list controller
This commit is contained in:
committed by
EmilieNumworks
parent
80defaad50
commit
45908263ff
@@ -1,4 +1,5 @@
|
||||
#include "sequence_toolbox.h"
|
||||
#include "../sequence_store.h"
|
||||
#include "../../../poincare/src/layout/baseline_relative_layout.h"
|
||||
#include "../../../poincare/src/layout/string_layout.h"
|
||||
#include <assert.h>
|
||||
@@ -74,9 +75,28 @@ void SequenceToolbox::setExtraCells(const char * sequenceName, int recurrenceDep
|
||||
m_addedCellLayout[i] = nullptr;
|
||||
}
|
||||
}
|
||||
m_numberOfAddedCells = recurrenceDepth;
|
||||
/* If recurrenceDepth < 0, the user is setting the initial conditions so we
|
||||
* do not want to add any cell in the toolbox. */
|
||||
if (recurrenceDepth < 0) {
|
||||
m_numberOfAddedCells = 0;
|
||||
return;
|
||||
}
|
||||
/* The cells added reprensent the sequence at smaller ranks than its depth
|
||||
* and the other sequence at ranks smaller or equal to the depth, ie:
|
||||
* if the sequence is u(n+1), we add cells u(n), v(n), v(n+1).
|
||||
* There is a special case for double recurrent sequences because we do not
|
||||
* want to parse symbols u(n+2) or v(n+2). */
|
||||
m_numberOfAddedCells = recurrenceDepth == 2 ? 2*recurrenceDepth : 2*recurrenceDepth+1;
|
||||
int sequenceIndex = sequenceName == SequenceStore::k_sequenceNames[0] ? 0 : 1;
|
||||
const char * otherSequenceName = SequenceStore::k_sequenceNames[1-sequenceIndex];
|
||||
for (int j = 0; j < recurrenceDepth; j++) {
|
||||
m_addedCellLayout[j] = new BaselineRelativeLayout(new StringLayout(sequenceName, 1, KDText::FontSize::Large), new StringLayout((char *)(j == 0? "n" : "n+1"), strlen((char *)(j == 0? "n" : "n+1")), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
|
||||
const char * indice = j == 0 ? "n" : "n+1";
|
||||
m_addedCellLayout[j] = new BaselineRelativeLayout(new StringLayout(sequenceName, 1, KDText::FontSize::Large), new StringLayout(indice, strlen(indice), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
|
||||
m_addedCellLayout[j+recurrenceDepth] = new BaselineRelativeLayout(new StringLayout(otherSequenceName, 1, KDText::FontSize::Large), new StringLayout(indice, strlen(indice), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
|
||||
}
|
||||
if (recurrenceDepth < 2) {
|
||||
const char * indice = recurrenceDepth == 0 ? "n" : (recurrenceDepth == 1 ? "n+1" : "n+2");
|
||||
m_addedCellLayout[2*recurrenceDepth] = new BaselineRelativeLayout(new StringLayout(otherSequenceName, 1, KDText::FontSize::Large), new StringLayout(indice, strlen(indice), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user