mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-22 15:20:39 +01:00
[escher] merge label view and text view in text view
Change-Id: Ia2422af03ebb79ba7450a1c8d220933cdd7a4586
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
#include <escher/text_view.h>
|
||||
|
||||
TextView::TextView() : TextView(nullptr, 0.0f, 0.0f)
|
||||
TextView::TextView() : TextView(nullptr, 0.0f, 0.0f, KDColorBlack, KDColorWhite)
|
||||
{
|
||||
}
|
||||
|
||||
TextView::TextView(const char * text, float horizontalAlignment, float verticalAlignment) :
|
||||
TextView::TextView(const char * text, float horizontalAlignment, float verticalAlignment,
|
||||
KDColor textColor, KDColor backgroundColor) :
|
||||
ChildlessView(),
|
||||
m_text(text),
|
||||
m_horizontalAlignment(horizontalAlignment),
|
||||
m_verticalAlignment(verticalAlignment)
|
||||
m_verticalAlignment(verticalAlignment),
|
||||
m_textColor(textColor),
|
||||
m_backgroundColor(backgroundColor)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -16,13 +19,23 @@ void TextView::setText(const char * text) {
|
||||
m_text = text;
|
||||
}
|
||||
|
||||
void TextView::setBackgroundColor(KDColor backgroundColor) {
|
||||
m_backgroundColor = backgroundColor;
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
void TextView::setTextColor(KDColor textColor) {
|
||||
m_textColor = textColor;
|
||||
markRectAsDirty(bounds());
|
||||
}
|
||||
|
||||
void TextView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDSize textSize = KDText::stringSize(m_text);
|
||||
KDPoint origin = {
|
||||
(KDCoordinate)(m_horizontalAlignment*(m_frame.width() - textSize.width())),
|
||||
(KDCoordinate)(m_verticalAlignment*(m_frame.height() - textSize.height()))
|
||||
};
|
||||
ctx->drawString(m_text, origin, 0);
|
||||
ctx->drawString(m_text, origin, m_textColor, m_backgroundColor);
|
||||
}
|
||||
|
||||
#if ESCHER_VIEW_LOGGING
|
||||
|
||||
Reference in New Issue
Block a user