mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 16:20:49 +01:00
[poincare] Simplify MatrixLayout code
Change-Id: I4bfcf3da94296b8314ff47a1a71dbc79150a4027
This commit is contained in:
@@ -89,8 +89,8 @@ public:
|
||||
virtual ExpressionLayoutCursor cursorRightOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) = 0;
|
||||
virtual ExpressionLayoutCursor cursorAbove(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false);
|
||||
virtual ExpressionLayoutCursor cursorUnder(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false);
|
||||
virtual ExpressionLayoutCursor cursorInDescendantsAbove(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout);
|
||||
virtual ExpressionLayoutCursor cursorInDescendantsUnder(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout);
|
||||
ExpressionLayoutCursor cursorInDescendantsAbove(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout);
|
||||
ExpressionLayoutCursor cursorInDescendantsUnder(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout);
|
||||
|
||||
/* Expression Engine */
|
||||
virtual int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const = 0;
|
||||
@@ -142,6 +142,7 @@ protected:
|
||||
int * resultScore);
|
||||
virtual void privateAddSibling(ExpressionLayoutCursor * cursor, ExpressionLayout * sibling, bool moveCursor);
|
||||
void collapseOnDirection(HorizontalDirection direction, int absorbingChildIndex);
|
||||
virtual ExpressionLayoutCursor cursorVerticalOf(VerticalDirection direction, ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited);
|
||||
ExpressionLayout * m_parent;
|
||||
KDCoordinate m_baseline;
|
||||
/* m_baseline is the signed vertical distance from the top of the layout to
|
||||
@@ -152,7 +153,6 @@ protected:
|
||||
bool m_positioned;
|
||||
private:
|
||||
void detachChildAtIndex(int i);
|
||||
ExpressionLayoutCursor cursorVerticalOf(VerticalDirection direction, ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited);
|
||||
ExpressionLayoutCursor cursorInDescendantsVerticalOf(VerticalDirection direction, ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout);
|
||||
ExpressionLayout * replaceWithJuxtapositionOf(ExpressionLayout * leftChild, ExpressionLayout * rightChild, bool deleteAfterReplace);
|
||||
KDRect m_frame;
|
||||
|
||||
@@ -73,34 +73,18 @@ ExpressionLayoutCursor MatrixLayout::cursorRightOf(ExpressionLayoutCursor cursor
|
||||
return GridLayout::cursorRightOf(cursor, shouldRecomputeLayout);
|
||||
}
|
||||
|
||||
ExpressionLayoutCursor MatrixLayout::cursorAbove(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
ExpressionLayoutCursor MatrixLayout::cursorVerticalOf(VerticalDirection direction, ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
bool shouldRemoveGreySquares = false;
|
||||
for (int childIndex = 0; childIndex < m_numberOfColumns; childIndex++) {
|
||||
int firstIndex = direction == VerticalDirection::Up ? 0 : numberOfChildren() - m_numberOfColumns;
|
||||
int lastIndex = direction == VerticalDirection::Up ? m_numberOfColumns : numberOfChildren();
|
||||
for (int childIndex = firstIndex; childIndex < lastIndex; childIndex++) {
|
||||
if (cursor.pointedExpressionLayout()->hasAncestor(child(childIndex), true)) {
|
||||
// The cursor is leaving the matrix, so remove the grey squares.
|
||||
shouldRemoveGreySquares = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ExpressionLayoutCursor resultCursor = GridLayout::cursorAbove(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
if (resultCursor.isDefined() && shouldRemoveGreySquares) {
|
||||
assert(hasGreySquares());
|
||||
removeGreySquares();
|
||||
*shouldRecomputeLayout = true;
|
||||
}
|
||||
return resultCursor;
|
||||
}
|
||||
|
||||
ExpressionLayoutCursor MatrixLayout::cursorUnder(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)) {
|
||||
// The cursor is leaving the matrix, so remove the grey squares.
|
||||
shouldRemoveGreySquares = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ExpressionLayoutCursor resultCursor = GridLayout::cursorUnder(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
ExpressionLayoutCursor resultCursor = GridLayout::cursorVerticalOf(direction, cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
if (resultCursor.isDefined() && shouldRemoveGreySquares) {
|
||||
assert(hasGreySquares());
|
||||
removeGreySquares();
|
||||
|
||||
@@ -13,8 +13,6 @@ public:
|
||||
/* Navigation */
|
||||
ExpressionLayoutCursor cursorLeftOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
|
||||
ExpressionLayoutCursor cursorRightOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
|
||||
ExpressionLayoutCursor cursorAbove(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
ExpressionLayoutCursor cursorUnder(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
|
||||
/* Dynamic layout */
|
||||
void replaceChild(const ExpressionLayout * oldChild, ExpressionLayout * newChild, bool deleteOldChild) override;
|
||||
@@ -35,6 +33,7 @@ protected:
|
||||
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
|
||||
KDSize computeSize() override;
|
||||
KDPoint positionOfChild(ExpressionLayout * child) override;
|
||||
ExpressionLayoutCursor cursorVerticalOf(VerticalDirection direction, ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) override;
|
||||
private:
|
||||
void childWasReplacedAtIndex(int index);
|
||||
bool isRowEmpty(int index) const;
|
||||
|
||||
Reference in New Issue
Block a user