Added Button::text property
This commit is contained in:
@@ -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) {
|
Button::Button(wstring text, glm::vec4 padding) : Panel(vec2(32,32), padding, 0) {
|
||||||
Label* label = new Label(text);
|
Label* label = new Label(text);
|
||||||
label->align(Align::center);
|
label->align(Align::center);
|
||||||
add(shared_ptr<UINode>(label));
|
this->label = shared_ptr<UINode>(label);
|
||||||
|
add(this->label);
|
||||||
scrollable(false);
|
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) {
|
void Button::drawBackground(Batch2D* batch, Assets* assets) {
|
||||||
vec2 coord = calcCoord();
|
vec2 coord = calcCoord();
|
||||||
batch->texture(nullptr);
|
batch->texture(nullptr);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace gui {
|
|||||||
glm::vec4 hoverColor {0.05f, 0.1f, 0.15f, 0.75f};
|
glm::vec4 hoverColor {0.05f, 0.1f, 0.15f, 0.75f};
|
||||||
glm::vec4 pressedColor {0.0f, 0.0f, 0.0f, 0.95f};
|
glm::vec4 pressedColor {0.0f, 0.0f, 0.0f, 0.95f};
|
||||||
std::vector<onaction> actions;
|
std::vector<onaction> actions;
|
||||||
|
std::shared_ptr<UINode> label = nullptr;
|
||||||
public:
|
public:
|
||||||
Button(std::shared_ptr<UINode> content, glm::vec4 padding=glm::vec4(2.0f));
|
Button(std::shared_ptr<UINode> content, glm::vec4 padding=glm::vec4(2.0f));
|
||||||
Button(std::wstring text, 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 void mouseRelease(GUI*, int x, int y) override;
|
||||||
virtual Button* listenAction(onaction action);
|
virtual Button* listenAction(onaction action);
|
||||||
|
|
||||||
|
virtual void text(std::wstring text);
|
||||||
|
virtual std::wstring text() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextBox : public Panel {
|
class TextBox : public Panel {
|
||||||
|
|||||||
Reference in New Issue
Block a user