improved charlist

This commit is contained in:
Eduardo Bart
2011-08-26 15:44:18 -03:00
parent c60b677baa
commit 0749e6a9d5
5 changed files with 74 additions and 32 deletions

View File

@@ -12,7 +12,9 @@ void UILabel::setup()
void UILabel::render()
{
UIWidget::render();
m_font->renderText(m_text, m_rect, m_align, m_foregroundColor);
Rect textRect = m_rect;
textRect.setTopLeft(textRect.topLeft() + m_offset);
m_font->renderText(m_text, textRect, m_align, m_foregroundColor);
}
void UILabel::setText(const std::string& text)
@@ -43,5 +45,8 @@ void UILabel::onStyleApply(const OTMLNodePtr& styleNode)
setText(node->value());
else if(node->tag() == "align")
setAlign(fw::translateAlignment(node->value()));
else if(node->tag() == "offset") {
setOffset(node->value<Point>());
}
}
}

View File

@@ -13,15 +13,18 @@ public:
void setText(const std::string& text);
void setAlign(AlignmentFlag align) { m_align = align; }
void setOffset(const Point& offset) { m_offset = offset; }
std::string getText() const { return m_text; }
AlignmentFlag getAlign() const { return m_align; }
Point getOffset() const { return m_offset; }
protected:
virtual void onStyleApply(const OTMLNodePtr& styleNode);
private:
std::string m_text;
Point m_offset;
AlignmentFlag m_align;
};