Fix standalone LUA

This commit is contained in:
Raphael Coeffic
2022-06-11 15:38:08 +02:00
committed by Raphael Coeffic
parent 7417b6568b
commit ab76639301
3 changed files with 24 additions and 5 deletions
+2 -1
View File
@@ -136,7 +136,8 @@ void buildLuaUi(std::vector<LuaScript> luaScripts, FormWindow *window, FormGridL
f_chdir(toolPath); f_chdir(toolPath);
luaExec(luaScript.path.c_str()); luaExec(luaScript.path.c_str());
StandaloneLuaWindow::instance()->attach(window); auto lua_win = StandaloneLuaWindow::instance();
lua_win->attach(window);
return 0; return 0;
}, },
+19 -3
View File
@@ -76,8 +76,18 @@ StandaloneLuaWindow* StandaloneLuaWindow::instance()
void StandaloneLuaWindow::attach(Window* newParent) void StandaloneLuaWindow::attach(Window* newParent)
{ {
Window::attach(newParent->getFullScreenWindow()); if (!prevScreen) {
Layer::push(this);
// backup previous screen
prevScreen = lv_scr_act();
Window::attach(newParent->getFullScreenWindow());
// and load new one
lv_scr_load(lvobj);
Layer::push(this);
}
setFocus(); setFocus();
} }
@@ -90,9 +100,15 @@ void StandaloneLuaWindow::deleteLater(bool detach, bool /*trash*/)
focusWindow = nullptr; focusWindow = nullptr;
} }
if (prevScreen) {
lv_scr_load(prevScreen);
prevScreen = nullptr;
}
// detach from parent // detach from parent
if (detach) if (detach) {
this->detach(); this->detach();
}
if (closeHandler) { if (closeHandler) {
closeHandler(); closeHandler();
+2
View File
@@ -64,6 +64,8 @@ public:
const char* info, bool& result); const char* info, bool& result);
protected: protected:
lv_obj_t* prevScreen = nullptr;
// GFX // GFX
BitmapBuffer lcdBuffer; BitmapBuffer lcdBuffer;