[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
This commit is contained in:
Gabriel Ozouf
2020-07-07 11:45:30 +02:00
committed by Émilie Feral
parent e49dc08759
commit 67af3a5b4e
3 changed files with 4 additions and 2 deletions

View File

@@ -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 */

View File

@@ -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<char *>(m_layoutField.layout().node());
returnValue = size;

View File

@@ -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));
}