mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Add Container widget type, use it to make Adapter code less hacky
This commit is contained in:
parent
086a7d9bc5
commit
f07f05ddd3
9 changed files with 107 additions and 35 deletions
35
components/lua_ui/container.cpp
Normal file
35
components/lua_ui/container.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include "container.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace LuaUi
|
||||
{
|
||||
void LuaContainer::updateChildren()
|
||||
{
|
||||
WidgetExtension::updateChildren();
|
||||
for (auto w : children())
|
||||
{
|
||||
w->onCoordChange([this](WidgetExtension* child, MyGUI::IntCoord coord)
|
||||
{ updateSizeToFit(); });
|
||||
}
|
||||
updateSizeToFit();
|
||||
}
|
||||
|
||||
MyGUI::IntSize LuaContainer::childScalingSize()
|
||||
{
|
||||
return MyGUI::IntSize();
|
||||
}
|
||||
|
||||
void LuaContainer::updateSizeToFit()
|
||||
{
|
||||
MyGUI::IntSize size;
|
||||
for (auto w : children())
|
||||
{
|
||||
MyGUI::IntCoord coord = w->widget()->getCoord();
|
||||
size.width = std::max(size.width, coord.left + coord.width);
|
||||
size.height = std::max(size.height, coord.top + coord.height);
|
||||
}
|
||||
setForcedSize(size);
|
||||
updateCoord();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue