diff --git a/apps/graph/function_title_cell.cpp b/apps/graph/function_title_cell.cpp index e4036acb5..ed336ee18 100644 --- a/apps/graph/function_title_cell.cpp +++ b/apps/graph/function_title_cell.cpp @@ -42,7 +42,7 @@ View * FunctionTitleCell::subviewAtIndex(int index) { void FunctionTitleCell::layoutSubviews() { KDRect textFrame(0, k_colorIndicatorThickness, bounds().width(), bounds().height() - k_colorIndicatorThickness); if (m_orientation == Orientation::VerticalIndicator){ - textFrame = KDRect(k_colorIndicatorThickness, 0, bounds().width() - k_colorIndicatorThickness, bounds().height()-k_separatorThickness); + textFrame = KDRect(k_colorIndicatorThickness, 0, bounds().width() - k_colorIndicatorThickness-k_separatorThickness, bounds().height()-k_separatorThickness); } m_bufferTextView.setFrame(textFrame); } diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index 9c84175d6..5984590cb 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -88,7 +88,7 @@ void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) { } void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) { - FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell; + ModelExpressionCell * myCell = (ModelExpressionCell *)cell; Function * f = m_functionStore->functionAtIndex(j); myCell->setExpressionLayout(f->layout()); bool active = f->isActive(); @@ -107,7 +107,7 @@ bool ListController::removeFunctionRow(Function * function) { View * ListController::loadView() { for (int i = 0; i < k_maxNumberOfRows; i++) { m_functionTitleCells[i] = new FunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator); - m_expressionCells[i] = new FunctionExpressionCell(); + m_expressionCells[i] = new ModelExpressionCell(); } return Shared::ListController::loadView(); } diff --git a/apps/graph/list/list_controller.h b/apps/graph/list/list_controller.h index 2eb9df238..4bcedbe21 100644 --- a/apps/graph/list/list_controller.h +++ b/apps/graph/list/list_controller.h @@ -3,9 +3,9 @@ #include #include "../function_title_cell.h" -#include "../../shared/function_expression_cell.h" #include "../cartesian_function_store.h" #include "../../shared/new_function_cell.h" +#include "../../shared/model_expression_cell.h" #include "../../shared/list_controller.h" #include "../../shared/list_parameter_controller.h" @@ -30,7 +30,7 @@ private: void unloadView(View * view) override; constexpr static int k_maxNumberOfRows = 5; FunctionTitleCell * m_functionTitleCells[k_maxNumberOfRows]; - Shared::FunctionExpressionCell * m_expressionCells[k_maxNumberOfRows]; + Shared::ModelExpressionCell * m_expressionCells[k_maxNumberOfRows]; Shared::ListParameterController m_parameterController; }; diff --git a/apps/sequence/list/list_controller.cpp b/apps/sequence/list/list_controller.cpp index 23e0ecf2c..7c697c91f 100644 --- a/apps/sequence/list/list_controller.cpp +++ b/apps/sequence/list/list_controller.cpp @@ -197,7 +197,7 @@ void ListController::willDisplayTitleCellAtIndex(HighlightCell * cell, int j) { } void ListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) { - FunctionExpressionCell * myCell = (FunctionExpressionCell *)cell; + ModelExpressionCell * myCell = (ModelExpressionCell *)cell; Sequence * sequence = m_sequenceStore->functionAtIndex(functionIndexForRow(j)); if (sequenceDefinitionForRow(j) == 0) { myCell->setExpressionLayout(sequence->layout()); @@ -304,7 +304,7 @@ void ListController::reinitExpression(Shared::Function * function) { View * ListController::loadView() { for (int i = 0; i < k_maxNumberOfRows; i++) { m_sequenceTitleCells[i] = new SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator); - m_expressionCells[i] = new FunctionExpressionCell(); + m_expressionCells[i] = new ModelExpressionCell(); } return Shared::ListController::loadView(); } diff --git a/apps/sequence/list/list_controller.h b/apps/sequence/list/list_controller.h index a6a95bc06..98bfa1550 100644 --- a/apps/sequence/list/list_controller.h +++ b/apps/sequence/list/list_controller.h @@ -4,9 +4,9 @@ #include #include "../sequence_title_cell.h" #include "../sequence_store.h" -#include "../../shared/function_expression_cell.h" #include "../../shared/list_controller.h" #include "../../shared/new_function_cell.h" +#include "../../shared/model_expression_cell.h" #include "../../shared/expression_layout_field_delegate.h" #include "../../shared/text_field_delegate.h" #include "list_parameter_controller.h" @@ -49,7 +49,7 @@ private: constexpr static int k_maxNumberOfRows = 3*MaxNumberOfSequences; SequenceStore * m_sequenceStore; SequenceTitleCell * m_sequenceTitleCells[k_maxNumberOfRows]; - Shared::FunctionExpressionCell * m_expressionCells[k_maxNumberOfRows]; + Shared::ModelExpressionCell * m_expressionCells[k_maxNumberOfRows]; ListParameterController m_parameterController; TypeParameterController m_typeParameterController; StackViewController m_typeStackController; diff --git a/apps/sequence/sequence_title_cell.cpp b/apps/sequence/sequence_title_cell.cpp index 7138d103f..b3371e88d 100644 --- a/apps/sequence/sequence_title_cell.cpp +++ b/apps/sequence/sequence_title_cell.cpp @@ -43,7 +43,7 @@ View * SequenceTitleCell::subviewAtIndex(int index) { void SequenceTitleCell::layoutSubviews() { KDRect textFrame(0, k_colorIndicatorThickness, bounds().width(), bounds().height() - k_colorIndicatorThickness); if (m_orientation == Orientation::VerticalIndicator){ - textFrame = KDRect(k_colorIndicatorThickness, 0, bounds().width() - k_colorIndicatorThickness, bounds().height()-k_separatorThickness); + textFrame = KDRect(k_colorIndicatorThickness, 0, bounds().width() - k_colorIndicatorThickness-k_separatorThickness, bounds().height()-k_separatorThickness); } m_titleTextView.setFrame(textFrame); } diff --git a/apps/shared/Makefile b/apps/shared/Makefile index 01c64faa4..901685a3c 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -17,7 +17,6 @@ app_objs += $(addprefix apps/shared/,\ function_graph_view.o\ function_graph_controller.o\ function_store.o\ - function_expression_cell.o\ function_title_cell.o\ go_to_parameter_controller.o\ initialisation_parameter_controller.o\ @@ -31,6 +30,7 @@ app_objs += $(addprefix apps/shared/,\ list_parameter_controller.o\ memoized_curve_view_range.o\ message_view.o\ + model_expression_cell.o\ new_function_cell.o\ ok_view.o\ parameter_text_field_delegate.o\ diff --git a/apps/shared/function_expression_cell.cpp b/apps/shared/function_expression_cell.cpp deleted file mode 100644 index c9345ee71..000000000 --- a/apps/shared/function_expression_cell.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "function_expression_cell.h" -#include - -using namespace Poincare; - -namespace Shared { - -FunctionExpressionCell::FunctionExpressionCell() : - EvenOddCell(), - m_expressionView() -{ -} - -void FunctionExpressionCell::setExpressionLayout(ExpressionLayout * expressionLayout) { - m_expressionView.setExpressionLayout(expressionLayout); -} - -void FunctionExpressionCell::setTextColor(KDColor textColor) { - m_expressionView.setTextColor(textColor); -} - -void FunctionExpressionCell::setEven(bool even) { - EvenOddCell::setEven(even); - m_expressionView.setBackgroundColor(backgroundColor()); -} - -void FunctionExpressionCell::setHighlighted(bool highlight) { - if (highlight != EvenOddCell::isHighlighted()) { - EvenOddCell::setHighlighted(highlight); - m_expressionView.setBackgroundColor(backgroundColor()); - } -} - -int FunctionExpressionCell::numberOfSubviews() const { - return 1; -} - -View * FunctionExpressionCell::subviewAtIndex(int index) { - assert(index == 0); - return &m_expressionView; -} - -void FunctionExpressionCell::layoutSubviews() { - KDRect expressionFrame(k_separatorThickness+k_margin, 0, bounds().width() - k_separatorThickness-k_margin, bounds().height()-k_separatorThickness); - m_expressionView.setFrame(expressionFrame); -} - -void FunctionExpressionCell::drawRect(KDContext * ctx, KDRect rect) const { - KDColor separatorColor = m_even ? Palette::WallScreen : KDColorWhite; - // Color the vertical separator - ctx->fillRect(KDRect(0, 0, k_separatorThickness, bounds().height()), Palette::GreyBright); - // Color the horizontal separator - ctx->fillRect(KDRect(k_separatorThickness, bounds().height()-k_separatorThickness, bounds().width()-k_separatorThickness, k_separatorThickness), separatorColor); - // Color the margin - ctx->fillRect(KDRect(k_separatorThickness, 0, k_margin, bounds().height()-k_separatorThickness), backgroundColor()); -} - -} diff --git a/apps/shared/function_expression_cell.h b/apps/shared/function_expression_cell.h deleted file mode 100644 index 351bbe360..000000000 --- a/apps/shared/function_expression_cell.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SHARED_FUNCTION_EXPRESSION_CELL_H -#define SHARED_FUNCTION_EXPRESSION_CELL_H - -#include -#include "function.h" - -namespace Shared { - -class FunctionExpressionCell : public EvenOddCell { -public: - FunctionExpressionCell(); - void setExpressionLayout(Poincare::ExpressionLayout * expressionLayout); - void setTextColor(KDColor color); - void setEven(bool even) override; - void setHighlighted(bool highlight) override; - int numberOfSubviews() const override; - View * subviewAtIndex(int index) override; - void layoutSubviews() override; - void drawRect(KDContext * ctx, KDRect rect) const override; -private: - constexpr static KDCoordinate k_separatorThickness = 1; - constexpr static KDCoordinate k_margin = 5; - ExpressionView m_expressionView; -}; - -} - -#endif diff --git a/apps/shared/function_title_cell.cpp b/apps/shared/function_title_cell.cpp index 495d8008c..76f57e7ca 100644 --- a/apps/shared/function_title_cell.cpp +++ b/apps/shared/function_title_cell.cpp @@ -17,12 +17,14 @@ void FunctionTitleCell::setColor(KDColor color) { void FunctionTitleCell::drawRect(KDContext * ctx, KDRect rect) const { if (m_orientation == Orientation::VerticalIndicator){ ctx->fillRect(KDRect(0, 0, k_colorIndicatorThickness, bounds().height()), m_functionColor); + // Color the vertical separator + ctx->fillRect(KDRect(bounds().width()-k_separatorThickness, 0, k_separatorThickness, bounds().height()), Palette::GreyBright); + KDColor separatorColor = m_even ? Palette::WallScreen : KDColorWhite; + // Color the horizontal separator + ctx->fillRect(KDRect(k_colorIndicatorThickness, bounds().height()-k_separatorThickness, bounds().width()-k_colorIndicatorThickness-k_separatorThickness, k_separatorThickness), separatorColor); } else { ctx->fillRect(KDRect(0, 0, bounds().width(), k_colorIndicatorThickness), m_functionColor); } - KDColor separatorColor = m_even ? Palette::WallScreen : KDColorWhite; - // Color the horizontal separator - ctx->fillRect(KDRect(k_colorIndicatorThickness, bounds().height()-k_separatorThickness, bounds().width()-k_colorIndicatorThickness, k_separatorThickness), separatorColor); } } diff --git a/apps/shared/function_title_cell.h b/apps/shared/function_title_cell.h index eba48301e..427926758 100644 --- a/apps/shared/function_title_cell.h +++ b/apps/shared/function_title_cell.h @@ -1,5 +1,5 @@ -#ifndef SEQUENCE_FUNCTION_TITLE_CELL_H -#define SEQUENCE_FUNCTION_TITLE_CELL_H +#ifndef SHARED_FUNCTION_TITLE_CELL_H +#define SHARED_FUNCTION_TITLE_CELL_H #include diff --git a/apps/shared/model_expression_cell.cpp b/apps/shared/model_expression_cell.cpp new file mode 100644 index 000000000..e12971fe9 --- /dev/null +++ b/apps/shared/model_expression_cell.cpp @@ -0,0 +1,28 @@ +#include "model_expression_cell.h" + +namespace Shared { + +ModelExpressionCell::ModelExpressionCell() : + EvenOddExpressionCell() +{ +} + +KDSize ModelExpressionCell::minimalSizeForOptimalDisplay() const { + KDSize expressionSize = m_expressionView.minimalSizeForOptimalDisplay(); + return KDSize(k_margin+expressionSize.width(), expressionSize.height()+k_separatorThickness); +} + +void ModelExpressionCell::drawRect(KDContext * ctx, KDRect rect) const { + KDColor separatorColor = m_even ? Palette::WallScreen : KDColorWhite; + // Color the horizontal separator + ctx->fillRect(KDRect(0, bounds().height()-k_separatorThickness, bounds().width(), k_separatorThickness), separatorColor); + // Color the margin + ctx->fillRect(KDRect(0, 0, k_margin, bounds().height()-k_separatorThickness), backgroundColor()); +} + +void ModelExpressionCell::layoutSubviews() { + KDRect expressionFrame(k_margin, 0, bounds().width() - k_margin, bounds().height()-k_separatorThickness); + m_expressionView.setFrame(expressionFrame); +} + +} diff --git a/apps/shared/model_expression_cell.h b/apps/shared/model_expression_cell.h new file mode 100644 index 000000000..a382caac2 --- /dev/null +++ b/apps/shared/model_expression_cell.h @@ -0,0 +1,21 @@ +#ifndef SHARED_MODEL_EXPRESSION_CELL_H +#define SHARED_MODEL_EXPRESSION_CELL_H + +#include + +namespace Shared { + +class ModelExpressionCell : public EvenOddExpressionCell { +public: + ModelExpressionCell(); + KDSize minimalSizeForOptimalDisplay() const override; + void drawRect(KDContext * ctx, KDRect rect) const override; + void layoutSubviews() override; +private: + constexpr static KDCoordinate k_separatorThickness = 1; + constexpr static KDCoordinate k_margin = 5; +}; + +} + +#endif diff --git a/escher/src/even_odd_expression_cell.cpp b/escher/src/even_odd_expression_cell.cpp index 4fb2e8739..6b2de9165 100644 --- a/escher/src/even_odd_expression_cell.cpp +++ b/escher/src/even_odd_expression_cell.cpp @@ -10,8 +10,10 @@ EvenOddExpressionCell::EvenOddExpressionCell(float horizontalAlignment, float ve } void EvenOddExpressionCell::setHighlighted(bool highlight) { - EvenOddCell::setHighlighted(highlight); - m_expressionView.setBackgroundColor(backgroundColor()); + if (highlight != EvenOddCell::isHighlighted()) { + EvenOddCell::setHighlighted(highlight); + m_expressionView.setBackgroundColor(backgroundColor()); + } } void EvenOddExpressionCell::setEven(bool even) {