Added Button::text property

This commit is contained in:
MihailRis
2023-11-27 20:59:41 +03:00
parent 7b4cc8f650
commit 385b667535
2 changed files with 21 additions and 1 deletions
+17 -1
View File
@@ -65,10 +65,26 @@ Button::Button(shared_ptr<UINode> content, glm::vec4 padding) : Panel(vec2(32,32
Button::Button(wstring text, glm::vec4 padding) : Panel(vec2(32,32), padding, 0) {
Label* label = new Label(text);
label->align(Align::center);
add(shared_ptr<UINode>(label));
this->label = shared_ptr<UINode>(label);
add(this->label);
scrollable(false);
}
void Button::text(std::wstring text) {
if (label) {
Label* label = (Label*)(this->label.get());
label->text(text);
}
}
wstring Button::text() const {
if (label) {
Label* label = (Label*)(this->label.get());
return label->text();
}
return L"";
}
void Button::drawBackground(Batch2D* batch, Assets* assets) {
vec2 coord = calcCoord();
batch->texture(nullptr);