mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-25 17:59:24 +01:00
made elements be able to set both width and height automatically
This commit is contained in:
parent
c6fff090e6
commit
6faba05b24
1 changed files with 7 additions and 3 deletions
|
@ -316,25 +316,29 @@ namespace MLEM.Ui.Elements {
|
|||
child.ForceUpdateArea();
|
||||
|
||||
if (this.Children.Count > 0) {
|
||||
var changed = false;
|
||||
if (this.SetHeightBasedOnChildren) {
|
||||
var lowest = this.GetLowestChild(e => !e.IsHidden);
|
||||
if (lowest != null) {
|
||||
var newHeight = (lowest.UnscrolledArea.Bottom - pos.Y + this.ScaledChildPadding.Bottom) / this.Scale;
|
||||
if ((int) newHeight != (int) this.size.Y) {
|
||||
this.size.Y = newHeight;
|
||||
this.ForceUpdateArea();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else if (this.SetWidthBasedOnChildren) {
|
||||
}
|
||||
if (this.SetWidthBasedOnChildren) {
|
||||
var rightmost = this.GetRightmostChild(e => !e.IsHidden);
|
||||
if (rightmost != null) {
|
||||
var newWidth = (rightmost.UnscrolledArea.Right - pos.X + this.ScaledChildPadding.Right) / this.Scale;
|
||||
if ((int) newWidth != (int) this.size.X) {
|
||||
this.size.X = newWidth;
|
||||
this.ForceUpdateArea();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed)
|
||||
this.ForceUpdateArea();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue