1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-31 20:33:38 +02:00

add the ability for scroll bars to hide themselves when they're empty

This commit is contained in:
Ellpeck 2019-09-01 19:53:52 +02:00
parent f65cd58a80
commit 3e7ddb8b1a
2 changed files with 5 additions and 1 deletions

View file

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

View file

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