From 62e2a71da1cf8c8b849389abe9c44903095599db Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Thu, 12 Nov 2020 12:06:51 +0100 Subject: [PATCH] [poincare/matrix_layout] Remove empty rows Empty columns are automatically removed ; the same is now done to empty rows. Change-Id: Ib66dfe83f1ea712d3f9a450eedd7ade709296413 --- poincare/src/matrix_layout.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/poincare/src/matrix_layout.cpp b/poincare/src/matrix_layout.cpp index e946fe98a..9fc54bfa3 100644 --- a/poincare/src/matrix_layout.cpp +++ b/poincare/src/matrix_layout.cpp @@ -314,6 +314,7 @@ void MatrixLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColo void MatrixLayoutNode::didReplaceChildAtIndex(int index, LayoutCursor * cursor, bool force) { assert(index >= 0 && index < m_numberOfColumns*m_numberOfRows); int rowIndex = rowAtChildIndex(index); + int rowIsEmpty = isRowEmpty(rowIndex); int columnIndex = columnAtChildIndex(index); bool columnIsEmpty = isColumnEmpty(columnIndex); int newIndex = index; @@ -322,6 +323,10 @@ void MatrixLayoutNode::didReplaceChildAtIndex(int index, LayoutCursor * cursor, deleteColumnAtIndex(columnIndex); newIndex -= rowIndex; } + if (rowIsEmpty && m_numberOfRows > 2) { + // If the row is now empty, delete it + deleteRowAtIndex(rowIndex); + } if (cursor) { assert(newIndex >= 0 && newIndex < m_numberOfColumns*m_numberOfRows); cursor->setLayoutNode(childAtIndex(newIndex));