[poincare/matrix_layout] Remove empty rows

Empty columns are automatically removed ; the same is now done to empty
rows.

Change-Id: Ib66dfe83f1ea712d3f9a450eedd7ade709296413
This commit is contained in:
Gabriel Ozouf
2020-11-12 12:06:51 +01:00
committed by LeaNumworks
parent 04b2683af2
commit 62e2a71da1

View File

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