diff --git a/apps/Makefile b/apps/Makefile index 9c3ecf405..16482bc60 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -1,5 +1,5 @@ EPSILON_I18N_LANGUAGES ?= en fr es de pt -EPSILON_APPS ?= expression_editor +EPSILON_APPS ?= expression_editor sequence settings statistics probability regression code include apps/shared/Makefile include apps/home/Makefile diff --git a/apps/sequence/graph/term_sum_controller.cpp b/apps/sequence/graph/term_sum_controller.cpp index cc136bd87..0681afad1 100644 --- a/apps/sequence/graph/term_sum_controller.cpp +++ b/apps/sequence/graph/term_sum_controller.cpp @@ -1,9 +1,10 @@ #include "term_sum_controller.h" #include "../../shared/text_field_delegate.h" -#include "../../../poincare/src/layout/baseline_relative_layout.h" +#include "../../../poincare/src/layout/char_layout.h" #include "../../../poincare/src/layout/condensed_sum_layout.h" -#include "../../../poincare/src/layout/string_layout.h" #include "../../../poincare/src/layout/horizontal_layout.h" +#include "../../../poincare/src/layout/vertical_offset_layout.h" +#include #include #include @@ -197,12 +198,16 @@ void TermSumController::LegendView::setSumSubscript(float start) { delete m_sumLayout; m_sumLayout = nullptr; } - const char sigma[] = {' ',Ion::Charset::CapitalSigma}; + const char sigma[] = {' ', Ion::Charset::CapitalSigma}; char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; Complex::convertFloatToText(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::FloatDisplayMode::Decimal); - m_sumLayout = new CondensedSumLayout(new StringLayout(sigma, sizeof(sigma)), new StringLayout(buffer, strlen(buffer), KDText::FontSize::Small), nullptr); - m_sum.setExpressionLayout(m_sumLayout); - m_sum.setAlignment(0.0f, 0.5f); + m_sumLayout = new CondensedSumLayout( + LayoutEngine::createStringLayout(sigma, sizeof(sigma), KDText::FontSize::Large), + LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small), + nullptr, + false); + m_sum.setExpressionLayout(m_sumLayout); + m_sum.setAlignment(0.0f, 0.5f); } void TermSumController::LegendView::setSumSuperscript(float start, float end) { @@ -215,20 +220,27 @@ void TermSumController::LegendView::setSumSuperscript(float start, float end) { Complex::convertFloatToText(start, bufferStart, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::FloatDisplayMode::Decimal); char bufferEnd[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; Complex::convertFloatToText(end, bufferEnd, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::FloatDisplayMode::Decimal); - m_sumLayout = new CondensedSumLayout(new StringLayout(sigma, sizeof(sigma)), new StringLayout(bufferStart, strlen(bufferStart), KDText::FontSize::Small), new StringLayout(bufferEnd, strlen(bufferEnd), KDText::FontSize::Small)); + m_sumLayout = new CondensedSumLayout( + LayoutEngine::createStringLayout(sigma, sizeof(sigma), KDText::FontSize::Large), + LayoutEngine::createStringLayout(bufferStart, strlen(bufferStart), KDText::FontSize::Small), + LayoutEngine::createStringLayout(bufferEnd, strlen(bufferEnd), KDText::FontSize::Small), + false); m_sum.setExpressionLayout(m_sumLayout); m_sum.setAlignment(0.0f, 0.5f); } void TermSumController::LegendView::setSumResult(const char * sequenceName, double result) { - ExpressionLayout * childrenLayouts[3]; char buffer[2+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; strlcpy(buffer, "= ", 3); Complex::convertFloatToText(result, buffer+2, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); - childrenLayouts[2] = new StringLayout(buffer, strlen(buffer), KDText::FontSize::Small); - childrenLayouts[1] = new BaselineRelativeLayout(new StringLayout(sequenceName, 1, KDText::FontSize::Small), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); - childrenLayouts[0] = m_sumLayout; - m_sumLayout = new HorizontalLayout(childrenLayouts, 3); + m_sumLayout = new HorizontalLayout( + m_sumLayout, + new HorizontalLayout( + new CharLayout(sequenceName[0], KDText::FontSize::Small), + new VerticalOffsetLayout(new CharLayout('n', KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false), + LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small), + false); m_sum.setExpressionLayout(m_sumLayout); m_sum.setAlignment(0.5f, 0.5f); } diff --git a/apps/sequence/list/sequence_toolbox.cpp b/apps/sequence/list/sequence_toolbox.cpp index ed5a3f49b..fddc7d061 100644 --- a/apps/sequence/list/sequence_toolbox.cpp +++ b/apps/sequence/list/sequence_toolbox.cpp @@ -1,7 +1,9 @@ #include "sequence_toolbox.h" #include "../sequence_store.h" -#include "../../../poincare/src/layout/baseline_relative_layout.h" -#include "../../../poincare/src/layout/string_layout.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 using namespace Poincare; @@ -91,30 +93,30 @@ void SequenceToolbox::setExtraCells(const char * sequenceName, int recurrenceDep 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 BaselineRelativeLayout(new StringLayout(sequenceName, 1, KDText::FontSize::Large), new StringLayout(indice, strlen(indice), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); - m_addedCellLayout[j+recurrenceDepth] = new BaselineRelativeLayout(new StringLayout(otherSequenceName, 1, KDText::FontSize::Large), new StringLayout(indice, strlen(indice), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_addedCellLayout[j] = new HorizontalLayout( + new CharLayout(sequenceName[0], KDText::FontSize::Large), + new VerticalOffsetLayout(LayoutEngine::createStringLayout(indice, strlen(indice), KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); + m_addedCellLayout[j+recurrenceDepth] = new HorizontalLayout( + new CharLayout(otherSequenceName[0], KDText::FontSize::Large), + new VerticalOffsetLayout(LayoutEngine::createStringLayout(indice, strlen(indice), KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); } if (recurrenceDepth < 2) { const char * indice = recurrenceDepth == 0 ? "n" : (recurrenceDepth == 1 ? "n+1" : "n+2"); - m_addedCellLayout[2*recurrenceDepth] = new BaselineRelativeLayout(new StringLayout(otherSequenceName, 1, KDText::FontSize::Large), new StringLayout(indice, strlen(indice), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_addedCellLayout[2*recurrenceDepth] = new HorizontalLayout( + new CharLayout(otherSequenceName[0], KDText::FontSize::Large), + new VerticalOffsetLayout(LayoutEngine::createStringLayout(indice, strlen(indice), KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); } } bool SequenceToolbox::selectAddedCell(int selectedRow){ - char buffer[10]; - BaselineRelativeLayout * layout = (BaselineRelativeLayout *)m_addedCellLayout[selectedRow]; - StringLayout * nameLayout = (StringLayout *)layout->baseLayout(); - StringLayout * subscriptLayout = (StringLayout *)layout->indiceLayout(); - int currentChar = 0; - strlcpy(buffer, nameLayout->text(), strlen(nameLayout->text())+1); - currentChar += strlen(nameLayout->text()); - buffer[currentChar++] = '('; - strlcpy(buffer+currentChar, subscriptLayout->text(), strlen(subscriptLayout->text())+1); - currentChar += strlen(subscriptLayout->text()); - buffer[currentChar++] = ')'; - buffer[currentChar] = 0; - sender()->insertTextAtLocation(buffer, sender()->cursorLocation()); - sender()->setCursorLocation(sender()->cursorLocation()+currentChar); + int bufferSize = 10; + char buffer[bufferSize]; + int currentChar = m_addedCellLayout[selectedRow]->writeTextInBuffer(buffer, bufferSize); + textFieldSender()->insertTextAtLocation(buffer, textFieldSender()->cursorLocation()); + textFieldSender()->setCursorLocation(textFieldSender()->cursorLocation()+currentChar); app()->dismissModalViewController(); return true; } diff --git a/apps/sequence/list/type_parameter_controller.cpp b/apps/sequence/list/type_parameter_controller.cpp index 037aaa98f..4c0bf513c 100644 --- a/apps/sequence/list/type_parameter_controller.cpp +++ b/apps/sequence/list/type_parameter_controller.cpp @@ -2,8 +2,10 @@ #include "list_controller.h" #include "../app.h" #include -#include "../../../poincare/src/layout/baseline_relative_layout.h" -#include "../../../poincare/src/layout/string_layout.h" +#include +#include "../../../poincare/src/layout/char_layout.h" +#include "../../../poincare/src/layout/horizontal_layout.h" +#include "../../../poincare/src/layout/vertical_offset_layout.h" using namespace Poincare; @@ -120,7 +122,10 @@ void TypeParameterController::willDisplayCellAtLocation(HighlightCell * cell, in delete m_expressionLayouts[j]; m_expressionLayouts[j] = nullptr; } - m_expressionLayouts[j] = new BaselineRelativeLayout(new StringLayout(nextName, 1, size), new StringLayout(subscripts[j], strlen(subscripts[j]), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_expressionLayouts[j] = new HorizontalLayout( + new CharLayout(nextName[0], size), + new VerticalOffsetLayout(LayoutEngine::createStringLayout(subscripts[j], strlen(subscripts[j]), KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); ExpressionTableCellWithPointer * myCell = (ExpressionTableCellWithPointer *)cell; myCell->setExpressionLayout(m_expressionLayouts[j]); } diff --git a/apps/sequence/sequence.cpp b/apps/sequence/sequence.cpp index 6658dbc0a..a7c204d59 100644 --- a/apps/sequence/sequence.cpp +++ b/apps/sequence/sequence.cpp @@ -1,8 +1,10 @@ #include "sequence.h" #include "sequence_store.h" #include "cache_context.h" -#include "../../poincare/src/layout/string_layout.h" -#include "../../poincare/src/layout/baseline_relative_layout.h" +#include +#include "../../poincare/src/layout/char_layout.h" +#include "../../poincare/src/layout/horizontal_layout.h" +#include "../../poincare/src/layout/vertical_offset_layout.h" #include #include @@ -227,7 +229,10 @@ int Sequence::numberOfElements() { Poincare::ExpressionLayout * Sequence::nameLayout() { if (m_nameLayout == nullptr) { - m_nameLayout = new BaselineRelativeLayout(new StringLayout(name(), 1), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_nameLayout = new HorizontalLayout( + new CharLayout(name()[0], KDText::FontSize::Large), + new VerticalOffsetLayout(new CharLayout('n', KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); } return m_nameLayout; } @@ -235,13 +240,22 @@ Poincare::ExpressionLayout * Sequence::nameLayout() { Poincare::ExpressionLayout * Sequence::definitionName() { if (m_definitionName == nullptr) { if (m_type == Type::Explicit) { - m_definitionName = new BaselineRelativeLayout(new StringLayout(name(), 1), new StringLayout("n ", 2, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_definitionName = new HorizontalLayout( + new CharLayout(name()[0], KDText::FontSize::Large), + new VerticalOffsetLayout(LayoutEngine::createStringLayout("n ", 2, KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); } if (m_type == Type::SingleRecurrence) { - m_definitionName = new BaselineRelativeLayout(new StringLayout(name(), 1), new StringLayout("n+1 ", 4, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_definitionName = new HorizontalLayout( + new CharLayout(name()[0], KDText::FontSize::Large), + new VerticalOffsetLayout(LayoutEngine::createStringLayout("n+1 ", 4, KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); } if (m_type == Type::DoubleRecurrence) { - m_definitionName = new BaselineRelativeLayout(new StringLayout(name(), 1), new StringLayout("n+2 ", 4, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); + m_definitionName = new HorizontalLayout( + new CharLayout(name()[0], KDText::FontSize::Large), + new VerticalOffsetLayout(LayoutEngine::createStringLayout("n+2 ", 4, KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); } } return m_definitionName; @@ -251,12 +265,10 @@ Poincare::ExpressionLayout * Sequence::firstInitialConditionName() { char buffer[k_initialRankNumberOfDigits+1]; Integer(m_initialRank).writeTextInBuffer(buffer, k_initialRankNumberOfDigits+1); if (m_firstInitialConditionName == nullptr) { - if (m_type == Type::SingleRecurrence) { - m_firstInitialConditionName = new BaselineRelativeLayout(new StringLayout(name(), 1), new StringLayout(buffer, strlen(buffer), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); - } - if (m_type == Type::DoubleRecurrence) { - m_firstInitialConditionName = new BaselineRelativeLayout(new StringLayout(name(), 1), new StringLayout(buffer, strlen(buffer), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); - } + m_firstInitialConditionName = new HorizontalLayout( + new CharLayout(name()[0], KDText::FontSize::Small), + new VerticalOffsetLayout(new CharLayout('0', KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); } return m_firstInitialConditionName; } @@ -266,8 +278,10 @@ Poincare::ExpressionLayout * Sequence::secondInitialConditionName() { Integer(m_initialRank+1).writeTextInBuffer(buffer, k_initialRankNumberOfDigits+1); if (m_secondInitialConditionName == nullptr) { if (m_type == Type::DoubleRecurrence) { - m_secondInitialConditionName = new BaselineRelativeLayout(new StringLayout(name(), 1), new StringLayout(buffer, strlen(buffer), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); - + m_secondInitialConditionName = new HorizontalLayout( + new CharLayout(name()[0], KDText::FontSize::Small), + new VerticalOffsetLayout(new CharLayout('1', KDText::FontSize::Small), VerticalOffsetLayout::Type::Subscript, false), + false); } } return m_secondInitialConditionName;