Added Button::text property
This commit is contained in:
parent
7b4cc8f650
commit
385b667535
@ -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);
|
||||
|
||||
@ -45,6 +45,7 @@ namespace gui {
|
||||
glm::vec4 hoverColor {0.05f, 0.1f, 0.15f, 0.75f};
|
||||
glm::vec4 pressedColor {0.0f, 0.0f, 0.0f, 0.95f};
|
||||
std::vector<onaction> actions;
|
||||
std::shared_ptr<UINode> label = nullptr;
|
||||
public:
|
||||
Button(std::shared_ptr<UINode> content, glm::vec4 padding=glm::vec4(2.0f));
|
||||
Button(std::wstring text, glm::vec4 padding=glm::vec4(2.0f));
|
||||
@ -55,6 +56,9 @@ namespace gui {
|
||||
|
||||
virtual void mouseRelease(GUI*, int x, int y) override;
|
||||
virtual Button* listenAction(onaction action);
|
||||
|
||||
virtual void text(std::wstring text);
|
||||
virtual std::wstring text() const;
|
||||
};
|
||||
|
||||
class TextBox : public Panel {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user