From 00842d9e5fb148d818697901aae3f8aa1d9eec33 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 24 Aug 2019 15:20:00 +0200 Subject: [PATCH] inline anchors should use the old system though --- MLEM.Ui/Elements/Element.cs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index bbc69d1..c8d55f9 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -263,7 +263,12 @@ namespace MLEM.Ui.Elements { } if (this.Anchor >= Anchor.AutoLeft) { - var previousChild = this.GetLowestOlderSibling(false, false); + Element previousChild; + if (this.Anchor == Anchor.AutoInline || this.Anchor == Anchor.AutoInlineIgnoreOverflow) { + previousChild = this.GetOlderSibling(false, false); + } else { + previousChild = this.GetLowestOlderSibling(false, false); + } if (previousChild != null) { var prevArea = previousChild.GetAreaForAutoAnchors(); switch (this.Anchor) { @@ -334,21 +339,32 @@ namespace MLEM.Ui.Elements { public Element GetLowestOlderSibling(bool hiddenAlso, bool unattachableAlso) { if (this.Parent == null) return null; - Element lowest = null; foreach (var child in this.Parent.Children) { if (child == this) break; if (!hiddenAlso && child.IsHidden || !unattachableAlso && !child.CanAutoAnchorsAttach) continue; - if (child.Anchor > Anchor.TopRight && child.Anchor < Anchor.AutoLeft) - continue; if (lowest == null || child.Area.Bottom >= lowest.Area.Bottom) lowest = child; } return lowest; } + public Element GetOlderSibling(bool hiddenAlso, bool unattachableAlso) { + if (this.Parent == null) + return null; + Element older = null; + foreach (var child in this.Parent.Children) { + if (child == this) + break; + if (!hiddenAlso && child.IsHidden || !unattachableAlso && !child.CanAutoAnchorsAttach) + continue; + older = child; + } + return older; + } + public IEnumerable GetSiblings(bool hiddenAlso) { if (this.Parent == null) yield break;