mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/sequence]Correct sequence toolbox
Change-Id: Ifbe1c45f6002604b248bcb072d57c08808e5c5b0
This commit is contained in:
@@ -125,18 +125,7 @@ void MathToolbox::didBecomeFirstResponder() {
|
||||
}
|
||||
|
||||
bool MathToolbox::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::Back) {
|
||||
return returnToPreviousMenu();
|
||||
}
|
||||
if (event == Ion::Events::OK) {
|
||||
int selectedRow = m_selectableTableView.selectedRow();
|
||||
ToolboxNode * selectedNode = (ToolboxNode *)m_nodeModel->children(selectedRow);
|
||||
if (selectedNode->numberOfChildren() == 0) {
|
||||
return selectLeaf(selectedNode);
|
||||
}
|
||||
return selectSubMenu(selectedNode);
|
||||
}
|
||||
return false;
|
||||
return handleEventForRow(event, m_selectableTableView.selectedRow());
|
||||
}
|
||||
|
||||
int MathToolbox::numberOfRows() {
|
||||
@@ -225,6 +214,20 @@ TextField * MathToolbox::sender() {
|
||||
return (TextField *)Toolbox::sender();
|
||||
}
|
||||
|
||||
bool MathToolbox::handleEventForRow(Ion::Events::Event event, int selectedRow) {
|
||||
if (event == Ion::Events::Back) {
|
||||
return returnToPreviousMenu();
|
||||
}
|
||||
if (event == Ion::Events::OK) {
|
||||
ToolboxNode * selectedNode = (ToolboxNode *)m_nodeModel->children(selectedRow);
|
||||
if (selectedNode->numberOfChildren() == 0) {
|
||||
return selectLeaf(selectedNode);
|
||||
}
|
||||
return selectSubMenu(selectedNode);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const ToolboxNode * MathToolbox::rootModel() {
|
||||
return &toolboxModel;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
protected:
|
||||
int stackDepth();
|
||||
TextField * sender() override;
|
||||
bool handleEventForRow(Ion::Events::Event event, int selectedRow);
|
||||
SelectableTableView m_selectableTableView;
|
||||
constexpr static int k_maxNumberOfDisplayedRows = 6; //240/40
|
||||
private:
|
||||
|
||||
@@ -21,7 +21,7 @@ bool SequenceToolbox::handleEvent(Ion::Events::Event event) {
|
||||
return selectAddedCell(selectedRow);
|
||||
}
|
||||
}
|
||||
return MathToolbox::handleEvent(event);
|
||||
return MathToolbox::handleEventForRow(event, mathToolboxIndex(m_selectableTableView.selectedRow()));
|
||||
}
|
||||
|
||||
int SequenceToolbox::numberOfRows() {
|
||||
@@ -47,7 +47,7 @@ void SequenceToolbox::willDisplayCellForIndex(HighlightCell * cell, int index) {
|
||||
myCell->setExpression(m_addedCellLayout[index]);
|
||||
return;
|
||||
} else {
|
||||
MathToolbox::willDisplayCellForIndex(cell, index);
|
||||
MathToolbox::willDisplayCellForIndex(cell, mathToolboxIndex(index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ KDCoordinate SequenceToolbox::rowHeight(int j) {
|
||||
if (typeAtLocation(0, j) == 2) {
|
||||
return k_addedRowHeight;
|
||||
}
|
||||
return MathToolbox::rowHeight(j);
|
||||
return MathToolbox::rowHeight(mathToolboxIndex(j));
|
||||
}
|
||||
|
||||
int SequenceToolbox::typeAtLocation(int i, int j) {
|
||||
if (stackDepth() == 0 && j < m_numberOfAddedCells) {
|
||||
return 2;
|
||||
}
|
||||
return MathToolbox::typeAtLocation(i,j);
|
||||
return MathToolbox::typeAtLocation(i,mathToolboxIndex(j));
|
||||
}
|
||||
|
||||
void SequenceToolbox::addCells(int recurrenceDepth) {
|
||||
@@ -95,4 +95,12 @@ bool SequenceToolbox::selectAddedCell(int selectedRow){
|
||||
return true;
|
||||
}
|
||||
|
||||
int SequenceToolbox::mathToolboxIndex(int index) {
|
||||
int indexMathToolbox = index;
|
||||
if (stackDepth() == 0) {
|
||||
indexMathToolbox = index - m_numberOfAddedCells;
|
||||
}
|
||||
return indexMathToolbox;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
void addCells(int recurrenceDepth);
|
||||
private:
|
||||
bool selectAddedCell(int selectedRow);
|
||||
int mathToolboxIndex(int index);
|
||||
constexpr static KDCoordinate k_addedRowHeight = 20;
|
||||
ExpressionTableCell m_addedCells[k_maxNumberOfDisplayedRows];
|
||||
Poincare::ExpressionLayout * m_addedCellLayout[k_maxNumberOfDisplayedRows];
|
||||
|
||||
Reference in New Issue
Block a user