mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 12:09:53 +00:00
Get rid of unncesesary onCoordChange
This commit is contained in:
parent
39df270ff2
commit
d214f6f6ef
4 changed files with 8 additions and 12 deletions
|
@ -19,10 +19,15 @@ namespace LuaUi
|
|||
mContainer = MyGUI::Gui::getInstancePtr()->createWidget<LuaContainer>(
|
||||
"", MyGUI::IntCoord(), MyGUI::Align::Default, "", "");
|
||||
mContainer->initialize(luaState, mContainer, false);
|
||||
mContainer->onCoordChange([this](WidgetExtension* ext, MyGUI::IntCoord coord) { setSize(coord.size()); });
|
||||
mContainer->widget()->eventChangeCoord += MyGUI::newDelegate(this, &LuaAdapter::containerChangedCoord);
|
||||
mContainer->widget()->attachToWidget(this);
|
||||
}
|
||||
|
||||
void LuaAdapter::containerChangedCoord(MyGUI::Widget*)
|
||||
{
|
||||
setSize(mContainer->getSize());
|
||||
}
|
||||
|
||||
void LuaAdapter::attach(const std::shared_ptr<Element>& element)
|
||||
{
|
||||
detachElement();
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace LuaUi
|
|||
|
||||
void attachElement();
|
||||
void detachElement();
|
||||
|
||||
void containerChangedCoord(MyGUI::Widget*);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,6 @@ namespace LuaUi
|
|||
clearCallbacks();
|
||||
clearEvents(mWidget);
|
||||
|
||||
mOnCoordChange.reset();
|
||||
|
||||
for (WidgetExtension* w : mChildren)
|
||||
w->deinitialize();
|
||||
for (WidgetExtension* w : mTemplateChildren)
|
||||
|
@ -264,8 +262,6 @@ namespace LuaUi
|
|||
if (oldCoord != newCoord)
|
||||
mWidget->setCoord(newCoord);
|
||||
updateChildrenCoord();
|
||||
if (oldCoord != newCoord && mOnCoordChange.has_value())
|
||||
mOnCoordChange.value()(this, newCoord);
|
||||
}
|
||||
|
||||
void WidgetExtension::setProperties(const sol::object& props)
|
||||
|
|
|
@ -69,11 +69,6 @@ namespace LuaUi
|
|||
return parseExternal(mExternal, name, defaultValue);
|
||||
}
|
||||
|
||||
void onCoordChange(const std::optional<std::function<void(WidgetExtension*, MyGUI::IntCoord)>>& callback)
|
||||
{
|
||||
mOnCoordChange = callback;
|
||||
}
|
||||
|
||||
virtual MyGUI::IntSize calculateSize();
|
||||
virtual MyGUI::IntPoint calculatePosition(const MyGUI::IntSize& size);
|
||||
MyGUI::IntCoord calculateCoord();
|
||||
|
@ -176,8 +171,6 @@ namespace LuaUi
|
|||
void focusGain(MyGUI::Widget*, MyGUI::Widget*);
|
||||
void focusLoss(MyGUI::Widget*, MyGUI::Widget*);
|
||||
|
||||
std::optional<std::function<void(WidgetExtension*, MyGUI::IntCoord)>> mOnCoordChange;
|
||||
|
||||
void updateVisible();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue