Skip to content

Commit

Permalink
Allow UI controls in App Mode widget when full screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Jan 20, 2025
1 parent a6542e1 commit dbf59f2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/mainview/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/colorlcd/standalone_lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 12 additions & 1 deletion radio/src/lua/api_colorlcd_lvgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(); }); })
Expand Down
8 changes: 4 additions & 4 deletions radio/src/lua/lua_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit dbf59f2

Please sign in to comment.