|
|
@ -53,6 +53,8 @@ namespace LuaUi
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!ext->isRoot())
|
|
|
|
if (!ext->isRoot())
|
|
|
|
destroyWidget(ext);
|
|
|
|
destroyWidget(ext);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
ext->widget()->detachFromWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void detachElements(LuaUi::WidgetExtension* ext)
|
|
|
|
void detachElements(LuaUi::WidgetExtension* ext)
|
|
|
@ -235,7 +237,6 @@ namespace LuaUi
|
|
|
|
|
|
|
|
|
|
|
|
Element::Element(sol::table layout)
|
|
|
|
Element::Element(sol::table layout)
|
|
|
|
: mRoot(nullptr)
|
|
|
|
: mRoot(nullptr)
|
|
|
|
, mAttachedTo(nullptr)
|
|
|
|
|
|
|
|
, mLayout(std::move(layout))
|
|
|
|
, mLayout(std::move(layout))
|
|
|
|
, mLayer()
|
|
|
|
, mLayer()
|
|
|
|
, mUpdate(false)
|
|
|
|
, mUpdate(false)
|
|
|
@ -257,7 +258,6 @@ namespace LuaUi
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mRoot = createWidget(layout(), 0);
|
|
|
|
mRoot = createWidget(layout(), 0);
|
|
|
|
mLayer = setLayer(mRoot, layout());
|
|
|
|
mLayer = setLayer(mRoot, layout());
|
|
|
|
updateAttachment();
|
|
|
|
|
|
|
|
updateRootCoord(mRoot);
|
|
|
|
updateRootCoord(mRoot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -281,7 +281,6 @@ namespace LuaUi
|
|
|
|
updateWidget(mRoot, layout(), 0);
|
|
|
|
updateWidget(mRoot, layout(), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mLayer = setLayer(mRoot, layout());
|
|
|
|
mLayer = setLayer(mRoot, layout());
|
|
|
|
updateAttachment();
|
|
|
|
|
|
|
|
updateRootCoord(mRoot);
|
|
|
|
updateRootCoord(mRoot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mUpdate = false;
|
|
|
|
mUpdate = false;
|
|
|
@ -297,34 +296,4 @@ namespace LuaUi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sAllElements.erase(this);
|
|
|
|
sAllElements.erase(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Element::attachToWidget(WidgetExtension* w)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mAttachedTo)
|
|
|
|
|
|
|
|
throw std::logic_error("A UI element can't be attached to two widgets at once");
|
|
|
|
|
|
|
|
mAttachedTo = w;
|
|
|
|
|
|
|
|
updateAttachment();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Element::detachFromWidget()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mRoot)
|
|
|
|
|
|
|
|
mRoot->widget()->detachFromWidget();
|
|
|
|
|
|
|
|
if (mAttachedTo)
|
|
|
|
|
|
|
|
mAttachedTo->setChildren({});
|
|
|
|
|
|
|
|
mAttachedTo = nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Element::updateAttachment()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!mRoot)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (mAttachedTo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!mLayer.empty())
|
|
|
|
|
|
|
|
Log(Debug::Warning) << "Ignoring element's layer " << mLayer << " because it's attached to a widget";
|
|
|
|
|
|
|
|
mAttachedTo->setChildren({ mRoot });
|
|
|
|
|
|
|
|
mAttachedTo->updateCoord();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|