added image.src property
This commit is contained in:
parent
66476ee642
commit
fad9dc85ad
@ -33,3 +33,11 @@ void Image::setAutoResize(bool flag) {
|
|||||||
bool Image::isAutoResize() const {
|
bool Image::isAutoResize() const {
|
||||||
return autoresize;
|
return autoresize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string& Image::getTexture() const {
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Image::setTexture(const std::string& name) {
|
||||||
|
texture = name;
|
||||||
|
}
|
||||||
|
|||||||
@ -15,6 +15,8 @@ namespace gui {
|
|||||||
|
|
||||||
virtual void setAutoResize(bool flag);
|
virtual void setAutoResize(bool flag);
|
||||||
virtual bool isAutoResize() const;
|
virtual bool isAutoResize() const;
|
||||||
|
virtual const std::string& getTexture() const;
|
||||||
|
virtual void setTexture(const std::string& name);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#include "../../../graphics/ui/gui_util.hpp"
|
#include "../../../graphics/ui/gui_util.hpp"
|
||||||
#include "../../../graphics/ui/elements/UINode.hpp"
|
#include "../../../graphics/ui/elements/UINode.hpp"
|
||||||
#include "../../../graphics/ui/elements/Button.hpp"
|
#include "../../../graphics/ui/elements/Button.hpp"
|
||||||
|
#include "../../../graphics/ui/elements/Image.hpp"
|
||||||
#include "../../../graphics/ui/elements/CheckBox.hpp"
|
#include "../../../graphics/ui/elements/CheckBox.hpp"
|
||||||
#include "../../../graphics/ui/elements/TextBox.hpp"
|
#include "../../../graphics/ui/elements/TextBox.hpp"
|
||||||
#include "../../../graphics/ui/elements/TrackBar.hpp"
|
#include "../../../graphics/ui/elements/TrackBar.hpp"
|
||||||
@ -233,6 +234,13 @@ static int p_get_editable(UINode* node) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int p_get_src(UINode* node) {
|
||||||
|
if (auto image = dynamic_cast<Image*>(node)) {
|
||||||
|
return state->pushstring(image->getTexture());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int p_get_add(UINode* node) {
|
static int p_get_add(UINode* node) {
|
||||||
if (dynamic_cast<Container*>(node)) {
|
if (dynamic_cast<Container*>(node)) {
|
||||||
return state->pushcfunction(l_container_add);
|
return state->pushcfunction(l_container_add);
|
||||||
@ -302,6 +310,7 @@ static int l_gui_getattr(lua_State* L) {
|
|||||||
{"caret", p_get_caret},
|
{"caret", p_get_caret},
|
||||||
{"text", p_get_text},
|
{"text", p_get_text},
|
||||||
{"editable", p_get_editable},
|
{"editable", p_get_editable},
|
||||||
|
{"src", p_get_src},
|
||||||
{"value", p_get_value},
|
{"value", p_get_value},
|
||||||
{"min", p_get_min},
|
{"min", p_get_min},
|
||||||
{"max", p_get_max},
|
{"max", p_get_max},
|
||||||
@ -371,6 +380,11 @@ static void p_set_editable(UINode* node, int idx) {
|
|||||||
box->setEditable(state->toboolean(idx));
|
box->setEditable(state->toboolean(idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void p_set_src(UINode* node, int idx) {
|
||||||
|
if (auto image = dynamic_cast<Image*>(node)) {
|
||||||
|
image->setTexture(state->requireString(idx));
|
||||||
|
}
|
||||||
|
}
|
||||||
static void p_set_value(UINode* node, int idx) {
|
static void p_set_value(UINode* node, int idx) {
|
||||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||||
bar->setValue(state->tonumber(idx));
|
bar->setValue(state->tonumber(idx));
|
||||||
@ -451,6 +465,7 @@ static int l_gui_setattr(lua_State* L) {
|
|||||||
{"placeholder", p_set_placeholder},
|
{"placeholder", p_set_placeholder},
|
||||||
{"text", p_set_text},
|
{"text", p_set_text},
|
||||||
{"editable", p_set_editable},
|
{"editable", p_set_editable},
|
||||||
|
{"src", p_set_src},
|
||||||
{"caret", p_set_caret},
|
{"caret", p_set_caret},
|
||||||
{"value", p_set_value},
|
{"value", p_set_value},
|
||||||
{"min", p_set_min},
|
{"min", p_set_min},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user