From cd199a97e6ca2093fee346cbceea240012660971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 6 Sep 2018 16:05:34 +0200 Subject: [PATCH] [sequence] Fix SequenceToolbox with new Poincare API --- apps/sequence/list/sequence_toolbox.cpp | 22 ++-------------------- apps/sequence/list/sequence_toolbox.h | 7 +------ 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/apps/sequence/list/sequence_toolbox.cpp b/apps/sequence/list/sequence_toolbox.cpp index 82f676221..47dd26108 100644 --- a/apps/sequence/list/sequence_toolbox.cpp +++ b/apps/sequence/list/sequence_toolbox.cpp @@ -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 #include @@ -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(cell)->setExpressionLayout(m_addedCellLayout[index]); + static_cast(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; diff --git a/apps/sequence/list/sequence_toolbox.h b/apps/sequence/list/sequence_toolbox.h index 5f6dfef42..f4ef36fa0 100644 --- a/apps/sequence/list/sequence_toolbox.h +++ b/apps/sequence/list/sequence_toolbox.h @@ -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; };