Merge remote-tracking branch 'upstream/main' into spawn_objects
This commit is contained in:
commit
7c6b52cb2a
@ -361,10 +361,18 @@ std::wstring TextBox::getText() const {
|
||||
return input;
|
||||
}
|
||||
|
||||
void TextBox::setText(std::wstring value) {
|
||||
void TextBox::setText(const std::wstring value) {
|
||||
this->input = value;
|
||||
}
|
||||
|
||||
std::wstring TextBox::getPlaceholder() const {
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
void TextBox::setPlaceholder(const std::wstring& placeholder) {
|
||||
this->placeholder = placeholder;
|
||||
}
|
||||
|
||||
// ============================== InputBindBox ================================
|
||||
InputBindBox::InputBindBox(Binding& binding, glm::vec4 padding)
|
||||
: Panel(glm::vec2(100,32), padding, 0),
|
||||
|
||||
@ -122,6 +122,8 @@ namespace gui {
|
||||
virtual std::wstring getText() const;
|
||||
/* Set TextBox content text */
|
||||
virtual void setText(std::wstring value);
|
||||
virtual std::wstring getPlaceholder() const;
|
||||
virtual void setPlaceholder(const std::wstring&);
|
||||
virtual bool validate();
|
||||
virtual void setValid(bool valid);
|
||||
virtual bool isValid() const;
|
||||
|
||||
@ -73,11 +73,11 @@ public:
|
||||
return map;
|
||||
}
|
||||
|
||||
static inline light_t combine(int r, int g, int b, int s) {
|
||||
static constexpr light_t combine(int r, int g, int b, int s) {
|
||||
return r | (g << 4) | (b << 8) | (s << 12);
|
||||
}
|
||||
|
||||
static inline light_t extract(light_t light, ubyte channel) {
|
||||
static constexpr light_t extract(light_t light, ubyte channel) {
|
||||
return (light >> (channel << 2)) & 0xF;
|
||||
}
|
||||
|
||||
|
||||
@ -103,6 +103,29 @@ static bool getattr(lua_State* L, gui::FullCheckBox* box, const std::string& att
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool getattr(lua_State* L, gui::TextBox* box, const std::string& attr) {
|
||||
if (box == nullptr)
|
||||
return false;
|
||||
if (attr == "text") {
|
||||
lua_pushstring(L, util::wstr2str_utf8(box->getText()).c_str());
|
||||
return true;
|
||||
} else if (attr == "placeholder") {
|
||||
lua_pushstring(L, util::wstr2str_utf8(box->getPlaceholder()).c_str());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool setattr(lua_State* L, gui::FullCheckBox* box, const std::string& attr) {
|
||||
if (box == nullptr)
|
||||
return false;
|
||||
if (attr == "checked") {
|
||||
box->setChecked(lua_toboolean(L, 4));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool setattr(lua_State* L, gui::Button* button, const std::string& attr) {
|
||||
if (button == nullptr)
|
||||
return false;
|
||||
@ -115,11 +138,14 @@ static bool setattr(lua_State* L, gui::Button* button, const std::string& attr)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool setattr(lua_State* L, gui::FullCheckBox* box, const std::string& attr) {
|
||||
static bool setattr(lua_State* L, gui::TextBox* box, const std::string& attr) {
|
||||
if (box == nullptr)
|
||||
return false;
|
||||
if (attr == "checked") {
|
||||
box->setChecked(lua_toboolean(L, 4));
|
||||
if (attr == "text") {
|
||||
box->setText(util::str2wstr_utf8(lua_tostring(L, 4)));
|
||||
return true;
|
||||
} else if (attr == "placeholder") {
|
||||
box->setPlaceholder(util::str2wstr_utf8(lua_tostring(L, 4)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -161,6 +187,8 @@ int l_gui_getattr(lua_State* L) {
|
||||
return 1;
|
||||
if (getattr(L, dynamic_cast<gui::Label*>(node), attr))
|
||||
return 1;
|
||||
if (getattr(L, dynamic_cast<gui::TextBox*>(node), attr))
|
||||
return 1;
|
||||
if (getattr(L, dynamic_cast<gui::TrackBar*>(node), attr))
|
||||
return 1;
|
||||
if (getattr(L, dynamic_cast<gui::FullCheckBox*>(node), attr))
|
||||
@ -197,6 +225,8 @@ int l_gui_setattr(lua_State* L) {
|
||||
return 0;
|
||||
if (setattr(L, dynamic_cast<gui::Label*>(node), attr))
|
||||
return 0;
|
||||
if (setattr(L, dynamic_cast<gui::TextBox*>(node), attr))
|
||||
return 0;
|
||||
if (setattr(L, dynamic_cast<gui::TrackBar*>(node), attr))
|
||||
return 0;
|
||||
if (setattr(L, dynamic_cast<gui::FullCheckBox*>(node), attr))
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class GLFWwindow;
|
||||
class ImageData;
|
||||
struct DisplaySettings;
|
||||
struct GLFWwindow;
|
||||
struct GLFWmonitor;
|
||||
|
||||
enum class blendmode {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user