[poincare/matrix_layout] Keep median rows and columns

Empty columns and rows are only removed automatically when they are the
last row/column. This way, the user can edit a median row/column without
the matrix collapsing.

Change-Id: If611fa0133f270d785809d433ae879879b6b093f
This commit is contained in:
Gabriel Ozouf
2020-11-12 12:09:42 +01:00
committed by LeaNumworks
parent 62e2a71da1
commit 7184202a6e

View File

@@ -318,12 +318,12 @@ void MatrixLayoutNode::didReplaceChildAtIndex(int index, LayoutCursor * cursor,
int columnIndex = columnAtChildIndex(index);
bool columnIsEmpty = isColumnEmpty(columnIndex);
int newIndex = index;
if (columnIsEmpty && m_numberOfColumns > 2) {
if (columnIsEmpty && m_numberOfColumns > 2 && columnIndex == m_numberOfColumns - 2) {
// If the column is now empty, delete it
deleteColumnAtIndex(columnIndex);
newIndex -= rowIndex;
}
if (rowIsEmpty && m_numberOfRows > 2) {
if (rowIsEmpty && m_numberOfRows > 2 && rowIndex == m_numberOfRows - 2) {
// If the row is now empty, delete it
deleteRowAtIndex(rowIndex);
}