[poincare] Delete empty layouts when adding something next to them.

Change-Id: Ie89fa84edb0bdd57ead42fac68cbb564c5327556
This commit is contained in:
Léa Saviot
2017-12-20 11:25:33 +01:00
parent 4d94764c36
commit 940f2cf387
3 changed files with 6 additions and 1 deletions

View File

@@ -47,7 +47,7 @@ public:
bool insertLayoutAtCursor(ExpressionLayout * newChild, ExpressionLayoutCursor * cursor);
void addBrother(ExpressionLayoutCursor * cursor, ExpressionLayout * brother);
virtual void addBrother(ExpressionLayoutCursor * cursor, ExpressionLayout * brother);
ExpressionLayout * replaceWith(ExpressionLayout * newChild, bool deleteAfterReplace = true);
ExpressionLayout * replaceWithJuxtapositionOf(ExpressionLayout * leftChild, ExpressionLayout * rightChild, bool deleteAfterReplace);
void replaceChild(const ExpressionLayout * oldChild, ExpressionLayout * newChild, bool deleteOldChild = true);

View File

@@ -15,6 +15,10 @@ ExpressionLayout * EmptyLayout::clone() const {
return layout;
}
void EmptyLayout::addBrother(ExpressionLayoutCursor * cursor, ExpressionLayout * brother) {
replaceWith(brother, true);
}
bool EmptyLayout::moveLeft(ExpressionLayoutCursor * cursor) {
assert(cursor->pointedExpressionLayout() == this);
// Ask the parent.

View File

@@ -10,6 +10,7 @@ class EmptyLayout : public StaticLayoutHierarchy<0> {
public:
EmptyLayout();
ExpressionLayout * clone() const override;
void addBrother(ExpressionLayoutCursor * cursor, ExpressionLayout * brother) override;
bool moveLeft(ExpressionLayoutCursor * cursor) override;
bool moveRight(ExpressionLayoutCursor * cursor) override;
protected: