diff --git a/components/lua_ui/element.cpp b/components/lua_ui/element.cpp index 6e7fe9ee16..b491acb7b3 100644 --- a/components/lua_ui/element.cpp +++ b/components/lua_ui/element.cpp @@ -54,7 +54,7 @@ namespace LuaUi if (!ext->isRoot()) destroyWidget(ext); else - ext->widget()->detachFromWidget(); + ext->detachFromParent(); } void detachElements(WidgetExtension* ext) @@ -62,14 +62,14 @@ namespace LuaUi for (auto* child : ext->children()) { if (child->isRoot()) - child->widget()->detachFromWidget(); + child->detachFromParent(); else detachElements(child); } for (auto* child : ext->templateChildren()) { if (child->isRoot()) - child->widget()->detachFromWidget(); + child->detachFromParent(); else detachElements(child); } @@ -272,12 +272,13 @@ namespace LuaUi void Element::create(uint64_t depth) { - assert(!mRoot); if (mState == New) { + assert(!mRoot); mRoot = createWidget(layout(), true, depth); mLayer = setLayer(mRoot, layout()); updateRootCoord(mRoot); + mState = Created; } } @@ -304,8 +305,8 @@ namespace LuaUi } mLayer = setLayer(mRoot, layout()); updateRootCoord(mRoot); + mState = Created; } - mState = Created; } void Element::destroy() diff --git a/components/lua_ui/widget.cpp b/components/lua_ui/widget.cpp index 9550c9de73..be0ea70387 100644 --- a/components/lua_ui/widget.cpp +++ b/components/lua_ui/widget.cpp @@ -112,6 +112,12 @@ namespace LuaUi ext->widget()->attachToWidget(widget()); } + void WidgetExtension::detachFromParent() + { + mParent = nullptr; + widget()->detachFromWidget(); + } + WidgetExtension* WidgetExtension::findDeep(std::string_view flagName) { for (WidgetExtension* w : mChildren) diff --git a/components/lua_ui/widget.hpp b/components/lua_ui/widget.hpp index 591c885ce9..05359705a1 100644 --- a/components/lua_ui/widget.hpp +++ b/components/lua_ui/widget.hpp @@ -35,6 +35,7 @@ namespace LuaUi bool isRoot() const { return mElementRoot; } WidgetExtension* getParent() const { return mParent; } + void detachFromParent(); void reset(); diff --git a/files/data/scripts/omw/settings/menu.lua b/files/data/scripts/omw/settings/menu.lua index 7d425f684b..4e6971a516 100644 --- a/files/data/scripts/omw/settings/menu.lua +++ b/files/data/scripts/omw/settings/menu.lua @@ -378,7 +378,7 @@ local function onSettingChanged(global) local value = common.getSection(global, group.key):get(settingKey) local settingsContent = groupElement.layout.content.settings.content auxUi.deepDestroy(settingsContent[settingKey]) -- support setting renderers which return UI elements - settingsContent[settingKey] = renderSetting(group, group.settings[settingKey], value) + settingsContent[settingKey] = renderSetting(group, group.settings[settingKey], value, global) groupElement:update() end) end @@ -408,7 +408,7 @@ local function onGroupRegistered(global, key) local element = groupElements[group.page][group.key] local settingsContent = element.layout.content.settings.content - settingsContent[settingKey] = renderSetting(group, group.settings[settingKey], value) + settingsContent[settingKey] = renderSetting(group, group.settings[settingKey], value, global) element:update() end)) end