From 7792ce99c855e40ac771d4aa10c28a65735b5ec4 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 26 Apr 2021 18:55:18 +0200 Subject: [PATCH] fixed auto-sized elements without children not being updated correctly --- MLEM.Ui/Elements/Element.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index 887e058..d0ae967 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -634,6 +634,8 @@ namespace MLEM.Ui.Elements { autoSize.Y = newHeight; foundChild = lowest; } + } else { + autoSize.Y = 0; } } if (this.SetWidthBasedOnChildren) { @@ -644,11 +646,13 @@ namespace MLEM.Ui.Elements { autoSize.X = newWidth; foundChild = rightmost; } + } else { + autoSize.X = 0; } } if (this.TreatSizeAsMinimum) autoSize = Vector2.Max(autoSize, actualSize); - if (foundChild != null) { + if (autoSize != this.UnscrolledArea.Size) { recursion++; if (recursion >= 16) { throw new ArithmeticException($"The area of {this} with root {this.Root?.Name} has recursively updated too often. Does its child {foundChild} contain any conflicting auto-sizing settings?");