add 'scroll' container property

This commit is contained in:
MihailRis
2025-03-21 05:31:46 +03:00
parent a8067ad9d6
commit 2ee0605f1f
5 changed files with 35 additions and 2 deletions
+16
View File
@@ -423,6 +423,13 @@ static int p_get_cursor(UINode* node, lua::State* L) {
return lua::pushstring(L, to_string(node->getCursor()));
}
static int p_get_scroll(UINode* node, lua::State* L) {
if (auto container = dynamic_cast<Container*>(node)) {
return lua::pushnumber(L, container->getContentOffset().y);
}
return 0;
}
static int l_gui_getattr(lua::State* L) {
auto docname = lua::require_string(L, 1);
auto element = lua::require_string(L, 2);
@@ -469,6 +476,7 @@ static int l_gui_getattr(lua::State* L) {
{"min", p_get_min},
{"max", p_get_max},
{"step", p_get_step},
{"scroll", p_get_scroll},
{"trackWidth", p_get_track_width},
{"trackColor", p_get_track_color},
{"textColor", p_get_text_color},
@@ -655,6 +663,13 @@ static void p_set_cursor(UINode* node, lua::State* L, int idx) {
}
}
static int p_set_scroll(UINode* node, lua::State* L, int idx) {
if (auto container = dynamic_cast<Container*>(node)) {
container->setScroll(lua::tointeger(L, idx));
}
return 0;
}
static int l_gui_setattr(lua::State* L) {
auto docname = lua::require_string(L, 1);
auto element = lua::require_string(L, 2);
@@ -692,6 +707,7 @@ static int l_gui_setattr(lua::State* L) {
{"min", p_set_min},
{"max", p_set_max},
{"step", p_set_step},
{"scroll", p_set_scroll},
{"trackWidth", p_set_track_width},
{"trackColor", p_set_track_color},
{"textColor", p_set_text_color},