1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-24 17:29:23 +01:00

automatically set TreatSizeAsMaximum for height-based scrolling panels

This commit is contained in:
Ell 2024-05-29 23:37:42 +02:00
parent ab96e97f8e
commit ee2b0266aa
3 changed files with 3 additions and 3 deletions

View file

@ -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

View file

@ -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") {

View file

@ -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;