mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 22:30:30 +01:00
[poincare] Move the cursor when collapsing a layout
Change-Id: I28a80ac19310214044bad653a6f887956d1fdacc
This commit is contained in:
@@ -50,7 +50,7 @@ public:
|
||||
/* Dynamic Layout */
|
||||
|
||||
// Collapse
|
||||
virtual void collapseBrothers() {}
|
||||
virtual void collapseBrothersAndMoveCursor(ExpressionLayoutCursor * cursor);
|
||||
|
||||
// Add
|
||||
virtual bool addChildAtIndex(ExpressionLayout * child, int index) { return false; }
|
||||
|
||||
@@ -64,10 +64,7 @@ void ExpressionLayoutCursor::addFractionLayoutAndCollapseBrothers() {
|
||||
HorizontalLayout * child2 = new HorizontalLayout(new EmptyLayout(), false);
|
||||
FractionLayout * newChild = new FractionLayout(child1, child2, false);
|
||||
pointedExpressionLayout()->addBrother(this, newChild);
|
||||
newChild->collapseBrothers();
|
||||
// Set the cursor position
|
||||
setPointedExpressionLayout(child2->editableChild(0));
|
||||
setPosition(Position::Left);
|
||||
newChild->collapseBrothersAndMoveCursor(this);
|
||||
}
|
||||
|
||||
void ExpressionLayoutCursor::addEmptyMatrixLayout(int numberOfRows, int numberOfColumns) {
|
||||
@@ -110,9 +107,7 @@ void ExpressionLayoutCursor::addEmptySquareRootLayout() {
|
||||
HorizontalLayout * child1 = new HorizontalLayout(new EmptyLayout(), false);
|
||||
NthRootLayout * newChild = new NthRootLayout(child1, false);
|
||||
m_pointedExpressionLayout->addBrother(this, newChild);
|
||||
newChild->collapseBrothers();
|
||||
setPointedExpressionLayout(child1);
|
||||
setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
newChild->collapseBrothersAndMoveCursor(this);
|
||||
}
|
||||
|
||||
void ExpressionLayoutCursor::addEmptySquarePowerLayout() {
|
||||
|
||||
@@ -105,6 +105,11 @@ bool ExpressionLayout::hasAncestor(const ExpressionLayout * e) const {
|
||||
return m_parent->hasAncestor(e);
|
||||
}
|
||||
|
||||
void ExpressionLayout::collapseBrothersAndMoveCursor(ExpressionLayoutCursor * cursor) {
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Right);
|
||||
}
|
||||
|
||||
void ExpressionLayout::addBrother(ExpressionLayoutCursor * cursor, ExpressionLayout * brother) {
|
||||
privateAddBrother(cursor, brother, false);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,11 @@ ExpressionLayout * FractionLayout::clone() const {
|
||||
return layout;
|
||||
}
|
||||
|
||||
void FractionLayout::collapseBrothers() {
|
||||
void FractionLayout::collapseBrothersAndMoveCursor(ExpressionLayoutCursor * cursor) {
|
||||
ExpressionLayout::collapseOnDirection(HorizontalDirection::Right, 1);
|
||||
ExpressionLayout::collapseOnDirection(HorizontalDirection::Left, 0);
|
||||
cursor->setPointedExpressionLayout(denominatorLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
}
|
||||
|
||||
void FractionLayout::backspaceAtCursor(ExpressionLayoutCursor * cursor) {
|
||||
|
||||
@@ -10,7 +10,7 @@ class FractionLayout : public StaticLayoutHierarchy<2> {
|
||||
public:
|
||||
using StaticLayoutHierarchy::StaticLayoutHierarchy;
|
||||
ExpressionLayout * clone() const override;
|
||||
void collapseBrothers() override;
|
||||
void collapseBrothersAndMoveCursor(ExpressionLayoutCursor * cursor) override;
|
||||
void backspaceAtCursor(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
|
||||
@@ -25,8 +25,10 @@ ExpressionLayout * NthRootLayout::clone() const {
|
||||
return new NthRootLayout(const_cast<NthRootLayout *>(this)->radicandLayout(), const_cast<NthRootLayout *>(this)->indexLayout(), true);
|
||||
}
|
||||
|
||||
void NthRootLayout::collapseBrothers() {
|
||||
void NthRootLayout::collapseBrothersAndMoveCursor(ExpressionLayoutCursor * cursor) {
|
||||
ExpressionLayout::collapseOnDirection(HorizontalDirection::Right, 0);
|
||||
cursor->setPointedExpressionLayout(radicandLayout());
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
}
|
||||
|
||||
void NthRootLayout::backspaceAtCursor(ExpressionLayoutCursor * cursor) {
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
ExpressionLayout * clone() const override;
|
||||
|
||||
/* Dynamic Layout*/
|
||||
void collapseBrothers() override;
|
||||
void collapseBrothersAndMoveCursor(ExpressionLayoutCursor * cursor) override;
|
||||
void backspaceAtCursor(ExpressionLayoutCursor * cursor) override;
|
||||
|
||||
/* Tree navigation */
|
||||
|
||||
Reference in New Issue
Block a user