mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 02:15:34 +00:00
Simplify detachFromParent
This commit is contained in:
parent
8cbcb82dd4
commit
1d13f7db8f
3 changed files with 14 additions and 15 deletions
|
@ -54,7 +54,7 @@ namespace LuaUi
|
|||
if (!ext->isRoot())
|
||||
destroyWidget(ext);
|
||||
else
|
||||
ext->detachFromParent(false);
|
||||
ext->detachFromParent();
|
||||
}
|
||||
|
||||
void detachElements(WidgetExtension* ext)
|
||||
|
|
|
@ -101,7 +101,15 @@ namespace LuaUi
|
|||
void WidgetExtension::attach(WidgetExtension* ext)
|
||||
{
|
||||
if (ext->mParent != this)
|
||||
ext->detachFromParent(true);
|
||||
{
|
||||
if (ext->mParent)
|
||||
{
|
||||
auto children = ext->mParent->children();
|
||||
std::erase(children, this);
|
||||
ext->mParent->setChildren(children);
|
||||
}
|
||||
ext->detachFromParent();
|
||||
}
|
||||
ext->mParent = this;
|
||||
ext->mTemplateChild = false;
|
||||
ext->widget()->attachToWidget(mSlot->widget());
|
||||
|
@ -114,18 +122,9 @@ namespace LuaUi
|
|||
ext->widget()->attachToWidget(widget());
|
||||
}
|
||||
|
||||
void WidgetExtension::detachFromParent(bool updateParent)
|
||||
void WidgetExtension::detachFromParent()
|
||||
{
|
||||
if (mParent)
|
||||
{
|
||||
if (updateParent)
|
||||
{
|
||||
auto children = mParent->children();
|
||||
std::erase(children, this);
|
||||
mParent->setChildren(children);
|
||||
}
|
||||
mParent = nullptr;
|
||||
}
|
||||
mParent = nullptr;
|
||||
widget()->detachFromWidget();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace LuaUi
|
|||
|
||||
bool isRoot() const { return mElementRoot; }
|
||||
WidgetExtension* getParent() const { return mParent; }
|
||||
void detachFromParent(bool updateParent);
|
||||
void detachFromParent();
|
||||
|
||||
void detachChildrenIf(auto&& predicate) { detachChildrenIf(predicate, mChildren); }
|
||||
void detachTemplateChildrenIf(auto&& predicate) { detachChildrenIf(predicate, mTemplateChildren); }
|
||||
|
@ -185,7 +185,7 @@ namespace LuaUi
|
|||
{
|
||||
if (predicate(*it))
|
||||
{
|
||||
(*it)->detachFromParent(false);
|
||||
(*it)->detachFromParent();
|
||||
it = children.erase(it);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue