From de4ae4a3a86fbf50d58edc138a447eb812553101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 19 Dec 2016 12:13:57 +0100 Subject: [PATCH] [escher] Add a class even odd pointer text cell Change-Id: I843ad6626fff17306ab288e532eba6273a034573 --- escher/Makefile | 1 + escher/include/escher.h | 1 + .../escher/even_odd_pointer_text_cell.h | 19 ++++++++++++ escher/src/even_odd_pointer_text_cell.cpp | 31 +++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 escher/include/escher/even_odd_pointer_text_cell.h create mode 100644 escher/src/even_odd_pointer_text_cell.cpp diff --git a/escher/Makefile b/escher/Makefile index 0d670414c..10a315c4c 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -12,6 +12,7 @@ objs += $(addprefix escher/src/,\ editable_text_cell.o\ even_odd_cell.o\ even_odd_editable_text_cell.o\ + even_odd_pointer_text_cell.o\ expression_view.o\ header_view_controller.o\ header_view_delegate.o\ diff --git a/escher/include/escher.h b/escher/include/escher.h index 1850e5503..6fdb9876b 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/escher/include/escher/even_odd_pointer_text_cell.h b/escher/include/escher/even_odd_pointer_text_cell.h new file mode 100644 index 000000000..9732efc30 --- /dev/null +++ b/escher/include/escher/even_odd_pointer_text_cell.h @@ -0,0 +1,19 @@ +#ifndef ESCHER_EVEN_ODD_POINTER_TEXT_CELL_H +#define ESCHER_EVEN_ODD_POINTER_TEXT_CELL_H + +#include +#include + +class EvenOddPointerTextCell : public EvenOddCell { +public: + EvenOddPointerTextCell(); + void reloadCell() override; + void setText(const char * textContent, KDColor textColor = KDColorBlack); + int numberOfSubviews() const override; + View * subviewAtIndex(int index) override; + void layoutSubviews() override; +protected: + PointerTextView m_pointerTextView; +}; + +#endif diff --git a/escher/src/even_odd_pointer_text_cell.cpp b/escher/src/even_odd_pointer_text_cell.cpp new file mode 100644 index 000000000..80439e37d --- /dev/null +++ b/escher/src/even_odd_pointer_text_cell.cpp @@ -0,0 +1,31 @@ +#include +#include + +EvenOddPointerTextCell::EvenOddPointerTextCell() : + EvenOddCell(), + m_pointerTextView(nullptr, 0.5f, 0.5f) +{ +} + +void EvenOddPointerTextCell::reloadCell() { + EvenOddCell::reloadCell(); + m_pointerTextView.setBackgroundColor(backgroundColor()); +} + +void EvenOddPointerTextCell::setText(const char * title, KDColor textColor) { + m_pointerTextView.setText(title); + m_pointerTextView.setTextColor(textColor); +} + +int EvenOddPointerTextCell::numberOfSubviews() const { + return 1; +} + +View * EvenOddPointerTextCell::subviewAtIndex(int index) { + assert(index == 0); + return &m_pointerTextView; +} + +void EvenOddPointerTextCell::layoutSubviews() { + m_pointerTextView.setFrame(bounds()); +}