From dbf59f2290762cd9921f3f6fe50b96abcabb6f8b Mon Sep 17 00:00:00 2001 From: philmoz Date: Mon, 20 Jan 2025 20:08:35 +1100 Subject: [PATCH] Allow UI controls in App Mode widget when full screen. --- radio/src/gui/colorlcd/mainview/widget.h | 1 + radio/src/gui/colorlcd/standalone_lua.h | 4 ++-- radio/src/lua/api_colorlcd_lvgl.cpp | 13 ++++++++++++- radio/src/lua/lua_widget.h | 8 ++++---- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/radio/src/gui/colorlcd/mainview/widget.h b/radio/src/gui/colorlcd/mainview/widget.h index c75a71d014c..a89a7e62b29 100644 --- a/radio/src/gui/colorlcd/mainview/widget.h +++ b/radio/src/gui/colorlcd/mainview/widget.h @@ -67,6 +67,7 @@ class Widget : public ButtonBase // Set/unset fullscreen mode void setFullscreen(bool enable); void closeFullscreen() { closeFS = true; } + bool isFullscreen() const { return fullscreen; } // Called when the widget options have changed virtual void update(); diff --git a/radio/src/gui/colorlcd/standalone_lua.h b/radio/src/gui/colorlcd/standalone_lua.h index 398c4961d87..a4ac6f32e33 100644 --- a/radio/src/gui/colorlcd/standalone_lua.h +++ b/radio/src/gui/colorlcd/standalone_lua.h @@ -53,13 +53,13 @@ class StandaloneLuaWindow : public Window, public LuaEventHandler, public LuaLvg void clear() override; bool useLvglLayout() const override { return useLvgl; } bool isAppMode() const override { return false; } + bool isWidget() override { return false; } + bool isFullscreen() override { return true; } void luaShowError() override; void showError(bool firstCall, const char* title, const char* msg); - bool isWidget() override { return false; } - static LAYOUT_VAL(POPUP_HEADER_HEIGHT, 30, 30); static LAYOUT_VAL(POPUP_X, 50, 40); static LAYOUT_VAL(POPUP_Y, 70, 110); diff --git a/radio/src/lua/api_colorlcd_lvgl.cpp b/radio/src/lua/api_colorlcd_lvgl.cpp index 6278c454b3d..2f94474f31d 100644 --- a/radio/src/lua/api_colorlcd_lvgl.cpp +++ b/radio/src/lua/api_colorlcd_lvgl.cpp @@ -185,7 +185,7 @@ static void buildLvgl(lua_State *L, int srcIndex, int refIndex) obj = new LvglWidgetBox(); else if (strcasecmp(p.type, "setting") == 0) obj = new LvglWidgetSetting(); - else if (!luaLvglManager->isWidget()) { + else if (!luaLvglManager->isWidget() || (luaLvglManager->isAppMode() && luaLvglManager->isFullscreen())) { if (strcasecmp(p.type, "button") == 0) obj = new LvglWidgetTextButton(); else if (strcasecmp(p.type, "toggle") == 0) @@ -269,11 +269,22 @@ static int luaLvglIsAppMode(lua_State *L) return 1; } +static int luaLvglIsFullscreen(lua_State *L) +{ + if (luaLvglManager) { + lua_pushboolean(L, luaLvglManager->isFullscreen()); + } else { + lua_pushboolean(L, false); + } + return 1; +} + // lvgl functions LROT_BEGIN(lvgllib, NULL, 0) LROT_FUNCENTRY(clear, luaLvglClear) LROT_FUNCENTRY(build, luaLvglBuild) LROT_FUNCENTRY(isAppMode, luaLvglIsAppMode) + LROT_FUNCENTRY(isFullscreen, luaLvglIsFullscreen) // Objects - widgets and standalone LROT_FUNCENTRY(label, [](lua_State* L) { return luaLvglObjEx(L, []() { return new LvglWidgetLabel(); }); }) LROT_FUNCENTRY(rectangle, [](lua_State* L) { return luaLvglObjEx(L, []() { return new LvglWidgetRectangle(); }); }) diff --git a/radio/src/lua/lua_widget.h b/radio/src/lua/lua_widget.h index 11f649ba617..ac16d48de11 100644 --- a/radio/src/lua/lua_widget.h +++ b/radio/src/lua/lua_widget.h @@ -52,11 +52,11 @@ class LuaLvglManager virtual void clear() = 0; virtual bool useLvglLayout() const = 0; virtual bool isAppMode() const = 0; + virtual bool isWidget() = 0; + virtual bool isFullscreen() = 0; virtual void luaShowError() = 0; - virtual bool isWidget() = 0; - uint8_t refreshInstructionsPercent; protected: @@ -119,13 +119,13 @@ class LuaWidget : public Widget, public LuaEventHandler, public LuaLvglManager bool useLvglLayout() const override; bool isAppMode() const override; + bool isWidget() override { return !inSettings; } + bool isFullscreen() override { return Widget::isFullscreen(); } void luaShowError() override {} void pushOptionsTable(); - bool isWidget() override { return !inSettings; } - protected: bool inSettings = false; lv_obj_t* errorLabel = nullptr;