From 71d7225b7de7940a3b6709637563e2ff78a080e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 9 Mar 2017 11:20:03 +0100 Subject: [PATCH] [poincare] In parenthesis layout, add an extern margin to seperate 'm' and '(' when consecutive Change-Id: Idc0490e3925081c28babf4067a0e43cf764ec132 --- poincare/src/layout/parenthesis_layout.cpp | 16 ++++++++-------- poincare/src/layout/parenthesis_layout.h | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/poincare/src/layout/parenthesis_layout.cpp b/poincare/src/layout/parenthesis_layout.cpp index e6916816b..e04e7e109 100644 --- a/poincare/src/layout/parenthesis_layout.cpp +++ b/poincare/src/layout/parenthesis_layout.cpp @@ -62,25 +62,25 @@ KDColor s_parenthesisWorkingBuffer[ParenthesisLayout::k_parenthesisCurveHeight*P void ParenthesisLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { KDSize operandSize = m_operandLayout->size(); - KDRect frame(p.x(), p.y(), k_parenthesisCurveWidth, k_parenthesisCurveHeight); + KDRect frame(p.x()+k_externWidthMargin, p.y(), k_parenthesisCurveWidth, k_parenthesisCurveHeight); ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topLeftCurve, (KDColor *)s_parenthesisWorkingBuffer); - frame = KDRect(p.x(), p.y() + operandSize.height() - k_parenthesisCurveHeight, + frame = KDRect(p.x()+k_externWidthMargin, p.y() + operandSize.height() - k_parenthesisCurveHeight, k_parenthesisCurveWidth, k_parenthesisCurveHeight); ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomLeftCurve, (KDColor *)s_parenthesisWorkingBuffer); - frame = KDRect(p.x() + operandSize.width() + 2*k_widthMargin + 2*k_lineThickness - k_parenthesisCurveWidth, p.y(), + frame = KDRect(p.x()+k_externWidthMargin + operandSize.width() + 2*k_widthMargin + 2*k_lineThickness - k_parenthesisCurveWidth, p.y(), k_parenthesisCurveWidth, k_parenthesisCurveHeight); ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topRightCurve, (KDColor *)s_parenthesisWorkingBuffer); - frame = KDRect(p.x() + operandSize.width() + 2*k_widthMargin + 2*k_lineThickness - k_parenthesisCurveWidth, p.y() + operandSize.height() - k_parenthesisCurveHeight, + frame = KDRect(p.x() +k_externWidthMargin + operandSize.width() + 2*k_widthMargin + 2*k_lineThickness - k_parenthesisCurveWidth, p.y() + operandSize.height() - k_parenthesisCurveHeight, k_parenthesisCurveWidth, k_parenthesisCurveHeight); ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomRightCurve, (KDColor *)s_parenthesisWorkingBuffer); - ctx->fillRect(KDRect(p.x(), p.y()+k_parenthesisCurveHeight, k_lineThickness, m_operandLayout->size().height() - 2*k_parenthesisCurveHeight), expressionColor); - ctx->fillRect(KDRect(p.x()+operandSize.width()+2*k_widthMargin+k_lineThickness, p.y()+k_parenthesisCurveHeight, k_lineThickness, m_operandLayout->size().height()- 2*k_parenthesisCurveHeight), expressionColor); + ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y()+k_parenthesisCurveHeight, k_lineThickness, m_operandLayout->size().height() - 2*k_parenthesisCurveHeight), expressionColor); + ctx->fillRect(KDRect(p.x()+k_externWidthMargin+operandSize.width()+2*k_widthMargin+k_lineThickness, p.y()+k_parenthesisCurveHeight, k_lineThickness, m_operandLayout->size().height()- 2*k_parenthesisCurveHeight), expressionColor); } KDSize ParenthesisLayout::computeSize() { KDSize operandSize = m_operandLayout->size(); - return KDSize(operandSize.width() + 2*k_widthMargin + 2*k_lineThickness, operandSize.height()); + return KDSize(operandSize.width() + 2*k_widthMargin + 2*k_lineThickness+2*k_externWidthMargin, operandSize.height()); } ExpressionLayout * ParenthesisLayout::child(uint16_t index) { @@ -91,7 +91,7 @@ ExpressionLayout * ParenthesisLayout::child(uint16_t index) { } KDPoint ParenthesisLayout::positionOfChild(ExpressionLayout * child) { - return KDPoint(k_widthMargin+k_lineThickness, 0); + return KDPoint(k_widthMargin+k_lineThickness+k_externWidthMargin, 0); } } diff --git a/poincare/src/layout/parenthesis_layout.h b/poincare/src/layout/parenthesis_layout.h index 792057336..565123359 100644 --- a/poincare/src/layout/parenthesis_layout.h +++ b/poincare/src/layout/parenthesis_layout.h @@ -18,6 +18,7 @@ protected: ExpressionLayout * child(uint16_t index) override; KDPoint positionOfChild(ExpressionLayout * child) override; private: + constexpr static KDCoordinate k_externWidthMargin = 1; constexpr static KDCoordinate k_widthMargin = 5; constexpr static KDCoordinate k_lineThickness = 1; ExpressionLayout * m_operandLayout;