From e1624c79aaab5288fd449476df331e9673a12f91 Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Fri, 28 Feb 2020 10:55:15 +0100 Subject: [PATCH] [apps/shared/sum_graph_controller] Class doesn't need to hold m_sumLayout --- apps/shared/sum_graph_controller.cpp | 14 +++++++------- apps/shared/sum_graph_controller.h | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/shared/sum_graph_controller.cpp b/apps/shared/sum_graph_controller.cpp index f7a72048a..2db803aad 100644 --- a/apps/shared/sum_graph_controller.cpp +++ b/apps/shared/sum_graph_controller.cpp @@ -157,7 +157,6 @@ void SumGraphController::reloadBannerView() { SumGraphController::LegendView::LegendView(SumGraphController * controller, InputEventHandlerDelegate * inputEventHandlerDelegate, CodePoint sumSymbol) : m_sum(0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), - m_sumLayout(), m_legend(k_font, I18n::Message::Default, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_editableZone(controller, m_textBuffer, k_editableZoneBufferSize, TextField::maxBufferSize(), inputEventHandlerDelegate, controller, k_font, 0.0f, 0.5f, KDColorBlack, Palette::GreyMiddle), m_sumSymbol(sumSymbol) @@ -190,14 +189,15 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl assert(step == Step::Result || functionLayout.isUninitialized()); constexpr int sigmaLength = 2; const CodePoint sigma[sigmaLength] = {' ', m_sumSymbol}; + Poincare::Layout sumLayout; if (step == Step::FirstParameter) { - m_sumLayout = LayoutHelper::CodePointString(sigma, sigmaLength); + sumLayout = LayoutHelper::CodePointString(sigma, sigmaLength); } else if (step == Step::SecondParameter) { constexpr int precision = Preferences::MediumNumberOfSignificantDigits; constexpr int bufferSize = PrintFloat::charSizeForFloatsWithPrecision(precision); char buffer[bufferSize]; PoincareHelpers::ConvertFloatToTextWithDisplayMode(start, buffer, bufferSize, precision, Preferences::PrintFloatMode::Decimal); - m_sumLayout = CondensedSumLayout::Builder( + sumLayout = CondensedSumLayout::Builder( LayoutHelper::CodePointString(sigma, sigmaLength), LayoutHelper::String(buffer, strlen(buffer), k_font), EmptyLayout::Builder(EmptyLayoutNode::Color::Yellow, false, k_font, false)); @@ -210,18 +210,18 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl Layout start = LayoutHelper::String(buffer, strlen(buffer), k_font); PoincareHelpers::ConvertFloatToTextWithDisplayMode(end, buffer, bufferSize, precision, Preferences::PrintFloatMode::Decimal); Layout end = LayoutHelper::String(buffer, strlen(buffer), k_font); - m_sumLayout = CondensedSumLayout::Builder( + sumLayout = CondensedSumLayout::Builder( LayoutHelper::CodePointString(sigma, sigmaLength), start, end); strlcpy(buffer, "= ", 3); PoincareHelpers::ConvertFloatToText(result, buffer+2, bufferSize-2, precision); - m_sumLayout = HorizontalLayout::Builder( - m_sumLayout, + sumLayout = HorizontalLayout::Builder( + sumLayout, functionLayout, LayoutHelper::String(buffer, strlen(buffer), k_font)); } - m_sum.setLayout(m_sumLayout); + m_sum.setLayout(sumLayout); if (step == Step::Result) { m_sum.setAlignment(0.5f, 0.5f); } else { diff --git a/apps/shared/sum_graph_controller.h b/apps/shared/sum_graph_controller.h index 8042117b2..c8ba87936 100644 --- a/apps/shared/sum_graph_controller.h +++ b/apps/shared/sum_graph_controller.h @@ -69,7 +69,6 @@ private: void layoutSubviews(bool force = false) override; void layoutSubviews(Step step, bool force); ExpressionView m_sum; - Poincare::Layout m_sumLayout; MessageTextView m_legend; TextField m_editableZone; char m_textBuffer[k_editableZoneBufferSize];