1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 12:58:33 +01:00

made disabling scroll bar hiding easier for the panel

This commit is contained in:
Ellpeck 2019-12-14 14:10:38 +01:00
parent b83d7f3526
commit 8dcf3d8e63

View file

@ -19,7 +19,7 @@ namespace MLEM.Ui.Elements {
private readonly List<Element> relevantChildren = new List<Element>();
private bool relevantChildrenDirty;
public Panel(Anchor anchor, Vector2 size, Vector2 positionOffset, bool setHeightBasedOnChildren = false, bool scrollOverflow = false, Point? scrollerSize = null) : base(anchor, size) {
public Panel(Anchor anchor, Vector2 size, Vector2 positionOffset, bool setHeightBasedOnChildren = false, bool scrollOverflow = false, Point? scrollerSize = null, bool autoHideScrollbar = true) : base(anchor, size) {
this.PositionOffset = positionOffset;
this.SetHeightBasedOnChildren = setHeightBasedOnChildren;
this.scrollOverflow = scrollOverflow;
@ -32,13 +32,14 @@ namespace MLEM.Ui.Elements {
StepPerScroll = 10,
OnValueChanged = (element, value) => this.ScrollChildren(),
CanAutoAnchorsAttach = false,
AutoHideWhenEmpty = true,
IsHidden = true
AutoHideWhenEmpty = autoHideScrollbar,
IsHidden = autoHideScrollbar
};
// modify the padding so that the scroll bar isn't over top of something else
this.ScrollBar.PositionOffset -= new Vector2(scrollSize.X + 1, 0);
this.ScrollBar.OnAutoHide += e => this.ChildPadding += new Padding(0, scrollSize.X, 0, 0) * (e.IsHidden ? -1 : 1);
if (autoHideScrollbar)
this.ScrollBar.OnAutoHide += e => this.ChildPadding += new Padding(0, scrollSize.X, 0, 0) * (e.IsHidden ? -1 : 1);
// handle automatic element selection, the scroller needs to scroll to the right location
this.OnSelectedElementChanged += (element, otherElement) => {