diff --git a/apps/shared/store_cell.cpp b/apps/shared/store_cell.cpp index 5a40d0dcf..cee473f52 100644 --- a/apps/shared/store_cell.cpp +++ b/apps/shared/store_cell.cpp @@ -1,10 +1,11 @@ #include "store_cell.h" +#include "escher/metric.h" namespace Shared { -void StoreCell::setSeparatorRight(bool separator) { - if (separatorRight() != separator) { - StoreSeparatorCell::setSeparatorRight(separator); +void StoreCell::setSeparatorLeft(bool separator) { + if (m_separatorLeft != separator) { + m_separatorLeft = separator; reloadCell(); } } @@ -12,14 +13,15 @@ void StoreCell::setSeparatorRight(bool separator) { void StoreCell::drawRect(KDContext * ctx, KDRect rect) const { HideableEvenOddEditableTextCell::drawRect(ctx, rect); // Draw the separator - if (separatorRight()) { - ctx->fillRect(KDRect(bounds().width() - k_separatorThickness, 0, k_separatorThickness, bounds().height()), HideableEvenOddEditableTextCell::hideColor()); + KDRect separatorRect(0, 0, Metric::TableSeparatorThickness, bounds().height()); + if (m_separatorLeft) { + ctx->fillRect(separatorRect, HideableEvenOddEditableTextCell::hideColor()); } } void StoreCell::layoutSubviews() { KDRect boundsThis = bounds(); - editableTextCell()->setFrame(KDRect(boundsThis.topLeft(), boundsThis.width() - k_separatorThickness, boundsThis.height())); + editableTextCell()->setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness, boundsThis.height())); } } diff --git a/apps/shared/store_cell.h b/apps/shared/store_cell.h index 4434ddc1e..cecf7dc55 100644 --- a/apps/shared/store_cell.h +++ b/apps/shared/store_cell.h @@ -2,19 +2,20 @@ #define APPS_SHARED_STORE_CELL_H #include "hideable_even_odd_editable_text_cell.h" -#include "store_separator_cell.h" namespace Shared { -class StoreCell : public HideableEvenOddEditableTextCell, public StoreSeparatorCell { +class StoreCell : public HideableEvenOddEditableTextCell { public: StoreCell(Responder * parentResponder = nullptr, TextFieldDelegate * delegate = nullptr, char * draftTextBuffer = nullptr) : HideableEvenOddEditableTextCell(parentResponder, delegate, draftTextBuffer), - StoreSeparatorCell() + m_separatorLeft(false) {} - void setSeparatorRight(bool separator) override; + void setSeparatorLeft(bool separator); void drawRect(KDContext * ctx, KDRect rect) const override; void layoutSubviews() override; +private: + bool m_separatorLeft; }; } diff --git a/apps/shared/store_controller.cpp b/apps/shared/store_controller.cpp index af3ee0a87..a0e6a5ef2 100644 --- a/apps/shared/store_controller.cpp +++ b/apps/shared/store_controller.cpp @@ -81,8 +81,8 @@ int StoreController::typeAtLocation(int i, int j) { void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) { // Handle the separator if (cellAtLocationIsEditable(i, j)) { - bool shoudHaveRightSeparator = i % FloatPairStore::k_numberOfColumnsPerSeries == 1; - static_cast(cell)->setSeparatorRight(shoudHaveRightSeparator); + bool shouldHaveLeftSeparator = i % FloatPairStore::k_numberOfColumnsPerSeries == 0; + static_cast(cell)->setSeparatorLeft(shouldHaveLeftSeparator); } // Handle empty cells if (j > 0 && j > m_store->numberOfPairsOfSeries(seriesAtColumn(i)) && j < numberOfRows()) { diff --git a/apps/shared/store_separator_cell.h b/apps/shared/store_separator_cell.h deleted file mode 100644 index d41697488..000000000 --- a/apps/shared/store_separator_cell.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef APPS_SHARED_STORE_SEPARATOR_CELL_H -#define APPS_SHARED_STORE_SEPARATOR_CELL_H - -namespace Shared { - -class StoreSeparatorCell { -public: - StoreSeparatorCell() : - m_separatorRight(false) - {} - bool separatorRight() const { return m_separatorRight; } - virtual void setSeparatorRight(bool separator) { m_separatorRight = separator; } -protected: - static constexpr KDCoordinate k_separatorThickness = 2; -private: - bool m_separatorRight; -}; - -} - -#endif diff --git a/apps/shared/store_title_cell.cpp b/apps/shared/store_title_cell.cpp index c57db4c67..8c341cfb4 100644 --- a/apps/shared/store_title_cell.cpp +++ b/apps/shared/store_title_cell.cpp @@ -1,11 +1,12 @@ #include "store_title_cell.h" #include "hideable_even_odd_editable_text_cell.h" +#include "escher/metric.h" namespace Shared { -void StoreTitleCell::setSeparatorRight(bool separator) { - if (separatorRight() != separator) { - StoreSeparatorCell::setSeparatorRight(separator); +void StoreTitleCell::setSeparatorLeft(bool separator) { + if (m_separatorLeft != separator) { + m_separatorLeft = separator; reloadCell(); } } @@ -13,8 +14,8 @@ void StoreTitleCell::setSeparatorRight(bool separator) { void StoreTitleCell::drawRect(KDContext * ctx, KDRect rect) const { BufferFunctionTitleCell::drawRect(ctx, rect); // Draw the separator - KDRect separatorRect(bounds().width() - StoreSeparatorCell::k_separatorThickness, separatorRight() ? 0 : k_colorIndicatorThickness, StoreSeparatorCell::k_separatorThickness, bounds().height()); - if (separatorRight()) { + KDRect separatorRect(0, m_separatorLeft ? 0 : k_colorIndicatorThickness, Metric::TableSeparatorThickness, bounds().height() - (m_separatorLeft ? 0 : k_colorIndicatorThickness)); + if (m_separatorLeft) { ctx->fillRect(separatorRect, HideableEvenOddEditableTextCell::hideColor()); } else { ctx->fillRect(separatorRect, backgroundColor()); @@ -23,7 +24,7 @@ void StoreTitleCell::drawRect(KDContext * ctx, KDRect rect) const { void StoreTitleCell::layoutSubviews() { KDRect textFrame = bufferTextViewFrame(); - bufferTextView()->setFrame(KDRect(textFrame.topLeft(), textFrame.width() - StoreSeparatorCell::k_separatorThickness, textFrame.height() )); + bufferTextView()->setFrame(KDRect(textFrame.left() + Metric::TableSeparatorThickness, textFrame.top(), textFrame.width() - Metric::TableSeparatorThickness, textFrame.height())); } } diff --git a/apps/shared/store_title_cell.h b/apps/shared/store_title_cell.h index aa86af37e..823c09c35 100644 --- a/apps/shared/store_title_cell.h +++ b/apps/shared/store_title_cell.h @@ -2,19 +2,20 @@ #define SHARED_STORE_TITLE_CELL_H #include "buffer_function_title_cell.h" -#include "store_separator_cell.h" namespace Shared { -class StoreTitleCell : public BufferFunctionTitleCell, public StoreSeparatorCell { +class StoreTitleCell : public BufferFunctionTitleCell { public: StoreTitleCell(Orientation orientation, KDText::FontSize size = KDText::FontSize::Large) : BufferFunctionTitleCell(orientation, size), - StoreSeparatorCell() + m_separatorLeft(false) {} - void setSeparatorRight(bool separator) override; + void setSeparatorLeft(bool separator); void drawRect(KDContext * ctx, KDRect rect) const override; void layoutSubviews() override; +private: + bool m_separatorLeft; }; } diff --git a/apps/statistics/Makefile b/apps/statistics/Makefile index a29315509..3e195aa67 100644 --- a/apps/statistics/Makefile +++ b/apps/statistics/Makefile @@ -8,6 +8,7 @@ app_objs += $(addprefix apps/statistics/,\ box_controller.o\ box_range.o\ box_view.o\ + calculation_cell.o\ calculation_controller.o\ histogram_banner_view.o\ histogram_controller.o\ diff --git a/apps/statistics/calculation_cell.cpp b/apps/statistics/calculation_cell.cpp new file mode 100644 index 000000000..8a7e3f1bd --- /dev/null +++ b/apps/statistics/calculation_cell.cpp @@ -0,0 +1,20 @@ +#include "calculation_cell.h" +#include "../shared/hideable_even_odd_editable_text_cell.h" +#include "escher/metric.h" + +namespace Statistics { + +void CalculationCell::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() { + KDRect boundsThis = bounds(); + m_bufferTextView.setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness, boundsThis.height())); +} + +} + diff --git a/apps/statistics/calculation_cell.h b/apps/statistics/calculation_cell.h new file mode 100644 index 000000000..bc33745ae --- /dev/null +++ b/apps/statistics/calculation_cell.h @@ -0,0 +1,17 @@ +#ifndef APPS_STATISTICS_CALCULATION_CELL_H +#define APPS_STATISTICS_CALCULATION_CELL_H + +#include + +namespace Statistics { + +class CalculationCell : public EvenOddBufferTextCell { +public: + using EvenOddBufferTextCell::EvenOddBufferTextCell; + void drawRect(KDContext * ctx, KDRect rect) const override; + void layoutSubviews() override; +}; + +} + +#endif diff --git a/apps/statistics/calculation_controller.cpp b/apps/statistics/calculation_controller.cpp index 0be21c480..ddf3cf922 100644 --- a/apps/statistics/calculation_controller.cpp +++ b/apps/statistics/calculation_controller.cpp @@ -200,14 +200,14 @@ Responder * CalculationController::tabController() const { View * CalculationController::loadView() { for (int i = 0; i < k_numberOfSeriesTitleCells; i++) { m_seriesTitleCells[i] = new StoreTitleCell(FunctionTitleCell::Orientation::HorizontalIndicator, KDText::FontSize::Small); - m_seriesTitleCells[i]->setSeparatorRight(true); + m_seriesTitleCells[i]->setSeparatorLeft(true); } for (int i = 0; i < k_numberOfCalculationTitleCells; i++) { m_calculationTitleCells[i] = new EvenOddMessageTextCell(KDText::FontSize::Small); m_calculationTitleCells[i]->setAlignment(1.0f, 0.5f); } for (int i = 0; i < k_numberOfCalculationCells; i++) { - m_calculationCells[i] = new EvenOddBufferTextCell(KDText::FontSize::Small); + m_calculationCells[i] = new CalculationCell(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 056acab2f..4ade377be 100644 --- a/apps/statistics/calculation_controller.h +++ b/apps/statistics/calculation_controller.h @@ -3,6 +3,7 @@ #include #include "store.h" +#include "calculation_cell.h" #include "../shared/hideable_even_odd_cell.h" #include "../shared/store_title_cell.h" #include "../shared/tab_table_controller.h" @@ -60,7 +61,7 @@ private: Shared::StoreTitleCell * m_seriesTitleCells[k_numberOfSeriesTitleCells]; EvenOddMessageTextCell * m_calculationTitleCells[k_numberOfCalculationTitleCells]; - EvenOddBufferTextCell * m_calculationCells[k_numberOfCalculationCells]; + CalculationCell * m_calculationCells[k_numberOfCalculationCells]; Shared::HideableEvenOddCell * m_hideableCell; Store * m_store; }; diff --git a/apps/statistics/store_controller.cpp b/apps/statistics/store_controller.cpp index f917ea312..ac9a15638 100644 --- a/apps/statistics/store_controller.cpp +++ b/apps/statistics/store_controller.cpp @@ -22,7 +22,7 @@ void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int return; } Shared::StoreTitleCell * mytitleCell = static_cast(cell); - mytitleCell->setSeparatorRight(i % Store::k_numberOfColumnsPerSeries == 1); + mytitleCell->setSeparatorLeft(i % Store::k_numberOfColumnsPerSeries == 0); int seriesIndex = i/Store::k_numberOfColumnsPerSeries; bool valuesColumn = i%Store::k_numberOfColumnsPerSeries == 0; assert(seriesIndex >= 0 && seriesIndex < FloatPairStore::k_numberOfSeries); diff --git a/escher/include/escher/metric.h b/escher/include/escher/metric.h index a2a7a1021..42e3211c0 100644 --- a/escher/include/escher/metric.h +++ b/escher/include/escher/metric.h @@ -29,6 +29,7 @@ public: constexpr static KDCoordinate FractionAndConjugateHorizontalOverflow = 2; constexpr static KDCoordinate FractionAndConjugateHorizontalMargin = 2; constexpr static KDCoordinate MinimalBracketAndParenthesisHeight = 18; + constexpr static KDCoordinate TableSeparatorThickness = 2; }; #endif