mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
added a bound check for the auto-calculated scroller size
This commit is contained in:
parent
6d554faaac
commit
dc15a9139f
1 changed files with 5 additions and 5 deletions
|
@ -221,21 +221,21 @@ namespace MLEM.Ui.Elements {
|
||||||
// if there is only one child, then we have just the scroll bar
|
// if there is only one child, then we have just the scroll bar
|
||||||
if (this.Children.Count == 1)
|
if (this.Children.Count == 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// the "real" first child is the scroll bar, which we want to ignore
|
// the "real" first child is the scroll bar, which we want to ignore
|
||||||
var firstChild = this.Children.First(c => c != this.ScrollBar);
|
var firstChild = this.Children.First(c => c != this.ScrollBar);
|
||||||
var lowestChild = this.GetLowestChild(c => c != this.ScrollBar && !c.IsHidden);
|
var lowestChild = this.GetLowestChild(c => c != this.ScrollBar && !c.IsHidden);
|
||||||
var childrenHeight = lowestChild.Area.Bottom - firstChild.Area.Top;
|
var childrenHeight = lowestChild.Area.Bottom - firstChild.Area.Top;
|
||||||
|
|
||||||
// the max value of the scrollbar is the amount of non-scaled pixels taken up by overflowing components
|
// 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;
|
var scrollBarMax = (childrenHeight - this.ChildPaddedArea.Height) / this.Scale;
|
||||||
if (this.ScrollBar.MaxValue != scrollBarMax) {
|
if (!this.ScrollBar.MaxValue.Equals(scrollBarMax, Epsilon)) {
|
||||||
this.ScrollBar.MaxValue = scrollBarMax;
|
this.ScrollBar.MaxValue = scrollBarMax;
|
||||||
this.relevantChildrenDirty = true;
|
this.relevantChildrenDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the scroller height has the same relation to the scroll bar height as the visible area has to the total height of the panel's content
|
// the scroller height has the same relation to the scroll bar height as the visible area has to the total height of the panel's content
|
||||||
var scrollerHeight = this.ChildPaddedArea.Height / childrenHeight / this.Scale * this.ScrollBar.Area.Height;
|
var scrollerHeight = Math.Min(this.ChildPaddedArea.Height / childrenHeight / this.Scale, 1) * this.ScrollBar.Area.Height;
|
||||||
this.ScrollBar.ScrollerSize = new Vector2(this.ScrollerSize.Value.X, Math.Max(this.ScrollerSize.Value.Y, scrollerHeight));
|
this.ScrollBar.ScrollerSize = new Vector2(this.ScrollerSize.Value.X, Math.Max(this.ScrollerSize.Value.Y, scrollerHeight));
|
||||||
|
|
||||||
// update the render target
|
// update the render target
|
||||||
|
|
Loading…
Reference in a new issue