mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 14:38:34 +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) {
|
this.ScrollBar = new ScrollBar(Anchor.TopRight, new Vector2(scrollSize.X, 1), scrollSize.Y, 0) {
|
||||||
StepPerScroll = 10,
|
StepPerScroll = 10,
|
||||||
OnValueChanged = (element, value) => this.ForceChildrenScroll(),
|
OnValueChanged = (element, value) => this.ForceChildrenScroll(),
|
||||||
CanAutoAnchorsAttach = false
|
CanAutoAnchorsAttach = false,
|
||||||
|
AutoHideWhenEmpty = true
|
||||||
};
|
};
|
||||||
this.AddChild(this.ScrollBar);
|
this.AddChild(this.ScrollBar);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@ namespace MLEM.Ui.Elements {
|
||||||
this.maxValue = Math.Max(0, value);
|
this.maxValue = Math.Max(0, value);
|
||||||
// force current value to be clamped
|
// force current value to be clamped
|
||||||
this.CurrentValue = this.currValue;
|
this.CurrentValue = this.currValue;
|
||||||
|
if (this.AutoHideWhenEmpty)
|
||||||
|
this.IsHidden = this.maxValue <= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private float currValue;
|
private float currValue;
|
||||||
|
@ -41,6 +43,7 @@ namespace MLEM.Ui.Elements {
|
||||||
private bool isMouseHeld;
|
private bool isMouseHeld;
|
||||||
private bool isDragging;
|
private bool isDragging;
|
||||||
private bool isTouchHeld;
|
private bool isTouchHeld;
|
||||||
|
public bool AutoHideWhenEmpty;
|
||||||
|
|
||||||
static ScrollBar() {
|
static ScrollBar() {
|
||||||
InputHandler.EnableGestures(GestureType.HorizontalDrag, GestureType.VerticalDrag);
|
InputHandler.EnableGestures(GestureType.HorizontalDrag, GestureType.VerticalDrag);
|
||||||
|
|
Loading…
Reference in a new issue