mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 08:10:50 +01:00
[poincare] Check equivalent positions when moving Up and Down
Change-Id: I5043d0a43c981592b0b72fd1221769497520b342
This commit is contained in:
@@ -82,8 +82,8 @@ public:
|
||||
/* Tree navigation */
|
||||
virtual bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) = 0;
|
||||
virtual bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) = 0;
|
||||
virtual bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout);
|
||||
virtual bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout);
|
||||
virtual bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false);
|
||||
virtual bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false);
|
||||
virtual bool moveUpInside(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout);
|
||||
virtual bool moveDownInside(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout);
|
||||
|
||||
@@ -147,6 +147,7 @@ protected:
|
||||
bool m_positioned;
|
||||
private:
|
||||
void detachChildAtIndex(int i);
|
||||
bool moveVertically(VerticalDirection direction, ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited);
|
||||
bool moveInside(VerticalDirection direction, ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout);
|
||||
ExpressionLayout * replaceWithJuxtapositionOf(ExpressionLayout * leftChild, ExpressionLayout * rightChild, bool deleteAfterReplace);
|
||||
KDRect m_frame;
|
||||
|
||||
@@ -76,22 +76,22 @@ bool BinomialCoefficientLayout::moveRight(ExpressionLayoutCursor * cursor, bool
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BinomialCoefficientLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool BinomialCoefficientLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// Case: kLayout.
|
||||
// Move to nLayout.
|
||||
if (cursor->pointedExpressionLayout()->hasAncestor(kLayout(), true)) {
|
||||
return nLayout()->moveUpInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool BinomialCoefficientLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool BinomialCoefficientLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// Case: nLayout.
|
||||
// Move to kLayout.
|
||||
if (cursor->pointedExpressionLayout()->hasAncestor(nLayout(), true)) {
|
||||
return kLayout()->moveDownInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
void BinomialCoefficientLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
ExpressionLayout * clone() const override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionLayoutTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "binomial");
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ bool CondensedSumLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shoul
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CondensedSumLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool CondensedSumLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is inside the subscript layout, move it to the superscript.
|
||||
if (subscriptLayout() && cursor->pointedExpressionLayout()->hasAncestor(subscriptLayout(), true)) {
|
||||
assert(superscriptLayout() != nullptr);
|
||||
@@ -104,10 +104,10 @@ bool CondensedSumLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRe
|
||||
assert(superscriptLayout() != nullptr);
|
||||
return superscriptLayout()->moveUpInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool CondensedSumLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool CondensedSumLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is inside the superscript layout, move it to the subscript.
|
||||
if (superscriptLayout() && cursor->pointedExpressionLayout()->hasAncestor(superscriptLayout(), true)) {
|
||||
assert(subscriptLayout() != nullptr);
|
||||
@@ -121,7 +121,7 @@ bool CondensedSumLayout::moveDown(ExpressionLayoutCursor * cursor, bool * should
|
||||
assert(subscriptLayout() != nullptr);
|
||||
return subscriptLayout()->moveUpInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
ExpressionLayout * CondensedSumLayout::layoutToPointWhenInserting() {
|
||||
|
||||
@@ -12,8 +12,8 @@ public:
|
||||
ExpressionLayout * clone() const override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override {
|
||||
return LayoutEngine::writePrefixExpressionLayoutTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "sum");
|
||||
}
|
||||
|
||||
@@ -237,22 +237,16 @@ char ExpressionLayout::XNTChar() const {
|
||||
return m_parent->XNTChar();
|
||||
}
|
||||
|
||||
bool ExpressionLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
if (m_parent) {
|
||||
return m_parent->moveUp(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return false;
|
||||
bool ExpressionLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
return moveVertically(VerticalDirection::Up, cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool ExpressionLayout::moveUpInside(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
return moveInside(VerticalDirection::Up, cursor, shouldRecomputeLayout);
|
||||
}
|
||||
|
||||
bool ExpressionLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
if (m_parent) {
|
||||
return m_parent->moveDown(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return false;
|
||||
bool ExpressionLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
return moveVertically(VerticalDirection::Down, cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool ExpressionLayout::moveDownInside(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
@@ -343,6 +337,29 @@ bool ExpressionLayout::moveInside(VerticalDirection direction, ExpressionLayoutC
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ExpressionLayout::moveVertically(VerticalDirection direction, ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
if (!equivalentPositionVisited) {
|
||||
ExpressionLayoutCursor cursorEquivalent = equivalentCursor(cursor);
|
||||
if (cursorEquivalent.isDefined()) {
|
||||
cursor->setPointedExpressionLayout(cursorEquivalent.pointedExpressionLayout());
|
||||
cursor->setPosition(cursorEquivalent.position());
|
||||
if (direction == VerticalDirection::Up) {
|
||||
return cursor->pointedExpressionLayout()->moveUp(cursor, shouldRecomputeLayout, true);
|
||||
} else {
|
||||
return cursor->pointedExpressionLayout()->moveDown(cursor, shouldRecomputeLayout, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_parent) {
|
||||
if (direction == VerticalDirection::Up) {
|
||||
return m_parent->moveUp(cursor, shouldRecomputeLayout, true);
|
||||
} else {
|
||||
return m_parent->moveDown(cursor, shouldRecomputeLayout, true);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ExpressionLayout::moveCursorInsideAtDirection (
|
||||
VerticalDirection direction,
|
||||
ExpressionLayoutCursor * cursor,
|
||||
|
||||
@@ -143,7 +143,7 @@ bool FractionLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shouldRec
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FractionLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool FractionLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is inside denominator, move it to the numerator.
|
||||
if (denominatorLayout() && cursor->pointedExpressionLayout()->hasAncestor(denominatorLayout(), true)) {
|
||||
assert(numeratorLayout() != nullptr);
|
||||
@@ -154,10 +154,10 @@ bool FractionLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomp
|
||||
assert(numeratorLayout() != nullptr);
|
||||
return numeratorLayout()->moveUpInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool FractionLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool FractionLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is inside numerator, move it to the denominator.
|
||||
if (numeratorLayout() && cursor->pointedExpressionLayout()->hasAncestor(numeratorLayout(), true)) {
|
||||
assert(denominatorLayout() != nullptr);
|
||||
@@ -168,7 +168,7 @@ bool FractionLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldReco
|
||||
assert(denominatorLayout() != nullptr);
|
||||
return denominatorLayout()->moveDownInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
int FractionLayout::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const {
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
void deleteBeforeCursor(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
ExpressionLayout * layoutToPointWhenInserting() override;
|
||||
bool canBeOmittedMultiplicationRightFactor() const override { return false; }
|
||||
|
||||
@@ -94,7 +94,7 @@ bool GridLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecompu
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GridLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool GridLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is child that is not on the top row, move it inside the upper
|
||||
// neighbourg.
|
||||
int childIndex = m_numberOfColumns;
|
||||
@@ -104,10 +104,10 @@ bool GridLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeL
|
||||
}
|
||||
childIndex++;
|
||||
}
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool GridLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool GridLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
int childIndex = 0;
|
||||
while (childIndex < numberOfChildren() - m_numberOfColumns) {
|
||||
if (cursor->pointedExpressionLayout()->hasAncestor(child(childIndex), true)) {
|
||||
@@ -115,7 +115,7 @@ bool GridLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomput
|
||||
}
|
||||
childIndex++;
|
||||
}
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
void GridLayout::removeChildAtIndex(int index, bool deleteAfterRemoval) {
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
/* Navigation */
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
|
||||
/* Dynamic layout */
|
||||
void removeChildAtIndex(int index, bool deleteAfterRemoval) override;
|
||||
|
||||
@@ -117,7 +117,7 @@ bool IntegralLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shouldRec
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IntegralLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool IntegralLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is inside the lower bound, move it to the upper bound.
|
||||
if (lowerBoundLayout() && cursor->pointedExpressionLayout()->hasAncestor(lowerBoundLayout(), true)) {
|
||||
assert(upperBoundLayout() != nullptr);
|
||||
@@ -131,10 +131,10 @@ bool IntegralLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomp
|
||||
assert(upperBoundLayout() != nullptr);
|
||||
return upperBoundLayout()->moveUpInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool IntegralLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool IntegralLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is inside the upper bound, move it to the lower bound.
|
||||
if (upperBoundLayout() && cursor->pointedExpressionLayout()->hasAncestor(upperBoundLayout(), true)) {
|
||||
assert(lowerBoundLayout() != nullptr);
|
||||
@@ -148,7 +148,7 @@ bool IntegralLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldReco
|
||||
assert(lowerBoundLayout() != nullptr);
|
||||
return lowerBoundLayout()->moveDownInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
int IntegralLayout::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const {
|
||||
|
||||
@@ -19,8 +19,8 @@ public:
|
||||
/* Tree navigation */
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
|
||||
/* Expression Engine */
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
|
||||
@@ -80,7 +80,7 @@ bool MatrixLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecom
|
||||
return GridLayout::moveRight(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
|
||||
bool MatrixLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool MatrixLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
bool shouldRemoveGreySquares = false;
|
||||
for (int childIndex = 0; childIndex < m_numberOfColumns; childIndex++) {
|
||||
if (cursor->pointedExpressionLayout()->hasAncestor(child(childIndex), true)) {
|
||||
@@ -89,7 +89,7 @@ bool MatrixLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomput
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool returnValue = GridLayout::moveUp(cursor, shouldRecomputeLayout);
|
||||
bool returnValue = GridLayout::moveUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
if (returnValue && shouldRemoveGreySquares) {
|
||||
assert(hasGreySquares());
|
||||
removeGreySquares();
|
||||
@@ -98,7 +98,7 @@ bool MatrixLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomput
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
bool MatrixLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool MatrixLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
bool shouldRemoveGreySquares = false;
|
||||
for (int childIndex = numberOfChildren() - m_numberOfColumns; childIndex < m_numberOfChildren; childIndex++) {
|
||||
if (cursor->pointedExpressionLayout()->hasAncestor(child(childIndex), true)) {
|
||||
@@ -107,7 +107,7 @@ bool MatrixLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomp
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool returnValue = GridLayout::moveDown(cursor, shouldRecomputeLayout);
|
||||
bool returnValue = GridLayout::moveDown(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
if (returnValue && shouldRemoveGreySquares) {
|
||||
assert(hasGreySquares());
|
||||
removeGreySquares();
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
/* Navigation */
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveUpInside(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDownInside(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ bool NthRootLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shouldReco
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NthRootLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool NthRootLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is Left of the radicand, move it to the index.
|
||||
if (indexLayout()
|
||||
&& radicandLayout()
|
||||
@@ -153,10 +153,10 @@ bool NthRootLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecompu
|
||||
cursor->setPosition(ExpressionLayoutCursor::Position::Left);
|
||||
return true;
|
||||
}
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool NthRootLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool NthRootLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
if (indexLayout() && cursor->pointedExpressionLayout()->hasAncestor(indexLayout(), true)) {
|
||||
// If the cursor is Right of the index, move it to the radicand.
|
||||
if (cursor->positionIsEquivalentTo(indexLayout(), ExpressionLayoutCursor::Position::Right)) {
|
||||
@@ -172,7 +172,7 @@ bool NthRootLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecom
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
static_assert('\x90' == Ion::Charset::Root, "Unicode error");
|
||||
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
/* Tree navigation */
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
|
||||
/* Expression Engine */
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
|
||||
@@ -98,7 +98,7 @@ bool SequenceLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shouldRec
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SequenceLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool SequenceLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is inside the lower bound, move it to the upper bound.
|
||||
if (lowerBoundLayout() && cursor->pointedExpressionLayout()->hasAncestor(lowerBoundLayout(), true)) {
|
||||
assert(upperBoundLayout() != nullptr);
|
||||
@@ -111,10 +111,10 @@ bool SequenceLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomp
|
||||
assert(upperBoundLayout() != nullptr);
|
||||
return upperBoundLayout()->moveUpInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool SequenceLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool SequenceLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// If the cursor is inside the upper bound, move it to the lower bound.
|
||||
if (upperBoundLayout() && cursor->pointedExpressionLayout()->hasAncestor(upperBoundLayout(), true)) {
|
||||
assert(lowerBoundLayout() != nullptr);
|
||||
@@ -127,7 +127,7 @@ bool SequenceLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldReco
|
||||
assert(lowerBoundLayout() != nullptr);
|
||||
return lowerBoundLayout()->moveDownInside(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
ExpressionLayout * SequenceLayout::layoutToPointWhenInserting() {
|
||||
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
void deleteBeforeCursor(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
ExpressionLayout * layoutToPointWhenInserting() override;
|
||||
char XNTChar() const override;
|
||||
protected:
|
||||
|
||||
@@ -120,7 +120,7 @@ bool VerticalOffsetLayout::moveRight(ExpressionLayoutCursor * cursor, bool * sho
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VerticalOffsetLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool VerticalOffsetLayout::moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// Case: Superscript.
|
||||
if (m_type == VerticalOffsetLayout::Type::Superscript) {
|
||||
// Case: Right.
|
||||
@@ -151,10 +151,10 @@ bool VerticalOffsetLayout::moveUp(ExpressionLayoutCursor * cursor, bool * should
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
return true;
|
||||
}
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
bool VerticalOffsetLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
bool VerticalOffsetLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
// Case: Subscript.
|
||||
if (m_type == VerticalOffsetLayout::Type::Subscript) {
|
||||
// Case: Right.
|
||||
@@ -184,7 +184,7 @@ bool VerticalOffsetLayout::moveDown(ExpressionLayoutCursor * cursor, bool * shou
|
||||
cursor->setPointedExpressionLayout(this);
|
||||
return true;
|
||||
}
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout);
|
||||
return ExpressionLayout::moveDown(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
int VerticalOffsetLayout::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const {
|
||||
|
||||
@@ -17,8 +17,8 @@ public:
|
||||
void deleteBeforeCursor(ExpressionLayoutCursor * cursor) override;
|
||||
bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
bool moveUp(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
bool moveDown(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
bool mustHaveLeftSibling() const override { return true; }
|
||||
bool isVerticalOffset() const { return true; }
|
||||
|
||||
Reference in New Issue
Block a user