[poincare] Fix cursor position when layout field is not editing

Change-Id: I39fa348a3e567621f4574b2e331b75a836353306
This commit is contained in:
Léa Saviot
2018-05-17 11:45:26 +02:00
committed by EmilieNumworks
parent 05334823e5
commit 2e03812cdb

View File

@@ -281,12 +281,17 @@ void ExpressionLayoutField::insertLayoutAtCursor(Poincare::ExpressionLayout * la
bool layoutWillBeMerged = layout->isHorizontal();
Poincare::ExpressionLayout * lastMergedLayoutChild = layoutWillBeMerged ? layout->editableChild(layout->numberOfChildren()-1) : nullptr;
m_contentView.cursor()->addLayoutAndMoveCursor(layout);
if (pointedLayout != nullptr && (pointedLayout != layout || !layoutWillBeMerged)) {
m_contentView.cursor()->setPointedExpressionLayout(pointedLayout);
m_contentView.cursor()->setPosition(Poincare::ExpressionLayoutCursor::Position::Right);
} else if (!layoutWillBeMerged) {
m_contentView.cursor()->setPointedExpressionLayout(layout->layoutToPointWhenInserting());
if (!isEditing()) {
m_contentView.cursor()->setPointedExpressionLayout(expressionLayout());
m_contentView.cursor()->setPosition(Poincare::ExpressionLayoutCursor::Position::Right);
} else {
if (pointedLayout != nullptr && (pointedLayout != layout || !layoutWillBeMerged)) {
m_contentView.cursor()->setPointedExpressionLayout(pointedLayout);
m_contentView.cursor()->setPosition(Poincare::ExpressionLayoutCursor::Position::Right);
} else if (!layoutWillBeMerged) {
m_contentView.cursor()->setPointedExpressionLayout(layout->layoutToPointWhenInserting());
m_contentView.cursor()->setPosition(Poincare::ExpressionLayoutCursor::Position::Right);
}
}
m_contentView.cursor()->pointedExpressionLayout()->addGreySquaresToAllMatrixAncestors();
m_contentView.cursor()->hideEmptyLayoutIfNeeded();