From 136fd779575749ae801dae906776b3b4c8a56dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 9 Mar 2017 09:43:23 +0100 Subject: [PATCH] [poincare] Clean parenthesis layout Change-Id: Iacedeb26c0dd4e7f2fdaa4c75e644c8c699dd745 --- poincare/src/layout/parenthesis_layout.cpp | 27 +++++++++++----------- poincare/src/layout/parenthesis_layout.h | 3 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/poincare/src/layout/parenthesis_layout.cpp b/poincare/src/layout/parenthesis_layout.cpp index 4a203b004..e6916816b 100644 --- a/poincare/src/layout/parenthesis_layout.cpp +++ b/poincare/src/layout/parenthesis_layout.cpp @@ -51,35 +51,36 @@ ParenthesisLayout::ParenthesisLayout(ExpressionLayout * operandLayout) : m_operandLayout(operandLayout) { m_operandLayout->setParent(this); - m_baseline = m_operandLayout->baseline() + k_heightMargin; + m_baseline = m_operandLayout->baseline(); } ParenthesisLayout::~ParenthesisLayout() { delete m_operandLayout; } +KDColor s_parenthesisWorkingBuffer[ParenthesisLayout::k_parenthesisCurveHeight*ParenthesisLayout::k_parenthesisCurveWidth]; + void ParenthesisLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { KDSize operandSize = m_operandLayout->size(); - KDColor workingBuffer[k_parenthesisCurveHeight*k_parenthesisCurveWidth]; KDRect frame(p.x(), p.y(), k_parenthesisCurveWidth, k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topLeftCurve, (KDColor *)workingBuffer); - frame = KDRect(p.x(), p.y() + operandSize.height() + 2*k_heightMargin - k_parenthesisCurveHeight, + ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topLeftCurve, (KDColor *)s_parenthesisWorkingBuffer); + frame = KDRect(p.x(), p.y() + operandSize.height() - k_parenthesisCurveHeight, k_parenthesisCurveWidth, k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomLeftCurve, (KDColor *)workingBuffer); - frame = KDRect(p.x() + operandSize.width() + 2*k_widthMargin + 2*k_lineThickness - k_parenthesisCurveWidth, p.y(), + 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(), k_parenthesisCurveWidth, k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topRightCurve, (KDColor *)workingBuffer); - frame = KDRect(p.x() + operandSize.width() + 2*k_widthMargin + 2*k_lineThickness - k_parenthesisCurveWidth, p.y() + operandSize.height() + 2*k_heightMargin - 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, k_parenthesisCurveWidth, k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomRightCurve, (KDColor *)workingBuffer); + 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_heightMargin - 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_heightMargin - 2*k_parenthesisCurveHeight), expressionColor); + 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); } KDSize ParenthesisLayout::computeSize() { KDSize operandSize = m_operandLayout->size(); - return KDSize(operandSize.width() + 2*k_widthMargin + 2*k_lineThickness, operandSize.height()+2*k_heightMargin); + return KDSize(operandSize.width() + 2*k_widthMargin + 2*k_lineThickness, operandSize.height()); } ExpressionLayout * ParenthesisLayout::child(uint16_t index) { @@ -90,7 +91,7 @@ ExpressionLayout * ParenthesisLayout::child(uint16_t index) { } KDPoint ParenthesisLayout::positionOfChild(ExpressionLayout * child) { - return KDPoint(k_widthMargin+k_lineThickness, k_heightMargin); + return KDPoint(k_widthMargin+k_lineThickness, 0); } } diff --git a/poincare/src/layout/parenthesis_layout.h b/poincare/src/layout/parenthesis_layout.h index ae90e5d8e..792057336 100644 --- a/poincare/src/layout/parenthesis_layout.h +++ b/poincare/src/layout/parenthesis_layout.h @@ -18,8 +18,7 @@ protected: ExpressionLayout * child(uint16_t index) override; KDPoint positionOfChild(ExpressionLayout * child) override; private: - constexpr static KDCoordinate k_widthMargin = 2; - constexpr static KDCoordinate k_heightMargin = 3; + constexpr static KDCoordinate k_widthMargin = 5; constexpr static KDCoordinate k_lineThickness = 1; ExpressionLayout * m_operandLayout; };