Widgets/BoxLayout: Try to fix widget layout
This commit is contained in:
parent
0c29bce3d8
commit
81c5322331
|
|
@ -65,6 +65,7 @@ namespace Nz
|
||||||
Nz::Vector2f layoutSize = GetSize();
|
Nz::Vector2f layoutSize = GetSize();
|
||||||
float maxLayoutSize = layoutSize[axis];
|
float maxLayoutSize = layoutSize[axis];
|
||||||
float availableSpace = maxLayoutSize - m_spacing * (widgetChildCount - 1);
|
float availableSpace = maxLayoutSize - m_spacing * (widgetChildCount - 1);
|
||||||
|
float optimalSize = availableSpace / widgetChildCount;
|
||||||
|
|
||||||
// Handle size
|
// Handle size
|
||||||
ForEachWidgetChild([&](BaseWidget* child)
|
ForEachWidgetChild([&](BaseWidget* child)
|
||||||
|
|
@ -94,6 +95,8 @@ namespace Nz
|
||||||
else
|
else
|
||||||
m_state->solver.addConstraint({ (sizeVar >= maxLayoutSize) | kiwi::strength::medium });
|
m_state->solver.addConstraint({ (sizeVar >= maxLayoutSize) | kiwi::strength::medium });
|
||||||
|
|
||||||
|
m_state->solver.addConstraint({ (sizeVar >= optimalSize) | kiwi::strength::medium });
|
||||||
|
|
||||||
sizeSum = sizeSum + sizeVar;
|
sizeSum = sizeSum + sizeVar;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue