Widgets/BoxLayout: Try to fix widget layout

This commit is contained in:
SirLynix 2023-12-04 09:49:48 +01:00
parent 0c29bce3d8
commit 81c5322331
1 changed files with 3 additions and 0 deletions

View File

@ -65,6 +65,7 @@ namespace Nz
Nz::Vector2f layoutSize = GetSize();
float maxLayoutSize = layoutSize[axis];
float availableSpace = maxLayoutSize - m_spacing * (widgetChildCount - 1);
float optimalSize = availableSpace / widgetChildCount;
// Handle size
ForEachWidgetChild([&](BaseWidget* child)
@ -94,6 +95,8 @@ namespace Nz
else
m_state->solver.addConstraint({ (sizeVar >= maxLayoutSize) | kiwi::strength::medium });
m_state->solver.addConstraint({ (sizeVar >= optimalSize) | kiwi::strength::medium });
sizeSum = sizeSum + sizeVar;
});