[lua] Add `resizeable` property to Dialog constructor (fix #5177)

This commit is contained in:
Christian Kaiser 2025-07-31 20:52:33 -03:00
parent 6d89a6bc15
commit 11a12a9cac
1 changed files with 9 additions and 2 deletions

View File

@ -127,12 +127,13 @@ struct Dialog {
int showRef = LUA_REFNIL; int showRef = LUA_REFNIL;
lua_State* L = nullptr; lua_State* L = nullptr;
Dialog(const ui::Window::Type windowType, const std::string& title) Dialog(const ui::Window::Type windowType, const std::string& title, bool sizeable)
: window(windowType, title) : window(windowType, title)
, grid(2, false) , grid(2, false)
, currentGrid(&grid) , currentGrid(&grid)
{ {
window.addChild(&grid); window.addChild(&grid);
window.setSizeable(sizeable);
all_dialogs.push_back(this); all_dialogs.push_back(this);
} }
@ -365,6 +366,7 @@ int Dialog_new(lua_State* L)
// Get the title and the type of window (with or without title bar) // Get the title and the type of window (with or without title bar)
ui::Window::Type windowType = ui::Window::WithTitleBar; ui::Window::Type windowType = ui::Window::WithTitleBar;
std::string title = "Script"; std::string title = "Script";
bool sizeable = true;
if (lua_isstring(L, 1)) { if (lua_isstring(L, 1)) {
title = lua_tostring(L, 1); title = lua_tostring(L, 1);
} }
@ -378,9 +380,14 @@ int Dialog_new(lua_State* L)
if (type != LUA_TNIL && lua_toboolean(L, -1)) if (type != LUA_TNIL && lua_toboolean(L, -1))
windowType = ui::Window::WithoutTitleBar; windowType = ui::Window::WithoutTitleBar;
lua_pop(L, 1); lua_pop(L, 1);
type = lua_getfield(L, 1, "resizeable");
if (type != LUA_TNIL && !lua_toboolean(L, -1))
sizeable = false;
lua_pop(L, 1);
} }
auto dlg = push_new<Dialog>(L, windowType, title); auto dlg = push_new<Dialog>(L, windowType, title, sizeable);
// The uservalue of the dialog userdata will contain a table that // The uservalue of the dialog userdata will contain a table that
// stores all the callbacks to handle events. As these callbacks can // stores all the callbacks to handle events. As these callbacks can