Initial commit.
This commit is contained in:
commit
59c6161fdb
134 changed files with 4751 additions and 0 deletions
35
src/ui_elements/widgets/Label.cpp
Normal file
35
src/ui_elements/widgets/Label.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include "Label.h"
|
||||
#include "TextElement.h"
|
||||
|
||||
Label::Label()
|
||||
: Widget(),
|
||||
mLabel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<Label> Label::Create()
|
||||
{
|
||||
return std::make_shared<Label>();
|
||||
}
|
||||
|
||||
void Label::SetLabel(const std::string& text)
|
||||
{
|
||||
mLabel = text;
|
||||
}
|
||||
|
||||
void Label::OnPaintEvent(PaintEventPtr event)
|
||||
{
|
||||
mLayers.clear();
|
||||
AddBackground(event);
|
||||
|
||||
if(!mLabel.empty())
|
||||
{
|
||||
auto middle = DiscretePoint(mLocation.GetX() + mWidth/2,
|
||||
mLocation.GetY() + mHeight/2);
|
||||
auto text = TextElement::Create(mLabel, middle);
|
||||
auto textLayer = VisualLayer::Create();
|
||||
textLayer->SetText(text);
|
||||
mLayers.push_back(textLayer);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue