mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/layout] Add parameter for selection when moving cursor
This commit is contained in:
@@ -15,10 +15,10 @@ public:
|
||||
Type type() const override { return Type::BinomialCoefficientLayout; }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
|
||||
// SerializableNode
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
|
||||
@@ -15,8 +15,8 @@ public:
|
||||
{}
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void invalidAllSizesPositionsAndBaselines() override;
|
||||
|
||||
// TreeNode
|
||||
|
||||
@@ -16,8 +16,8 @@ public:
|
||||
static void RenderWithChildSize(KDSize childSize, KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor);
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void deleteBeforeCursor(LayoutCursor * cursor) override;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
bool shouldCollapseSiblingsOnRight() const override{ return true; }
|
||||
|
||||
@@ -28,8 +28,8 @@ public:
|
||||
const KDFont * font() const { return m_font; }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const override;
|
||||
bool canBeOmittedMultiplicationLeftFactor() const override;
|
||||
|
||||
@@ -18,10 +18,10 @@ public:
|
||||
|
||||
/* CondensedSumLayout is only used in apps/shared/sum_graph_controller.cpp, in
|
||||
* a view with no cursor. */
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override { assert(false); }
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override { assert(false); }
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override { assert(false); }
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override { assert(false); }
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override { assert(false); }
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override { assert(false); }
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) override { assert(false); }
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) override { assert(false); }
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
assert(false);
|
||||
return 0;
|
||||
|
||||
@@ -14,8 +14,8 @@ public:
|
||||
Type type() const override { return Type::ConjugateLayout; }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
bool shouldCollapseSiblingsOnRight() const override { return true; }
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ public:
|
||||
|
||||
// LayoutNode
|
||||
void deleteBeforeCursor(LayoutCursor * cursor) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
bool isEmpty() const override { return true; }
|
||||
bool hasText() const override { return false; }
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
KDCoordinate width() const { return m_font->glyphSize().width() - 2 * k_marginWidth; }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) override;
|
||||
void moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) override;
|
||||
bool willAddSibling(LayoutCursor * cursor, LayoutNode * sibling, bool moveCursor) override;
|
||||
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override;
|
||||
bool protectedIsIdenticalTo(Layout l) override;
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
Type type() const override { return Type::FractionLayout; }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void deleteBeforeCursor(LayoutCursor * cursor) override;
|
||||
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
|
||||
@@ -32,10 +32,10 @@ public:
|
||||
KDSize gridSize() const { return KDSize(width(), height()); }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
|
||||
// SerializableNode
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
Type type() const override { return Type::HorizontalLayout; }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
LayoutCursor equivalentCursor(LayoutCursor * cursor) override;
|
||||
void deleteBeforeCursor(LayoutCursor * cursor) override;
|
||||
LayoutNode * layoutToPointWhenInserting(Expression * correspondingExpression) override;
|
||||
|
||||
@@ -18,10 +18,10 @@ public:
|
||||
Type type() const override { return Type::IntegralLayout; }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void deleteBeforeCursor(LayoutCursor * cursor) override;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
LayoutNode * layoutToPointWhenInserting(Expression * correspondingExpression) override { return lowerBoundLayout(); }
|
||||
|
||||
@@ -82,24 +82,20 @@ public:
|
||||
KDPoint middleLeftPoint();
|
||||
|
||||
/* Move */
|
||||
void move(Direction direction, bool * shouldRecomputeLayout);
|
||||
void moveLeft(bool * shouldRecomputeLayout) {
|
||||
layoutNode()->moveCursorLeft(this, shouldRecomputeLayout);
|
||||
void move(Direction direction, bool * shouldRecomputeLayout, bool forSelection = false);
|
||||
void moveLeft(bool * shouldRecomputeLayout, bool forSelection = false) {
|
||||
layoutNode()->moveCursorLeft(this, shouldRecomputeLayout, forSelection);
|
||||
}
|
||||
void moveRight(bool * shouldRecomputeLayout) {
|
||||
layoutNode()->moveCursorRight(this, shouldRecomputeLayout);
|
||||
void moveRight(bool * shouldRecomputeLayout, bool forSelection = false) {
|
||||
layoutNode()->moveCursorRight(this, shouldRecomputeLayout, forSelection);
|
||||
}
|
||||
void moveAbove(bool * shouldRecomputeLayout) {
|
||||
layoutNode()->moveCursorUp(this, shouldRecomputeLayout);
|
||||
void moveAbove(bool * shouldRecomputeLayout, bool forSelection = false) {
|
||||
layoutNode()->moveCursorUp(this, shouldRecomputeLayout, false, forSelection);
|
||||
}
|
||||
void moveUnder(bool * shouldRecomputeLayout) {
|
||||
layoutNode()->moveCursorDown(this, shouldRecomputeLayout);
|
||||
}
|
||||
LayoutCursor cursorAtDirection(Direction direction, bool * shouldRecomputeLayout) {
|
||||
LayoutCursor result = clone();
|
||||
result.move(direction, shouldRecomputeLayout);
|
||||
return result;
|
||||
void moveUnder(bool * shouldRecomputeLayout, bool forSelection = false) {
|
||||
layoutNode()->moveCursorDown(this, shouldRecomputeLayout, false, forSelection);
|
||||
}
|
||||
LayoutCursor cursorAtDirection(Direction direction, bool * shouldRecomputeLayout, bool forSelection = false);
|
||||
|
||||
/* Select */
|
||||
void select(Direction direction, bool * shouldRecomputeLayout, Layout * selection);
|
||||
|
||||
@@ -75,19 +75,19 @@ public:
|
||||
LayoutNode * root() override { return static_cast<LayoutNode *>(TreeNode::root()); }
|
||||
|
||||
// Tree navigation
|
||||
virtual void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) = 0;
|
||||
virtual void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) = 0;
|
||||
virtual void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) {
|
||||
moveCursorVertically(VerticalDirection::Up, cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
virtual void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection = false) = 0;
|
||||
virtual void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection = false) = 0;
|
||||
virtual void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) {
|
||||
moveCursorVertically(VerticalDirection::Up, cursor, shouldRecomputeLayout, equivalentPositionVisited, forSelection);
|
||||
}
|
||||
virtual void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) {
|
||||
moveCursorVertically(VerticalDirection::Down, cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
virtual void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) {
|
||||
moveCursorVertically(VerticalDirection::Down, cursor, shouldRecomputeLayout, equivalentPositionVisited, forSelection);
|
||||
}
|
||||
void moveCursorUpInDescendants(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
return moveCursorInDescendantsVertically(VerticalDirection::Up, cursor, shouldRecomputeLayout);
|
||||
void moveCursorUpInDescendants(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection = false) {
|
||||
return moveCursorInDescendantsVertically(VerticalDirection::Up, cursor, shouldRecomputeLayout, forSelection);
|
||||
}
|
||||
void moveCursorDownInDescendants(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
return moveCursorInDescendantsVertically(VerticalDirection::Down, cursor, shouldRecomputeLayout);
|
||||
void moveCursorDownInDescendants(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection = false) {
|
||||
return moveCursorInDescendantsVertically(VerticalDirection::Down, cursor, shouldRecomputeLayout, forSelection);
|
||||
}
|
||||
virtual LayoutCursor equivalentCursor(LayoutCursor * cursor);
|
||||
|
||||
@@ -143,7 +143,7 @@ protected:
|
||||
virtual bool protectedIsIdenticalTo(Layout l);
|
||||
|
||||
// Tree navigation
|
||||
virtual void moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited);
|
||||
virtual void moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection);
|
||||
|
||||
// Tree
|
||||
Direct<LayoutNode> children() { return Direct<LayoutNode>(this); }
|
||||
@@ -163,14 +163,15 @@ protected:
|
||||
bool m_positioned;
|
||||
bool m_sized;
|
||||
private:
|
||||
void moveCursorInDescendantsVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout);
|
||||
void moveCursorInDescendantsVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection);
|
||||
void scoreCursorInDescendantsVertically (
|
||||
VerticalDirection direction,
|
||||
LayoutCursor * cursor,
|
||||
bool * shouldRecomputeLayout,
|
||||
LayoutNode ** childResult,
|
||||
void * resultPosition,
|
||||
int * resultScore);
|
||||
int * resultScore,
|
||||
bool forSelection);
|
||||
virtual void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) = 0;
|
||||
bool changeGreySquaresOfAllMatrixAncestors(bool add);
|
||||
};
|
||||
|
||||
@@ -23,8 +23,8 @@ public:
|
||||
void removeGreySquares();
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void willAddSiblingToEmptyChildAtIndex(int childIndex) override;
|
||||
void deleteBeforeCursor(LayoutCursor * cursor) override;
|
||||
|
||||
@@ -43,7 +43,7 @@ protected:
|
||||
// LayoutNode
|
||||
KDSize computeSize() override;
|
||||
KDPoint positionOfChild(LayoutNode * l) override;
|
||||
void moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) override;
|
||||
void moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) override;
|
||||
|
||||
private:
|
||||
// MatrixNode
|
||||
|
||||
@@ -25,10 +25,10 @@ public:
|
||||
Type type() const override { return Type::NthRootLayout; }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void deleteBeforeCursor(LayoutCursor * cursor) override;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
bool shouldCollapseSiblingsOnRight() const override { return true; }
|
||||
|
||||
@@ -14,10 +14,10 @@ public:
|
||||
using LayoutNode::LayoutNode;
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void deleteBeforeCursor(LayoutCursor * cursor) override;
|
||||
LayoutNode * layoutToPointWhenInserting(Expression * correspondingExpression) override { return lowerBoundLayout(); }
|
||||
CodePoint XNTCodePoint(int childIndex = -1) const override;
|
||||
|
||||
@@ -25,10 +25,10 @@ public:
|
||||
Position position() const { return m_position; }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) override;
|
||||
void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false, bool forSelection = false) override;
|
||||
void deleteBeforeCursor(LayoutCursor * cursor) override;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
bool mustHaveLeftSibling() const override { return true; }
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Poincare {
|
||||
|
||||
static inline KDCoordinate maxCoordinate(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; }
|
||||
|
||||
void BinomialCoefficientLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void BinomialCoefficientLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->position() == LayoutCursor::Position::Left
|
||||
&& (cursor->layoutNode() == nLayout()
|
||||
|| cursor->layoutNode() == kLayout()))
|
||||
@@ -33,7 +33,7 @@ void BinomialCoefficientLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool *
|
||||
}
|
||||
}
|
||||
|
||||
void BinomialCoefficientLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void BinomialCoefficientLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->position() == LayoutCursor::Position::Right
|
||||
&& (cursor->layoutNode() == nLayout()
|
||||
|| cursor->layoutNode() == kLayout()))
|
||||
@@ -57,7 +57,7 @@ void BinomialCoefficientLayoutNode::moveCursorRight(LayoutCursor * cursor, bool
|
||||
}
|
||||
}
|
||||
|
||||
void BinomialCoefficientLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void BinomialCoefficientLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (cursor->layoutNode()->hasAncestor(kLayout(), true)) {
|
||||
// Case: kLayout. Move to nLayout.
|
||||
return nLayout()->moveCursorUpInDescendants(cursor, shouldRecomputeLayout);
|
||||
@@ -65,7 +65,7 @@ void BinomialCoefficientLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * s
|
||||
LayoutNode::moveCursorUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
void BinomialCoefficientLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void BinomialCoefficientLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (cursor->layoutNode()->hasAncestor(nLayout(), true)) {
|
||||
// Case: nLayout. Move to kLayout.
|
||||
return kLayout()->moveCursorDownInDescendants(cursor, shouldRecomputeLayout);
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Poincare {
|
||||
|
||||
static inline KDCoordinate maxCoordinate(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; }
|
||||
|
||||
void BracketLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void BracketLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
assert(cursor->layoutNode() == this);
|
||||
if (cursor->position() == LayoutCursor::Position::Right) {
|
||||
// Case: Right. Go Left.
|
||||
@@ -22,7 +22,7 @@ void BracketLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecom
|
||||
}
|
||||
}
|
||||
|
||||
void BracketLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void BracketLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
assert(cursor->layoutNode() == this);
|
||||
if (cursor->position() == LayoutCursor::Position::Left) {
|
||||
// Case: Left. Go Right.
|
||||
|
||||
@@ -23,7 +23,7 @@ void BracketPairLayoutNode::RenderWithChildSize(KDSize childSize, KDContext * ct
|
||||
ctx->fillRect(KDRect(p.x()+k_externWidthMargin+2*k_lineThickness+childSize.width()+2*k_widthMargin-k_bracketWidth, p.y()+k_verticalExternMargin+verticalBarHeight-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
|
||||
}
|
||||
|
||||
void BracketPairLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void BracketPairLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == childLayout()
|
||||
&& cursor->position() == LayoutCursor::Position::Left)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ void BracketPairLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldR
|
||||
}
|
||||
}
|
||||
|
||||
void BracketPairLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void BracketPairLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == childLayout()
|
||||
&& cursor->position() == LayoutCursor::Position::Right)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace Poincare {
|
||||
|
||||
// LayoutNode
|
||||
void CodePointLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void CodePointLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->position() == LayoutCursor::Position::Right) {
|
||||
cursor->setPosition(LayoutCursor::Position::Left);
|
||||
return;
|
||||
@@ -16,7 +16,7 @@ void CodePointLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRec
|
||||
}
|
||||
}
|
||||
|
||||
void CodePointLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void CodePointLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->position() == LayoutCursor::Position::Left) {
|
||||
cursor->setPosition(LayoutCursor::Position::Right);
|
||||
return;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
void ConjugateLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void ConjugateLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == childLayout()
|
||||
&& cursor->position() == LayoutCursor::Position::Left)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ void ConjugateLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRec
|
||||
}
|
||||
}
|
||||
|
||||
void ConjugateLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void ConjugateLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
// Case: Right of the operand. Move Right.
|
||||
if (cursor->layoutNode() == childLayout()
|
||||
&& cursor->position() == LayoutCursor::Position::Right)
|
||||
|
||||
@@ -13,7 +13,7 @@ void EmptyLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) {
|
||||
}
|
||||
}
|
||||
|
||||
void EmptyLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void EmptyLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
assert(cursor->layoutNode() == this);
|
||||
// Ask the parent.
|
||||
LayoutNode * p = parent();
|
||||
@@ -23,7 +23,7 @@ void EmptyLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecompu
|
||||
}
|
||||
}
|
||||
|
||||
void EmptyLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void EmptyLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
assert(cursor->layoutNode() == this);
|
||||
// Ask the parent.
|
||||
LayoutNode * p = parent();
|
||||
@@ -50,19 +50,19 @@ KDCoordinate EmptyLayoutNode::computeBaseline() {
|
||||
return (m_margins ? k_marginHeight : 0) + height()/2;
|
||||
}
|
||||
|
||||
void EmptyLayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void EmptyLayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
/* The two cursor positions around an EmptyLayoutNode are equivalent, so both
|
||||
* should be checked. */
|
||||
assert(cursor->layoutNode() == this);
|
||||
LayoutCursor cursorResult = cursor->clone();
|
||||
LayoutNode::moveCursorVertically(direction, &cursorResult, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
LayoutNode::moveCursorVertically(direction, &cursorResult, shouldRecomputeLayout, equivalentPositionVisited, forSelection);
|
||||
if (cursorResult.isDefined()) {
|
||||
cursor->setTo(&cursorResult);
|
||||
return;
|
||||
}
|
||||
LayoutCursor::Position newPosition = cursor->position() == LayoutCursor::Position::Left ? LayoutCursor::Position::Right : LayoutCursor::Position::Left;
|
||||
cursor->setPosition(newPosition);
|
||||
LayoutNode::moveCursorVertically(direction, cursor, shouldRecomputeLayout, false);
|
||||
LayoutNode::moveCursorVertically(direction, cursor, shouldRecomputeLayout, false, forSelection);
|
||||
}
|
||||
|
||||
bool EmptyLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode * sibling, bool moveCursor) {
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Poincare {
|
||||
|
||||
static inline KDCoordinate maxCoordinate(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; }
|
||||
|
||||
void FractionLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void FractionLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->position() == LayoutCursor::Position::Left
|
||||
&& (cursor->layoutNode() == numeratorLayout()
|
||||
|| cursor->layoutNode() == denominatorLayout()))
|
||||
@@ -34,7 +34,7 @@ void FractionLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldReco
|
||||
}
|
||||
}
|
||||
|
||||
void FractionLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void FractionLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->position() == LayoutCursor::Position::Right
|
||||
&& (cursor->layoutNode() == numeratorLayout()
|
||||
|| cursor->layoutNode() == denominatorLayout()))
|
||||
@@ -57,7 +57,7 @@ void FractionLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRec
|
||||
}
|
||||
}
|
||||
|
||||
void FractionLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void FractionLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (cursor->layoutNode()->hasAncestor(denominatorLayout(), true)) {
|
||||
// If the cursor is inside denominator, move it to the numerator.
|
||||
numeratorLayout()->moveCursorUpInDescendants(cursor, shouldRecomputeLayout);
|
||||
@@ -71,7 +71,7 @@ void FractionLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomp
|
||||
LayoutNode::moveCursorUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
void FractionLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void FractionLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (cursor->layoutNode()->hasAncestor(numeratorLayout(), true)) {
|
||||
// If the cursor is inside numerator, move it to the denominator.
|
||||
denominatorLayout()->moveCursorDownInDescendants(cursor, shouldRecomputeLayout);
|
||||
|
||||
@@ -8,7 +8,7 @@ static inline KDCoordinate maxCoordinate(KDCoordinate x, KDCoordinate y) { retur
|
||||
|
||||
// LayoutNode
|
||||
|
||||
void GridLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void GridLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == this && cursor->position() == LayoutCursor::Position::Right) {
|
||||
// Case: Right. Go to the last entry.
|
||||
cursor->setLayoutNode(childAtIndex(numberOfChildren() - 1));
|
||||
@@ -36,7 +36,7 @@ void GridLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomput
|
||||
}
|
||||
}
|
||||
|
||||
void GridLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void GridLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == this && cursor->position() == LayoutCursor::Position::Left) {
|
||||
// Case: Left. Go to the first entry.
|
||||
assert(numberOfChildren() >= 1);
|
||||
@@ -65,7 +65,7 @@ void GridLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecompu
|
||||
}
|
||||
}
|
||||
|
||||
void GridLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void GridLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
/* If the cursor is child that is not on the top row, move it inside its upper
|
||||
* neighbour. */
|
||||
int childIndex = m_numberOfColumns;
|
||||
@@ -79,7 +79,7 @@ void GridLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeL
|
||||
LayoutNode::moveCursorUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
void GridLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void GridLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
int childIndex = 0;
|
||||
int maxIndex = numberOfChildren() - m_numberOfColumns;
|
||||
for (LayoutNode * l : children()) {
|
||||
|
||||
@@ -10,7 +10,7 @@ static inline KDCoordinate maxCoordinate(KDCoordinate c1, KDCoordinate c2) { ret
|
||||
|
||||
// LayoutNode
|
||||
|
||||
void HorizontalLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void HorizontalLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (this == cursor->layoutNode()) {
|
||||
if (cursor->position() == LayoutCursor::Position::Left) {
|
||||
// Case: Left. Ask the parent.
|
||||
@@ -50,7 +50,7 @@ void HorizontalLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRe
|
||||
cursor->moveLeft(shouldRecomputeLayout);
|
||||
}
|
||||
|
||||
void HorizontalLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void HorizontalLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (this == cursor->layoutNode()) {
|
||||
if (cursor->position() == LayoutCursor::Position::Right) {
|
||||
// Case: Right. Ask the parent.
|
||||
|
||||
@@ -23,7 +23,7 @@ const uint8_t bottomSymbolPixel[IntegralLayoutNode::k_symbolHeight][IntegralLayo
|
||||
{0xFF, 0xFF, 0x00, 0x00},
|
||||
};
|
||||
|
||||
void IntegralLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void IntegralLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == upperBoundLayout()
|
||||
|| cursor->layoutNode() == lowerBoundLayout())
|
||||
{
|
||||
@@ -63,7 +63,7 @@ void IntegralLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldReco
|
||||
}
|
||||
}
|
||||
|
||||
void IntegralLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void IntegralLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == upperBoundLayout()
|
||||
|| cursor->layoutNode() == lowerBoundLayout())
|
||||
{
|
||||
@@ -104,7 +104,7 @@ void IntegralLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRec
|
||||
}
|
||||
}
|
||||
|
||||
void IntegralLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void IntegralLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (cursor->layoutNode()->hasAncestor(lowerBoundLayout(), true)) {
|
||||
// If the cursor is inside the lower bound, move it to the upper bound.
|
||||
upperBoundLayout()->moveCursorUpInDescendants(cursor, shouldRecomputeLayout);
|
||||
@@ -118,7 +118,7 @@ void IntegralLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomp
|
||||
LayoutNode::moveCursorUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
void IntegralLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void IntegralLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (cursor->layoutNode()->hasAncestor(upperBoundLayout(), true)) {
|
||||
// If the cursor is inside the upper bound, move it to the lower bound.
|
||||
lowerBoundLayout()->moveCursorDownInDescendants(cursor, shouldRecomputeLayout);
|
||||
|
||||
@@ -58,20 +58,25 @@ KDPoint LayoutCursor::middleLeftPoint() {
|
||||
}
|
||||
|
||||
/* Move */
|
||||
void LayoutCursor::move(Direction direction, bool * shouldRecomputeLayout) {
|
||||
void LayoutCursor::move(Direction direction, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (direction == Direction::Left) {
|
||||
moveLeft(shouldRecomputeLayout);
|
||||
moveLeft(shouldRecomputeLayout, forSelection);
|
||||
} else if (direction == Direction::Right) {
|
||||
moveRight(shouldRecomputeLayout);
|
||||
moveRight(shouldRecomputeLayout, forSelection);
|
||||
} else if (direction == Direction::Up) {
|
||||
moveAbove(shouldRecomputeLayout);
|
||||
} else if (direction == Direction::Down) {
|
||||
moveUnder(shouldRecomputeLayout);
|
||||
moveAbove(shouldRecomputeLayout, forSelection);
|
||||
} else {
|
||||
assert(false);
|
||||
assert(direction == Direction::Down);
|
||||
moveUnder(shouldRecomputeLayout, forSelection);
|
||||
}
|
||||
}
|
||||
|
||||
LayoutCursor LayoutCursor::cursorAtDirection(Direction direction, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
LayoutCursor result = clone();
|
||||
result.move(direction, shouldRecomputeLayout, forSelection);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Select */
|
||||
|
||||
void LayoutCursor::select(Direction direction, bool * shouldRecomputeLayout, Layout * selection) {
|
||||
@@ -360,7 +365,7 @@ void LayoutCursor::selectLeftRight(bool right, bool * shouldRecomputeLayout, Lay
|
||||
|
||||
void LayoutCursor::selectUpDown(bool up, bool * shouldRecomputeLayout, Layout * selection) {
|
||||
// Move the cursor in the selection direction
|
||||
LayoutCursor c = cursorAtDirection(up ? Direction::Up : Direction::Down, shouldRecomputeLayout);
|
||||
LayoutCursor c = cursorAtDirection(up ? Direction::Up : Direction::Down, shouldRecomputeLayout, true);
|
||||
if (!c.isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ bool LayoutNode::protectedIsIdenticalTo(Layout l) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void LayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void LayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (!equivalentPositionVisited) {
|
||||
LayoutCursor cursorEquivalent = equivalentCursor(cursor);
|
||||
if (cursorEquivalent.isDefined()) {
|
||||
@@ -195,7 +195,7 @@ void LayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutNode::moveCursorInDescendantsVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void LayoutNode::moveCursorInDescendantsVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
LayoutNode * childResult = nullptr;
|
||||
LayoutNode ** childResultPtr = &childResult;
|
||||
LayoutCursor::Position resultPosition = LayoutCursor::Position::Left;
|
||||
@@ -203,7 +203,7 @@ void LayoutNode::moveCursorInDescendantsVertically(VerticalDirection direction,
|
||||
* than this initial value of score. */
|
||||
int resultScore = Ion::Display::Width*Ion::Display::Width + Ion::Display::Height*Ion::Display::Height;
|
||||
|
||||
scoreCursorInDescendantsVertically(direction, cursor, shouldRecomputeLayout, childResultPtr, &resultPosition, &resultScore);
|
||||
scoreCursorInDescendantsVertically(direction, cursor, shouldRecomputeLayout, childResultPtr, &resultPosition, &resultScore, forSelection);
|
||||
|
||||
// If there is a valid result
|
||||
Layout resultRef(childResult);
|
||||
@@ -221,7 +221,8 @@ void LayoutNode::scoreCursorInDescendantsVertically (
|
||||
bool * shouldRecomputeLayout,
|
||||
LayoutNode ** childResult,
|
||||
void * resultPosition,
|
||||
int * resultScore)
|
||||
int * resultScore,
|
||||
bool forSelection)
|
||||
{
|
||||
LayoutCursor::Position * castedResultPosition = static_cast<LayoutCursor::Position *>(resultPosition);
|
||||
KDPoint cursorMiddleLeft = cursor->middleLeftPoint();
|
||||
@@ -247,7 +248,7 @@ void LayoutNode::scoreCursorInDescendantsVertically (
|
||||
}
|
||||
if (layoutIsUnderOrAbove || layoutContains) {
|
||||
for (LayoutNode * c : children()) {
|
||||
c->scoreCursorInDescendantsVertically(direction, cursor, shouldRecomputeLayout, childResult, castedResultPosition, resultScore);
|
||||
c->scoreCursorInDescendantsVertically(direction, cursor, shouldRecomputeLayout, childResult, castedResultPosition, resultScore, forSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ void MatrixLayoutNode::removeGreySquares() {
|
||||
|
||||
// LayoutNode
|
||||
|
||||
void MatrixLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void MatrixLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
int childIndex = indexOfChild(cursor->layoutNode());
|
||||
if (childIndex >= 0
|
||||
&& cursor->position() == LayoutCursor::Position::Left
|
||||
@@ -54,10 +54,10 @@ void MatrixLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomp
|
||||
cursor->setLayoutNode(lastChild);
|
||||
return;
|
||||
}
|
||||
GridLayoutNode::moveCursorLeft(cursor, shouldRecomputeLayout);
|
||||
GridLayoutNode::moveCursorLeft(cursor, shouldRecomputeLayout, forSelection);
|
||||
}
|
||||
|
||||
void MatrixLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void MatrixLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == this
|
||||
&& cursor->position() == LayoutCursor::Position::Left)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ void MatrixLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecom
|
||||
return;
|
||||
|
||||
}
|
||||
GridLayoutNode::moveCursorRight(cursor, shouldRecomputeLayout);
|
||||
GridLayoutNode::moveCursorRight(cursor, shouldRecomputeLayout, forSelection);
|
||||
}
|
||||
|
||||
void MatrixLayoutNode::willAddSiblingToEmptyChildAtIndex(int childIndex) {
|
||||
@@ -182,7 +182,7 @@ KDPoint MatrixLayoutNode::positionOfChild(LayoutNode * l) {
|
||||
return GridLayoutNode::positionOfChild(l).translatedBy(KDPoint(KDPoint(SquareBracketLayoutNode::BracketWidth(), SquareBracketLayoutNode::k_lineThickness)));
|
||||
}
|
||||
|
||||
void MatrixLayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void MatrixLayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
MatrixLayout thisRef = MatrixLayout(this);
|
||||
bool shouldRemoveGreySquares = false;
|
||||
int firstIndex = direction == VerticalDirection::Up ? 0 : numberOfChildren() - m_numberOfColumns;
|
||||
@@ -199,7 +199,7 @@ void MatrixLayoutNode::moveCursorVertically(VerticalDirection direction, LayoutC
|
||||
}
|
||||
i++;
|
||||
}
|
||||
GridLayoutNode::moveCursorVertically(direction, cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
GridLayoutNode::moveCursorVertically(direction, cursor, shouldRecomputeLayout, equivalentPositionVisited, forSelection);
|
||||
if (cursor->isDefined() && shouldRemoveGreySquares) {
|
||||
assert(thisRef.hasGreySquares());
|
||||
thisRef.removeGreySquares();
|
||||
|
||||
@@ -32,7 +32,7 @@ bool NthRootLayoutNode::isSquareRoot() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void NthRootLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void NthRootLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == radicandLayout()
|
||||
&& cursor->position() == LayoutCursor::Position::Left)
|
||||
{
|
||||
@@ -67,7 +67,7 @@ void NthRootLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecom
|
||||
}
|
||||
}
|
||||
|
||||
void NthRootLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void NthRootLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == radicandLayout()
|
||||
&& cursor->position() == LayoutCursor::Position::Right)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ void NthRootLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldReco
|
||||
}
|
||||
}
|
||||
|
||||
void NthRootLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void NthRootLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (indexLayout() != nullptr
|
||||
&& cursor->isEquivalentTo(LayoutCursor(radicandLayout(), LayoutCursor::Position::Left)))
|
||||
{
|
||||
@@ -123,7 +123,7 @@ void NthRootLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecompu
|
||||
LayoutNode::moveCursorUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
void NthRootLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void NthRootLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (indexLayout() != nullptr
|
||||
&& cursor->layoutNode()->hasAncestor(indexLayout(), true))
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Poincare {
|
||||
|
||||
static inline KDCoordinate maxCoordinate(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; }
|
||||
|
||||
void SequenceLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void SequenceLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == upperBoundLayout())
|
||||
{
|
||||
assert(cursor->position() == LayoutCursor::Position::Left);
|
||||
@@ -55,7 +55,7 @@ void SequenceLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldReco
|
||||
}
|
||||
}
|
||||
|
||||
void SequenceLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void SequenceLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == lowerBoundLayout()
|
||||
|| cursor->layoutNode() == upperBoundLayout())
|
||||
{
|
||||
@@ -94,7 +94,7 @@ void SequenceLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRec
|
||||
}
|
||||
}
|
||||
|
||||
void SequenceLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void SequenceLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (cursor->layoutNode()->hasAncestor(lowerBoundLayout(), true) || cursor->layoutNode()->hasAncestor(variableLayout(), true)) {
|
||||
// If the cursor is inside the lower bound or inside the variable name, move it to the upper bound
|
||||
upperBoundLayout()->moveCursorUpInDescendants(cursor, shouldRecomputeLayout);
|
||||
@@ -114,7 +114,7 @@ void SequenceLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomp
|
||||
LayoutNode::moveCursorUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
void SequenceLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void SequenceLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (cursor->layoutNode()->hasAncestor(upperBoundLayout(), true)) {
|
||||
// If the cursor is inside the upper bound, move it to the lower bound
|
||||
lowerBoundLayout()->moveCursorDownInDescendants(cursor, shouldRecomputeLayout);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Poincare {
|
||||
|
||||
static inline int minInt(int x, int y) { return x < y ? x : y; }
|
||||
|
||||
void VerticalOffsetLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void VerticalOffsetLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == indiceLayout()
|
||||
&& cursor->position() == LayoutCursor::Position::Left)
|
||||
{
|
||||
@@ -33,7 +33,7 @@ void VerticalOffsetLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shou
|
||||
}
|
||||
}
|
||||
|
||||
void VerticalOffsetLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
void VerticalOffsetLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool forSelection) {
|
||||
if (cursor->layoutNode() == indiceLayout()
|
||||
&& cursor->position() == LayoutCursor::Position::Right)
|
||||
{
|
||||
@@ -55,7 +55,7 @@ void VerticalOffsetLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * sho
|
||||
}
|
||||
}
|
||||
|
||||
void VerticalOffsetLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void VerticalOffsetLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (m_position == Position::Superscript) {
|
||||
// Case: Superscript.
|
||||
if (cursor->isEquivalentTo(LayoutCursor(this, LayoutCursor::Position::Right))) {
|
||||
@@ -83,7 +83,7 @@ void VerticalOffsetLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * should
|
||||
LayoutNode::moveCursorUp(cursor, shouldRecomputeLayout, equivalentPositionVisited);
|
||||
}
|
||||
|
||||
void VerticalOffsetLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) {
|
||||
void VerticalOffsetLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited, bool forSelection) {
|
||||
if (m_position == Position::Subscript) {
|
||||
// Case: Subscript.
|
||||
if (cursor->isEquivalentTo(LayoutCursor(this, LayoutCursor::Position::Right))) {
|
||||
|
||||
Reference in New Issue
Block a user