From dfd34cbd0446e8d922d1b1535476dfea6b1b2311 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 19 Apr 2018 14:59:42 +0200 Subject: [PATCH] [poincare] Rename ParenthesisLeftRightLayout into ParenthesisLayout Change-Id: I45e7812d43318bbc13f712a36d758c43ce8781a5 --- poincare/Makefile | 2 +- .../layout/binomial_coefficient_layout.cpp | 4 +-- ...ight_layout.cpp => parenthesis_layout.cpp} | 20 ++++++------ ...ft_right_layout.h => parenthesis_layout.h} | 8 ++--- .../src/layout/parenthesis_left_layout.cpp | 32 +++++++++---------- poincare/src/layout/parenthesis_left_layout.h | 6 ++-- .../src/layout/parenthesis_right_layout.cpp | 32 +++++++++---------- .../src/layout/parenthesis_right_layout.h | 6 ++-- 8 files changed, 55 insertions(+), 55 deletions(-) rename poincare/src/layout/{parenthesis_left_right_layout.cpp => parenthesis_layout.cpp} (88%) rename poincare/src/layout/{parenthesis_left_right_layout.h => parenthesis_layout.h} (85%) diff --git a/poincare/Makefile b/poincare/Makefile index 6d900aa72..4634ba8c1 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -110,7 +110,7 @@ objs += $(addprefix poincare/src/layout/,\ matrix_layout.o\ nth_root_layout.o\ parenthesis_left_layout.o\ - parenthesis_left_right_layout.o\ + parenthesis_layout.o\ parenthesis_right_layout.o\ product_layout.o\ sequence_layout.o\ diff --git a/poincare/src/layout/binomial_coefficient_layout.cpp b/poincare/src/layout/binomial_coefficient_layout.cpp index 300ccf0b2..7e39c9883 100644 --- a/poincare/src/layout/binomial_coefficient_layout.cpp +++ b/poincare/src/layout/binomial_coefficient_layout.cpp @@ -3,7 +3,7 @@ #include "grid_layout.h" #include "horizontal_layout.h" #include "parenthesis_left_layout.h" -#include "parenthesis_left_right_layout.h" +#include "parenthesis_layout.h" #include "parenthesis_right_layout.h" #include #include @@ -108,7 +108,7 @@ void BinomialCoefficientLayout::render(KDContext * ctx, KDPoint p, KDColor expre KDSize BinomialCoefficientLayout::computeSize() { KDSize coefficientsSize = GridLayout(ExpressionLayoutArray(nLayout(), kLayout()).array(), 2, 1, true).size(); - return KDSize(coefficientsSize.width() + 2*ParenthesisLeftRightLayout::parenthesisWidth(), coefficientsSize.height()); + return KDSize(coefficientsSize.width() + 2*ParenthesisLayout::parenthesisWidth(), coefficientsSize.height()); } void BinomialCoefficientLayout::computeBaseline() { diff --git a/poincare/src/layout/parenthesis_left_right_layout.cpp b/poincare/src/layout/parenthesis_layout.cpp similarity index 88% rename from poincare/src/layout/parenthesis_left_right_layout.cpp rename to poincare/src/layout/parenthesis_layout.cpp index 75f0afc8e..de28adc27 100644 --- a/poincare/src/layout/parenthesis_left_right_layout.cpp +++ b/poincare/src/layout/parenthesis_layout.cpp @@ -1,4 +1,4 @@ -#include "parenthesis_left_right_layout.h" +#include "parenthesis_layout.h" #include #include extern "C" { @@ -11,18 +11,18 @@ namespace Poincare { static inline int max(int x, int y) { return (x>y ? x : y); } -ParenthesisLeftRightLayout::ParenthesisLeftRightLayout() : +ParenthesisLayout::ParenthesisLayout() : StaticLayoutHierarchy<0>(), m_operandHeightComputed(false) { } -void ParenthesisLeftRightLayout::invalidAllSizesPositionsAndBaselines() { +void ParenthesisLayout::invalidAllSizesPositionsAndBaselines() { m_operandHeightComputed = false; ExpressionLayout::invalidAllSizesPositionsAndBaselines(); } -bool ParenthesisLeftRightLayout::moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) { +bool ParenthesisLayout::moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) { assert(cursor->pointedExpressionLayout() == this); // Case: Right. // Go Left. @@ -39,7 +39,7 @@ bool ParenthesisLeftRightLayout::moveLeft(ExpressionLayoutCursor * cursor, bool return false; } -bool ParenthesisLeftRightLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) { +bool ParenthesisLayout::moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) { assert(cursor->pointedExpressionLayout() == this); // Case: Left. // Go Right. @@ -56,11 +56,11 @@ bool ParenthesisLeftRightLayout::moveRight(ExpressionLayoutCursor * cursor, bool return false; } -KDSize ParenthesisLeftRightLayout::computeSize() { +KDSize ParenthesisLayout::computeSize() { return KDSize(parenthesisWidth(), operandHeight() + k_verticalMargin); } -void ParenthesisLeftRightLayout::computeBaseline() { +void ParenthesisLayout::computeBaseline() { assert(m_parent != nullptr); bool isParenthesisLeft = isLeftParenthesis(); int indexInParent = m_parent->indexOfChild(this); @@ -111,7 +111,7 @@ void ParenthesisLeftRightLayout::computeBaseline() { m_baselined = true; } -KDCoordinate ParenthesisLeftRightLayout::operandHeight() { +KDCoordinate ParenthesisLayout::operandHeight() { if (!m_operandHeightComputed) { computeOperandHeight(); m_operandHeightComputed = true; @@ -119,7 +119,7 @@ KDCoordinate ParenthesisLeftRightLayout::operandHeight() { return m_operandHeight; } -void ParenthesisLeftRightLayout::computeOperandHeight() { +void ParenthesisLayout::computeOperandHeight() { assert(m_parent != nullptr); m_operandHeight = Metric::MinimalBracketAndParenthesisHeight; bool isParenthesisLeft = isLeftParenthesis(); @@ -172,7 +172,7 @@ void ParenthesisLeftRightLayout::computeOperandHeight() { } } -KDPoint ParenthesisLeftRightLayout::positionOfChild(ExpressionLayout * child) { +KDPoint ParenthesisLayout::positionOfChild(ExpressionLayout * child) { assert(false); return KDPointZero; } diff --git a/poincare/src/layout/parenthesis_left_right_layout.h b/poincare/src/layout/parenthesis_layout.h similarity index 85% rename from poincare/src/layout/parenthesis_left_right_layout.h rename to poincare/src/layout/parenthesis_layout.h index 67e663121..46cc1bbd0 100644 --- a/poincare/src/layout/parenthesis_left_right_layout.h +++ b/poincare/src/layout/parenthesis_layout.h @@ -1,13 +1,13 @@ -#ifndef POINCARE_PARENTHESIS_LEFT_RIGHT_LAYOUT_H -#define POINCARE_PARENTHESIS_LEFT_RIGHT_LAYOUT_H +#ifndef POINCARE_PARENTHESIS_LAYOUT_H +#define POINCARE_PARENTHESIS_LAYOUT_H #include namespace Poincare { -class ParenthesisLeftRightLayout : public StaticLayoutHierarchy<0> { +class ParenthesisLayout : public StaticLayoutHierarchy<0> { public: - ParenthesisLeftRightLayout(); + ParenthesisLayout(); void invalidAllSizesPositionsAndBaselines() override; bool moveLeft(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override; bool moveRight(ExpressionLayoutCursor * cursor, bool * shouldRecomputeLayout) override; diff --git a/poincare/src/layout/parenthesis_left_layout.cpp b/poincare/src/layout/parenthesis_left_layout.cpp index fcd377dcf..bd486d9c2 100644 --- a/poincare/src/layout/parenthesis_left_layout.cpp +++ b/poincare/src/layout/parenthesis_left_layout.cpp @@ -6,7 +6,7 @@ extern "C" { namespace Poincare { -const uint8_t topLeftCurve[ParenthesisLeftRightLayout::k_parenthesisCurveHeight][ParenthesisLeftRightLayout::k_parenthesisCurveWidth] = { +const uint8_t topLeftCurve[ParenthesisLayout::k_parenthesisCurveHeight][ParenthesisLayout::k_parenthesisCurveWidth] = { {0xFF, 0xFF, 0xFF, 0xF9, 0x66}, {0xFF, 0xFF, 0xEB, 0x40, 0x9A}, {0xFF, 0xF2, 0x40, 0xBF, 0xFF}, @@ -16,7 +16,7 @@ const uint8_t topLeftCurve[ParenthesisLeftRightLayout::k_parenthesisCurveHeight] {0x11, 0xEE, 0xFF, 0xFF, 0xFF}, }; -const uint8_t bottomLeftCurve[ParenthesisLeftRightLayout::k_parenthesisCurveHeight][ParenthesisLeftRightLayout::k_parenthesisCurveWidth] = { +const uint8_t bottomLeftCurve[ParenthesisLayout::k_parenthesisCurveHeight][ParenthesisLayout::k_parenthesisCurveWidth] = { {0x11, 0xEE, 0xFF, 0xFF, 0xFF}, {0x45, 0xBE, 0xFF, 0xFF, 0xFF}, {0xA9, 0x5A, 0xFF, 0xFF, 0xFF}, @@ -40,24 +40,24 @@ bool ParenthesisLeftLayout::isCollapsable(int * numberOfOpenParenthesis, bool go } void ParenthesisLeftLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { - KDRect frame(p.x()+ParenthesisLeftRightLayout::k_externWidthMargin, - p.y()+ParenthesisLeftRightLayout::k_externHeightMargin, - ParenthesisLeftRightLayout::k_parenthesisCurveWidth, - ParenthesisLeftRightLayout::k_parenthesisCurveHeight); + KDRect frame(p.x()+ParenthesisLayout::k_externWidthMargin, + p.y()+ParenthesisLayout::k_externHeightMargin, + ParenthesisLayout::k_parenthesisCurveWidth, + ParenthesisLayout::k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topLeftCurve, (KDColor *)(ParenthesisLeftRightLayout::s_parenthesisWorkingBuffer)); + ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topLeftCurve, (KDColor *)(ParenthesisLayout::s_parenthesisWorkingBuffer)); - frame = KDRect(p.x()+ParenthesisLeftRightLayout::k_externWidthMargin, - p.y() + size().height() - ParenthesisLeftRightLayout::k_parenthesisCurveHeight - ParenthesisLeftRightLayout::k_externHeightMargin, - ParenthesisLeftRightLayout::k_parenthesisCurveWidth, - ParenthesisLeftRightLayout::k_parenthesisCurveHeight); + frame = KDRect(p.x()+ParenthesisLayout::k_externWidthMargin, + p.y() + size().height() - ParenthesisLayout::k_parenthesisCurveHeight - ParenthesisLayout::k_externHeightMargin, + ParenthesisLayout::k_parenthesisCurveWidth, + ParenthesisLayout::k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomLeftCurve, (KDColor *)(ParenthesisLeftRightLayout::s_parenthesisWorkingBuffer)); + ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomLeftCurve, (KDColor *)(ParenthesisLayout::s_parenthesisWorkingBuffer)); - ctx->fillRect(KDRect(p.x()+ParenthesisLeftRightLayout::k_externWidthMargin, - p.y()+ParenthesisLeftRightLayout::k_parenthesisCurveHeight+ParenthesisLeftRightLayout::k_externHeightMargin, - ParenthesisLeftRightLayout::k_lineThickness, - size().height() - 2*(ParenthesisLeftRightLayout::k_parenthesisCurveHeight+ParenthesisLeftRightLayout::k_externHeightMargin)), + ctx->fillRect(KDRect(p.x()+ParenthesisLayout::k_externWidthMargin, + p.y()+ParenthesisLayout::k_parenthesisCurveHeight+ParenthesisLayout::k_externHeightMargin, + ParenthesisLayout::k_lineThickness, + size().height() - 2*(ParenthesisLayout::k_parenthesisCurveHeight+ParenthesisLayout::k_externHeightMargin)), expressionColor); } diff --git a/poincare/src/layout/parenthesis_left_layout.h b/poincare/src/layout/parenthesis_left_layout.h index 565719038..13aaff112 100644 --- a/poincare/src/layout/parenthesis_left_layout.h +++ b/poincare/src/layout/parenthesis_left_layout.h @@ -1,16 +1,16 @@ #ifndef POINCARE_PARENTHESIS_LEFT_LAYOUT_H #define POINCARE_PARENTHESIS_LEFT_LAYOUT_H -#include +#include #include namespace Poincare { -class ParenthesisLeftLayout : public ParenthesisLeftRightLayout { +class ParenthesisLeftLayout : public ParenthesisLayout { friend class BinomialCoefficientLayout; friend class SequenceLayout; public: - using ParenthesisLeftRightLayout::ParenthesisLeftRightLayout; + using ParenthesisLayout::ParenthesisLayout; ExpressionLayout * clone() const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, '('); diff --git a/poincare/src/layout/parenthesis_right_layout.cpp b/poincare/src/layout/parenthesis_right_layout.cpp index c3e256ab0..7ac78ef93 100644 --- a/poincare/src/layout/parenthesis_right_layout.cpp +++ b/poincare/src/layout/parenthesis_right_layout.cpp @@ -6,7 +6,7 @@ extern "C" { namespace Poincare { -const uint8_t topRightCurve[ParenthesisLeftRightLayout::k_parenthesisCurveHeight][ParenthesisLeftRightLayout::k_parenthesisCurveWidth] = { +const uint8_t topRightCurve[ParenthesisLayout::k_parenthesisCurveHeight][ParenthesisLayout::k_parenthesisCurveWidth] = { {0x66, 0xF9, 0xFF, 0xFF, 0xFF}, {0x9A, 0x40, 0xEB, 0xFF, 0xFF}, {0xFF, 0xBF, 0x40, 0xF2, 0xFF}, @@ -16,7 +16,7 @@ const uint8_t topRightCurve[ParenthesisLeftRightLayout::k_parenthesisCurveHeight {0xFF, 0xFF, 0xFF, 0xEE, 0x11}, }; -const uint8_t bottomRightCurve[ParenthesisLeftRightLayout::k_parenthesisCurveHeight][ParenthesisLeftRightLayout::k_parenthesisCurveWidth] = { +const uint8_t bottomRightCurve[ParenthesisLayout::k_parenthesisCurveHeight][ParenthesisLayout::k_parenthesisCurveWidth] = { {0xFF, 0xFF, 0xFF, 0xEE, 0x11}, {0xFF, 0xFF, 0xFF, 0xBE, 0x45}, {0xFF, 0xFF, 0xFF, 0x5A, 0xA9}, @@ -40,24 +40,24 @@ bool ParenthesisRightLayout::isCollapsable(int * numberOfOpenParenthesis, bool g } void ParenthesisRightLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { - KDRect frame = KDRect(p.x() + ParenthesisLeftRightLayout::k_widthMargin + ParenthesisLeftRightLayout::k_lineThickness - ParenthesisLeftRightLayout::k_parenthesisCurveWidth, - p.y() + ParenthesisLeftRightLayout::k_externHeightMargin, - ParenthesisLeftRightLayout::k_parenthesisCurveWidth, - ParenthesisLeftRightLayout::k_parenthesisCurveHeight); + KDRect frame = KDRect(p.x() + ParenthesisLayout::k_widthMargin + ParenthesisLayout::k_lineThickness - ParenthesisLayout::k_parenthesisCurveWidth, + p.y() + ParenthesisLayout::k_externHeightMargin, + ParenthesisLayout::k_parenthesisCurveWidth, + ParenthesisLayout::k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topRightCurve, (KDColor *)(ParenthesisLeftRightLayout::s_parenthesisWorkingBuffer)); + ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topRightCurve, (KDColor *)(ParenthesisLayout::s_parenthesisWorkingBuffer)); - frame = KDRect(p.x() + ParenthesisLeftRightLayout::k_widthMargin + ParenthesisLeftRightLayout::k_lineThickness - ParenthesisLeftRightLayout::k_parenthesisCurveWidth, - p.y() + size().height() - ParenthesisLeftRightLayout::k_parenthesisCurveHeight - ParenthesisLeftRightLayout::k_externHeightMargin, - ParenthesisLeftRightLayout::k_parenthesisCurveWidth, - ParenthesisLeftRightLayout::k_parenthesisCurveHeight); + frame = KDRect(p.x() + ParenthesisLayout::k_widthMargin + ParenthesisLayout::k_lineThickness - ParenthesisLayout::k_parenthesisCurveWidth, + p.y() + size().height() - ParenthesisLayout::k_parenthesisCurveHeight - ParenthesisLayout::k_externHeightMargin, + ParenthesisLayout::k_parenthesisCurveWidth, + ParenthesisLayout::k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomRightCurve, (KDColor *)(ParenthesisLeftRightLayout::s_parenthesisWorkingBuffer)); + ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomRightCurve, (KDColor *)(ParenthesisLayout::s_parenthesisWorkingBuffer)); - ctx->fillRect(KDRect(p.x()+ParenthesisLeftRightLayout::k_widthMargin, - p.y()+ParenthesisLeftRightLayout::k_parenthesisCurveHeight+2, - ParenthesisLeftRightLayout::k_lineThickness, - size().height() - 2*(ParenthesisLeftRightLayout::k_parenthesisCurveHeight+ParenthesisLeftRightLayout::k_externHeightMargin)), + ctx->fillRect(KDRect(p.x()+ParenthesisLayout::k_widthMargin, + p.y()+ParenthesisLayout::k_parenthesisCurveHeight+2, + ParenthesisLayout::k_lineThickness, + size().height() - 2*(ParenthesisLayout::k_parenthesisCurveHeight+ParenthesisLayout::k_externHeightMargin)), expressionColor); } diff --git a/poincare/src/layout/parenthesis_right_layout.h b/poincare/src/layout/parenthesis_right_layout.h index 964bf3d60..63565c827 100644 --- a/poincare/src/layout/parenthesis_right_layout.h +++ b/poincare/src/layout/parenthesis_right_layout.h @@ -1,16 +1,16 @@ #ifndef POINCARE_PARENTHESIS_RIGHT_LAYOUT_H #define POINCARE_PARENTHESIS_RIGHT_LAYOUT_H -#include +#include #include namespace Poincare { -class ParenthesisRightLayout : public ParenthesisLeftRightLayout { +class ParenthesisRightLayout : public ParenthesisLayout { friend class BinomialCoefficientLayout; friend class SequenceLayout; public: - using ParenthesisLeftRightLayout::ParenthesisLeftRightLayout; + using ParenthesisLayout::ParenthesisLayout; ExpressionLayout * clone() const override; int writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const override { return LayoutEngine::writeOneCharInBuffer(buffer, bufferSize, ')');