49 lines
965 B
C++
49 lines
965 B
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "UISimpleLabel.hpp"
|
|
|
|
using namespace Dawn;
|
|
|
|
UISimpleLabel::UISimpleLabel(std::weak_ptr<SceneItem> i) :
|
|
UILabel(i),
|
|
text("Hello World"),
|
|
font(nullptr),
|
|
size(12),
|
|
style(0),
|
|
decorations(0),
|
|
color(COLOR_WHITE)
|
|
{
|
|
}
|
|
|
|
void UISimpleLabel::onStart() {
|
|
UILabel::onStart();
|
|
|
|
useEffect([&] {
|
|
if(this->font == nullptr) {
|
|
this->rebufferQuads({ });
|
|
return;
|
|
}
|
|
|
|
struct UILabelText text;
|
|
struct UILabelStyle style;
|
|
style.font = this->font;
|
|
style.size = this->size;
|
|
style.style = this->style;
|
|
style.decorations = this->decorations;
|
|
style.color = this->color;
|
|
|
|
text.style = style;
|
|
text.text = this->text;
|
|
this->rebufferQuads({ text });
|
|
}, {
|
|
&this->text,
|
|
&this->font,
|
|
&this->size,
|
|
&this->style,
|
|
&this->decorations,
|
|
&this->color
|
|
})();
|
|
} |