diff --git a/escher/Makefile b/escher/Makefile index a540f4c6b..c8b54c943 100644 --- a/escher/Makefile +++ b/escher/Makefile @@ -41,6 +41,7 @@ objs += $(addprefix escher/src/,\ message_tree.o\ modal_view_controller.o\ palette.o\ + pointer_text_view.o\ responder.o\ run_loop.o\ scroll_view.o\ diff --git a/escher/include/escher.h b/escher/include/escher.h index 2b3aac774..265e194d0 100644 --- a/escher/include/escher.h +++ b/escher/include/escher.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/escher/include/escher/pointer_text_view.h b/escher/include/escher/pointer_text_view.h new file mode 100644 index 000000000..c5877fa9c --- /dev/null +++ b/escher/include/escher/pointer_text_view.h @@ -0,0 +1,18 @@ +#ifndef ESCHER_POINTER_TEXT_VIEW_H +#define ESCHER_POINTER_TEXT_VIEW_H + +#include +#include + +class PointerTextView : public TextView { +public: + PointerTextView(KDText::FontSize size = KDText::FontSize::Large, const char * text = nullptr, float horizontalAlignment = 0.0f, float verticalAlignment = 0.0f, + KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite); + const char * text() const override { return m_text; } + void setText(const char * text) override; + KDSize minimalSizeForOptimalDisplay() const override; +private: + const char * m_text; +}; + +#endif diff --git a/escher/src/pointer_text_view.cpp b/escher/src/pointer_text_view.cpp new file mode 100644 index 000000000..a20412f82 --- /dev/null +++ b/escher/src/pointer_text_view.cpp @@ -0,0 +1,20 @@ +#include +#include + +PointerTextView::PointerTextView(KDText::FontSize size, const char * text, float horizontalAlignment, float verticalAlignment, + KDColor textColor, KDColor backgroundColor) : + TextView(size, horizontalAlignment, verticalAlignment, textColor, backgroundColor), + m_text(text) +{ +} + +void PointerTextView::setText(const char * text) { + if (text != m_text) { + m_text = text; + markRectAsDirty(bounds()); + } +} + +KDSize PointerTextView::minimalSizeForOptimalDisplay() const { + return KDText::stringSize(text(), m_fontSize); +}