mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
made disabling scroll bar hiding easier for the panel
This commit is contained in:
parent
b83d7f3526
commit
8dcf3d8e63
1 changed files with 5 additions and 4 deletions
|
@ -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,12 +32,13 @@ 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);
|
||||||
|
if (autoHideScrollbar)
|
||||||
this.ScrollBar.OnAutoHide += e => this.ChildPadding += new Padding(0, scrollSize.X, 0, 0) * (e.IsHidden ? -1 : 1);
|
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
|
||||||
|
|
Loading…
Reference in a new issue