diff --git a/apps/sequence/graph/term_sum_controller.cpp b/apps/sequence/graph/term_sum_controller.cpp index 1cdf439c8..4d0574fae 100644 --- a/apps/sequence/graph/term_sum_controller.cpp +++ b/apps/sequence/graph/term_sum_controller.cpp @@ -2,9 +2,7 @@ #include "../../shared/text_field_delegate.h" #include "../app.h" -#include #include "../../../poincare/src/layout/char_layout.h" -#include "../../../poincare/src/layout/condensed_sum_layout.h" #include "../../../poincare/src/layout/horizontal_layout.h" #include "../../../poincare/src/layout/vertical_offset_layout.h" @@ -52,115 +50,14 @@ double TermSumController::cursorNextStep(double x, int direction) { return std::round(m_cursor->x()+delta); } -<<<<<<< HEAD ExpressionLayout * TermSumController::createFunctionLayout(const char * functionName) { - return new BaselineRelativeLayout(new StringLayout(functionName, 1, KDText::FontSize::Small), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript); -======= -/* Legend View */ - -TermSumController::LegendView::LegendView() : - m_sum(0.0f, 0.5f, KDColorBlack, Palette::GreyBright), - m_sumLayout(nullptr), - m_legend(KDText::FontSize::Small, I18n::Message::Default, 0.0f, 0.5f, KDColorBlack, Palette::GreyBright) -{ -} - -TermSumController::LegendView::~LegendView() { - if (m_sumLayout != nullptr) { - delete m_sumLayout; - m_sumLayout = nullptr; - } -} - -void TermSumController::LegendView::drawRect(KDContext * ctx, KDRect rect) const { - ctx->fillRect(KDRect(0, bounds().height() - k_legendHeight, bounds().width(), k_legendHeight), Palette::GreyMiddle); -} - -KDSize TermSumController::LegendView::minimalSizeForOptimalDisplay() const { - return KDSize(0, k_legendHeight); -} - -void TermSumController::LegendView::setLegendMessage(I18n::Message message) { - m_legend.setMessage(message); - layoutSubviews(); -} - -void TermSumController::LegendView::setSumSubscript(float start) { - if (m_sumLayout) { - delete m_sumLayout; - m_sumLayout = nullptr; - } - 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( - 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) { - if (m_sumLayout) { - delete m_sumLayout; - m_sumLayout = nullptr; - } - const char sigma[] = {' ', Ion::Charset::CapitalSigma}; - char bufferStart[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; - 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( - 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) { - char buffer[2+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; - strlcpy(buffer, "= ", 3); - Complex::convertFloatToText(result, buffer+2, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); - 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), + return new HorizontalLayout( + new CharLayout(functionName[0], KDText::FontSize::Small), + new VerticalOffsetLayout( + new CharLayout('n', KDText::FontSize::Small), + VerticalOffsetLayout::Type::Subscript, false), - LayoutEngine::createStringLayout(buffer, strlen(buffer), KDText::FontSize::Small), false); - m_sum.setExpressionLayout(m_sumLayout); - m_sum.setAlignment(0.5f, 0.5f); -} - -int TermSumController::LegendView::numberOfSubviews() const { - return 2; -} - -View * TermSumController::LegendView::subviewAtIndex(int index) { - assert(index >= 0 && index < 2); - if (index == 0) { - return &m_sum; - } - return &m_legend; -} - -void TermSumController::LegendView::layoutSubviews() { - KDCoordinate width = bounds().width(); - KDCoordinate heigth = bounds().height(); - KDSize legendSize = m_legend.minimalSizeForOptimalDisplay(); - if (legendSize.width() > 0) { - m_sum.setFrame(KDRect(0, 0, width-legendSize.width(), heigth)); - m_legend.setFrame(KDRect(width-legendSize.width(), 0, legendSize.width(), heigth)); - return; - } - m_sum.setFrame(bounds()); - m_legend.setFrame(KDRectZero); ->>>>>>> SaisieJolieRebase1201 } }