diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index 7acfb4cc8..9be9106f3 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -26,7 +26,7 @@ CalculationController::CalculationController(Responder * parentResponder, Button m_hideableCell(nullptr), m_store(store) { - m_r2Layout = new HorizontalLayout(new CharLayout('r', KDText::FontSize::Small), new VerticalOffsetLayout(new CharLayout('2', KDText::FontSize::Small), VerticalOffsetLayout::Type::Superscript, false), false); + m_r2Layout = HorizontalLayoutRef(CharLayoutRef('r', KDText::FontSize::Small), VerticalOffsetLayoutRef(CharLayoutRef('2', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Superscript)); } CalculationController::~CalculationController() { diff --git a/apps/regression/model/cubic_model.cpp b/apps/regression/model/cubic_model.cpp index c0a32306c..a703de950 100644 --- a/apps/regression/model/cubic_model.cpp +++ b/apps/regression/model/cubic_model.cpp @@ -13,29 +13,29 @@ ExpressionLayout * CubicModel::layout() { static ExpressionLayout * layout = nullptr; if (layout == nullptr) { const ExpressionLayout * layoutChildren[] = { - new CharLayout('a', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new VerticalOffsetLayout( - new CharLayout('3', KDText::FontSize::Small), - VerticalOffsetLayout::Type::Superscript, - false), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('b', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new VerticalOffsetLayout( - new CharLayout('2', KDText::FontSize::Small), - VerticalOffsetLayout::Type::Superscript, - false), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('c', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('d', KDText::FontSize::Small), + CharLayoutRef('a', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + VerticalOffsetLayoutRef( + CharLayoutRef('3', KDText::FontSize::Small), + VerticalOffsetLayoutNode::Type::Superscript + ), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('b', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + VerticalOffsetLayoutRef( + CharLayoutRef('2', KDText::FontSize::Small), + VerticalOffsetLayoutNode::Type::Superscript + ), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('c', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('d', KDText::FontSize::Small), }; - layout = new HorizontalLayout(layoutChildren, 15, false); + layout = HorizontalLayoutRef(layoutChildren, 15); } return layout; } diff --git a/apps/regression/model/exponential_model.cpp b/apps/regression/model/exponential_model.cpp index da57242d3..998e8c317 100644 --- a/apps/regression/model/exponential_model.cpp +++ b/apps/regression/model/exponential_model.cpp @@ -11,19 +11,19 @@ ExpressionLayout * ExponentialModel::layout() { static ExpressionLayout * layout = nullptr; if (layout == nullptr) { const ExpressionLayout * layoutChildren[] = { - new CharLayout('a', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('e', KDText::FontSize::Small), - new VerticalOffsetLayout( - new HorizontalLayout( - new CharLayout('b', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - false), - VerticalOffsetLayout::Type::Superscript, - false) + CharLayoutRef('a', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('e', KDText::FontSize::Small), + VerticalOffsetLayoutRef( + HorizontalLayoutRef( + CharLayoutRef('b', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small) + ), + VerticalOffsetLayoutNode::Type::Superscript + ) }; - layout = new HorizontalLayout(layoutChildren, 4, false); + layout = HorizontalLayoutRef(layoutChildren, 4); } return layout; } diff --git a/apps/regression/model/linear_model.cpp b/apps/regression/model/linear_model.cpp index 31a69ca21..dd4ae4f10 100644 --- a/apps/regression/model/linear_model.cpp +++ b/apps/regression/model/linear_model.cpp @@ -12,13 +12,13 @@ ExpressionLayout * LinearModel::layout() { static ExpressionLayout * layout = nullptr; if (layout == nullptr) { const ExpressionLayout * layoutChildren[] = { - new CharLayout('a', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('b', KDText::FontSize::Small), + CharLayoutRef('a', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('b', KDText::FontSize::Small), }; - layout = new HorizontalLayout(layoutChildren, 5, false); + layout = HorizontalLayoutRef(layoutChildren, 5); } return layout; } diff --git a/apps/regression/model/logarithmic_model.cpp b/apps/regression/model/logarithmic_model.cpp index eb6c082f2..4b61db90d 100644 --- a/apps/regression/model/logarithmic_model.cpp +++ b/apps/regression/model/logarithmic_model.cpp @@ -12,17 +12,17 @@ ExpressionLayout * LogarithmicModel::layout() { static ExpressionLayout * layout = nullptr; if (layout == nullptr) { const ExpressionLayout * layoutChildren[] = { - new CharLayout('a', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('l', KDText::FontSize::Small), - new CharLayout('n', KDText::FontSize::Small), - new CharLayout('(', KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new CharLayout(')', KDText::FontSize::Small), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('b', KDText::FontSize::Small) + CharLayoutRef('a', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('l', KDText::FontSize::Small), + CharLayoutRef('n', KDText::FontSize::Small), + CharLayoutRef('(', KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + CharLayoutRef(')', KDText::FontSize::Small), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('b', KDText::FontSize::Small) }; - layout = new HorizontalLayout(layoutChildren, 9, false); + layout = HorizontalLayoutRef(layoutChildren, 9); } return layout; } diff --git a/apps/regression/model/logistic_model.cpp b/apps/regression/model/logistic_model.cpp index f70b48dc7..af94e1fca 100644 --- a/apps/regression/model/logistic_model.cpp +++ b/apps/regression/model/logistic_model.cpp @@ -11,26 +11,26 @@ ExpressionLayout * LogisticModel::layout() { static ExpressionLayout * layout = nullptr; if (layout == nullptr) { const ExpressionLayout * exponentLayoutChildren[] = { - new CharLayout('-', KDText::FontSize::Small), - new CharLayout('b', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small) + CharLayoutRef('-', KDText::FontSize::Small), + CharLayoutRef('b', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small) }; const ExpressionLayout * layoutChildren[] = { - new CharLayout('1', KDText::FontSize::Small), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('a', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('e', KDText::FontSize::Small), - new VerticalOffsetLayout( - new HorizontalLayout(exponentLayoutChildren, 4, false), - VerticalOffsetLayout::Type::Superscript, - false) + CharLayoutRef('1', KDText::FontSize::Small), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('a', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('e', KDText::FontSize::Small), + VerticalOffsetLayoutRef( + HorizontalLayoutRef(exponentLayoutChildren, 4), + VerticalOffsetLayoutNode::Type::Superscript + ) }; - layout = new FractionLayout( - new CharLayout('c', KDText::FontSize::Small), - new HorizontalLayout(layoutChildren, 6, false), - false); + layout = FractionLayoutRef( + CharLayoutRef('c', KDText::FontSize::Small), + HorizontalLayoutRef(layoutChildren, 6), + ); } return layout; } diff --git a/apps/regression/model/power_model.cpp b/apps/regression/model/power_model.cpp index d60286988..5040db104 100644 --- a/apps/regression/model/power_model.cpp +++ b/apps/regression/model/power_model.cpp @@ -12,15 +12,15 @@ ExpressionLayout * PowerModel::layout() { static ExpressionLayout * layout = nullptr; if (layout == nullptr) { const ExpressionLayout * layoutChildren[] = { - new CharLayout('a', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new VerticalOffsetLayout( - new CharLayout('b', KDText::FontSize::Small), - VerticalOffsetLayout::Type::Superscript, - false), + CharLayoutRef('a', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + VerticalOffsetLayoutRef( + CharLayoutRef('b', KDText::FontSize::Small), + VerticalOffsetLayoutNode::Type::Superscript + ), }; - layout = new HorizontalLayout(layoutChildren, 4, false); + layout = HorizontalLayoutRef(layoutChildren, 4); } return layout; } diff --git a/apps/regression/model/quadratic_model.cpp b/apps/regression/model/quadratic_model.cpp index 17c558dd1..f7295f0ff 100644 --- a/apps/regression/model/quadratic_model.cpp +++ b/apps/regression/model/quadratic_model.cpp @@ -13,21 +13,21 @@ ExpressionLayout * QuadraticModel::layout() { static ExpressionLayout * layout = nullptr; if (layout == nullptr) { const ExpressionLayout * layoutChildren[] = { - new CharLayout('a', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new VerticalOffsetLayout( - new CharLayout('2', KDText::FontSize::Small), - VerticalOffsetLayout::Type::Superscript, - false), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('b', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('c', KDText::FontSize::Small), + CharLayoutRef('a', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + VerticalOffsetLayoutRef( + CharLayoutRef('2', KDText::FontSize::Small), + VerticalOffsetLayoutNode::Type::Superscript + ), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('b', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('c', KDText::FontSize::Small), }; - layout = new HorizontalLayout(layoutChildren, 10, false); + layout = HorizontalLayoutRef(layoutChildren, 10); } return layout; } diff --git a/apps/regression/model/quartic_model.cpp b/apps/regression/model/quartic_model.cpp index 34741c9a2..b8b7cb2ed 100644 --- a/apps/regression/model/quartic_model.cpp +++ b/apps/regression/model/quartic_model.cpp @@ -13,37 +13,37 @@ ExpressionLayout * QuarticModel::layout() { static ExpressionLayout * layout = nullptr; if (layout == nullptr) { const ExpressionLayout * layoutChildren[] = { - new CharLayout('a', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new VerticalOffsetLayout( - new CharLayout('4', KDText::FontSize::Small), - VerticalOffsetLayout::Type::Superscript, - false), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('b', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new VerticalOffsetLayout( - new CharLayout('3', KDText::FontSize::Small), - VerticalOffsetLayout::Type::Superscript, - false), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('c', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new VerticalOffsetLayout( - new CharLayout('2', KDText::FontSize::Small), - VerticalOffsetLayout::Type::Superscript, - false), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('d', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('e', KDText::FontSize::Small), + CharLayoutRef('a', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + VerticalOffsetLayoutRef( + CharLayoutRef('4', KDText::FontSize::Small), + VerticalOffsetLayoutNode::Type::Superscript + ), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('b', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + VerticalOffsetLayoutRef( + CharLayoutRef('3', KDText::FontSize::Small), + VerticalOffsetLayoutNode::Type::Superscript + ), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('c', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + VerticalOffsetLayoutRef( + CharLayoutRef('2', KDText::FontSize::Small), + VerticalOffsetLayoutNode::Type::Superscript + ), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('d', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('e', KDText::FontSize::Small), }; - layout = new HorizontalLayout(layoutChildren, 20, false); + layout = HorizontalLayoutRef(layoutChildren, 20); } return layout; } diff --git a/apps/regression/model/trigonometric_model.cpp b/apps/regression/model/trigonometric_model.cpp index 50c14e6b6..307a35d38 100644 --- a/apps/regression/model/trigonometric_model.cpp +++ b/apps/regression/model/trigonometric_model.cpp @@ -14,22 +14,22 @@ ExpressionLayout * TrigonometricModel::layout() { static ExpressionLayout * layout = nullptr; if (layout == nullptr) { const ExpressionLayout * layoutChildren[] = { - new CharLayout('a', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('s', KDText::FontSize::Small), - new CharLayout('i', KDText::FontSize::Small), - new CharLayout('n', KDText::FontSize::Small), - new CharLayout('(', KDText::FontSize::Small), - new CharLayout('b', KDText::FontSize::Small), - new CharLayout(Ion::Charset::MiddleDot, KDText::FontSize::Small), - new CharLayout('X', KDText::FontSize::Small), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('c', KDText::FontSize::Small), - new CharLayout(')', KDText::FontSize::Small), - new CharLayout('+', KDText::FontSize::Small), - new CharLayout('d', KDText::FontSize::Small) + CharLayoutRef('a', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('s', KDText::FontSize::Small), + CharLayoutRef('i', KDText::FontSize::Small), + CharLayoutRef('n', KDText::FontSize::Small), + CharLayoutRef('(', KDText::FontSize::Small), + CharLayoutRef('b', KDText::FontSize::Small), + CharLayoutRef(Ion::Charset::MiddleDot, KDText::FontSize::Small), + CharLayoutRef('X', KDText::FontSize::Small), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('c', KDText::FontSize::Small), + CharLayoutRef(')', KDText::FontSize::Small), + CharLayoutRef('+', KDText::FontSize::Small), + CharLayoutRef('d', KDText::FontSize::Small) }; - layout = new HorizontalLayout(layoutChildren, 14, false); + layout = HorizontalLayoutRef(layoutChildren, 14, false); } return layout; } diff --git a/apps/sequence/list/sequence_toolbox.cpp b/apps/sequence/list/sequence_toolbox.cpp index fb247c524..82f676221 100644 --- a/apps/sequence/list/sequence_toolbox.cpp +++ b/apps/sequence/list/sequence_toolbox.cpp @@ -91,21 +91,21 @@ void SequenceToolbox::buildExtraCellsLayouts(const char * sequenceName, int recu const char * otherSequenceName = SequenceStore::k_sequenceNames[1-sequenceIndex]; for (int j = 0; j < recurrenceDepth; j++) { const char * indice = j == 0 ? "n" : "n+1"; - m_addedCellLayout[j] = new HorizontalLayout( - new CharLayout(sequenceName[0], KDText::FontSize::Large), - new VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false), - false); - m_addedCellLayout[j+recurrenceDepth] = new HorizontalLayout( - new CharLayout(otherSequenceName[0], KDText::FontSize::Large), - new VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false), - false); + m_addedCellLayout[j] = HorizontalLayoutRef( + CharLayoutRef(sequenceName[0], KDText::FontSize::Large), + VerticalOffsetLayoutRef(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + ); + m_addedCellLayout[j+recurrenceDepth] = HorizontalLayoutRef( + CharLayoutRef(otherSequenceName[0], KDText::FontSize::Large), + VerticalOffsetLayoutRef(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + ); } if (recurrenceDepth < 2) { const char * indice = recurrenceDepth == 0 ? "n" : (recurrenceDepth == 1 ? "n+1" : "n+2"); - m_addedCellLayout[2*recurrenceDepth] = new HorizontalLayout( - new CharLayout(otherSequenceName[0], KDText::FontSize::Large), - new VerticalOffsetLayout(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false), - false); + m_addedCellLayout[2*recurrenceDepth] = HorizontalLayoutRef( + CharLayoutRef(otherSequenceName[0], KDText::FontSize::Large), + VerticalOffsetLayoutRef(LayoutHelper::String(indice, strlen(indice), KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + ); } } diff --git a/apps/sequence/sequence.cpp b/apps/sequence/sequence.cpp index ab3e44ff8..85d598d64 100644 --- a/apps/sequence/sequence.cpp +++ b/apps/sequence/sequence.cpp @@ -220,10 +220,10 @@ int Sequence::numberOfElements() { Poincare::ExpressionLayout * Sequence::nameLayout() { if (m_nameLayout == nullptr) { - m_nameLayout = new HorizontalLayout( - new CharLayout(name()[0], KDText::FontSize::Small), - new VerticalOffsetLayout(new CharLayout('n', KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), - false); + m_nameLayout = HorizontalLayoutRef( + CharLayoutRef(name()[0], KDText::FontSize::Small), + VerticalOffsetLayoutRef(CharLayoutRef('n', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Subscript) + ); } return m_nameLayout; } @@ -231,22 +231,22 @@ Poincare::ExpressionLayout * Sequence::nameLayout() { Poincare::ExpressionLayout * Sequence::definitionName() { if (m_definitionName == nullptr) { if (m_type == Type::Explicit) { - m_definitionName = new HorizontalLayout( - new CharLayout(name()[0], KDText::FontSize::Large), - new VerticalOffsetLayout(LayoutHelper::String("n", 1, KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false), - false); + m_definitionName = HorizontalLayoutRef( + CharLayoutRef(name()[0], KDText::FontSize::Large), + VerticalOffsetLayoutRef(LayoutHelper::String("n", 1, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + ); } if (m_type == Type::SingleRecurrence) { - m_definitionName = new HorizontalLayout( - new CharLayout(name()[0], KDText::FontSize::Large), - new VerticalOffsetLayout(LayoutHelper::String("n+1", 3, KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false), - false); + m_definitionName = HorizontalLayoutRef( + CharLayoutRef(name()[0], KDText::FontSize::Large), + VerticalOffsetLayoutRef(LayoutHelper::String("n+1", 3, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + ); } if (m_type == Type::DoubleRecurrence) { - m_definitionName = new HorizontalLayout( - new CharLayout(name()[0], KDText::FontSize::Large), - new VerticalOffsetLayout(LayoutHelper::String("n+2", 3, KDText::FontSize::Large), VerticalOffsetLayout::Type::Subscript, false), - false); + m_definitionName = HorizontalLayoutRef( + CharLayoutRef(name()[0], KDText::FontSize::Large), + VerticalOffsetLayoutRef(LayoutHelper::String("n+2", 3, KDText::FontSize::Large), VerticalOffsetLayoutNode::Type::Subscript) + ); } } return m_definitionName; @@ -260,10 +260,10 @@ Poincare::ExpressionLayout * Sequence::firstInitialConditionName() { || m_type == Type::DoubleRecurrence)) { ExpressionLayout * indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large); - m_firstInitialConditionName = new HorizontalLayout( - new CharLayout(name()[0], KDText::FontSize::Large), - new VerticalOffsetLayout(indexLayout, VerticalOffsetLayout::Type::Subscript, false), - false); + m_firstInitialConditionName = HorizontalLayoutRef( + CharLayoutRef(name()[0], KDText::FontSize::Large), + VerticalOffsetLayoutRef(indexLayout, VerticalOffsetLayoutNode::Type::Subscript) + ); } return m_firstInitialConditionName; } @@ -274,10 +274,10 @@ Poincare::ExpressionLayout * Sequence::secondInitialConditionName() { if (m_secondInitialConditionName == nullptr) { if (m_type == Type::DoubleRecurrence) { ExpressionLayout * indexLayout = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Large); - m_secondInitialConditionName = new HorizontalLayout( - new CharLayout(name()[0], KDText::FontSize::Large), - new VerticalOffsetLayout(indexLayout, VerticalOffsetLayout::Type::Subscript, false), - false); + m_secondInitialConditionName = HorizontalLayoutRef( + CharLayoutRef(name()[0], KDText::FontSize::Large), + VerticalOffsetLayoutRef(indexLayout, VerticalOffsetLayoutNode::Type::Subscript) + ); } } return m_secondInitialConditionName; diff --git a/apps/shared/sum_graph_controller.cpp b/apps/shared/sum_graph_controller.cpp index 14bc6290f..5c36b109a 100644 --- a/apps/shared/sum_graph_controller.cpp +++ b/apps/shared/sum_graph_controller.cpp @@ -240,7 +240,7 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl m_sumLayoutRef = LayoutHelper::String(sigma, sizeof(sigma));/* TODO new CondensedSumLayout( LayoutHelper::String(sigma, sizeof(sigma)), LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small), - new EmptyLayout(EmptyLayout::Color::Yellow, false, KDText::FontSize::Small, false), + EmptyLayoutRef(EmptyLayout::Color::Yellow, false, KDText::FontSize::Small, false), false); */ } else { m_sumLayoutRef = LayoutHelper::String(sigma, sizeof(sigma)); @@ -261,7 +261,7 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl childrenLayouts[2] = LayoutHelper::String(buffer, strlen(buffer), KDText::FontSize::Small); childrenLayouts[1] = functionLayout; childrenLayouts[0] = m_sumLayoutRef; - m_sumLayoutRef = new HorizontalLayout(childrenLayouts, 3, false);*/ + m_sumLayoutRef = HorizontalLayoutRef(childrenLayouts, 3, false);*/ } m_sum.setLayoutRef(m_sumLayoutRef); if (step == Step::Result) { diff --git a/apps/solver/solutions_controller.cpp b/apps/solver/solutions_controller.cpp index 0cb4cbad5..aa70b181f 100644 --- a/apps/solver/solutions_controller.cpp +++ b/apps/solver/solutions_controller.cpp @@ -66,9 +66,9 @@ SolutionsController::SolutionsController(Responder * parentResponder, EquationSt m_delta2Layout(nullptr), m_contentView(this) { - m_delta2Layout = new HorizontalLayout(new VerticalOffsetLayout(new CharLayout('2', KDText::FontSize::Small), VerticalOffsetLayout::Type::Superscript, false), LayoutHelper::String("-4ac", 4, KDText::FontSize::Small), false); + m_delta2Layout = HorizontalLayoutRef(VerticalOffsetLayoutRef(CharLayoutRef('2', KDText::FontSize::Small), VerticalOffsetLayoutNode::Type::Superscript), LayoutHelper::String("-4ac", 4, KDText::FontSize::Small)); char deltaB[] = {Ion::Charset::CapitalDelta, '=', 'b'}; - static_cast(m_delta2Layout)->addOrMergeChildAtIndex(LayoutHelper::String(deltaB, 3, KDText::FontSize::Small), 0, false); + static_cast(m_delta2Layout)->addOrMergeChildAtIndex(LayoutHelper::String(deltaB, 3, KDText::FontSize::Small), 0, false); for (int i = 0; i < EquationStore::k_maxNumberOfExactSolutions; i++) { m_exactValueCells[i].setParentResponder(m_contentView.selectableTableView()); } diff --git a/poincare/test/fraction_layout.cpp b/poincare/test/fraction_layout.cpp index 5be5192b9..c8b04bd61 100644 --- a/poincare/test/fraction_layout.cpp +++ b/poincare/test/fraction_layout.cpp @@ -13,12 +13,11 @@ QUIZ_CASE(poincare_fraction_layout_create) { * 12|34+5 -> "Divide" -> --- + 5 * |34 * */ - HorizontalLayout * layout = static_cast(LayoutHelper::String("1234+5", 6)); + HorizontalLayoutRef layout = static_cast(LayoutHelper::String("1234+5", 6)); ExpressionLayoutCursor cursor(layout->editableChild(2), ExpressionLayoutCursor::Position::Left); cursor.addFractionLayoutAndCollapseSiblings(); assert_expression_layout_serialize_to(layout, "(12)/(34)+5"); quiz_assert(cursor.isEquivalentTo(ExpressionLayoutCursor(layout->editableChild(0)->editableChild(1), ExpressionLayoutCursor::Position::Left))); - delete layout; } QUIZ_CASE(poincare_fraction_layout_delete) { @@ -27,42 +26,39 @@ QUIZ_CASE(poincare_fraction_layout_delete) { * --- -> "BackSpace" -> 12|34 * |34 * */ - HorizontalLayout * layout1 = new HorizontalLayout( - new FractionLayout( + HorizontalLayoutRef layout1 = HorizontalLayoutRef( + FractionLayoutRef( LayoutHelper::String("12", 2), - LayoutHelper::String("34", 2), - false), - false); - ExpressionLayoutCursor cursor1(layout1->editableChild(0)->editableChild(1), ExpressionLayoutCursor::Position::Left); + LayoutHelper::String("34", 2) + ) + ); + ExpressionLayoutCursor cursor1(layout1.editableChild(0)->editableChild(1), ExpressionLayoutCursor::Position::Left); cursor1.performBackspace(); assert_expression_layout_serialize_to(layout1, "1234"); - quiz_assert(cursor1.isEquivalentTo(ExpressionLayoutCursor(layout1->editableChild(1), ExpressionLayoutCursor::Position::Right))); - delete layout1; + quiz_assert(cursor1.isEquivalentTo(ExpressionLayoutCursor(layout1.editableChild(1), ExpressionLayoutCursor::Position::Right))); /* ΓΈ * 1 + --- -> "BackSpace" -> 1+|3 * |3 * */ - HorizontalLayout * layout2 = new HorizontalLayout( - new CharLayout('1'), - new CharLayout('+'), - new FractionLayout( - new EmptyLayout(), - new CharLayout('3'), - false), - false); - ExpressionLayoutCursor cursor2(layout2->editableChild(2)->editableChild(1), ExpressionLayoutCursor::Position::Left); + HorizontalLayoutRef layout2 = HorizontalLayoutRef( + CharLayoutRef('1'), + CharLayoutRef('+'), + FractionLayoutRef( + EmptyLayoutRef(), + CharLayoutRef('3') + ) + ); + ExpressionLayoutCursor cursor2(layout2.editableChild(2)->editableChild(1), ExpressionLayoutCursor::Position::Left); cursor2.performBackspace(); assert_expression_layout_serialize_to(layout2, "1+3"); - quiz_assert(cursor2.isEquivalentTo(ExpressionLayoutCursor(layout2->editableChild(1), ExpressionLayoutCursor::Position::Right))); - delete layout2; + quiz_assert(cursor2.isEquivalentTo(ExpressionLayoutCursor(layout2.editableChild(1), ExpressionLayoutCursor::Position::Right))); } QUIZ_CASE(poincare_fraction_layout_serialize) { - FractionLayout * layout = new FractionLayout( - new CharLayout('1'), - LayoutHelper::String("2+3", 3), - false); + FractionLayoutRef layout = FractionLayoutRef( + CharLayoutRef('1'), + LayoutHelper::String("2+3", 3) + ); assert_expression_layout_serialize_to(layout, "(1)/(2+3)"); - delete layout; } diff --git a/poincare/test/parentheses_layout.cpp b/poincare/test/parentheses_layout.cpp index 1a68549e8..a1ce6a656 100644 --- a/poincare/test/parentheses_layout.cpp +++ b/poincare/test/parentheses_layout.cpp @@ -12,21 +12,20 @@ QUIZ_CASE(poincare_parenthesis_layout_size) { * 4 * Assert that the first and last parentheses have the same size. */ - HorizontalLayout * layout = new HorizontalLayout(); - LeftParenthesisLayout leftPar = new LeftParenthesisLayout(); - RightParenthesisLayout rightPar = new RightParenthesisLayout(); - layout->addChildAtIndexInPlace(leftPar, 0); - layout->addChildAtIndexInPlace(new CharLayout('2'), 1); - layout->addChildAtIndexInPlace(new CharLayout('+'), 2); - layout->addChildAtIndexInPlace(new LeftParenthesisLayout(), 3); - layout->addChildAtIndexInPlace(new FractionLayout( - new CharLayout('3'), - new CharLayout('4')), + HorizontalLayoutRef layout = HorizontalLayoutRef(); + LeftParenthesisLayout leftPar = LeftParenthesisLayoutRef(); + RightParenthesisLayout rightPar = RightParenthesisLayoutRef(); + layout.addChildAtIndexInPlace(leftPar, 0); + layout.addChildAtIndexInPlace(CharLayoutRef('2'), 1); + layout.addChildAtIndexInPlace(CharLayoutRef('+'), 2); + layout.addChildAtIndexInPlace(LeftParenthesisLayoutRef(), 3); + layout.addChildAtIndexInPlace(FractionLayoutRef( + CharLayoutRef('3'), + CharLayoutRef('4')), 4); - layout->addChildAtIndexInPlace(new RightParenthesisLayout(), 3); - layout->addChildAtIndexInPlace(new CharLayout('6'), 5); - layout->addChildAtIndexInPlace(rightPar, 7); - layout->addChildAtIndexInPlace(new CharLayout('1'), 8); + layout.addChildAtIndexInPlace(RightParenthesisLayoutRef(), 3); + layout.addChildAtIndexInPlace(CharLayoutRef('6'), 5); + layout.addChildAtIndexInPlace(rightPar, 7); + layout.addChildAtIndexInPlace(CharLayoutRef('1'), 8); quiz_assert(leftPar->size().height() == rightPar->size().height()); - delete layout; } diff --git a/poincare/test/vertical_offset_layout.cpp b/poincare/test/vertical_offset_layout.cpp index d0de63c9b..5f52bbdc5 100644 --- a/poincare/test/vertical_offset_layout.cpp +++ b/poincare/test/vertical_offset_layout.cpp @@ -10,14 +10,12 @@ using namespace Poincare; QUIZ_CASE(poincare_vertical_offset_layout_serialize) { assert_parsed_expression_layout_serialize_to_self("(2)^(3)"); - HorizontalLayout * layout = new HorizontalLayout( - new CharLayout('2'), - new VerticalOffsetLayout( + HorizontalLayoutRef layout = HorizontalLayoutRef( + CharLayoutRef('2'), + VerticalOffsetLayoutRef( LayoutHelper::String("4+5", 3), - VerticalOffsetLayout::Type::Superscript, - false), - false); + VerticalOffsetLayoutNode::Type::Superscript + ) + ); assert_expression_layout_serialize_to(layout, "2^(4+5)"); - delete layout; - }