diff --git a/apps/regression/Makefile b/apps/regression/Makefile index c35c184a3..60595c5fc 100644 --- a/apps/regression/Makefile +++ b/apps/regression/Makefile @@ -5,7 +5,7 @@ app_objs += $(addprefix apps/regression/,\ app.o\ banner_view.o\ calculation_controller.o\ - even_odd_double_buffer_text_cell.o\ + even_odd_double_buffer_text_cell_with_separator.o\ go_to_parameter_controller.o\ graph_controller.o\ graph_view.o\ diff --git a/apps/regression/calculation_controller.cpp b/apps/regression/calculation_controller.cpp index 78cfdddaa..3bd262ee5 100644 --- a/apps/regression/calculation_controller.cpp +++ b/apps/regression/calculation_controller.cpp @@ -44,14 +44,14 @@ bool CalculationController::handleEvent(Ion::Events::Event event) { } if (event == Ion::Events::Copy && selectedColumn() == 1 && selectedRow() > 0) { if (selectedRow() <= k_totalNumberOfDoubleBufferRows) { - EvenOddDoubleBufferTextCell * myCell = (EvenOddDoubleBufferTextCell *)selectableTableView()->selectedCell(); + EvenOddDoubleBufferTextCellWithSeparator * myCell = (EvenOddDoubleBufferTextCellWithSeparator *)selectableTableView()->selectedCell(); if (myCell->firstTextSelected()) { Clipboard::sharedClipboard()->store(myCell->firstText()); } else { Clipboard::sharedClipboard()->store(myCell->secondText()); } } else { - EvenOddBufferTextCell * myCell = (EvenOddBufferTextCell *)selectableTableView()->selectedCell(); + SeparatorEvenOddBufferTextCell * myCell = (SeparatorEvenOddBufferTextCell *)selectableTableView()->selectedCell(); Clipboard::sharedClipboard()->store(myCell->text()); } return true; @@ -84,10 +84,10 @@ void CalculationController::tableViewDidChangeSelection(SelectableTableView * t, } } if (t->selectedColumn() > 0 && t->selectedRow() >= 0 && t->selectedRow() <= k_totalNumberOfDoubleBufferRows) { - EvenOddDoubleBufferTextCell * myCell = (EvenOddDoubleBufferTextCell *)t->selectedCell(); + EvenOddDoubleBufferTextCellWithSeparator * myCell = (EvenOddDoubleBufferTextCellWithSeparator *)t->selectedCell(); bool firstSubCellSelected = true; if (previousSelectedCellX == 1 && previousSelectedCellY >= 0 && previousSelectedCellY <= k_totalNumberOfDoubleBufferRows) { - EvenOddDoubleBufferTextCell * myPreviousCell = (EvenOddDoubleBufferTextCell *)t->cellAtLocation(previousSelectedCellX, previousSelectedCellY); + EvenOddDoubleBufferTextCellWithSeparator * myPreviousCell = (EvenOddDoubleBufferTextCellWithSeparator *)t->cellAtLocation(previousSelectedCellX, previousSelectedCellY); firstSubCellSelected = myPreviousCell->firstTextSelected(); } myCell->selectFirstText(firstSubCellSelected); @@ -129,7 +129,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int myCell->setExpressionLayout(m_r2Layout); return; } - EvenOddMessageTextCell * myCell = (EvenOddMessageTextCell *)cell; + MarginEvenOddMessageTextCell * myCell = (MarginEvenOddMessageTextCell *)cell; if (j == 0) { myCell->setMessage(I18n::Message::Default); return; @@ -145,7 +145,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int // Coordinate and series title if (j == 0 && i > 0) { - EvenOddDoubleBufferTextCell * myCell = (EvenOddDoubleBufferTextCell *)cell; + EvenOddDoubleBufferTextCellWithSeparator * myCell = (EvenOddDoubleBufferTextCellWithSeparator *)cell; char buffer[] = {'X', static_cast('0' + seriesNumber), 0}; myCell->setFirstText(buffer); buffer[0] = 'Y'; @@ -158,7 +158,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int ArgCalculPointer calculationMethods[k_totalNumberOfDoubleBufferRows] = {&Store::meanOfColumn, &Store::sumOfColumn, &Store::squaredValueSumOfColumn, &Store::standardDeviationOfColumn, &Store::varianceOfColumn}; double calculation1 = (m_store->*calculationMethods[j-1])(seriesNumber, 0); double calculation2 = (m_store->*calculationMethods[j-1])(seriesNumber, 1); - EvenOddDoubleBufferTextCell * myCell = (EvenOddDoubleBufferTextCell *)cell; + EvenOddDoubleBufferTextCellWithSeparator * myCell = (EvenOddDoubleBufferTextCellWithSeparator *)cell; char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; PrintFloat::convertFloatToText(calculation1, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); myCell->setFirstText(buffer); @@ -167,7 +167,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int return; } if (i > 0 && j == 9) { - EvenOddBufferTextCell * myCell = (EvenOddBufferTextCell *)cell; + SeparatorEvenOddBufferTextCell * myCell = (SeparatorEvenOddBufferTextCell *)cell; myCell->setText("ax+b"); return; } @@ -175,7 +175,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int assert(j != 9); CalculPointer calculationMethods[k_totalNumberOfRows-k_totalNumberOfDoubleBufferRows] = {&Store::doubleCastedNumberOfPairsOfSeries, &Store::covariance, &Store::columnProductSum, nullptr, &Store::slope, &Store::yIntercept, &Store::correlationCoefficient, &Store::squaredCorrelationCoefficient}; double calculation = (m_store->*calculationMethods[j-k_totalNumberOfDoubleBufferRows-1])(seriesNumber); - EvenOddBufferTextCell * myCell = (EvenOddBufferTextCell *)cell; + SeparatorEvenOddBufferTextCell * myCell = (SeparatorEvenOddBufferTextCell *)cell; char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; PrintFloat::convertFloatToText(calculation, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits); myCell->setText(buffer); @@ -259,18 +259,18 @@ View * CalculationController::loadView() { ; m_r2TitleCell = new EvenOddExpressionCell(1.0f, 0.5f); for (int i = 0; i < Store::k_numberOfSeries; i++) { - m_columnTitleCells[i] = new EvenOddDoubleBufferTextCell(tableView); + m_columnTitleCells[i] = new EvenOddDoubleBufferTextCellWithSeparator(tableView); } for (int i = 0; i < k_maxNumberOfDisplayableRows; i++) { - m_titleCells[i] = new EvenOddMessageTextCell(KDText::FontSize::Small); + m_titleCells[i] = new MarginEvenOddMessageTextCell(KDText::FontSize::Small); } for (int i = 0; i < k_numberOfDoubleCalculationCells; i++) { - m_doubleCalculationCells[i] = new EvenOddDoubleBufferTextCell(); + m_doubleCalculationCells[i] = new EvenOddDoubleBufferTextCellWithSeparator(); m_doubleCalculationCells[i]->setTextColor(Palette::GreyDark); m_doubleCalculationCells[i]->setParentResponder(tableView); } for (int i = 0; i < k_numberOfCalculationCells;i++) { - m_calculationCells[i] = new EvenOddBufferTextCell(KDText::FontSize::Small); + m_calculationCells[i] = new SeparatorEvenOddBufferTextCell(KDText::FontSize::Small); m_calculationCells[i]->setTextColor(Palette::GreyDark); } return tableView; diff --git a/apps/regression/calculation_controller.h b/apps/regression/calculation_controller.h index 382127586..98bb9245f 100644 --- a/apps/regression/calculation_controller.h +++ b/apps/regression/calculation_controller.h @@ -3,9 +3,12 @@ #include #include "store.h" -#include "even_odd_double_buffer_text_cell.h" +#include "even_odd_double_buffer_text_cell_with_separator.h" +#include "../shared/margin_even_odd_message_text_cell.h" #include "../shared/tab_table_controller.h" #include "../shared/regular_table_view_data_source.h" +#include "../shared/separator_even_odd_buffer_text_cell.h" +#include "../shared/store_cell.h" namespace Regression { @@ -53,12 +56,12 @@ private: static constexpr KDCoordinate k_cellHeight = 25; static constexpr KDCoordinate k_cellWidth = Ion::Display::Width/2 - Metric::CommonRightMargin/2 - Metric::CommonLeftMargin/2; - EvenOddMessageTextCell * m_titleCells[k_maxNumberOfDisplayableRows]; + Shared::MarginEvenOddMessageTextCell * m_titleCells[k_maxNumberOfDisplayableRows]; EvenOddExpressionCell * m_r2TitleCell; Poincare::ExpressionLayout * m_r2Layout; - EvenOddDoubleBufferTextCell * m_columnTitleCells[Store::k_numberOfSeries]; - EvenOddDoubleBufferTextCell * m_doubleCalculationCells[k_numberOfDoubleCalculationCells]; - EvenOddBufferTextCell * m_calculationCells[k_numberOfCalculationCells]; + EvenOddDoubleBufferTextCellWithSeparator * m_columnTitleCells[Store::k_numberOfSeries]; + EvenOddDoubleBufferTextCellWithSeparator * m_doubleCalculationCells[k_numberOfDoubleCalculationCells]; + Shared::SeparatorEvenOddBufferTextCell * m_calculationCells[k_numberOfCalculationCells]; Store * m_store; }; diff --git a/apps/regression/even_odd_double_buffer_text_cell.cpp b/apps/regression/even_odd_double_buffer_text_cell.cpp deleted file mode 100644 index 84776c85c..000000000 --- a/apps/regression/even_odd_double_buffer_text_cell.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "even_odd_double_buffer_text_cell.h" -#include - -EvenOddDoubleBufferTextCell::EvenOddDoubleBufferTextCell(Responder * parentResponder) : - EvenOddCell(), - Responder(parentResponder), - m_firstTextSelected(true), - m_firstBufferTextView(KDText::FontSize::Small), - m_secondBufferTextView(KDText::FontSize::Small) -{ -} - -const char * EvenOddDoubleBufferTextCell::firstText() { - return m_firstBufferTextView.text(); -} - -const char * EvenOddDoubleBufferTextCell::secondText() { - return m_secondBufferTextView.text(); -} - -bool EvenOddDoubleBufferTextCell::firstTextSelected() { - return m_firstTextSelected; -} - -void EvenOddDoubleBufferTextCell::selectFirstText(bool selectFirstText) { - m_firstTextSelected = selectFirstText; - m_firstBufferTextView.setHighlighted(selectFirstText); - m_secondBufferTextView.setHighlighted(!selectFirstText); - reloadCell(); -} - -void EvenOddDoubleBufferTextCell::reloadCell() { - m_firstBufferTextView.reloadCell(); - m_secondBufferTextView.reloadCell(); -} - -void EvenOddDoubleBufferTextCell::setHighlighted(bool highlight) { - m_firstBufferTextView.setHighlighted(false); - m_secondBufferTextView.setHighlighted(false); - HighlightCell::setHighlighted(highlight); - if (isHighlighted()) { - if (m_firstTextSelected) { - m_firstBufferTextView.setHighlighted(true); - } else { - m_secondBufferTextView.setHighlighted(false); - } - } - reloadCell(); -} - -void EvenOddDoubleBufferTextCell::setEven(bool even) { - m_firstBufferTextView.setEven(even); - m_secondBufferTextView.setEven(even); - reloadCell(); -} - -void EvenOddDoubleBufferTextCell::setFirstText(const char * textContent) { - m_firstBufferTextView.setText(textContent); -} - -void EvenOddDoubleBufferTextCell::setSecondText(const char * textContent) { - m_secondBufferTextView.setText(textContent); -} - -void EvenOddDoubleBufferTextCell::setTextColor(KDColor textColor) { - m_firstBufferTextView.setTextColor(textColor); - m_secondBufferTextView.setTextColor(textColor); -} - -int EvenOddDoubleBufferTextCell::numberOfSubviews() const { - return 2; -} - -View * EvenOddDoubleBufferTextCell::subviewAtIndex(int index) { - assert(index == 0 || index == 1); - if (index == 0) { - return &m_firstBufferTextView; - } - return &m_secondBufferTextView; -} - -void EvenOddDoubleBufferTextCell::layoutSubviews() { - KDCoordinate width = bounds().width(); - KDCoordinate height = bounds().height(); - m_firstBufferTextView.setFrame(KDRect(0, 0, width/2, height)); - m_secondBufferTextView.setFrame(KDRect(width/2, 0, width/2, height)); -} - -bool EvenOddDoubleBufferTextCell::handleEvent(Ion::Events::Event event) { - if (m_firstTextSelected && event == Ion::Events::Right) { - selectFirstText(false); - return true; - } - if (!m_firstTextSelected && event == Ion::Events::Left) { - selectFirstText(true); - return true; - } - return false; -} - 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 new file mode 100644 index 000000000..966fbd8b8 --- /dev/null +++ b/apps/regression/even_odd_double_buffer_text_cell_with_separator.cpp @@ -0,0 +1,109 @@ +#include "even_odd_double_buffer_text_cell_with_separator.h" +#include "../shared/hideable_even_odd_editable_text_cell.h" +#include "escher/metric.h" +#include + +EvenOddDoubleBufferTextCellWithSeparator::EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder) : + EvenOddCell(), + Responder(parentResponder), + m_firstTextSelected(true), + m_firstBufferTextView(KDText::FontSize::Small), + m_secondBufferTextView(KDText::FontSize::Small) +{ +} + +const char * EvenOddDoubleBufferTextCellWithSeparator::firstText() { + return m_firstBufferTextView.text(); +} + +const char * EvenOddDoubleBufferTextCellWithSeparator::secondText() { + return m_secondBufferTextView.text(); +} + +bool EvenOddDoubleBufferTextCellWithSeparator::firstTextSelected() { + return m_firstTextSelected; +} + +void EvenOddDoubleBufferTextCellWithSeparator::selectFirstText(bool selectFirstText) { + m_firstTextSelected = selectFirstText; + m_firstBufferTextView.setHighlighted(selectFirstText); + m_secondBufferTextView.setHighlighted(!selectFirstText); + reloadCell(); +} + +void EvenOddDoubleBufferTextCellWithSeparator::reloadCell() { + m_firstBufferTextView.reloadCell(); + m_secondBufferTextView.reloadCell(); +} + +void EvenOddDoubleBufferTextCellWithSeparator::setHighlighted(bool highlight) { + m_firstBufferTextView.setHighlighted(false); + m_secondBufferTextView.setHighlighted(false); + HighlightCell::setHighlighted(highlight); + if (isHighlighted()) { + if (m_firstTextSelected) { + m_firstBufferTextView.setHighlighted(true); + } else { + m_secondBufferTextView.setHighlighted(false); + } + } + reloadCell(); +} + +void EvenOddDoubleBufferTextCellWithSeparator::setEven(bool even) { + m_firstBufferTextView.setEven(even); + m_secondBufferTextView.setEven(even); + reloadCell(); +} + +void EvenOddDoubleBufferTextCellWithSeparator::setFirstText(const char * textContent) { + m_firstBufferTextView.setText(textContent); +} + +void EvenOddDoubleBufferTextCellWithSeparator::setSecondText(const char * textContent) { + m_secondBufferTextView.setText(textContent); +} + +void EvenOddDoubleBufferTextCellWithSeparator::setTextColor(KDColor textColor) { + m_firstBufferTextView.setTextColor(textColor); + m_secondBufferTextView.setTextColor(textColor); +} + +void EvenOddDoubleBufferTextCellWithSeparator::drawRect(KDContext * ctx, KDRect rect) const { + EvenOddCell::drawRect(ctx, rect); + // Draw the separator + KDRect separatorRect(0, 0, Metric::TableSeparatorThickness, bounds().height()); + ctx->fillRect(separatorRect, Shared::HideableEvenOddEditableTextCell::hideColor()); +} + +int EvenOddDoubleBufferTextCellWithSeparator::numberOfSubviews() const { + return 2; +} + +View * EvenOddDoubleBufferTextCellWithSeparator::subviewAtIndex(int index) { + assert(index == 0 || index == 1); + if (index == 0) { + return &m_firstBufferTextView; + } + return &m_secondBufferTextView; +} + +void EvenOddDoubleBufferTextCellWithSeparator::layoutSubviews() { + KDCoordinate width = bounds().width() - Metric::TableSeparatorThickness; + KDCoordinate height = bounds().height(); + m_firstBufferTextView.setFrame(KDRect(Metric::TableSeparatorThickness, 0, width/2, height)); + m_secondBufferTextView.setFrame(KDRect(Metric::TableSeparatorThickness + width/2, 0, width/2, height)); +} + +bool EvenOddDoubleBufferTextCellWithSeparator::handleEvent(Ion::Events::Event event) { + if (m_firstTextSelected && event == Ion::Events::Right) { + selectFirstText(false); + return true; + } + if (!m_firstTextSelected && event == Ion::Events::Left) { + selectFirstText(true); + return true; + } + return false; +} + diff --git a/apps/regression/even_odd_double_buffer_text_cell.h b/apps/regression/even_odd_double_buffer_text_cell_with_separator.h similarity index 68% rename from apps/regression/even_odd_double_buffer_text_cell.h rename to apps/regression/even_odd_double_buffer_text_cell_with_separator.h index b3e8b6b2d..a79a2aad6 100644 --- a/apps/regression/even_odd_double_buffer_text_cell.h +++ b/apps/regression/even_odd_double_buffer_text_cell_with_separator.h @@ -1,11 +1,11 @@ -#ifndef REGRESSION_EVEN_ODD_DOUBLE_BUFFER_TEXT_CELL_H -#define REGRESSION_EVEN_ODD_DOUBLE_BUFFER_TEXT_CELL_H +#ifndef REGRESSION_EVEN_ODD_DOUBLE_BUFFER_TEXT_CELL_WITH_SEPARATOR_H +#define REGRESSION_EVEN_ODD_DOUBLE_BUFFER_TEXT_CELL_WITH_SEPARATOR_H #include -class EvenOddDoubleBufferTextCell : public EvenOddCell, public Responder{ +class EvenOddDoubleBufferTextCellWithSeparator : public EvenOddCell, public Responder{ public: - EvenOddDoubleBufferTextCell(Responder * parentResponder = nullptr); + EvenOddDoubleBufferTextCellWithSeparator(Responder * parentResponder = nullptr); const char * firstText(); const char * secondText(); void reloadCell() override; @@ -19,6 +19,7 @@ public: void setFirstText(const char * textContent); void setSecondText(const char * textContent); void setTextColor(KDColor textColor); + void drawRect(KDContext * ctx, KDRect rect) const override; int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews() override; diff --git a/apps/shared/Makefile b/apps/shared/Makefile index a07fccbc5..4eb69c7ed 100644 --- a/apps/shared/Makefile +++ b/apps/shared/Makefile @@ -8,6 +8,7 @@ app_objs += $(addprefix apps/shared/,\ curve_view_range.o\ editable_cell_table_view_controller.o\ expression_field_delegate_app.o\ + expression_layout_field_delegate.o\ float_pair_store.o\ float_parameter_controller.o\ function.o\ @@ -32,6 +33,7 @@ app_objs += $(addprefix apps/shared/,\ language_controller.o\ list_controller.o\ list_parameter_controller.o\ + margin_even_odd_message_text_cell.o\ memoized_curve_view_range.o\ message_view.o\ new_function_cell.o\ @@ -40,8 +42,8 @@ app_objs += $(addprefix apps/shared/,\ range_parameter_controller.o\ regular_table_view_data_source.o\ round_cursor_view.o\ + separator_even_odd_buffer_text_cell.o\ simple_interactive_curve_view_controller.o\ - expression_layout_field_delegate.o\ store_cell.o\ store_controller.o\ store_parameter_controller.o\ diff --git a/apps/shared/margin_even_odd_message_text_cell.cpp b/apps/shared/margin_even_odd_message_text_cell.cpp new file mode 100644 index 000000000..7ed79a3b3 --- /dev/null +++ b/apps/shared/margin_even_odd_message_text_cell.cpp @@ -0,0 +1,10 @@ +#include "margin_even_odd_message_text_cell.h" + +namespace Shared { + +void MarginEvenOddMessageTextCell::layoutSubviews() { + m_messageTextView.setFrame(KDRect(bounds().topLeft(), bounds().width() - k_rightMargin, bounds().height())); +} + +} + diff --git a/apps/shared/margin_even_odd_message_text_cell.h b/apps/shared/margin_even_odd_message_text_cell.h new file mode 100644 index 000000000..051b988ab --- /dev/null +++ b/apps/shared/margin_even_odd_message_text_cell.h @@ -0,0 +1,20 @@ +#ifndef APPS_SHARED_MARGIN_EVEN_ODD_MESSAGE_TEXT_CELL_H +#define APPS_SHARED_MARGIN_EVEN_ODD_MESSAGE_TEXT_CELL_H + +#include + +namespace Shared { + +class MarginEvenOddMessageTextCell : public EvenOddMessageTextCell { +public: + MarginEvenOddMessageTextCell(KDText::FontSize size = KDText::FontSize::Small) : + EvenOddMessageTextCell(size) + {} + void layoutSubviews() override; +private: + constexpr static KDCoordinate k_rightMargin = 2; +}; + +} + +#endif diff --git a/apps/statistics/calculation_cell.cpp b/apps/shared/separator_even_odd_buffer_text_cell.cpp similarity index 62% rename from apps/statistics/calculation_cell.cpp rename to apps/shared/separator_even_odd_buffer_text_cell.cpp index ccb886a26..c87c45f91 100644 --- a/apps/statistics/calculation_cell.cpp +++ b/apps/shared/separator_even_odd_buffer_text_cell.cpp @@ -1,17 +1,17 @@ -#include "calculation_cell.h" -#include "../shared/hideable_even_odd_editable_text_cell.h" -#include "escher/metric.h" +#include "separator_even_odd_buffer_text_cell.h" +#include "hideable_even_odd_editable_text_cell.h" +#include -namespace Statistics { +namespace Shared { -void CalculationCell::drawRect(KDContext * ctx, KDRect rect) const { +void SeparatorEvenOddBufferTextCell::drawRect(KDContext * ctx, KDRect rect) const { EvenOddBufferTextCell::drawRect(ctx, rect); // Draw the separator KDRect separatorRect(0, 0, Metric::TableSeparatorThickness, bounds().height()); ctx->fillRect(separatorRect, Shared::HideableEvenOddEditableTextCell::hideColor()); } -void CalculationCell::layoutSubviews() { +void SeparatorEvenOddBufferTextCell::layoutSubviews() { KDRect boundsThis = bounds(); m_bufferTextView.setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness - k_rightMargin, boundsThis.height())); } diff --git a/apps/statistics/calculation_cell.h b/apps/shared/separator_even_odd_buffer_text_cell.h similarity index 60% rename from apps/statistics/calculation_cell.h rename to apps/shared/separator_even_odd_buffer_text_cell.h index a4ca0a4bc..1fd885ed5 100644 --- a/apps/statistics/calculation_cell.h +++ b/apps/shared/separator_even_odd_buffer_text_cell.h @@ -1,11 +1,11 @@ -#ifndef APPS_STATISTICS_CALCULATION_CELL_H -#define APPS_STATISTICS_CALCULATION_CELL_H +#ifndef APPS_SHARED_SEPARATOR_EVEN_ODD_CELL_H +#define APPS_SHARED_SEPARATOR_EVEN_ODD_CELL_H #include -namespace Statistics { +namespace Shared { -class CalculationCell : public EvenOddBufferTextCell { +class SeparatorEvenOddBufferTextCell : public EvenOddBufferTextCell { public: using EvenOddBufferTextCell::EvenOddBufferTextCell; void drawRect(KDContext * ctx, KDRect rect) const override; diff --git a/apps/statistics/Makefile b/apps/statistics/Makefile index f1d5a02b3..17245d25d 100644 --- a/apps/statistics/Makefile +++ b/apps/statistics/Makefile @@ -8,10 +8,8 @@ app_objs += $(addprefix apps/statistics/,\ box_controller.o\ box_range.o\ box_view.o\ - calculation_cell.o\ calculation_controller.o\ calculation_selectable_table_view.o\ - calculation_title_cell.o\ histogram_banner_view.o\ histogram_controller.o\ histogram_parameter_controller.o\ diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index a6a3f649b..48fe4e700 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -75,7 +75,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int I18n::Message::Sum, I18n::Message::SquareSum, I18n::Message::SampleStandardDeviationS}; - CalculationTitleCell * calcTitleCell = static_cast(cell); + MarginEvenOddMessageTextCell * calcTitleCell = static_cast(cell); calcTitleCell->setMessage(titles[j-1]); return; } @@ -205,11 +205,11 @@ View * CalculationController::loadView() { m_seriesTitleCells[i]->setSeparatorLeft(true); } for (int i = 0; i < k_numberOfCalculationTitleCells; i++) { - m_calculationTitleCells[i] = new CalculationTitleCell(KDText::FontSize::Small); + m_calculationTitleCells[i] = new MarginEvenOddMessageTextCell(KDText::FontSize::Small); m_calculationTitleCells[i]->setAlignment(1.0f, 0.5f); } for (int i = 0; i < k_numberOfCalculationCells; i++) { - m_calculationCells[i] = new CalculationCell(KDText::FontSize::Small); + m_calculationCells[i] = new SeparatorEvenOddBufferTextCell(KDText::FontSize::Small); m_calculationCells[i]->setTextColor(Palette::GreyDark); } m_hideableCell = new HideableEvenOddCell(); diff --git a/apps/statistics/calculation_controller.h b/apps/statistics/calculation_controller.h index 90a25dfb1..2744272b6 100644 --- a/apps/statistics/calculation_controller.h +++ b/apps/statistics/calculation_controller.h @@ -6,6 +6,8 @@ #include "calculation_cell.h" #include "calculation_title_cell.h" #include "../shared/hideable_even_odd_cell.h" +#include "../shared/margin_even_odd_message_text_cell.h" +#include "../shared/separator_even_odd_buffer_text_cell.h" #include "../shared/store_title_cell.h" #include "../shared/tab_table_controller.h" @@ -63,8 +65,8 @@ private: void unloadView(View * view) override; Shared::StoreTitleCell * m_seriesTitleCells[k_numberOfSeriesTitleCells]; - CalculationTitleCell * m_calculationTitleCells[k_numberOfCalculationTitleCells]; - CalculationCell * m_calculationCells[k_numberOfCalculationCells]; + Shared::MarginEvenOddMessageTextCell * m_calculationTitleCells[k_numberOfCalculationTitleCells]; + Shared::SeparatorEvenOddBufferTextCell * m_calculationCells[k_numberOfCalculationCells]; Shared::HideableEvenOddCell * m_hideableCell; Store * m_store; }; diff --git a/apps/statistics/calculation_title_cell.cpp b/apps/statistics/calculation_title_cell.cpp deleted file mode 100644 index fcfb58bec..000000000 --- a/apps/statistics/calculation_title_cell.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "calculation_title_cell.h" - -namespace Statistics { - -void CalculationTitleCell::layoutSubviews() { - m_messageTextView.setFrame(KDRect(bounds().topLeft(), bounds().width() - k_rightMargin, bounds().height())); -} - -} - diff --git a/apps/statistics/calculation_title_cell.h b/apps/statistics/calculation_title_cell.h deleted file mode 100644 index 22a5f85e6..000000000 --- a/apps/statistics/calculation_title_cell.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef APPS_STATISTICS_CALCULATION_TITLE_CELL_H -#define APPS_STATISTICS_CALCULATION_TITLE_CELL_H - -#include - -namespace Statistics { - -class CalculationTitleCell : public EvenOddMessageTextCell { -public: - CalculationTitleCell(KDText::FontSize size = KDText::FontSize::Small) : - EvenOddMessageTextCell(size) - {} - void layoutSubviews() override; -private: - constexpr static KDCoordinate k_rightMargin = 2; -}; - -} - -#endif