diff --git a/apps/sequence/list/list_controller.cpp b/apps/sequence/list/list_controller.cpp index 7019ae973..56204e2d4 100644 --- a/apps/sequence/list/list_controller.cpp +++ b/apps/sequence/list/list_controller.cpp @@ -59,7 +59,7 @@ bool ListController::handleEvent(Ion::Events::Event event) { if (event == Ion::Events::OK && m_selectableTableView.selectedColumn() == 1 && m_selectableTableView.selectedRow() == numberOfRows() - 1) { m_selectableTableView.dataHasChanged(true); - app()->displayModalViewController(&m_typeStackController, 0.f, 0.f, 50, 50, 0, 50); + app()->displayModalViewController(&m_typeStackController, 0.f, 0.f, 32, 20, 20, 20); return true; } return false; diff --git a/apps/sequence/list/sequence_title_cell.cpp b/apps/sequence/list/sequence_title_cell.cpp index 335506263..35cda2364 100644 --- a/apps/sequence/list/sequence_title_cell.cpp +++ b/apps/sequence/list/sequence_title_cell.cpp @@ -1,30 +1,54 @@ #include "sequence_title_cell.h" +#include "../../../poincare/src/layout/baseline_relative_layout.h" +#include "../../../poincare/src/layout/string_layout.h" using namespace Shared; +using namespace Poincare; namespace Sequence { SequenceTitleCell::SequenceTitleCell(Responder * parentResponder, ListParameterController * listParameterController) : SequenceCell(parentResponder), m_backgroungCell(FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator)), - m_definitionView(KDText::FontSize::Large, 0.5f, 0.5f), - m_firstInitialConditionView(KDText::FontSize::Large, 0.5f, 0.5f), - m_secondInitialConditionView(KDText::FontSize::Large, 0.5f, 0.5f), + m_definitionView(0.5f, 0.5f), + m_firstInitialConditionView(0.5f, 0.5f), + m_secondInitialConditionView(0.5f, 0.5f), m_listParameterController(listParameterController) { } +SequenceTitleCell::~SequenceTitleCell() { + for (int i = 0; i < 3; i++) { + if (m_expressionLayouts[i]) { + delete m_expressionLayouts[i]; + } + } +} + void SequenceTitleCell::setSequence(Sequence * sequence) { SequenceCell::setSequence(sequence); - char bufferName[5] = {*sequence->name(),'(',sequence->symbol(),')', 0}; - m_definitionView.setText(bufferName); - if (m_numberOfSubCells > 0) { - char bufferName[7] = {*sequence->name(),'(',sequence->symbol(),'+','1',')', 0}; - m_firstInitialConditionView.setText(bufferName); + for (int i = 0; i < 3; i++) { + if (m_expressionLayouts[i]) { + delete m_expressionLayouts[i]; + } } - if (m_numberOfSubCells > 1) { - char bufferName[7] = {*sequence->name(),'(',sequence->symbol(),'+','2',')', 0}; - m_secondInitialConditionView.setText(bufferName); + if (m_numberOfSubCells == 1) { + m_expressionLayouts[0] = new BaselineRelativeLayout(new StringLayout(sequence->name(), 1), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_definitionView.setExpression(m_expressionLayouts[0]); + } + if (m_numberOfSubCells == 2) { + m_expressionLayouts[0] = new BaselineRelativeLayout(new StringLayout(sequence->name(), 1), new StringLayout("n+1", 3, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_definitionView.setExpression(m_expressionLayouts[0]); + m_expressionLayouts[1] = new BaselineRelativeLayout(new StringLayout(sequence->name(), 1), new StringLayout("0", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_firstInitialConditionView.setExpression(m_expressionLayouts[1]); + } + if (m_numberOfSubCells == 3) { + m_expressionLayouts[0] = new BaselineRelativeLayout(new StringLayout(sequence->name(), 1), new StringLayout("n+2", 3, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_definitionView.setExpression(m_expressionLayouts[0]); + m_expressionLayouts[1] = new BaselineRelativeLayout(new StringLayout(sequence->name(), 1), new StringLayout("0", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_firstInitialConditionView.setExpression(m_expressionLayouts[1]); + m_expressionLayouts[2] = new BaselineRelativeLayout(new StringLayout(sequence->name(), 1), new StringLayout("1", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_secondInitialConditionView.setExpression(m_expressionLayouts[2]); } KDColor nameColor = sequence->isActive() ? sequence->color() : Palette::GreyDark; setColor(nameColor); diff --git a/apps/sequence/list/sequence_title_cell.h b/apps/sequence/list/sequence_title_cell.h index 525a0dbd1..7fa7e7cde 100644 --- a/apps/sequence/list/sequence_title_cell.h +++ b/apps/sequence/list/sequence_title_cell.h @@ -11,6 +11,7 @@ namespace Sequence { class SequenceTitleCell : public SequenceCell { public: SequenceTitleCell(Responder * parentResponder, ListParameterController * listParameterController); + ~SequenceTitleCell(); void setSequence(Sequence * sequence) override; void setColor(KDColor color); int numberOfSubviews() const override; @@ -22,9 +23,10 @@ private: EvenOddCell * viewAtIndex(int index) override; StackViewController * stackController(); Shared::FunctionTitleCell m_backgroungCell; - EvenOddBufferTextCell m_definitionView; - EvenOddBufferTextCell m_firstInitialConditionView; - EvenOddBufferTextCell m_secondInitialConditionView; + EvenOddExpressionCell m_definitionView; + EvenOddExpressionCell m_firstInitialConditionView; + EvenOddExpressionCell m_secondInitialConditionView; + Poincare::ExpressionLayout * m_expressionLayouts[3]; ListParameterController * m_listParameterController; }; diff --git a/apps/sequence/sequence.cpp b/apps/sequence/sequence.cpp index 6c99abdd8..4bb0909f2 100644 --- a/apps/sequence/sequence.cpp +++ b/apps/sequence/sequence.cpp @@ -76,7 +76,7 @@ void Sequence::setFirstInitialConditionContent(const char * c) { } m_firstInitialConditionLayout = nullptr; if (m_firstInitialConditionExpression) { - m_firstInitialConditionLayout = expression()->createLayout(); + m_firstInitialConditionLayout = m_firstInitialConditionExpression->createLayout(); } } @@ -91,7 +91,7 @@ void Sequence::setSecondInitialConditionContent(const char * c) { } m_secondInitialConditionLayout = nullptr; if (m_secondInitialConditionExpression) { - m_secondInitialConditionLayout = expression()->createLayout(); + m_secondInitialConditionLayout = m_secondInitialConditionExpression->createLayout(); } }