diff --git a/apps/regression/Makefile b/apps/regression/Makefile index 8266a5b9a..455d988f1 100644 --- a/apps/regression/Makefile +++ b/apps/regression/Makefile @@ -5,6 +5,7 @@ app_objs += $(addprefix apps/regression/,\ app.o\ banner_view.o\ calculation_controller.o\ + column_title_cell.o\ even_odd_buffer_text_cell_with_margin.o\ even_odd_double_buffer_text_cell_with_separator.o\ even_odd_expression_cell_with_margin.o\ diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index e73dfe314..38ca5df2d 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -145,11 +145,12 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int // Coordinate and series title if (j == 0 && i > 0) { - EvenOddDoubleBufferTextCellWithSeparator * myCell = (EvenOddDoubleBufferTextCellWithSeparator *)cell; + ColumnTitleCell * myCell = (ColumnTitleCell *)cell; char buffer[] = {'X', static_cast('0' + seriesNumber), 0}; myCell->setFirstText(buffer); buffer[0] = 'Y'; myCell->setSecondText(buffer); + myCell->setColor(Palette::DataColor[seriesNumber]); return; } @@ -259,7 +260,7 @@ View * CalculationController::loadView() { ; m_r2TitleCell = new EvenOddExpressionCellWithMargin(1.0f, 0.5f); for (int i = 0; i < Store::k_numberOfSeries; i++) { - m_columnTitleCells[i] = new EvenOddDoubleBufferTextCellWithSeparator(tableView); + m_columnTitleCells[i] = new ColumnTitleCell(tableView); } for (int i = 0; i < k_maxNumberOfDisplayableRows; i++) { m_titleCells[i] = new MarginEvenOddMessageTextCell(KDText::FontSize::Small); diff --git a/apps/regression/calculation_controller.h b/apps/regression/calculation_controller.h index 8f1f0f207..341b82828 100644 --- a/apps/regression/calculation_controller.h +++ b/apps/regression/calculation_controller.h @@ -3,6 +3,7 @@ #include #include "store.h" +#include "column_title_cell.h" #include "even_odd_double_buffer_text_cell_with_separator.h" #include "even_odd_expression_cell_with_margin.h" #include "../shared/margin_even_odd_message_text_cell.h" @@ -60,7 +61,7 @@ private: Shared::MarginEvenOddMessageTextCell * m_titleCells[k_maxNumberOfDisplayableRows]; EvenOddExpressionCellWithMargin * m_r2TitleCell; Poincare::ExpressionLayout * m_r2Layout; - EvenOddDoubleBufferTextCellWithSeparator * m_columnTitleCells[Store::k_numberOfSeries]; + ColumnTitleCell * m_columnTitleCells[Store::k_numberOfSeries]; EvenOddDoubleBufferTextCellWithSeparator * m_doubleCalculationCells[k_numberOfDoubleCalculationCells]; Shared::SeparatorEvenOddBufferTextCell * m_calculationCells[k_numberOfCalculationCells]; Store * m_store; diff --git a/apps/regression/column_title_cell.cpp b/apps/regression/column_title_cell.cpp new file mode 100644 index 000000000..12eeaf985 --- /dev/null +++ b/apps/regression/column_title_cell.cpp @@ -0,0 +1,24 @@ +#include "column_title_cell.h" + +namespace Regression { + +void ColumnTitleCell::setColor(KDColor color) { + m_functionColor = color; + m_firstBufferTextView.setTextColor(color); + m_secondBufferTextView.setTextColor(color); + reloadCell(); +} + +void ColumnTitleCell::drawRect(KDContext * ctx, KDRect rect) const { + EvenOddDoubleBufferTextCellWithSeparator::drawRect(ctx, rect); + ctx->fillRect(KDRect(Metric::TableSeparatorThickness, 0, bounds().width(), k_colorIndicatorThickness), m_functionColor); +} + +void ColumnTitleCell::layoutSubviews() { + KDCoordinate width = bounds().width() - Metric::TableSeparatorThickness; + KDCoordinate height = bounds().height(); + m_firstBufferTextView.setFrame(KDRect(Metric::TableSeparatorThickness, k_colorIndicatorThickness, width/2, height - k_colorIndicatorThickness)); + m_secondBufferTextView.setFrame(KDRect(Metric::TableSeparatorThickness + width/2, k_colorIndicatorThickness, width/2, height - k_colorIndicatorThickness)); +} + +} diff --git a/apps/regression/column_title_cell.h b/apps/regression/column_title_cell.h new file mode 100644 index 000000000..fa85817a1 --- /dev/null +++ b/apps/regression/column_title_cell.h @@ -0,0 +1,25 @@ +#ifndef REGRESSION_COLUMN_TITLE_CELL_H +#define REGRESSION_COLUMN_TITLE_CELL_H + +#include "even_odd_double_buffer_text_cell_with_separator.h" + +namespace Regression { + +class ColumnTitleCell : public EvenOddDoubleBufferTextCellWithSeparator { +public: + ColumnTitleCell(Responder * parentResponder = nullptr) : + EvenOddDoubleBufferTextCellWithSeparator(parentResponder, 0.5f, 0.5f), + m_functionColor(Palette::Red) + { + } + virtual void setColor(KDColor color); + void drawRect(KDContext * ctx, KDRect rect) const override; + void layoutSubviews() override; +private: + constexpr static KDCoordinate k_colorIndicatorThickness = 2; + KDColor m_functionColor; +}; + +} + +#endif diff --git a/apps/regression/even_odd_double_buffer_text_cell_with_separator.cpp b/apps/regression/even_odd_double_buffer_text_cell_with_separator.cpp index 0375ee3d7..3921dd6e5 100644 --- a/apps/regression/even_odd_double_buffer_text_cell_with_separator.cpp +++ b/apps/regression/even_odd_double_buffer_text_cell_with_separator.cpp @@ -5,12 +5,12 @@ namespace Regression { -EvenOddDoubleBufferTextCellWithSeparator::EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder) : +EvenOddDoubleBufferTextCellWithSeparator::EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder, float horizontalAlignment, float verticalAlignment) : EvenOddCell(), Responder(parentResponder), m_firstTextSelected(true), - m_firstBufferTextView(KDText::FontSize::Small), - m_secondBufferTextView(KDText::FontSize::Small) + m_firstBufferTextView(KDText::FontSize::Small, horizontalAlignment, verticalAlignment), + m_secondBufferTextView(KDText::FontSize::Small, horizontalAlignment, verticalAlignment) { } diff --git a/apps/regression/even_odd_double_buffer_text_cell_with_separator.h b/apps/regression/even_odd_double_buffer_text_cell_with_separator.h index e140bdeba..830655ef1 100644 --- a/apps/regression/even_odd_double_buffer_text_cell_with_separator.h +++ b/apps/regression/even_odd_double_buffer_text_cell_with_separator.h @@ -8,7 +8,7 @@ namespace Regression { class EvenOddDoubleBufferTextCellWithSeparator : public EvenOddCell, public Responder{ public: - EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder = nullptr); + EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder = nullptr, float horizontalAlignment = 1.0f, float verticalAlignment = 0.5f); const char * firstText(); const char * secondText(); void reloadCell() override;