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);
luaExec(luaScript.path.c_str());
StandaloneLuaWindow::instance()->attach(window);
auto lua_win = StandaloneLuaWindow::instance();
lua_win->attach(window);
return 0;
},
+20 -4
View File
@@ -76,8 +76,18 @@ StandaloneLuaWindow* StandaloneLuaWindow::instance()
void StandaloneLuaWindow::attach(Window* newParent)
{
Window::attach(newParent->getFullScreenWindow());
Layer::push(this);
if (!prevScreen) {
// backup previous screen
prevScreen = lv_scr_act();
Window::attach(newParent->getFullScreenWindow());
// and load new one
lv_scr_load(lvobj);
Layer::push(this);
}
setFocus();
}
@@ -90,9 +100,15 @@ void StandaloneLuaWindow::deleteLater(bool detach, bool /*trash*/)
focusWindow = nullptr;
}
if (prevScreen) {
lv_scr_load(prevScreen);
prevScreen = nullptr;
}
// detach from parent
if (detach)
if (detach) {
this->detach();
}
if (closeHandler) {
closeHandler();
@@ -221,4 +237,4 @@ bool StandaloneLuaWindow::displayPopup(event_t event, uint8_t type, const char*
}
return false;
}
}
+2
View File
@@ -64,6 +64,8 @@ public:
const char* info, bool& result);
protected:
lv_obj_t* prevScreen = nullptr;
// GFX
BitmapBuffer lcdBuffer;