1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-26 06:28:35 +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 readonly List<Element> relevantChildren = new List<Element>();
private bool relevantChildrenDirty; 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.PositionOffset = positionOffset;
this.SetHeightBasedOnChildren = setHeightBasedOnChildren; this.SetHeightBasedOnChildren = setHeightBasedOnChildren;
this.scrollOverflow = scrollOverflow; this.scrollOverflow = scrollOverflow;
@ -32,13 +32,14 @@ namespace MLEM.Ui.Elements {
StepPerScroll = 10, StepPerScroll = 10,
OnValueChanged = (element, value) => this.ScrollChildren(), OnValueChanged = (element, value) => this.ScrollChildren(),
CanAutoAnchorsAttach = false, CanAutoAnchorsAttach = false,
AutoHideWhenEmpty = true, AutoHideWhenEmpty = autoHideScrollbar,
IsHidden = true IsHidden = autoHideScrollbar
}; };
// modify the padding so that the scroll bar isn't over top of something else // 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.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 // handle automatic element selection, the scroller needs to scroll to the right location
this.OnSelectedElementChanged += (element, otherElement) => { this.OnSelectedElementChanged += (element, otherElement) => {