1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-31 20:33:38 +02:00

Ensure auto anchors keep their initial values if no siblings can be found (94a54c3)

This commit is contained in:
Ell 2023-03-29 21:00:17 +02:00
parent db454ebd71
commit e0d4bb3472

View file

@ -672,6 +672,12 @@ namespace MLEM.Ui.Elements {
switch (this.anchor) { switch (this.anchor) {
case Anchor.TopLeft: case Anchor.TopLeft:
case Anchor.AutoLeft: case Anchor.AutoLeft:
case Anchor.AutoInline:
case Anchor.AutoInlineCenter:
case Anchor.AutoInlineBottom:
case Anchor.AutoInlineIgnoreOverflow:
case Anchor.AutoInlineCenterIgnoreOverflow:
case Anchor.AutoInlineBottomIgnoreOverflow:
pos.X = parentArea.X + this.ScaledOffset.X; pos.X = parentArea.X + this.ScaledOffset.X;
pos.Y = parentArea.Y + this.ScaledOffset.Y; pos.Y = parentArea.Y + this.ScaledOffset.Y;
break; break;
@ -728,7 +734,6 @@ namespace MLEM.Ui.Elements {
pos.Y += anchorElArea.Height - newSize.Y; pos.Y += anchorElArea.Height - newSize.Y;
} }
} else { } else {
pos.X = parentArea.X + this.ScaledOffset.X;
// inline anchors that overflow into the next line act like AutoLeft // inline anchors that overflow into the next line act like AutoLeft
var newlineAnchorEl = this.GetLowestOlderSibling(e => !e.IsHidden && e.CanAutoAnchorsAttach); var newlineAnchorEl = this.GetLowestOlderSibling(e => !e.IsHidden && e.CanAutoAnchorsAttach);
if (newlineAnchorEl != null) if (newlineAnchorEl != null)
@ -736,7 +741,7 @@ namespace MLEM.Ui.Elements {
} }
} }
} else { } else {
// non-inline auto anchors keep their x coordinates from the switch above // auto anchors keep their x coordinates from the switch above
var anchorEl = this.GetLowestOlderSibling(e => !e.IsHidden && e.CanAutoAnchorsAttach); var anchorEl = this.GetLowestOlderSibling(e => !e.IsHidden && e.CanAutoAnchorsAttach);
if (anchorEl != null) if (anchorEl != null)
pos.Y = anchorEl.GetAreaForAutoAnchors().Bottom + this.ScaledOffset.Y; pos.Y = anchorEl.GetAreaForAutoAnchors().Bottom + this.ScaledOffset.Y;