From 67af3a5b4e59074a695ed877bec849d763962f64 Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Tue, 7 Jul 2020 11:45:30 +0200 Subject: [PATCH] [apps/calculation] Fixed grey and yellow squares When closing and reopening Calculation, if the cursor was on an EmptyLayout, this layout would be invisible, instead of being denoted by its usual yellow square. This also fixes a bug that would leave the grey squares in matrices when leaving and reopening the app, causing a failed assertion on the simulator. Change-Id: Ib723797c079f1441f5cde174aa5c492ad4226335 --- escher/include/escher/expression_field.h | 2 +- escher/src/expression_field.cpp | 3 ++- escher/src/layout_field.cpp | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/escher/include/escher/expression_field.h b/escher/include/escher/expression_field.h index e89c1dc98..f0931d5db 100644 --- a/escher/include/escher/expression_field.h +++ b/escher/include/escher/expression_field.h @@ -26,7 +26,7 @@ public: bool inputViewHeightDidChange(); bool handleEventWithText(const char * text, bool indentation = false, bool forceCursorRightOfText = false); void setLayoutInsertionCursorEvent(Ion::Events::Event event) { m_layoutField.setInsertionCursorEvent(event); } - size_t dumpLayout(char * buffer, size_t bufferSize) const; + size_t dumpLayout(char * buffer, size_t bufferSize); void restoreLayout(const char * buffer, size_t size); /* View */ diff --git a/escher/src/expression_field.cpp b/escher/src/expression_field.cpp index 46d09b611..723d89543 100644 --- a/escher/src/expression_field.cpp +++ b/escher/src/expression_field.cpp @@ -122,7 +122,7 @@ KDCoordinate ExpressionField::inputViewHeight() const { std::max(k_minimalHeight, m_layoutField.minimalSizeForOptimalDisplay().height()))); } -size_t ExpressionField::dumpLayout(char * buffer, size_t bufferSize) const { +size_t ExpressionField::dumpLayout(char * buffer, size_t bufferSize) { size_t size; size_t returnValue; char * currentLayout; @@ -146,6 +146,7 @@ size_t ExpressionField::dumpLayout(char * buffer, size_t bufferSize) const { buffer[0] = 0; return 0; } + m_layoutField.putCursorRightOfLayout(); size = m_layoutField.layout().size(); currentLayout = reinterpret_cast(m_layoutField.layout().node()); returnValue = size; diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index ff6b493dd..4ee8e166f 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -336,6 +336,7 @@ CodePoint LayoutField::XNTCodePoint(CodePoint defaultXNTCodePoint) { void LayoutField::putCursorRightOfLayout() { m_contentView.cursor()->layout().removeGreySquaresFromAllMatrixAncestors(); + m_contentView.cursor()->showEmptyLayoutIfNeeded(); m_contentView.setCursor(LayoutCursor(m_contentView.expressionView()->layout(), LayoutCursor::Position::Right)); }