merge total remake

This commit is contained in:
Eduardo Bart
2011-08-13 23:09:11 -03:00
parent 0af7856475
commit 55862b07ad
253 changed files with 6777 additions and 8463 deletions

View File

@@ -1,11 +1,39 @@
#include <global.h>
#include <ui/uilabel.h>
#include <ui/uielementskin.h>
#include "uilabel.h"
#include <graphics/font.h>
#include <otml/otmlnode.h>
void UILabel::setText(const std::string& text)
UILabel::UILabel() : UIWidget(UITypeLabel)
{
m_text = text;
// text size changed, reaplly skin
if(getSkin())
getSkin()->apply(this);
m_align = AlignLeft;
}
UILabelPtr UILabel::create()
{
UILabelPtr label(new UILabel);
label->setStyle("Label");
return label;
}
void UILabel::loadStyleFromOTML(const OTMLNodePtr& styleNode)
{
UIWidget::loadStyleFromOTML(styleNode);
m_text = styleNode->readAt("text", m_text);
if(styleNode->hasChild("align"))
m_align = parseAlignment(styleNode->readAt<std::string>("align"));
// auto resize if no size supplied
if(!m_text.empty() && !getGeometry().isValid())
resizeToText();
}
void UILabel::render()
{
getFont()->renderText(m_text, getGeometry(), m_align, getColor());
}
void UILabel::resizeToText()
{
resize(getFont()->calculateTextRectSize(m_text));
}