diff --git a/poincare/include/poincare/binomial_coefficient_layout.h b/poincare/include/poincare/binomial_coefficient_layout.h index 9a6136616..6f39472e3 100644 --- a/poincare/include/poincare/binomial_coefficient_layout.h +++ b/poincare/include/poincare/binomial_coefficient_layout.h @@ -39,7 +39,7 @@ protected: KDPoint positionOfChild(LayoutNode * child) override; private: KDCoordinate knHeight() { return nLayout()->layoutSize().height() + GridLayoutNode::k_gridEntryMargin + kLayout()->layoutSize().height(); } - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; LayoutNode * nLayout() { return childAtIndex(0); } LayoutNode * kLayout() { return childAtIndex(1); } }; diff --git a/poincare/include/poincare/bracket_pair_layout.h b/poincare/include/poincare/bracket_pair_layout.h index 7505596c8..259a95bb8 100644 --- a/poincare/include/poincare/bracket_pair_layout.h +++ b/poincare/include/poincare/bracket_pair_layout.h @@ -49,7 +49,7 @@ private: virtual KDCoordinate verticalExternMargin() const { return k_verticalExternMargin; } virtual bool renderTopBar() const { return true; } virtual bool renderBottomBar() const { return true; } - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; }; } diff --git a/poincare/include/poincare/code_point_layout.h b/poincare/include/poincare/code_point_layout.h index d86fd1712..3af1c1975 100644 --- a/poincare/include/poincare/code_point_layout.h +++ b/poincare/include/poincare/code_point_layout.h @@ -60,7 +60,7 @@ protected: } private: - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; bool isMultiplicationCodePoint() const; bool protectedIsIdenticalTo(Layout l) override; CodePoint m_codePoint; diff --git a/poincare/include/poincare/condensed_sum_layout.h b/poincare/include/poincare/condensed_sum_layout.h index 7724eb7ea..7c340c9ff 100644 --- a/poincare/include/poincare/condensed_sum_layout.h +++ b/poincare/include/poincare/condensed_sum_layout.h @@ -47,7 +47,7 @@ protected: KDCoordinate computeBaseline() override; KDPoint positionOfChild(LayoutNode * child) override; private: - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override {} + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override {} LayoutNode * baseLayout() { return childAtIndex(0); } LayoutNode * subscriptLayout() { return childAtIndex(1); } LayoutNode * superscriptLayout() { return childAtIndex(2); } diff --git a/poincare/include/poincare/conjugate_layout.h b/poincare/include/poincare/conjugate_layout.h index 4f7747d47..1fa23ae15 100644 --- a/poincare/include/poincare/conjugate_layout.h +++ b/poincare/include/poincare/conjugate_layout.h @@ -38,7 +38,7 @@ private: constexpr static KDCoordinate k_overlineVerticalMargin = 1; LayoutNode * childLayout() { return childAtIndex(0); } bool willReplaceChild(LayoutNode * oldChild, LayoutNode * newChild, LayoutCursor * cursor, bool force) override; - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; }; class ConjugateLayout final : public Layout { diff --git a/poincare/include/poincare/empty_layout.h b/poincare/include/poincare/empty_layout.h index 16aa8962b..b29d63c08 100644 --- a/poincare/include/poincare/empty_layout.h +++ b/poincare/include/poincare/empty_layout.h @@ -65,7 +65,7 @@ private: // LayoutNode void moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) override; bool willAddSibling(LayoutCursor * cursor, LayoutNode * sibling, bool moveCursor) override; - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) 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; bool m_isVisible; diff --git a/poincare/include/poincare/fraction_layout.h b/poincare/include/poincare/fraction_layout.h index 48593f078..d8cb07a46 100644 --- a/poincare/include/poincare/fraction_layout.h +++ b/poincare/include/poincare/fraction_layout.h @@ -54,7 +54,7 @@ protected: private: constexpr static KDCoordinate k_fractionLineMargin = 2; constexpr static KDCoordinate k_fractionLineHeight = 1; - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; LayoutNode * numeratorLayout() { return childAtIndex(0); } LayoutNode * denominatorLayout() { return childAtIndex(1); } }; diff --git a/poincare/include/poincare/grid_layout.h b/poincare/include/poincare/grid_layout.h index f58fc3bc7..6d81e5304 100644 --- a/poincare/include/poincare/grid_layout.h +++ b/poincare/include/poincare/grid_layout.h @@ -86,7 +86,7 @@ private: KDCoordinate height() const; KDCoordinate columnWidth(int j) const; KDCoordinate width() const; - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override {} + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override {} }; class GridLayout : public Layout { diff --git a/poincare/include/poincare/horizontal_layout.h b/poincare/include/poincare/horizontal_layout.h index 0e4cf338f..e8842f556 100644 --- a/poincare/include/poincare/horizontal_layout.h +++ b/poincare/include/poincare/horizontal_layout.h @@ -62,7 +62,7 @@ private: bool willRemoveChild(LayoutNode * l, LayoutCursor * cursor, bool force) override; void didRemoveChildAtIndex(int index, LayoutCursor * cursor, bool force) override; bool willReplaceChild(LayoutNode * oldChild, LayoutNode * newChild, LayoutCursor * cursor, bool force) override; - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override {} + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; // See comment on NAryExpressionNode uint16_t m_numberOfChildren; }; diff --git a/poincare/include/poincare/integral_layout.h b/poincare/include/poincare/integral_layout.h index 188677460..437c04b2e 100644 --- a/poincare/include/poincare/integral_layout.h +++ b/poincare/include/poincare/integral_layout.h @@ -56,7 +56,7 @@ private: LayoutNode * differentialLayout() { return childAtIndex(k_differentialLayoutIndex); } // dx LayoutNode * lowerBoundLayout() { return childAtIndex(2); } // a LayoutNode * upperBoundLayout() { return childAtIndex(3); } // b - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; }; class IntegralLayout final : public Layout { diff --git a/poincare/include/poincare/layout.h b/poincare/include/poincare/layout.h index 94c5af639..ce2894900 100644 --- a/poincare/include/poincare/layout.h +++ b/poincare/include/poincare/layout.h @@ -34,8 +34,8 @@ public: void draw(KDContext * ctx, KDPoint p, KDColor expressionColor = KDColorBlack, KDColor backgroundColor = KDColorWhite, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = Palette::Select) { return node()->draw(ctx, p, expressionColor, backgroundColor, selectionStart, selectionEnd, selectionColor); } - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { - return node()->render(ctx, p, expressionColor, backgroundColor); + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) { + return node()->render(ctx, p, expressionColor, backgroundColor, selectionStart, selectionEnd, selectionColor); } KDSize layoutSize() { return node()->layoutSize(); } KDPoint absoluteOrigin() { return node()->absoluteOrigin(); } diff --git a/poincare/include/poincare/layout_node.h b/poincare/include/poincare/layout_node.h index 12d8a62f2..03717277f 100644 --- a/poincare/include/poincare/layout_node.h +++ b/poincare/include/poincare/layout_node.h @@ -171,7 +171,7 @@ private: LayoutNode ** childResult, void * resultPosition, int * resultScore); - virtual void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) = 0; + 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); }; diff --git a/poincare/include/poincare/left_parenthesis_layout.h b/poincare/include/poincare/left_parenthesis_layout.h index f552a16f7..7f535042e 100644 --- a/poincare/include/poincare/left_parenthesis_layout.h +++ b/poincare/include/poincare/left_parenthesis_layout.h @@ -32,7 +32,7 @@ public: #endif protected: - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; }; class LeftParenthesisLayout final : public Layout { diff --git a/poincare/include/poincare/left_square_bracket_layout.h b/poincare/include/poincare/left_square_bracket_layout.h index 6789a741d..99630a785 100644 --- a/poincare/include/poincare/left_square_bracket_layout.h +++ b/poincare/include/poincare/left_square_bracket_layout.h @@ -27,7 +27,7 @@ public: #endif protected: - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; }; class LeftSquareBracketLayout final : public Layout { diff --git a/poincare/include/poincare/matrix_layout.h b/poincare/include/poincare/matrix_layout.h index c39c10047..9f7a5b430 100644 --- a/poincare/include/poincare/matrix_layout.h +++ b/poincare/include/poincare/matrix_layout.h @@ -53,7 +53,7 @@ private: bool hasGreySquares() const; // LayoutNode - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; void didReplaceChildAtIndex(int index, LayoutCursor * cursor, bool force) override; }; diff --git a/poincare/include/poincare/nth_root_layout.h b/poincare/include/poincare/nth_root_layout.h index 2af308d5b..fa91328da 100644 --- a/poincare/include/poincare/nth_root_layout.h +++ b/poincare/include/poincare/nth_root_layout.h @@ -53,7 +53,7 @@ private: constexpr static KDCoordinate k_widthMargin = 2; constexpr static KDCoordinate k_radixLineThickness = 1; KDSize adjustedIndexSize(); - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) 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; LayoutNode * radicandLayout() { return childAtIndex(0); } LayoutNode * indexLayout() { return m_hasIndex ? childAtIndex(1) : nullptr; } diff --git a/poincare/include/poincare/product_layout.h b/poincare/include/poincare/product_layout.h index fa78f0b1a..85035cfe8 100644 --- a/poincare/include/poincare/product_layout.h +++ b/poincare/include/poincare/product_layout.h @@ -22,7 +22,7 @@ public: #endif protected: - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; private: constexpr static KDCoordinate k_lineThickness = 1; }; diff --git a/poincare/include/poincare/right_parenthesis_layout.h b/poincare/include/poincare/right_parenthesis_layout.h index 42c81295c..fac6ad338 100644 --- a/poincare/include/poincare/right_parenthesis_layout.h +++ b/poincare/include/poincare/right_parenthesis_layout.h @@ -33,7 +33,7 @@ public: #endif protected: - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; }; class RightParenthesisLayout final : public Layout { diff --git a/poincare/include/poincare/right_square_bracket_layout.h b/poincare/include/poincare/right_square_bracket_layout.h index 1689e7782..62fabddb1 100644 --- a/poincare/include/poincare/right_square_bracket_layout.h +++ b/poincare/include/poincare/right_square_bracket_layout.h @@ -27,7 +27,7 @@ public: #endif protected: - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; }; class RightSquareBracketLayout final : public Layout { diff --git a/poincare/include/poincare/sequence_layout.h b/poincare/include/poincare/sequence_layout.h index 011cb8ea5..4d1942317 100644 --- a/poincare/include/poincare/sequence_layout.h +++ b/poincare/include/poincare/sequence_layout.h @@ -43,7 +43,7 @@ protected: LayoutNode * variableLayout() { return childAtIndex(k_variableLayoutIndex); } LayoutNode * lowerBoundLayout() { return childAtIndex(2); } LayoutNode * upperBoundLayout() { return childAtIndex(3); } - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; private: static constexpr int k_argumentLayoutIndex = 0; static constexpr int k_variableLayoutIndex = 1; diff --git a/poincare/include/poincare/sum_layout.h b/poincare/include/poincare/sum_layout.h index ee040c522..15a15fbff 100644 --- a/poincare/include/poincare/sum_layout.h +++ b/poincare/include/poincare/sum_layout.h @@ -22,7 +22,7 @@ public: #endif private: - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; + void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart = nullptr, Layout * selectionEnd = nullptr, KDColor selectionColor = KDColorRed) override; }; class SumLayout final : public Layout { diff --git a/poincare/include/poincare/vertical_offset_layout.h b/poincare/include/poincare/vertical_offset_layout.h index 062dfb0ae..43b4b4163 100644 --- a/poincare/include/poincare/vertical_offset_layout.h +++ b/poincare/include/poincare/vertical_offset_layout.h @@ -52,7 +52,7 @@ private: constexpr static KDCoordinate k_indiceHeight = 5; constexpr static KDCoordinate k_separationMargin = 5; bool willAddSibling(LayoutCursor * cursor, LayoutNode * sibling, bool moveCursor) override; - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) 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; LayoutNode * indiceLayout() { return childAtIndex(0); } LayoutNode * baseLayout(); diff --git a/poincare/src/binomial_coefficient_layout.cpp b/poincare/src/binomial_coefficient_layout.cpp index 839d2cd55..6b3053d2e 100644 --- a/poincare/src/binomial_coefficient_layout.cpp +++ b/poincare/src/binomial_coefficient_layout.cpp @@ -98,7 +98,7 @@ KDPoint BinomialCoefficientLayoutNode::positionOfChild(LayoutNode * child) { return KDPoint(horizontalCenter - kLayout()->layoutSize().width()/2, knHeight() - kLayout()->layoutSize().height()); } -void BinomialCoefficientLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void BinomialCoefficientLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { // Render the parentheses. KDCoordinate childHeight = knHeight(); KDCoordinate rightParenthesisPointX = maxCoordinate(nLayout()->layoutSize().width(), kLayout()->layoutSize().width()) + LeftParenthesisLayoutNode::ParenthesisWidth(); diff --git a/poincare/src/bracket_pair_layout.cpp b/poincare/src/bracket_pair_layout.cpp index a7d751e1a..a919603cf 100644 --- a/poincare/src/bracket_pair_layout.cpp +++ b/poincare/src/bracket_pair_layout.cpp @@ -111,7 +111,7 @@ int BracketPairLayoutNode::serialize(char * buffer, int bufferSize, Preferences: return numberOfChar; } -void BracketPairLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void BracketPairLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { KDSize childSize = childLayout()->layoutSize(); KDCoordinate verticalBarHeight = childSize.height() + 2*k_verticalMargin; ctx->fillRect(KDRect(p.x()+externWidthMargin(), p.y()+verticalExternMargin(), k_lineThickness, verticalBarHeight), expressionColor); diff --git a/poincare/src/code_point_layout.cpp b/poincare/src/code_point_layout.cpp index 606310393..8eeff264a 100644 --- a/poincare/src/code_point_layout.cpp +++ b/poincare/src/code_point_layout.cpp @@ -103,7 +103,7 @@ KDCoordinate CodePointLayoutNode::computeBaseline() { return m_font->glyphSize().height()/2; } -void CodePointLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void CodePointLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { constexpr int bufferSize = sizeof(CodePoint)/sizeof(char) + 1; // Null-terminating char char buffer[bufferSize]; SerializationHelper::CodePoint(buffer, bufferSize, m_codePoint); diff --git a/poincare/src/conjugate_layout.cpp b/poincare/src/conjugate_layout.cpp index 63e0b2432..fbf60948c 100644 --- a/poincare/src/conjugate_layout.cpp +++ b/poincare/src/conjugate_layout.cpp @@ -81,7 +81,7 @@ KDPoint ConjugateLayoutNode::positionOfChild(LayoutNode * child) { k_overlineWidth + k_overlineVerticalMargin); } -void ConjugateLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void ConjugateLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { ctx->fillRect( KDRect( p.x() + Metric::FractionAndConjugateHorizontalMargin, diff --git a/poincare/src/empty_layout.cpp b/poincare/src/empty_layout.cpp index b89329cbc..03f1ccc08 100644 --- a/poincare/src/empty_layout.cpp +++ b/poincare/src/empty_layout.cpp @@ -86,7 +86,7 @@ bool EmptyLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode * sibling } } -void EmptyLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void EmptyLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { if (m_isVisible) { KDColor fillColor = m_color == Color::Yellow ? Palette::YellowDark : Palette::GreyBright; ctx->fillRect(KDRect(p.x()+(m_margins ? k_marginWidth : 0), p.y()+(m_margins ? k_marginHeight : 0), width(), height()), fillColor); diff --git a/poincare/src/fraction_layout.cpp b/poincare/src/fraction_layout.cpp index ab9bb044d..3a7cb32d2 100644 --- a/poincare/src/fraction_layout.cpp +++ b/poincare/src/fraction_layout.cpp @@ -188,7 +188,7 @@ KDPoint FractionLayoutNode::positionOfChild(LayoutNode * child) { return KDPoint(x, y); } -void FractionLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void FractionLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { KDCoordinate fractionLineY = p.y() + numeratorLayout()->layoutSize().height() + k_fractionLineMargin; ctx->fillRect(KDRect(p.x()+Metric::FractionAndConjugateHorizontalMargin, fractionLineY, layoutSize().width()-2*Metric::FractionAndConjugateHorizontalMargin, k_fractionLineHeight), expressionColor); } diff --git a/poincare/src/horizontal_layout.cpp b/poincare/src/horizontal_layout.cpp index 510df3d98..8998adb96 100644 --- a/poincare/src/horizontal_layout.cpp +++ b/poincare/src/horizontal_layout.cpp @@ -416,6 +416,43 @@ bool HorizontalLayoutNode::willReplaceChild(LayoutNode * oldChild, LayoutNode * return true; } +void HorizontalLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { + // Fill the background + KDSize s = layoutSize(); + ctx->fillRect(KDRect(p, s), backgroundColor); + // Fill the selection background + HorizontalLayout thisLayout = HorizontalLayout(this); + bool childrenAreSelected = selectionStart != nullptr && selectionEnd != nullptr + && !selectionStart->isUninitialized() && !selectionStart->isUninitialized() + && thisLayout.hasChild(*selectionStart); + if (childrenAreSelected) { + assert(thisLayout.hasChild(*selectionEnd)); + + // Compute the positions + KDCoordinate selectionXStart = positionOfChild(selectionStart->node()).x(); + KDCoordinate selectionXEnd = positionOfChild(selectionEnd->node()).x() + selectionEnd->layoutSize().width(); + KDCoordinate drawX = p.x() + selectionXStart; + KDCoordinate drawWidth = selectionXEnd - selectionXStart; + + // Compute the height + int firstSelectedNodeIndex = thisLayout.indexOfChild(*selectionStart); + int secondSelectedNodeIndex = thisLayout.indexOfChild(*selectionEnd); + if (firstSelectedNodeIndex == 0 && secondSelectedNodeIndex == numberOfChildren() - 1) { + ctx->fillRect(KDRect(KDPoint(drawX, p.y()), KDSize(drawWidth, s.height())), selectionColor); + return; + } + KDCoordinate maxUnderBaseline = 0; + KDCoordinate maxAboveBaseline = 0; + for (int i = firstSelectedNodeIndex; i <= secondSelectedNodeIndex; i++) { + Layout childi = thisLayout.childAtIndex(i); + KDSize childSize = childi.layoutSize(); + maxUnderBaseline = maxCoordinate(maxUnderBaseline, childSize.height() - childi.baseline()); + maxAboveBaseline = maxCoordinate(maxAboveBaseline, childi.baseline()); + } + ctx->fillRect(KDRect(KDPoint(drawX, p.y() + baseline() - maxAboveBaseline), KDSize(drawWidth, maxUnderBaseline + maxAboveBaseline)), selectionColor); + } +} + // HorizontalLayout void HorizontalLayout::addOrMergeChildAtIndex(Layout l, int index, bool removeEmptyChildren, LayoutCursor * cursor) { diff --git a/poincare/src/integral_layout.cpp b/poincare/src/integral_layout.cpp index 8987329c4..2927d97ab 100644 --- a/poincare/src/integral_layout.cpp +++ b/poincare/src/integral_layout.cpp @@ -248,7 +248,7 @@ KDPoint IntegralLayoutNode::positionOfChild(LayoutNode * child) { return KDPoint(x,y); } -void IntegralLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void IntegralLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { KDSize integrandSize = integrandLayout()->layoutSize(); KDSize differentialSize = differentialLayout()->layoutSize(); KDSize upperBoundSize = upperBoundLayout()->layoutSize(); diff --git a/poincare/src/layout_cursor.cpp b/poincare/src/layout_cursor.cpp index 04c3a1e47..809c94a54 100644 --- a/poincare/src/layout_cursor.cpp +++ b/poincare/src/layout_cursor.cpp @@ -85,6 +85,7 @@ void LayoutCursor::select(MoveDirection direction, bool * shouldRecomputeLayout, } else { selectUpDown(direction == MoveDirection::Up, shouldRecomputeLayout, selection); } + *shouldRecomputeLayout = true; } /* Layout modification */ diff --git a/poincare/src/layout_node.cpp b/poincare/src/layout_node.cpp index a2b8677c1..d53aaaa5c 100644 --- a/poincare/src/layout_node.cpp +++ b/poincare/src/layout_node.cpp @@ -27,7 +27,7 @@ void LayoutNode::draw(KDContext * ctx, KDPoint p, KDColor expressionColor, KDCol KDColor backColor = isSelected ? selectionColor : backgroundColor; KDPoint renderingAbsoluteOrigin = absoluteOrigin().translatedBy(p); ctx->fillRect(KDRect(renderingAbsoluteOrigin, layoutSize()), backColor); - render(ctx, renderingAbsoluteOrigin, expressionColor, backColor); + render(ctx, renderingAbsoluteOrigin, expressionColor, backColor, selectionStart, selectionEnd, selectionColor); if (!isSelected) { for (LayoutNode * l : children()) { l->draw(ctx, p, expressionColor, backgroundColor, selectionStart, selectionEnd, selectionColor); diff --git a/poincare/src/left_parenthesis_layout.cpp b/poincare/src/left_parenthesis_layout.cpp index 8ddd2dea5..5297a2eff 100644 --- a/poincare/src/left_parenthesis_layout.cpp +++ b/poincare/src/left_parenthesis_layout.cpp @@ -55,7 +55,7 @@ bool LeftParenthesisLayoutNode::isCollapsable(int * numberOfOpenParenthesis, boo return true; } -void LeftParenthesisLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void LeftParenthesisLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { RenderWithChildHeight(ParenthesisLayoutNode::ChildHeightGivenLayoutHeight(layoutSize().height()), ctx, p, expressionColor, backgroundColor); } diff --git a/poincare/src/left_square_bracket_layout.cpp b/poincare/src/left_square_bracket_layout.cpp index 2a8d85c92..0bea360ba 100644 --- a/poincare/src/left_square_bracket_layout.cpp +++ b/poincare/src/left_square_bracket_layout.cpp @@ -2,7 +2,7 @@ namespace Poincare { -void LeftSquareBracketLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void LeftSquareBracketLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y(), k_lineThickness, childHeight()), expressionColor); ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y(), k_bracketWidth, k_lineThickness), expressionColor); ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y() + childHeight(), k_bracketWidth, k_lineThickness), expressionColor); diff --git a/poincare/src/matrix_layout.cpp b/poincare/src/matrix_layout.cpp index ad9101422..921afea40 100644 --- a/poincare/src/matrix_layout.cpp +++ b/poincare/src/matrix_layout.cpp @@ -308,7 +308,7 @@ bool MatrixLayoutNode::hasGreySquares() const { return false; } -void MatrixLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void MatrixLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { BracketPairLayoutNode::RenderWithChildSize(gridSize(), ctx, p, expressionColor, backgroundColor); } diff --git a/poincare/src/nth_root_layout.cpp b/poincare/src/nth_root_layout.cpp index b04f8168a..06e5480f4 100644 --- a/poincare/src/nth_root_layout.cpp +++ b/poincare/src/nth_root_layout.cpp @@ -207,7 +207,7 @@ KDSize NthRootLayoutNode::adjustedIndexSize() { KDSize(maxCoordinate(k_leftRadixWidth, indexLayout()->layoutSize().width()), indexLayout()->layoutSize().height()); } -void NthRootLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void NthRootLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { KDSize radicandSize = radicandLayout()->layoutSize(); KDSize indexSize = adjustedIndexSize(); KDColor workingBuffer[k_leftRadixWidth*k_leftRadixHeight]; diff --git a/poincare/src/product_layout.cpp b/poincare/src/product_layout.cpp index 210ea88b6..6333c6735 100644 --- a/poincare/src/product_layout.cpp +++ b/poincare/src/product_layout.cpp @@ -10,7 +10,7 @@ int ProductLayoutNode::serialize(char * buffer, int bufferSize, Preferences::Pri return SequenceLayoutNode::writeDerivedClassInBuffer("product", buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits); } -void ProductLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void ProductLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { // Compute sizes. KDSize upperBoundSize = upperBoundLayout()->layoutSize(); KDSize lowerBoundNEqualsSize = lowerBoundSizeWithVariableEquals(); diff --git a/poincare/src/right_parenthesis_layout.cpp b/poincare/src/right_parenthesis_layout.cpp index d38345f20..9f4a12eaa 100644 --- a/poincare/src/right_parenthesis_layout.cpp +++ b/poincare/src/right_parenthesis_layout.cpp @@ -55,7 +55,7 @@ bool RightParenthesisLayoutNode::isCollapsable(int * numberOfOpenParenthesis, bo return true; } -void RightParenthesisLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void RightParenthesisLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { RenderWithChildHeight(ParenthesisLayoutNode::ChildHeightGivenLayoutHeight(layoutSize().height()), ctx, p, expressionColor, backgroundColor); } diff --git a/poincare/src/right_square_bracket_layout.cpp b/poincare/src/right_square_bracket_layout.cpp index cd1608a02..c5deb3add 100644 --- a/poincare/src/right_square_bracket_layout.cpp +++ b/poincare/src/right_square_bracket_layout.cpp @@ -2,7 +2,7 @@ namespace Poincare { -void RightSquareBracketLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void RightSquareBracketLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { ctx->fillRect(KDRect(p.x()+k_widthMargin, p.y(), k_lineThickness, childHeight()), expressionColor); ctx->fillRect(KDRect(p.x()+k_widthMargin-k_bracketWidth+1, p.y(), k_bracketWidth, k_lineThickness), expressionColor); ctx->fillRect(KDRect(p.x()+k_widthMargin-k_bracketWidth+1, p.y() + childHeight(), k_bracketWidth, k_lineThickness), expressionColor); diff --git a/poincare/src/sequence_layout.cpp b/poincare/src/sequence_layout.cpp index ab9efca71..0e8593deb 100644 --- a/poincare/src/sequence_layout.cpp +++ b/poincare/src/sequence_layout.cpp @@ -244,7 +244,7 @@ int SequenceLayoutNode::writeDerivedClassInBuffer(const char * operatorName, cha return numberOfChar; } -void SequenceLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void SequenceLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { // Render the "=" KDSize variableSize = variableLayout()->layoutSize(); KDPoint equalPosition = positionOfChild(variableLayout()).translatedBy(KDPoint(variableSize.width(), variableLayout()->baseline()-k_font->stringSize(k_equal).height()/2)); diff --git a/poincare/src/sum_layout.cpp b/poincare/src/sum_layout.cpp index b6ddec112..9d7cda716 100644 --- a/poincare/src/sum_layout.cpp +++ b/poincare/src/sum_layout.cpp @@ -29,7 +29,7 @@ int SumLayoutNode::serialize(char * buffer, int bufferSize, Preferences::PrintFl return SequenceLayoutNode::writeDerivedClassInBuffer("sum", buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits); } -void SumLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { +void SumLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor, Layout * selectionStart, Layout * selectionEnd, KDColor selectionColor) { // Computes sizes. KDSize upperBoundSize = upperBoundLayout()->layoutSize(); KDSize lowerBoundNEqualsSize = lowerBoundSizeWithVariableEquals();