mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03: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>(
|
mContainer = MyGUI::Gui::getInstancePtr()->createWidget<LuaContainer>(
|
||||||
"", MyGUI::IntCoord(), MyGUI::Align::Default, "", "");
|
"", MyGUI::IntCoord(), MyGUI::Align::Default, "", "");
|
||||||
mContainer->initialize(luaState, mContainer, false);
|
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);
|
mContainer->widget()->attachToWidget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LuaAdapter::containerChangedCoord(MyGUI::Widget*)
|
||||||
|
{
|
||||||
|
setSize(mContainer->getSize());
|
||||||
|
}
|
||||||
|
|
||||||
void LuaAdapter::attach(const std::shared_ptr<Element>& element)
|
void LuaAdapter::attach(const std::shared_ptr<Element>& element)
|
||||||
{
|
{
|
||||||
detachElement();
|
detachElement();
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace LuaUi
|
||||||
|
|
||||||
void attachElement();
|
void attachElement();
|
||||||
void detachElement();
|
void detachElement();
|
||||||
|
|
||||||
|
void containerChangedCoord(MyGUI::Widget*);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,6 @@ namespace LuaUi
|
||||||
clearCallbacks();
|
clearCallbacks();
|
||||||
clearEvents(mWidget);
|
clearEvents(mWidget);
|
||||||
|
|
||||||
mOnCoordChange.reset();
|
|
||||||
|
|
||||||
for (WidgetExtension* w : mChildren)
|
for (WidgetExtension* w : mChildren)
|
||||||
w->deinitialize();
|
w->deinitialize();
|
||||||
for (WidgetExtension* w : mTemplateChildren)
|
for (WidgetExtension* w : mTemplateChildren)
|
||||||
|
@ -264,8 +262,6 @@ namespace LuaUi
|
||||||
if (oldCoord != newCoord)
|
if (oldCoord != newCoord)
|
||||||
mWidget->setCoord(newCoord);
|
mWidget->setCoord(newCoord);
|
||||||
updateChildrenCoord();
|
updateChildrenCoord();
|
||||||
if (oldCoord != newCoord && mOnCoordChange.has_value())
|
|
||||||
mOnCoordChange.value()(this, newCoord);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetExtension::setProperties(const sol::object& props)
|
void WidgetExtension::setProperties(const sol::object& props)
|
||||||
|
|
|
@ -69,11 +69,6 @@ namespace LuaUi
|
||||||
return parseExternal(mExternal, name, defaultValue);
|
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::IntSize calculateSize();
|
||||||
virtual MyGUI::IntPoint calculatePosition(const MyGUI::IntSize& size);
|
virtual MyGUI::IntPoint calculatePosition(const MyGUI::IntSize& size);
|
||||||
MyGUI::IntCoord calculateCoord();
|
MyGUI::IntCoord calculateCoord();
|
||||||
|
@ -176,8 +171,6 @@ namespace LuaUi
|
||||||
void focusGain(MyGUI::Widget*, MyGUI::Widget*);
|
void focusGain(MyGUI::Widget*, MyGUI::Widget*);
|
||||||
void focusLoss(MyGUI::Widget*, MyGUI::Widget*);
|
void focusLoss(MyGUI::Widget*, MyGUI::Widget*);
|
||||||
|
|
||||||
std::optional<std::function<void(WidgetExtension*, MyGUI::IntCoord)>> mOnCoordChange;
|
|
||||||
|
|
||||||
void updateVisible();
|
void updateVisible();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue