From db454ebd7144ebf2cc980c255ca51f14b089547c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 29 Mar 2023 20:56:56 +0200 Subject: [PATCH] Fixed AutoInline elements overflowing into their parent if it's taller --- CHANGELOG.md | 3 ++- MLEM.Ui/Elements/Element.cs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4584933..6368be1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,10 +34,11 @@ Removals ### MLEM.Ui Additions -- Added `AutoInlineCenter` and `AutoInlineBottom` anchors +- Added AutoInlineCenter and AutoInlineBottom anchors Fixes - Fixed images not updating their hidden state properly when the displayed texture changes +- Fixed AutoInline elements overflowing into their parent if it's taller Improvements - Increased Element area calculation recursion limit to 64 diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index 951464f..7e180e4 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -728,9 +728,11 @@ namespace MLEM.Ui.Elements { pos.Y += anchorElArea.Height - newSize.Y; } } else { - // all inline anchors act the same when overflowing into the next line pos.X = parentArea.X + this.ScaledOffset.X; - pos.Y = anchorElArea.Bottom + this.ScaledOffset.Y; + // inline anchors that overflow into the next line act like AutoLeft + var newlineAnchorEl = this.GetLowestOlderSibling(e => !e.IsHidden && e.CanAutoAnchorsAttach); + if (newlineAnchorEl != null) + pos.Y = newlineAnchorEl.GetAreaForAutoAnchors().Bottom + this.ScaledOffset.Y; } } } else {