diff --git a/CHANGELOG.md b/CHANGELOG.md index d42c801..2cf498a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ Additions - Added the ability to display tooltips using the auto-nav style even when using the mouse Improvements -- Allow scrolling panels to set height based on children with TreatSizeAsMaximum +- Allow scrolling panels to set height based on children by setting TreatSizeAsMaximum Fixes - Fixed hidden scroll bars inhibiting scrolling on their parent panel diff --git a/Demos/UiDemo.cs b/Demos/UiDemo.cs index c401601..12ef1c5 100644 --- a/Demos/UiDemo.cs +++ b/Demos/UiDemo.cs @@ -226,8 +226,7 @@ namespace Demos { this.root.AddChild(new VerticalSpace(3)); var dynamicSubPanel = this.root.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1, 50), Vector2.Zero, true, true) { Texture = null, - ChildPadding = Padding.Empty, - TreatSizeAsMaximum = true + ChildPadding = Padding.Empty }); dynamicSubPanel.AddChild(new Paragraph(Anchor.AutoLeft, 1, "This is a dynamic height nested panel with a maximum height, at which point it starts displaying a scroll bar instead!")); dynamicSubPanel.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 10), "Press to add more") { diff --git a/MLEM.Ui/Elements/Panel.cs b/MLEM.Ui/Elements/Panel.cs index 2da13d3..4b85e1e 100644 --- a/MLEM.Ui/Elements/Panel.cs +++ b/MLEM.Ui/Elements/Panel.cs @@ -78,6 +78,7 @@ namespace MLEM.Ui.Elements { public Panel(Anchor anchor, Vector2 size, Vector2 positionOffset, bool setHeightBasedOnChildren = false, bool scrollOverflow = false, bool autoHideScrollbar = true) : base(anchor, size) { this.PositionOffset = positionOffset; this.SetHeightBasedOnChildren = setHeightBasedOnChildren; + this.TreatSizeAsMaximum = setHeightBasedOnChildren && scrollOverflow; this.scrollOverflow = scrollOverflow; this.CanBeSelected = false;