From 6f70924893b3d650d413dca7f0091733b3dac71a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 23 Sep 2019 15:33:27 +0200 Subject: [PATCH] [escher] EvenOddBufferTextCell wraps the text view with a 2-pixel margin --- apps/regression/Makefile | 1 - .../even_odd_buffer_text_cell_with_margin.cpp | 12 ------------ .../even_odd_buffer_text_cell_with_margin.h | 17 ----------------- ...odd_double_buffer_text_cell_with_separator.h | 5 ++--- .../separator_even_odd_buffer_text_cell.cpp | 2 +- .../include/escher/even_odd_buffer_text_cell.h | 1 + escher/src/even_odd_buffer_text_cell.cpp | 4 +++- 7 files changed, 7 insertions(+), 35 deletions(-) delete mode 100644 apps/regression/even_odd_buffer_text_cell_with_margin.cpp delete mode 100644 apps/regression/even_odd_buffer_text_cell_with_margin.h diff --git a/apps/regression/Makefile b/apps/regression/Makefile index 085082ed3..580f13cd4 100644 --- a/apps/regression/Makefile +++ b/apps/regression/Makefile @@ -25,7 +25,6 @@ app_regression_src = $(addprefix apps/regression/,\ banner_view.cpp \ calculation_controller.cpp \ column_title_cell.cpp \ - even_odd_buffer_text_cell_with_margin.cpp \ even_odd_double_buffer_text_cell_with_separator.cpp \ graph_controller.cpp \ graph_options_controller.cpp \ diff --git a/apps/regression/even_odd_buffer_text_cell_with_margin.cpp b/apps/regression/even_odd_buffer_text_cell_with_margin.cpp deleted file mode 100644 index 63602fe64..000000000 --- a/apps/regression/even_odd_buffer_text_cell_with_margin.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "even_odd_buffer_text_cell_with_margin.h" -#include - -namespace Regression { - -void EvenOddBufferTextCellWithMargin::layoutSubviews() { - KDRect boundsThis = bounds(); - KDRect boundsBuffer = KDRect(boundsThis.left() + k_horizontalMargin, boundsThis.top(), boundsThis.width() - 2*k_horizontalMargin, boundsThis.height()); - m_bufferTextView.setFrame(boundsBuffer); -} - -} diff --git a/apps/regression/even_odd_buffer_text_cell_with_margin.h b/apps/regression/even_odd_buffer_text_cell_with_margin.h deleted file mode 100644 index 414f9cfd5..000000000 --- a/apps/regression/even_odd_buffer_text_cell_with_margin.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef REGRESSION_EVEN_ODD_BUFFER_TEXT_CELL_WITH_MARGIN_H -#define REGRESSION_EVEN_ODD_BUFFER_TEXT_CELL_WITH_MARGIN_H - -#include - -namespace Regression { - -class EvenOddBufferTextCellWithMargin : public EvenOddBufferTextCell { -public: - using EvenOddBufferTextCell::EvenOddBufferTextCell; - void layoutSubviews() override; -private: - static constexpr KDCoordinate k_horizontalMargin = 2; -}; - -} -#endif 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 00c8f580d..8f7c8c260 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 @@ -2,7 +2,6 @@ #define REGRESSION_EVEN_ODD_DOUBLE_BUFFER_TEXT_CELL_WITH_SEPARATOR_H #include -#include "even_odd_buffer_text_cell_with_margin.h" namespace Regression { @@ -30,8 +29,8 @@ public: bool handleEvent(Ion::Events::Event event) override; protected: bool m_firstTextSelected; - EvenOddBufferTextCellWithMargin m_firstBufferTextView; - EvenOddBufferTextCellWithMargin m_secondBufferTextView; + EvenOddBufferTextCell m_firstBufferTextView; + EvenOddBufferTextCell m_secondBufferTextView; }; } diff --git a/apps/shared/separator_even_odd_buffer_text_cell.cpp b/apps/shared/separator_even_odd_buffer_text_cell.cpp index c87c45f91..10eb5ef83 100644 --- a/apps/shared/separator_even_odd_buffer_text_cell.cpp +++ b/apps/shared/separator_even_odd_buffer_text_cell.cpp @@ -13,7 +13,7 @@ void SeparatorEvenOddBufferTextCell::drawRect(KDContext * ctx, KDRect rect) cons void SeparatorEvenOddBufferTextCell::layoutSubviews() { KDRect boundsThis = bounds(); - m_bufferTextView.setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness - k_rightMargin, boundsThis.height())); + m_bufferTextView.setFrame(KDRect(boundsThis.left() + Metric::TableSeparatorThickness + k_horizontalMargin, boundsThis.top(), boundsThis.width() - Metric::TableSeparatorThickness - 2*k_horizontalMargin, boundsThis.height())); } } diff --git a/escher/include/escher/even_odd_buffer_text_cell.h b/escher/include/escher/even_odd_buffer_text_cell.h index 45e0405d5..98e961407 100644 --- a/escher/include/escher/even_odd_buffer_text_cell.h +++ b/escher/include/escher/even_odd_buffer_text_cell.h @@ -22,6 +22,7 @@ public: void setText(const char * textContent); void setTextColor(KDColor textColor); protected: + static constexpr KDCoordinate k_horizontalMargin = 2; int numberOfSubviews() const override; View * subviewAtIndex(int index) override; void layoutSubviews() override; diff --git a/escher/src/even_odd_buffer_text_cell.cpp b/escher/src/even_odd_buffer_text_cell.cpp index 0e33e2d0c..48e3ba1ea 100644 --- a/escher/src/even_odd_buffer_text_cell.cpp +++ b/escher/src/even_odd_buffer_text_cell.cpp @@ -39,5 +39,7 @@ View * EvenOddBufferTextCell::subviewAtIndex(int index) { } void EvenOddBufferTextCell::layoutSubviews() { - m_bufferTextView.setFrame(bounds()); + KDRect boundsThis = bounds(); + KDRect boundsBuffer = KDRect(boundsThis.left() + k_horizontalMargin, boundsThis.top(), boundsThis.width() - 2*k_horizontalMargin, boundsThis.height()); + m_bufferTextView.setFrame(boundsBuffer); }