mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 14:38:34 +01:00
simplify auto-size checks
This commit is contained in:
parent
7792ce99c8
commit
2abc3264a2
1 changed files with 5 additions and 11 deletions
|
@ -629,11 +629,8 @@ namespace MLEM.Ui.Elements {
|
||||||
if (this.SetHeightBasedOnChildren) {
|
if (this.SetHeightBasedOnChildren) {
|
||||||
var lowest = this.GetLowestChild(e => !e.IsHidden);
|
var lowest = this.GetLowestChild(e => !e.IsHidden);
|
||||||
if (lowest != null) {
|
if (lowest != null) {
|
||||||
var newHeight = lowest.UnscrolledArea.Bottom - pos.Y + this.ScaledChildPadding.Bottom;
|
autoSize.Y = lowest.UnscrolledArea.Bottom - pos.Y + this.ScaledChildPadding.Bottom;
|
||||||
if (!newHeight.Equals(autoSize.Y, 0.01F)) {
|
|
||||||
autoSize.Y = newHeight;
|
|
||||||
foundChild = lowest;
|
foundChild = lowest;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
autoSize.Y = 0;
|
autoSize.Y = 0;
|
||||||
}
|
}
|
||||||
|
@ -641,18 +638,15 @@ namespace MLEM.Ui.Elements {
|
||||||
if (this.SetWidthBasedOnChildren) {
|
if (this.SetWidthBasedOnChildren) {
|
||||||
var rightmost = this.GetRightmostChild(e => !e.IsHidden);
|
var rightmost = this.GetRightmostChild(e => !e.IsHidden);
|
||||||
if (rightmost != null) {
|
if (rightmost != null) {
|
||||||
var newWidth = rightmost.UnscrolledArea.Right - pos.X + this.ScaledChildPadding.Right;
|
autoSize.X = rightmost.UnscrolledArea.Right - pos.X + this.ScaledChildPadding.Right;
|
||||||
if (!newWidth.Equals(autoSize.X, 0.01F)) {
|
|
||||||
autoSize.X = newWidth;
|
|
||||||
foundChild = rightmost;
|
foundChild = rightmost;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
autoSize.X = 0;
|
autoSize.X = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.TreatSizeAsMinimum)
|
if (this.TreatSizeAsMinimum)
|
||||||
autoSize = Vector2.Max(autoSize, actualSize);
|
autoSize = Vector2.Max(autoSize, actualSize);
|
||||||
if (autoSize != this.UnscrolledArea.Size) {
|
if (!autoSize.Equals(this.UnscrolledArea.Size, 0.01F)) {
|
||||||
recursion++;
|
recursion++;
|
||||||
if (recursion >= 16) {
|
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?");
|
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?");
|
||||||
|
|
Loading…
Reference in a new issue