Cleanup of some code

This commit is contained in:
2023-08-10 19:14:19 -07:00
parent 9fd31edc4a
commit 0cde186bf7
9 changed files with 132 additions and 3 deletions

View File

@ -8,4 +8,5 @@ target_sources(${DAWN_TARGET_NAME}
PRIVATE
UILabel.cpp
UIRichTextLabel.cpp
UISimpleLabel.cpp
)

View 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
})();
}

View File

@ -0,0 +1,29 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "UILabel.hpp"
namespace Dawn {
class UISimpleLabel : public UILabel {
public:
// @optional
StateProperty<std::string> text;
// @optional
StateProperty<TrueTypeAsset*> font;
// @optional
StateProperty<uint32_t> size;
// @optional
StateProperty<flag_t> style;
// @optional
StateProperty<flag_t> decorations;
// @optional
StateProperty<struct Color> color;
UISimpleLabel(SceneItem *item);
void onStart() override;
};
}