diff --git a/escher/Makefile b/escher/Makefile index aec85857e..f21b2daf3 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -4,6 +4,7 @@ escher_src += $(addprefix escher/src/,\ alternate_empty_view_controller.cpp \ app.cpp \ bank_view_controller.cpp \ + bordered_cell.cpp \ buffer_text_view.cpp \ burger_menu_view.cpp \ button.cpp \ diff --git a/escher/include/escher/bordered_cell.h b/escher/include/escher/bordered_cell.h new file mode 100644 index 000000000..d1e02a651 --- /dev/null +++ b/escher/include/escher/bordered_cell.h @@ -0,0 +1,16 @@ +#ifndef ESCHER_BORDERED_CELL_H +#define ESCHER_BORDERED_CELL_H + +#include +#include + +class BorderedCell : public HighlightCell { +public: + using HighlightCell::HighlightCell; + void drawRect(KDContext * ctx, KDRect rect) const override; +protected: + constexpr static KDCoordinate k_separatorThickness = Metric::CellSeparatorThickness; +}; + +#endif + diff --git a/escher/include/escher/table_cell.h b/escher/include/escher/table_cell.h index a30cd08e7..12393e46e 100644 --- a/escher/include/escher/table_cell.h +++ b/escher/include/escher/table_cell.h @@ -1,10 +1,9 @@ #ifndef ESCHER_TABLE_CELL_H #define ESCHER_TABLE_CELL_H -#include -#include +#include -class TableCell : public HighlightCell { +class TableCell : public BorderedCell { public: /* Layout enum class determines the way subviews are layouted. * We can split the cell vertically or horizontally. @@ -28,7 +27,6 @@ protected: int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews(bool force = false) override; - constexpr static KDCoordinate k_separatorThickness = Metric::CellSeparatorThickness; constexpr static KDCoordinate k_verticalMargin = Metric::TableCellVerticalMargin; constexpr static KDCoordinate k_horizontalMargin = Metric::TableCellHorizontalMargin; private: diff --git a/escher/src/bordered_cell.cpp b/escher/src/bordered_cell.cpp new file mode 100644 index 000000000..1902ad3c1 --- /dev/null +++ b/escher/src/bordered_cell.cpp @@ -0,0 +1,12 @@ +#include +#include + +void BorderedCell::drawRect(KDContext * ctx, KDRect rect) const { + KDCoordinate width = bounds().width(); + KDCoordinate height = bounds().height(); + // Draw rectangle around cell + ctx->fillRect(KDRect(0, 0, width, k_separatorThickness), Palette::GreyBright); + ctx->fillRect(KDRect(0, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); + ctx->fillRect(KDRect(width-k_separatorThickness, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); + ctx->fillRect(KDRect(0, height-k_separatorThickness, width, k_separatorThickness), Palette::GreyBright); + } diff --git a/escher/src/table_cell.cpp b/escher/src/table_cell.cpp index 9df058c2c..196927436 100644 --- a/escher/src/table_cell.cpp +++ b/escher/src/table_cell.cpp @@ -6,7 +6,7 @@ static inline KDCoordinate minCoordinate(KDCoordinate x, KDCoordinate y) { retur static inline KDCoordinate maxCoordinate(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; } TableCell::TableCell(Layout layout) : - HighlightCell(), + BorderedCell(), m_layout(layout) { } @@ -169,9 +169,5 @@ void TableCell::drawRect(KDContext * ctx, KDRect rect) const { KDCoordinate height = bounds().height(); KDColor backgroundColor = isHighlighted() ? Palette::Select : KDColorWhite; ctx->fillRect(KDRect(k_separatorThickness, k_separatorThickness, width-2*k_separatorThickness, height-k_separatorThickness), backgroundColor); - // Draw rectangle around cell - ctx->fillRect(KDRect(0, 0, width, k_separatorThickness), Palette::GreyBright); - ctx->fillRect(KDRect(0, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); - ctx->fillRect(KDRect(width-k_separatorThickness, k_separatorThickness, k_separatorThickness, height-k_separatorThickness), Palette::GreyBright); - ctx->fillRect(KDRect(0, height-k_separatorThickness, width, k_separatorThickness), Palette::GreyBright); + BorderedCell::drawRect(ctx, rect); }