mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[escher] Add a PointerTextView class
This commit is contained in:
committed by
EmilieNumworks
parent
0682d21a32
commit
314fde955a
@@ -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\
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <escher/metric.h>
|
||||
#include <escher/modal_view_controller.h>
|
||||
#include <escher/palette.h>
|
||||
#include <escher/pointer_text_view.h>
|
||||
#include <escher/responder.h>
|
||||
#include <escher/scroll_view.h>
|
||||
#include <escher/scroll_view_data_source.h>
|
||||
|
||||
18
escher/include/escher/pointer_text_view.h
Normal file
18
escher/include/escher/pointer_text_view.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef ESCHER_POINTER_TEXT_VIEW_H
|
||||
#define ESCHER_POINTER_TEXT_VIEW_H
|
||||
|
||||
#include <escher/text_view.h>
|
||||
#include <escher/i18n.h>
|
||||
|
||||
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
|
||||
20
escher/src/pointer_text_view.cpp
Normal file
20
escher/src/pointer_text_view.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <escher/pointer_text_view.h>
|
||||
#include <assert.h>
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user