From 27a0935311fedbbef7cd62fc0d50dfa66d25c5f0 Mon Sep 17 00:00:00 2001 From: Quentin Date: Fri, 19 Jun 2020 11:12:09 +0200 Subject: [PATCH] [Fix] Patched colors --- .../additional_outputs/complex_graph_cell.cpp | 21 ++++++++++--------- .../expression_with_equal_sign_view.h | 3 ++- .../additional_outputs/illustration_cell.cpp | 2 +- .../scrollable_three_expressions_cell.h | 5 +++-- .../trigonometry_graph_cell.cpp | 15 ++++++------- apps/code/console_line_cell.cpp | 2 +- apps/code/editor_view.cpp | 4 ++-- apps/code/script_parameter_controller.cpp | 2 +- apps/hardware_test/keyboard_view.cpp | 2 +- apps/probability/distribution_controller.h | 2 +- apps/shared/curve_view.cpp | 3 ++- .../scrollable_multiple_expressions_view.cpp | 14 ++++++------- apps/variable_box_empty_controller.cpp | 2 +- .../escher/scrollable_expression_view.h | 3 ++- escher/src/palette.cpp | 1 + 15 files changed, 44 insertions(+), 37 deletions(-) diff --git a/apps/calculation/additional_outputs/complex_graph_cell.cpp b/apps/calculation/additional_outputs/complex_graph_cell.cpp index bc8a687b3..fe38bf910 100644 --- a/apps/calculation/additional_outputs/complex_graph_cell.cpp +++ b/apps/calculation/additional_outputs/complex_graph_cell.cpp @@ -1,4 +1,5 @@ #include "complex_graph_cell.h" +#include using namespace Shared; using namespace Poincare; @@ -12,7 +13,7 @@ ComplexGraphView::ComplexGraphView(ComplexModel * complexModel) : } void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const { - ctx->fillRect(rect, KDColorWhite); + ctx->fillRect(rect, Palette::BackgroundApps); // Draw grid, axes and graduations drawGrid(ctx, rect); @@ -25,7 +26,7 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const { assert(!std::isnan(real) && !std::isnan(imag) && !std::isinf(real) && !std::isinf(imag)); // Draw the segment from the origin to the dot (real, imag) - drawSegment(ctx, rect, 0.0f, 0.0f, m_complex->real(), m_complex->imag(), Palette::GreyDark, false); + drawSegment(ctx, rect, 0.0f, 0.0f, m_complex->real(), m_complex->imag(), Palette::SecondaryText, false); /* Draw the partial ellipse indicating the angle θ * - the ellipse parameters are a = |real|/5 and b = |imag|/5, @@ -58,27 +59,27 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const { float a = parameters.real(); float b = parameters.imag(); return Poincare::Coordinate2D(a*std::cos(t*th), b*std::sin(t*th)); - }, ¶meters, &th, false, Palette::GreyDark, false); + }, ¶meters, &th, false, Palette::SecondaryText, false); // Draw dashed segment to indicate real and imaginary - drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, real, 0.0f, imag, Palette::Red, 1, 3); - drawHorizontalOrVerticalSegment(ctx, rect, Axis::Horizontal, imag, 0.0f, real, Palette::Red, 1, 3); + drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, real, 0.0f, imag, Palette::CalculationTrigoAndComplexForeground, 1, 3); + drawHorizontalOrVerticalSegment(ctx, rect, Axis::Horizontal, imag, 0.0f, real, Palette::CalculationTrigoAndComplexForeground, 1, 3); // Draw complex position on the plan - drawDot(ctx, rect, real, imag, Palette::Red, Size::Large); + drawDot(ctx, rect, real, imag, Palette::CalculationTrigoAndComplexForeground, Size::Large); // Draw labels // 're(z)' label - drawLabel(ctx, rect, real, 0.0f, "re(z)", Palette::Red, CurveView::RelativePosition::None, imag >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After); + drawLabel(ctx, rect, real, 0.0f, "re(z)", Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, imag >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After); // 'im(z)' label - drawLabel(ctx, rect, 0.0f, imag, "im(z)", Palette::Red, real >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None); + drawLabel(ctx, rect, 0.0f, imag, "im(z)", Palette::CalculationTrigoAndComplexForeground, real >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None); // '|z|' label, the relative horizontal position of this label depends on the quadrant CurveView::RelativePosition verticalPosition = real*imag < 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After; if (real == 0.0f) { // Edge case: pure imaginary verticalPosition = CurveView::RelativePosition::None; } - drawLabel(ctx, rect, real/2.0f, imag/2.0f, "|z|", Palette::Red, CurveView::RelativePosition::None, verticalPosition); + drawLabel(ctx, rect, real/2.0f, imag/2.0f, "|z|", Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, verticalPosition); // 'arg(z)' label, the absolute and relative horizontal/vertical positions of this label depends on the quadrant CurveView::RelativePosition horizontalPosition = real >= 0.0f ? CurveView::RelativePosition::After : CurveView::RelativePosition::None; verticalPosition = imag >= 0.0f ? CurveView::RelativePosition::After : CurveView::RelativePosition::Before; @@ -87,7 +88,7 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const { * and for the left half plan, we position the label at the half angle. The * relative position is chosen accordingly. */ float anglePositionRatio = real >= 0.0f ? 0.0f : 0.5f; - drawLabel(ctx, rect, a*std::cos(anglePositionRatio*th), b*std::sin(anglePositionRatio*th), "arg(z)", Palette::Red, horizontalPosition, verticalPosition); + drawLabel(ctx, rect, a*std::cos(anglePositionRatio*th), b*std::sin(anglePositionRatio*th), "arg(z)", Palette::CalculationTrigoAndComplexForeground, horizontalPosition, verticalPosition); } } diff --git a/apps/calculation/additional_outputs/expression_with_equal_sign_view.h b/apps/calculation/additional_outputs/expression_with_equal_sign_view.h index 865a7393f..359fbe46b 100644 --- a/apps/calculation/additional_outputs/expression_with_equal_sign_view.h +++ b/apps/calculation/additional_outputs/expression_with_equal_sign_view.h @@ -4,13 +4,14 @@ #include #include #include +#include namespace Calculation { class ExpressionWithEqualSignView : public ExpressionView { public: ExpressionWithEqualSignView() : - m_equalSign(KDFont::LargeFont, I18n::Message::Equal, 0.5f, 0.5f, KDColorBlack) + m_equalSign(KDFont::LargeFont, I18n::Message::Equal, 0.5f, 0.5f, Palette::PrimaryText) {} KDSize minimalSizeForOptimalDisplay() const override; void drawRect(KDContext * ctx, KDRect rect) const override; diff --git a/apps/calculation/additional_outputs/illustration_cell.cpp b/apps/calculation/additional_outputs/illustration_cell.cpp index bd2471710..20249c7d8 100644 --- a/apps/calculation/additional_outputs/illustration_cell.cpp +++ b/apps/calculation/additional_outputs/illustration_cell.cpp @@ -10,7 +10,7 @@ void IllustrationCell::layoutSubviews(bool force) { } void IllustrationCell::drawRect(KDContext * ctx, KDRect rect) const { - drawBorderOfRect(ctx, bounds(), Palette::GreyBright); + drawBorderOfRect(ctx, bounds(), Palette::ListCellBorder); } } diff --git a/apps/calculation/additional_outputs/scrollable_three_expressions_cell.h b/apps/calculation/additional_outputs/scrollable_three_expressions_cell.h index e8daa7f26..b1b72a08a 100644 --- a/apps/calculation/additional_outputs/scrollable_three_expressions_cell.h +++ b/apps/calculation/additional_outputs/scrollable_three_expressions_cell.h @@ -5,6 +5,7 @@ #include "../../shared/scrollable_multiple_expressions_view.h" #include "../calculation.h" #include "expression_with_equal_sign_view.h" +#include namespace Calculation { @@ -13,7 +14,7 @@ public: static constexpr KDCoordinate k_margin = Metric::CommonSmallMargin; ScrollableThreeExpressionsView(Responder * parentResponder) : Shared::AbstractScrollableMultipleExpressionsView(parentResponder, &m_contentCell), m_contentCell() { setMargins(k_margin, k_margin, k_margin, k_margin); // Left Right margins are already added by TableCell - setBackgroundColor(KDColorWhite); + setBackgroundColor(Palette::BackgroundApps); } void resetMemoization(); void setCalculation(Calculation * calculation); @@ -24,7 +25,7 @@ private: class ContentCell : public Shared::AbstractScrollableMultipleExpressionsView::ContentCell { public: ContentCell() : m_leftExpressionView() {} - KDColor backgroundColor() const override { return KDColorWhite; } + KDColor backgroundColor() const override { return Palette::BackgroundApps; } void setEven(bool even) override { return; } ExpressionView * leftExpressionView() const override { return const_cast(&m_leftExpressionView); } private: diff --git a/apps/calculation/additional_outputs/trigonometry_graph_cell.cpp b/apps/calculation/additional_outputs/trigonometry_graph_cell.cpp index f28c107f4..636ce588a 100644 --- a/apps/calculation/additional_outputs/trigonometry_graph_cell.cpp +++ b/apps/calculation/additional_outputs/trigonometry_graph_cell.cpp @@ -1,4 +1,5 @@ #include "trigonometry_graph_cell.h" +#include using namespace Shared; using namespace Poincare; @@ -14,24 +15,24 @@ TrigonometryGraphView::TrigonometryGraphView(TrigonometryModel * model) : void TrigonometryGraphView::drawRect(KDContext * ctx, KDRect rect) const { float s = std::sin(m_model->angle()); float c = std::cos(m_model->angle()); - ctx->fillRect(rect, KDColorWhite); + ctx->fillRect(rect, Palette::BackgroundApps); drawGrid(ctx, rect); drawAxes(ctx, rect); // Draw the circle drawCurve(ctx, rect, 0.0f, 2.0f*M_PI, M_PI/180.0f, [](float t, void * model, void * context) { return Poincare::Coordinate2D(std::cos(t), std::sin(t)); - }, nullptr, nullptr, true, Palette::GreyDark, false); + }, nullptr, nullptr, true, Palette::SecondaryText, false); // Draw dashed segment to indicate sine and cosine - drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, c, 0.0f, s, Palette::Red, 1, 3); - drawHorizontalOrVerticalSegment(ctx, rect, Axis::Horizontal, s, 0.0f, c, Palette::Red, 1, 3); + drawHorizontalOrVerticalSegment(ctx, rect, Axis::Vertical, c, 0.0f, s, Palette::CalculationTrigoAndComplexForeground, 1, 3); + drawHorizontalOrVerticalSegment(ctx, rect, Axis::Horizontal, s, 0.0f, c, Palette::CalculationTrigoAndComplexForeground, 1, 3); // Draw angle position on the circle - drawDot(ctx, rect, c, s, Palette::Red, Size::Large); + drawDot(ctx, rect, c, s, Palette::CalculationTrigoAndComplexForeground, Size::Large); // Draw graduations drawLabelsAndGraduations(ctx, rect, Axis::Vertical, false, true); drawLabelsAndGraduations(ctx, rect, Axis::Horizontal, false, true); // Draw labels - drawLabel(ctx, rect, 0.0f, s, "sin(θ)", Palette::Red, c >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None); - drawLabel(ctx, rect, c, 0.0f, "cos(θ)", Palette::Red, CurveView::RelativePosition::None, s >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After); + drawLabel(ctx, rect, 0.0f, s, "sin(θ)", Palette::CalculationTrigoAndComplexForeground, c >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None); + drawLabel(ctx, rect, c, 0.0f, "cos(θ)", Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, s >= 0.0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After); } } diff --git a/apps/code/console_line_cell.cpp b/apps/code/console_line_cell.cpp index 458c8eb42..3cad12787 100644 --- a/apps/code/console_line_cell.cpp +++ b/apps/code/console_line_cell.cpp @@ -19,7 +19,7 @@ void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::setLine(Consol void ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(bounds(), Palette::CodeBackground); - ctx->drawString(m_line->text(), KDPointZero, GlobalPreferences::sharedGlobalPreferences()->font(), textColor(m_line), isHighlighted()? Palette::Select : KDColorWhite); + ctx->drawString(m_line->text(), KDPointZero, GlobalPreferences::sharedGlobalPreferences()->font(), textColor(m_line), isHighlighted()? Palette::Select : Palette::BackgroundApps); } KDSize ConsoleLineCell::ScrollableConsoleLineView::ConsoleLineView::minimalSizeForOptimalDisplay() const { diff --git a/apps/code/editor_view.cpp b/apps/code/editor_view.cpp index ec27baf50..2e0c63acd 100644 --- a/apps/code/editor_view.cpp +++ b/apps/code/editor_view.cpp @@ -53,8 +53,8 @@ void EditorView::layoutSubviews(bool force) { /* EditorView::GutterView */ void EditorView::GutterView::drawRect(KDContext * ctx, KDRect rect) const { - KDColor textColor = KDColor::RGB24(0x919EA4); - KDColor backgroundColor = KDColor::RGB24(0xE4E6E7); + KDColor textColor = Palette::PrimaryText; + KDColor backgroundColor = Palette::CodeGutterViewBackground; ctx->fillRect(rect, backgroundColor); diff --git a/apps/code/script_parameter_controller.cpp b/apps/code/script_parameter_controller.cpp index 806699302..6e99b63a7 100644 --- a/apps/code/script_parameter_controller.cpp +++ b/apps/code/script_parameter_controller.cpp @@ -100,7 +100,7 @@ void ScriptParameterController::willDisplayCellForIndex(HighlightCell * cell, in MessageTableCellWithBuffer * myCell = (MessageTableCellWithBuffer *)cell; GetScriptSize(myCell); myCell->setAccessoryFont(KDFont::SmallFont); - myCell->setAccessoryTextColor(Palette::GreyDark); + myCell->setAccessoryTextColor(Palette::SecondaryText); } } diff --git a/apps/hardware_test/keyboard_view.cpp b/apps/hardware_test/keyboard_view.cpp index 1b15f28df..9af6b9169 100644 --- a/apps/hardware_test/keyboard_view.cpp +++ b/apps/hardware_test/keyboard_view.cpp @@ -59,7 +59,7 @@ void KeyboardView::drawKey(int keyIndex, KDContext * ctx, KDRect rect) const { KDColor KeyboardView::keyColor(Ion::Keyboard::Key key) const { if (!m_keyboardModel.belongsToTestedKeysSubset(key)) { - return Palette::GreyBright; + return Palette::ListCellBorder; } if (m_keyboardModel.testedKey() == key) { return KDColorBlue; diff --git a/apps/probability/distribution_controller.h b/apps/probability/distribution_controller.h index ee5086a58..78b0c7c4a 100644 --- a/apps/probability/distribution_controller.h +++ b/apps/probability/distribution_controller.h @@ -26,7 +26,7 @@ private: class ContentView : public View { public: ContentView(SelectableTableView * selectableTableView) : - m_titleView(KDFont::SmallFont, I18n::Message::ChooseDistribution, 0.5f, 0.5f, Palette::GreyDark, Palette::BackgroundApps), + m_titleView(KDFont::SmallFont, I18n::Message::ChooseDistribution, 0.5f, 0.5f, Palette::SecondaryText, Palette::BackgroundApps), m_selectableTableView(selectableTableView) {} constexpr static KDCoordinate k_titleMargin = 8; diff --git a/apps/shared/curve_view.cpp b/apps/shared/curve_view.cpp index 89065ac6a..b1ca44cfc 100644 --- a/apps/shared/curve_view.cpp +++ b/apps/shared/curve_view.cpp @@ -7,6 +7,7 @@ #include #include #include +#include using namespace Poincare; @@ -252,7 +253,7 @@ void CurveView::drawLabel(KDContext * ctx, KDRect rect, float xPosition, float y KDPoint position = positionLabel(xCoordinate, yCoordinate, labelSize, horizontalPosition, verticalPosition); if (rect.intersects(KDRect(position, labelSize))) { // TODO: should we blend? - ctx->drawString(label, position, k_font, color, KDColorWhite); + ctx->drawString(label, position, k_font, color, Palette::BackgroundApps); } } diff --git a/apps/shared/scrollable_multiple_expressions_view.cpp b/apps/shared/scrollable_multiple_expressions_view.cpp index eeaeb3a6a..802c7d7f6 100644 --- a/apps/shared/scrollable_multiple_expressions_view.cpp +++ b/apps/shared/scrollable_multiple_expressions_view.cpp @@ -8,7 +8,7 @@ namespace Shared { AbstractScrollableMultipleExpressionsView::ContentCell::ContentCell() : m_rightExpressionView(), - m_approximateSign(k_font, k_defaultApproximateMessage, 0.5f, 0.5f, Palette::GreyVeryDark), + m_approximateSign(k_font, k_defaultApproximateMessage, 0.5f, 0.5f, Palette::SecondaryText), m_centeredExpressionView(), m_selectedSubviewPosition(SubviewPosition::Center), m_displayCenter(true) @@ -16,7 +16,7 @@ AbstractScrollableMultipleExpressionsView::ContentCell::ContentCell() : } KDColor AbstractScrollableMultipleExpressionsView::ContentCell::backgroundColor() const { - KDColor background = m_even ? KDColorWhite : Palette::BackgroundApps; + KDColor background = m_even ? Palette::CalculationBackgroundEven : Palette::CalculationBackgroundOdd; return background; } @@ -24,13 +24,13 @@ void AbstractScrollableMultipleExpressionsView::ContentCell::setHighlighted(bool // Do not call HighlightCell::setHighlighted to avoid marking all cell as dirty m_highlighted = highlight; KDColor defaultColor = backgroundColor(); - KDColor color = highlight && m_selectedSubviewPosition == SubviewPosition::Center ? Palette::Select : defaultColor; + KDColor color = highlight && m_selectedSubviewPosition == SubviewPosition::Center ? Palette::ExpressionInputBackground : defaultColor; m_centeredExpressionView.setBackgroundColor(color); - color = highlight && m_selectedSubviewPosition == SubviewPosition::Right ? Palette::Select : defaultColor; + color = highlight && m_selectedSubviewPosition == SubviewPosition::Right ? Palette::ExpressionInputBackground : defaultColor; m_rightExpressionView.setBackgroundColor(color); m_approximateSign.setBackgroundColor(defaultColor); if (leftExpressionView()) { - color = highlight && m_selectedSubviewPosition == SubviewPosition::Left ? Palette::Select : defaultColor; + color = highlight && m_selectedSubviewPosition == SubviewPosition::Left ? Palette::ExpressionInputBackground : defaultColor; leftExpressionView()->setBackgroundColor(color); } } @@ -48,9 +48,9 @@ void AbstractScrollableMultipleExpressionsView::ContentCell::setEven(bool even) void AbstractScrollableMultipleExpressionsView::ContentCell::reloadTextColor() { if (displayCenter()) { - m_rightExpressionView.setTextColor(Palette::GreyVeryDark); + m_rightExpressionView.setTextColor(Palette::SecondaryText); } else { - m_rightExpressionView.setTextColor(KDColorBlack); + m_rightExpressionView.setTextColor(Palette::PrimaryText); } } diff --git a/apps/variable_box_empty_controller.cpp b/apps/variable_box_empty_controller.cpp index 758865a88..ec6a9a24c 100644 --- a/apps/variable_box_empty_controller.cpp +++ b/apps/variable_box_empty_controller.cpp @@ -29,7 +29,7 @@ void VariableBoxEmptyController::VariableBoxEmptyView::setLayout(Poincare::Layou } void VariableBoxEmptyController::VariableBoxEmptyView::drawRect(KDContext * ctx, KDRect rect) const { - drawBorderOfRect(ctx, bounds(), Palette::GreyBright); + drawBorderOfRect(ctx, bounds(), Palette::ListCellBorder); } int VariableBoxEmptyController::VariableBoxEmptyView::numberOfSubviews() const { diff --git a/escher/include/escher/scrollable_expression_view.h b/escher/include/escher/scrollable_expression_view.h index a932757b0..2ba69f0da 100644 --- a/escher/include/escher/scrollable_expression_view.h +++ b/escher/include/escher/scrollable_expression_view.h @@ -4,10 +4,11 @@ #include #include #include +#include class ScrollableExpressionView : public ScrollableView, public ScrollViewDataSource { public: - ScrollableExpressionView(Responder * parentResponder, KDCoordinate leftRightMargin, KDCoordinate topBottomMargin, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); + ScrollableExpressionView(Responder * parentResponder, KDCoordinate leftRightMargin, KDCoordinate topBottomMargin, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = Palette::PrimaryText, KDColor backgroundColor = Palette::BackgroundApps); Poincare::Layout layout() const; void setLayout(Poincare::Layout layout); void setBackgroundColor(KDColor backgroundColor) override; diff --git a/escher/src/palette.cpp b/escher/src/palette.cpp index 2d7ae9708..9f5371178 100644 --- a/escher/src/palette.cpp +++ b/escher/src/palette.cpp @@ -36,6 +36,7 @@ constexpr KDColor Palette::CodeNumber; constexpr KDColor Palette::CodeKeyword; constexpr KDColor Palette::CodeOperator; constexpr KDColor Palette::CodeString; +constexpr KDColor Palette::CodeGutterViewBackground; constexpr KDColor Palette::ProbabilityCurve; constexpr KDColor Palette::ProbabilityCellBorder;