mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-30 03:32:36 +00:00
Detach Lua Elements properly from their parent
This commit is contained in:
parent
0f60052bb8
commit
af8662daee
@ -54,7 +54,7 @@ namespace LuaUi
|
|||||||
if (!ext->isRoot())
|
if (!ext->isRoot())
|
||||||
destroyWidget(ext);
|
destroyWidget(ext);
|
||||||
else
|
else
|
||||||
ext->widget()->detachFromWidget();
|
ext->detachFromParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void detachElements(WidgetExtension* ext)
|
void detachElements(WidgetExtension* ext)
|
||||||
@ -62,14 +62,14 @@ namespace LuaUi
|
|||||||
for (auto* child : ext->children())
|
for (auto* child : ext->children())
|
||||||
{
|
{
|
||||||
if (child->isRoot())
|
if (child->isRoot())
|
||||||
child->widget()->detachFromWidget();
|
child->detachFromParent();
|
||||||
else
|
else
|
||||||
detachElements(child);
|
detachElements(child);
|
||||||
}
|
}
|
||||||
for (auto* child : ext->templateChildren())
|
for (auto* child : ext->templateChildren())
|
||||||
{
|
{
|
||||||
if (child->isRoot())
|
if (child->isRoot())
|
||||||
child->widget()->detachFromWidget();
|
child->detachFromParent();
|
||||||
else
|
else
|
||||||
detachElements(child);
|
detachElements(child);
|
||||||
}
|
}
|
||||||
@ -272,9 +272,9 @@ namespace LuaUi
|
|||||||
|
|
||||||
void Element::create(uint64_t depth)
|
void Element::create(uint64_t depth)
|
||||||
{
|
{
|
||||||
assert(!mRoot);
|
|
||||||
if (mState == New)
|
if (mState == New)
|
||||||
{
|
{
|
||||||
|
assert(!mRoot);
|
||||||
mRoot = createWidget(layout(), true, depth);
|
mRoot = createWidget(layout(), true, depth);
|
||||||
mLayer = setLayer(mRoot, layout());
|
mLayer = setLayer(mRoot, layout());
|
||||||
updateRootCoord(mRoot);
|
updateRootCoord(mRoot);
|
||||||
|
@ -112,6 +112,12 @@ namespace LuaUi
|
|||||||
ext->widget()->attachToWidget(widget());
|
ext->widget()->attachToWidget(widget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WidgetExtension::detachFromParent()
|
||||||
|
{
|
||||||
|
mParent = nullptr;
|
||||||
|
widget()->detachFromWidget();
|
||||||
|
}
|
||||||
|
|
||||||
WidgetExtension* WidgetExtension::findDeep(std::string_view flagName)
|
WidgetExtension* WidgetExtension::findDeep(std::string_view flagName)
|
||||||
{
|
{
|
||||||
for (WidgetExtension* w : mChildren)
|
for (WidgetExtension* w : mChildren)
|
||||||
|
@ -35,6 +35,7 @@ namespace LuaUi
|
|||||||
|
|
||||||
bool isRoot() const { return mElementRoot; }
|
bool isRoot() const { return mElementRoot; }
|
||||||
WidgetExtension* getParent() const { return mParent; }
|
WidgetExtension* getParent() const { return mParent; }
|
||||||
|
void detachFromParent();
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user