From 7ee866643b4d9c5ec93698b04cd79a523a6a6aaa Mon Sep 17 00:00:00 2001 From: lampysprites Date: Sun, 11 Jun 2023 22:27:50 +0600 Subject: [PATCH] [lua] Add width and height properties to app --- src/app/script/app_object.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/app/script/app_object.cpp b/src/app/script/app_object.cpp index fa78726a1..7ec24ba85 100644 --- a/src/app/script/app_object.cpp +++ b/src/app/script/app_object.cpp @@ -37,6 +37,7 @@ #include "app/ui/editor/editor.h" #include "app/ui/editor/tool_loop_impl.h" #include "app/ui/timeline/timeline.h" +#include "app/ui/main_window.h" #include "app/ui_context.h" #include "base/fs.h" #include "base/replace_string.h" @@ -700,6 +701,28 @@ int App_get_defaultPalette(lua_State* L) return 1; } +int App_get_width(lua_State* L) +{ +#if ENABLE_UI + App* app = App::instance(); + lua_pushinteger(L, app->mainWindow()->bounds().w); + return 1; +#endif + lua_pushinteger(L, 0); + return 1; +} + +int App_get_height(lua_State* L) +{ +#if ENABLE_UI + App* app = App::instance(); + lua_pushinteger(L, app->mainWindow()->bounds().h); + return 1; +#endif + lua_pushinteger(L, 0); + return 1; +} + int App_set_sprite(lua_State* L) { auto sprite = may_get_docobj(L, 2); @@ -814,6 +837,8 @@ const Property App_properties[] = { { "range", App_get_range, nullptr }, { "isUIAvailable", App_get_isUIAvailable, nullptr }, { "defaultPalette", App_get_defaultPalette, App_set_defaultPalette }, + { "width", App_get_width, nullptr }, + { "height", App_get_height, nullptr }, { "events", App_get_events, nullptr }, { "theme", App_get_theme, nullptr }, { "uiScale", App_get_uiScale, nullptr },