mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
add the ability for scroll bars to hide themselves when they're empty
This commit is contained in:
parent
f65cd58a80
commit
3e7ddb8b1a
2 changed files with 5 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue