From 15b468bab42d11890112f76c240732ff3052ae1c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 18 Aug 2019 17:49:52 +0200 Subject: [PATCH] add the ability for elements to override the position that children will be auto-anchored to --- 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 dd6cd43..afdb8df 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -275,7 +275,7 @@ namespace MLEM.Ui.Elements { if (this.Anchor >= Anchor.AutoLeft) { var previousChild = this.GetPreviousChild(false); if (previousChild != null) { - var prevArea = previousChild.Area; + var prevArea = previousChild.GetAreaForAutoAnchors(); switch (this.Anchor) { case Anchor.AutoLeft: case Anchor.AutoCenter: @@ -325,6 +325,10 @@ namespace MLEM.Ui.Elements { (this.size.Y > 1 ? this.ScaledSize.Y : parentArea.Height * this.size.Y).Floor()); } + protected Rectangle GetAreaForAutoAnchors() { + return this.Area; + } + protected Element GetPreviousChild(bool hiddenAlso) { if (this.Parent == null) return null;