[sequence] Fix SequenceToolbox with new Poincare API

This commit is contained in:
Émilie Feral
2018-09-06 16:05:34 +02:00
parent f70f72da1a
commit cd199a97e6
2 changed files with 3 additions and 26 deletions

View File

@@ -1,8 +1,5 @@
#include "sequence_toolbox.h"
#include "../sequence_store.h"
#include "../../../poincare/src/layout/char_layout.h"
#include "../../../poincare/src/layout/horizontal_layout.h"
#include "../../../poincare/src/layout/vertical_offset_layout.h"
#include <poincare/layout_helper.h>
#include <assert.h>
@@ -17,15 +14,6 @@ SequenceToolbox::SequenceToolbox() :
{
}
SequenceToolbox::~SequenceToolbox() {
for (int i = 0; i < k_maxNumberOfDisplayedRows; i++) {
if (m_addedCellLayout[i]) {
delete m_addedCellLayout[i];
m_addedCellLayout[i] = nullptr;
}
}
}
bool SequenceToolbox::handleEvent(Ion::Events::Event event) {
if (selectedRow() < m_numberOfAddedCells && stackDepth() == 0) {
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
@@ -55,7 +43,7 @@ HighlightCell * SequenceToolbox::reusableCell(int index, int type) {
void SequenceToolbox::willDisplayCellForIndex(HighlightCell * cell, int index) {
if (typeAtLocation(0, index) == 2) {
static_cast<ExpressionTableCell *>(cell)->setExpressionLayout(m_addedCellLayout[index]);
static_cast<ExpressionTableCell *>(cell)->setLayoutRef(m_addedCellLayout[index]);
return;
}
MathToolbox::willDisplayCellForIndex(cell, mathToolboxIndex(index));
@@ -69,12 +57,6 @@ int SequenceToolbox::typeAtLocation(int i, int j) {
}
void SequenceToolbox::buildExtraCellsLayouts(const char * sequenceName, int recurrenceDepth) {
for (int i = 0; i < k_maxNumberOfDisplayedRows; i++) {
if (m_addedCellLayout[i]) {
delete m_addedCellLayout[i];
m_addedCellLayout[i] = nullptr;
}
}
/* 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) {
@@ -112,7 +94,7 @@ void SequenceToolbox::buildExtraCellsLayouts(const char * sequenceName, int recu
bool SequenceToolbox::selectAddedCell(int selectedRow){
int bufferSize = 10;
char buffer[bufferSize];
m_addedCellLayout[selectedRow]->serialize(buffer, bufferSize);
m_addedCellLayout[selectedRow].serialize(buffer, bufferSize);
sender()->handleEventWithText(buffer);
app()->dismissModalViewController();
return true;

View File

@@ -8,11 +8,6 @@ namespace Sequence {
class SequenceToolbox : public MathToolbox {
public:
SequenceToolbox();
~SequenceToolbox();
SequenceToolbox(const SequenceToolbox& other) = delete;
SequenceToolbox(SequenceToolbox&& other) = delete;
SequenceToolbox& operator=(const SequenceToolbox& other) = delete;
SequenceToolbox& operator=(SequenceToolbox&& other) = delete;
bool handleEvent(Ion::Events::Event event) override;
int numberOfRows() override;
HighlightCell * reusableCell(int index, int type) override;
@@ -23,7 +18,7 @@ private:
bool selectAddedCell(int selectedRow);
int mathToolboxIndex(int index);
ExpressionTableCell m_addedCells[k_maxNumberOfDisplayedRows];
Poincare::ExpressionLayout * m_addedCellLayout[k_maxNumberOfDisplayedRows];
Poincare::LayoutReference m_addedCellLayout[k_maxNumberOfDisplayedRows];
int m_numberOfAddedCells;
};