Cleanup of some code
This commit is contained in:
49
src/dawn/scene/components/ui/text/UISimpleLabel.cpp
Normal file
49
src/dawn/scene/components/ui/text/UISimpleLabel.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// 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(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
|
||||
})();
|
||||
}
|
Reference in New Issue
Block a user