C++20
uramer 3 years ago
parent 01d65a14f1
commit 7f796d148e

@ -36,7 +36,6 @@ namespace LuaUi
{ "LuaTextEdit", "TextEdit" }, { "LuaTextEdit", "TextEdit" },
{ "LuaWindow", "Window" }, { "LuaWindow", "Window" },
{ "LuaImage", "Image" }, { "LuaImage", "Image" },
{ "LuaContainer", "Container" },
}; };
return types; return types;
} }

@ -65,7 +65,7 @@ namespace LuaUi
mWidget->eventKeySetFocus.clear(); mWidget->eventKeySetFocus.clear();
mWidget->eventKeyLostFocus.clear(); mWidget->eventKeyLostFocus.clear();
mOnSizeChange.reset(); mOnCoordChange.reset();
for (WidgetExtension* w : mChildren) for (WidgetExtension* w : mChildren)
w->deinitialize(); w->deinitialize();
@ -212,11 +212,7 @@ namespace LuaUi
if (oldCoord != newCoord) if (oldCoord != newCoord)
mWidget->setCoord(newCoord); mWidget->setCoord(newCoord);
if (oldCoord.size() != newCoord.size()) if (oldCoord.size() != newCoord.size())
{
updateChildrenCoord(); updateChildrenCoord();
if (mOnSizeChange.has_value())
mOnSizeChange.value()(newCoord.size());
}
if (oldCoord != newCoord && mOnCoordChange.has_value()) if (oldCoord != newCoord && mOnCoordChange.has_value())
mOnCoordChange.value()(this, newCoord); mOnCoordChange.value()(this, newCoord);
} }

@ -62,11 +62,6 @@ namespace LuaUi
mOnCoordChange = callback; mOnCoordChange = callback;
} }
void onSizeChange(const std::optional<std::function<void(MyGUI::IntSize)>>& callback)
{
mOnSizeChange = callback;
}
protected: protected:
virtual void initialize(); virtual void initialize();
sol::table makeTable() const; sol::table makeTable() const;
@ -137,7 +132,6 @@ namespace LuaUi
void focusLoss(MyGUI::Widget*, MyGUI::Widget*); void focusLoss(MyGUI::Widget*, MyGUI::Widget*);
std::optional<std::function<void(WidgetExtension*, MyGUI::IntCoord)>> mOnCoordChange; std::optional<std::function<void(WidgetExtension*, MyGUI::IntCoord)>> mOnCoordChange;
std::optional<std::function<void(MyGUI::IntSize)>> mOnSizeChange;
}; };
class LuaWidget : public MyGUI::Widget, public WidgetExtension class LuaWidget : public MyGUI::Widget, public WidgetExtension

Loading…
Cancel
Save