1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 04:53:29 +01:00

Fixed panels that don't auto-hide their scroll bars ignoring their width for child padding

This commit is contained in:
Ell 2021-11-14 19:50:24 +01:00
parent 6702efd7fa
commit 9cd72e9b4e
2 changed files with 7 additions and 6 deletions

View file

@ -35,6 +35,7 @@ Improvements
Fixes
- Fixed VerticalSpace height parameter being an integer
- Fixed text not being pasted into a text field at all if it contains characters that don't match the input rule
- Fixed panels that don't auto-hide their scroll bars ignoring their width for child padding
### MLEM.Data
Additions

View file

@ -76,12 +76,6 @@ namespace MLEM.Ui.Elements {
AutoHideWhenEmpty = autoHideScrollbar,
IsHidden = autoHideScrollbar
};
if (autoHideScrollbar) {
this.ScrollBar.OnAutoHide += e => {
this.ChildPadding += new Padding(0, this.ScrollerSize.Value.X + this.ScrollBarOffset, 0, 0) * (e.IsHidden ? -1 : 1);
this.SetAreaDirty();
};
}
// handle automatic element selection, the scroller needs to scroll to the right location
this.OnSelectedElementChanged += (element, otherElement) => {
@ -235,7 +229,13 @@ namespace MLEM.Ui.Elements {
// the max value of the scrollbar is the amount of non-scaled pixels taken up by overflowing components
var scrollBarMax = (childrenHeight - this.ChildPaddedArea.Height) / this.Scale;
if (!this.ScrollBar.MaxValue.Equals(scrollBarMax, Epsilon)) {
var wasZero = this.ScrollBar.MaxValue <= Epsilon;
this.ScrollBar.MaxValue = scrollBarMax;
if (this.ScrollBar.MaxValue <= Epsilon != wasZero) {
// update child padding based on whether the scroll bar is visible
this.ChildPadding += new Padding(0, this.ScrollerSize.Value.X + this.ScrollBarOffset, 0, 0) * (this.ScrollBar.IsHidden ? -1 : 1);
this.SetAreaDirty();
}
this.relevantChildrenDirty = true;
}