Don't reassign Size in Container if the new size is identical to current size in RecalculateSizes.

This commit is contained in:
2025-06-24 23:44:38 +02:00
parent d44341974f
commit 389a73cf24
2 changed files with 22 additions and 16 deletions

View File

@@ -127,22 +127,23 @@ public class TestGame : Game
private ResourceRef<Sound> _sound; private ResourceRef<Sound> _sound;
private ResourceRef<Texture2d> _icon; private ResourceRef<Texture2d> _icon;
// private FlexContainer _container = new(minimumSize: new Rect(64.0f, 64.0f), new()) private FlexContainer _container = new(minimumSize: new Rect(64.0f, 64.0f), new())
// {
// Anchor = Anchor.Center,
// Size = new Rect(500, 300),
// Direction = FlexDirection.Column,
// Justify = JustifyContent.Start,
// Align = AlignItems.Center,
// Wrap = true,
// Gap = 10f
// };
private Frame _frame = new();
private VerticalContainer _container = new(new Rect(128.0f, 64.0f), new(), 16)
{ {
ConfineToContents = true, ConfineToContents = true,
Anchor = Anchor.CenterLeft, Anchor = Anchor.Center,
AnchorOffset = new Vector2(0.5f, 0.0f) Size = new Rect(500, 300),
Direction = FlexDirection.Column,
Justify = JustifyContent.Start,
Align = AlignItems.Center,
Wrap = true,
Gap = 10f
}; };
private Frame _frame = new();
// private HorizontalContainer _container = new(new Rect(128.0f, 64.0f), new(), 16)
// {
// ConfineToContents = true,
// Anchor = Anchor.CenterRight,
// AnchorOffset = new Vector2(0.5f, 0.0f)
// };
} }

View File

@@ -95,7 +95,12 @@ public abstract class Container : UIElement, IParentableElement
float finalWidth = MathF.Max(occupiedWidth, _minimumSize.Width); float finalWidth = MathF.Max(occupiedWidth, _minimumSize.Width);
float finalHeight = MathF.Max(occupiedHeight, _minimumSize.Height); float finalHeight = MathF.Max(occupiedHeight, _minimumSize.Height);
Size = new Rect(finalWidth, finalHeight); var finalSize = new Rect(finalWidth, finalHeight);
if (finalSize != Size)
{
Size = finalSize;
}
if (_minimumSize > Size) if (_minimumSize > Size)
{ {