From 0b683b6994ee2b268a79b0d1efd946e0064bc2b4 Mon Sep 17 00:00:00 2001 From: Hugo Saint-Vignes Date: Thu, 23 Jul 2020 10:28:28 +0200 Subject: [PATCH] [apps/shared] Handle identical layout in MinimalSizeForOptimalDisplay Change-Id: I99a523e9e88ea9c3064e4367d96b01edb0020df9 --- apps/calculation/history_view_cell.cpp | 1 + apps/shared/scrollable_multiple_expressions_view.cpp | 2 +- apps/shared/scrollable_multiple_expressions_view.h | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/calculation/history_view_cell.cpp b/apps/calculation/history_view_cell.cpp index e560ccbf3..e30995750 100644 --- a/apps/calculation/history_view_cell.cpp +++ b/apps/calculation/history_view_cell.cpp @@ -299,6 +299,7 @@ void HistoryViewCell::setCalculation(Calculation * calculation, bool expanded, b m_calculationDisplayOutput = calculation->displayOutput(context); // We must set which subviews are displayed before setLayouts to mark the right rectangle as dirty + m_scrollableOutputView.setDisplayableCenter(m_calculationDisplayOutput == Calculation::DisplayOutput::ExactAndApproximate || m_calculationDisplayOutput == Calculation::DisplayOutput::ExactAndApproximateToggle); m_scrollableOutputView.setDisplayCenter(m_calculationDisplayOutput == Calculation::DisplayOutput::ExactAndApproximate || m_calculationExpanded); m_scrollableOutputView.setLayouts(Poincare::Layout(), exactOutputLayout, approximateOutputLayout); I18n::Message equalMessage = calculation->exactAndApproximateDisplayedOutputsAreEqual(context) == Calculation::EqualSign::Equal ? I18n::Message::Equal : I18n::Message::AlmostEqual; diff --git a/apps/shared/scrollable_multiple_expressions_view.cpp b/apps/shared/scrollable_multiple_expressions_view.cpp index 50f97419b..ed9bb5db7 100644 --- a/apps/shared/scrollable_multiple_expressions_view.cpp +++ b/apps/shared/scrollable_multiple_expressions_view.cpp @@ -172,7 +172,7 @@ KDSize AbstractScrollableMultipleExpressionsView::ContentCell::privateMinimalSiz } KDSize centerSize = KDSizeZero; - if (displayCenter() || (forceFullDisplay && !m_centeredExpressionView.layout().isUninitialized())) { + if (displayCenter() || (forceFullDisplay && displayableCenter())) { centerSize = m_centeredExpressionView.minimalSizeForOptimalDisplay(); width += centerSize.width() + 2 * AbstractScrollableMultipleExpressionsView::k_horizontalMargin + m_approximateSign.minimalSizeForOptimalDisplay().width(); } diff --git a/apps/shared/scrollable_multiple_expressions_view.h b/apps/shared/scrollable_multiple_expressions_view.h index 89dc76b16..54f1e67b0 100644 --- a/apps/shared/scrollable_multiple_expressions_view.h +++ b/apps/shared/scrollable_multiple_expressions_view.h @@ -33,6 +33,7 @@ public: } bool displayCenter() const { return constContentCell()->displayCenter(); } void setDisplayCenter(bool display); + void setDisplayableCenter(bool displayable) { contentCell()->setDisplayableCenter(displayable); } void reloadScroll(); bool handleEvent(Ion::Events::Event event) override; Poincare::Layout layout() const { return constContentCell()->layout(); } @@ -63,7 +64,9 @@ protected: } void setSelectedSubviewPosition(SubviewPosition subviewPosition); bool displayCenter() const { return m_displayCenter && !m_centeredExpressionView.layout().isUninitialized(); } + bool displayableCenter() const { return m_displayableCenter && !m_centeredExpressionView.layout().isUninitialized(); } void setDisplayCenter(bool display); + void setDisplayableCenter(bool displayable) {m_displayableCenter = displayable;} void layoutSubviews(bool force = false) override; int numberOfSubviews() const override; virtual Poincare::Layout layout() const override; @@ -79,6 +82,7 @@ protected: ExpressionView m_centeredExpressionView; SubviewPosition m_selectedSubviewPosition; bool m_displayCenter; + bool m_displayableCenter; }; virtual ContentCell * contentCell() = 0; virtual const ContentCell * constContentCell() const = 0;