mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 08:10:50 +01:00
[poincare] Fix cursorAbove/Under in EmptyLayout.
Change-Id: I9e5ac6eb557d07644310e391d5cc7bc75408c628
This commit is contained in:
@@ -45,6 +45,29 @@ ExpressionLayoutCursor EmptyLayout::cursorRightOf(ExpressionLayoutCursor cursor,
|
||||
return ExpressionLayoutCursor();
|
||||
}
|
||||
|
||||
ExpressionLayoutCursor EmptyLayout::cursorAbove(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
return cursorVerticalOf(VerticalDirection::Up, cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
ExpressionLayoutCursor EmptyLayout::cursorUnder(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
return cursorVerticalOf(VerticalDirection::Down, cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
ExpressionLayoutCursor EmptyLayout::cursorVerticalOf(VerticalDirection direction, ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
assert(cursor.pointedExpressionLayout() == this);
|
||||
ExpressionLayoutCursor cursorResult = direction == VerticalDirection::Up ?
|
||||
ExpressionLayout::cursorAbove(cursor, shouldRecomputeLayout, equivalentPositionVisited) :
|
||||
ExpressionLayout::cursorUnder(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
if (cursorResult.isDefined()) {
|
||||
return cursorResult;
|
||||
}
|
||||
ExpressionLayoutCursor::Position newPosition = cursor.position() == ExpressionLayoutCursor::Position::Left ? ExpressionLayoutCursor::Position::Right : ExpressionLayoutCursor::Position::Left;
|
||||
cursor.setPosition(newPosition);
|
||||
return direction == VerticalDirection::Up ?
|
||||
ExpressionLayout::cursorAbove(cursor, shouldRecomputeLayout, equivalentPositionVisited) :
|
||||
ExpressionLayout::cursorUnder(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
int EmptyLayout::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const {
|
||||
if (bufferSize == 0) {
|
||||
return -1;
|
||||
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
void deleteBeforeCursor(ExpressionLayoutCursor * cursor) override;
|
||||
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;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
bool isEmpty() const override { return true; }
|
||||
Color color() const { return m_color; }
|
||||
@@ -38,6 +40,7 @@ private:
|
||||
constexpr static KDCoordinate k_marginWidth = 1;
|
||||
constexpr static KDCoordinate k_marginHeight = 3;
|
||||
constexpr static KDCoordinate k_lineThickness = 1;
|
||||
ExpressionLayoutCursor cursorVerticalOf(VerticalDirection direction, ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited);
|
||||
bool m_isVisible;
|
||||
Color m_color;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user