mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 08:10:50 +01:00
[poincare] EmptyLayout reorganization.
Change-Id: Ie575bd4f022058316ba18504666b70c10786d1a7
This commit is contained in:
@@ -45,23 +45,6 @@ ExpressionLayoutCursor EmptyLayout::cursorRightOf(ExpressionLayoutCursor cursor,
|
||||
return ExpressionLayoutCursor();
|
||||
}
|
||||
|
||||
ExpressionLayoutCursor EmptyLayout::cursorVerticalOf(VerticalDirection direction, ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
/* The two cursor positions around an EmptyLayout are equivalent, so both
|
||||
* should be checked. */
|
||||
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;
|
||||
@@ -108,4 +91,21 @@ void EmptyLayout::privateAddSibling(ExpressionLayoutCursor * cursor, ExpressionL
|
||||
}
|
||||
}
|
||||
|
||||
ExpressionLayoutCursor EmptyLayout::cursorVerticalOf(VerticalDirection direction, ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
/* The two cursor positions around an EmptyLayout are equivalent, so both
|
||||
* should be checked. */
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,20 +12,32 @@ public:
|
||||
Yellow,
|
||||
Grey
|
||||
};
|
||||
// Constructor
|
||||
EmptyLayout(Color color = Color::Yellow, bool visible = true);
|
||||
ExpressionLayout * clone() const override;
|
||||
void deleteBeforeCursor(ExpressionLayoutCursor * cursor) override;
|
||||
ExpressionLayoutCursor cursorLeftOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
|
||||
ExpressionLayoutCursor cursorRightOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
bool isEmpty() const override { return true; }
|
||||
|
||||
// EmptyLayout
|
||||
Color color() const { return m_color; }
|
||||
void setColor(Color color) { m_color = color; }
|
||||
bool isVisible() const { return m_isVisible; }
|
||||
void setVisible(bool visible) { m_isVisible = visible; }
|
||||
|
||||
// User input
|
||||
void deleteBeforeCursor(ExpressionLayoutCursor * cursor) override;
|
||||
|
||||
// Tree navigation
|
||||
ExpressionLayoutCursor cursorLeftOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
|
||||
ExpressionLayoutCursor cursorRightOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
|
||||
|
||||
// Serialization
|
||||
int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override;
|
||||
|
||||
// Other
|
||||
bool isEmpty() const override { return true; }
|
||||
|
||||
protected:
|
||||
virtual void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
|
||||
virtual KDSize computeSize() override;
|
||||
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
|
||||
KDSize computeSize() override;
|
||||
void computeBaseline() override;
|
||||
KDPoint positionOfChild(ExpressionLayout * child) override {
|
||||
assert(false);
|
||||
|
||||
Reference in New Issue
Block a user