From 3af2f88da72943fbb38e5d80d6f6af04ca94cd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 7 Dec 2017 16:01:41 +0100 Subject: [PATCH] [poincare] Added extern margins on BracketLayout to see the cursor. Change-Id: I32f6d54c2121b4de1d7ae2552239a1e8ac557913 --- poincare/src/layout/bracket_layout.cpp | 22 ++++++++++++++-------- poincare/src/layout/bracket_layout.h | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/poincare/src/layout/bracket_layout.cpp b/poincare/src/layout/bracket_layout.cpp index 32cdb10b0..c185fff75 100644 --- a/poincare/src/layout/bracket_layout.cpp +++ b/poincare/src/layout/bracket_layout.cpp @@ -47,22 +47,26 @@ bool BracketLayout::moveLeft(ExpressionLayoutCursor * cursor) { } void BracketLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { + const KDCoordinate k_widthMargin = widthMargin(); + const KDCoordinate k_externWidthMargin = externWidthMargin(); KDSize operandSize = m_operandLayout->size(); - ctx->fillRect(KDRect(p.x(), p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor); - ctx->fillRect(KDRect(p.x()+operandSize.width()+2*widthMargin()+k_lineThickness, p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor); + ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor); + ctx->fillRect(KDRect(p.x()+k_externWidthMargin+operandSize.width()+2*k_widthMargin+k_lineThickness, p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor); if (renderTopBar()) { - ctx->fillRect(KDRect(p.x(), p.y(), k_bracketWidth, k_lineThickness), expressionColor); - ctx->fillRect(KDRect(p.x()+2*k_lineThickness+operandSize.width()+2*widthMargin()-k_bracketWidth, p.y(), k_bracketWidth, k_lineThickness), expressionColor); + ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y(), k_bracketWidth, k_lineThickness), expressionColor); + ctx->fillRect(KDRect(p.x()+k_externWidthMargin+2*k_lineThickness+operandSize.width()+2*k_widthMargin-k_bracketWidth, p.y(), k_bracketWidth, k_lineThickness), expressionColor); } if (renderBottomBar()) { - ctx->fillRect(KDRect(p.x(), p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor); - ctx->fillRect(KDRect(p.x()+2*k_lineThickness+operandSize.width()+2*widthMargin()-k_bracketWidth, p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor); + ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor); + ctx->fillRect(KDRect(p.x()+k_externWidthMargin+2*k_lineThickness+operandSize.width()+2*k_widthMargin-k_bracketWidth, p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor); } } KDSize BracketLayout::computeSize() { + const KDCoordinate k_widthMargin = widthMargin(); + const KDCoordinate k_externWidthMargin = externWidthMargin(); KDSize operandSize = m_operandLayout->size(); - return KDSize(operandSize.width() + 2*widthMargin() + 2*k_lineThickness, operandSize.height()); + return KDSize(operandSize.width() + 2*k_externWidthMargin + 2*k_widthMargin + 2*k_lineThickness, operandSize.height()); } ExpressionLayout * BracketLayout::child(uint16_t index) { @@ -73,7 +77,9 @@ ExpressionLayout * BracketLayout::child(uint16_t index) { } KDPoint BracketLayout::positionOfChild(ExpressionLayout * child) { - return KDPoint(widthMargin()+k_lineThickness, 0); + const KDCoordinate k_widthMargin = widthMargin(); + const KDCoordinate k_externWidthMargin = externWidthMargin(); + return KDPoint(k_widthMargin+k_externWidthMargin+k_lineThickness, 0); } } diff --git a/poincare/src/layout/bracket_layout.h b/poincare/src/layout/bracket_layout.h index 9016cb803..f110789aa 100644 --- a/poincare/src/layout/bracket_layout.h +++ b/poincare/src/layout/bracket_layout.h @@ -16,6 +16,7 @@ public: BracketLayout& operator=(BracketLayout&& other) = delete; bool moveLeft(ExpressionLayoutCursor * cursor) override; protected: + KDCoordinate externWidthMargin() const { return 2; } virtual KDCoordinate widthMargin() const { return 5; } virtual bool renderTopBar() const { return true; } virtual bool renderBottomBar() const { return true; }