diff --git a/MLEM.Ui/Elements/Panel.cs b/MLEM.Ui/Elements/Panel.cs index be9c330..4e9e832 100644 --- a/MLEM.Ui/Elements/Panel.cs +++ b/MLEM.Ui/Elements/Panel.cs @@ -27,7 +27,8 @@ namespace MLEM.Ui.Elements { this.ScrollBar = new ScrollBar(Anchor.TopRight, new Vector2(scrollSize.X, 1), scrollSize.Y, 0) { StepPerScroll = 10, OnValueChanged = (element, value) => this.ForceChildrenScroll(), - CanAutoAnchorsAttach = false + CanAutoAnchorsAttach = false, + AutoHideWhenEmpty = true }; this.AddChild(this.ScrollBar); diff --git a/MLEM.Ui/Elements/ScrollBar.cs b/MLEM.Ui/Elements/ScrollBar.cs index 2fe5347..ee9e94d 100644 --- a/MLEM.Ui/Elements/ScrollBar.cs +++ b/MLEM.Ui/Elements/ScrollBar.cs @@ -22,6 +22,8 @@ namespace MLEM.Ui.Elements { this.maxValue = Math.Max(0, value); // force current value to be clamped this.CurrentValue = this.currValue; + if (this.AutoHideWhenEmpty) + this.IsHidden = this.maxValue <= 0; } } private float currValue; @@ -41,6 +43,7 @@ namespace MLEM.Ui.Elements { private bool isMouseHeld; private bool isDragging; private bool isTouchHeld; + public bool AutoHideWhenEmpty; static ScrollBar() { InputHandler.EnableGestures(GestureType.HorizontalDrag, GestureType.VerticalDrag);