mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-12-26 02:09:24 +01:00
Fixed scrolling panels calculating their height incorrectly when their first child is hidden
This commit is contained in:
parent
5d4f1293c7
commit
7f4cc773ec
2 changed files with 6 additions and 5 deletions
|
@ -51,6 +51,7 @@ Improvements
|
|||
Fixes
|
||||
- Fixed panels updating their relevant children too much when the scroll bar is hidden
|
||||
- Fixed a stack overflow exception when a panel's scroll bar auto-hiding causes elements to gain height
|
||||
- Fixed scrolling panels calculating their height incorrectly when their first child is hidden
|
||||
|
||||
### MLEM.Extended
|
||||
Improvements
|
||||
|
|
|
@ -223,10 +223,10 @@ namespace MLEM.Ui.Elements {
|
|||
/// </summary>
|
||||
/// <param name="elementY">The y coordinate to scroll to, which should have this element's <see cref="Element.Scale"/> applied.</param>
|
||||
public void ScrollToElement(float elementY) {
|
||||
var firstChild = this.Children.FirstOrDefault(c => c != this.ScrollBar);
|
||||
if (firstChild == null)
|
||||
var highestValidChild = this.Children.FirstOrDefault(c => c != this.ScrollBar && !c.IsHidden);
|
||||
if (highestValidChild == null)
|
||||
return;
|
||||
this.ScrollBar.CurrentValue = (elementY - this.Area.Height / 2 - firstChild.Area.Top) / this.Scale + this.ChildPadding.Value.Height / 2;
|
||||
this.ScrollBar.CurrentValue = (elementY - this.Area.Height / 2 - highestValidChild.Area.Top) / this.Scale + this.ChildPadding.Value.Height / 2;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -282,9 +282,9 @@ namespace MLEM.Ui.Elements {
|
|||
|
||||
float childrenHeight;
|
||||
if (this.Children.Count > 1) {
|
||||
var firstChild = this.Children.FirstOrDefault(c => c != this.ScrollBar);
|
||||
var highestValidChild = this.Children.FirstOrDefault(c => c != this.ScrollBar && !c.IsHidden);
|
||||
var lowestChild = this.GetLowestChild(c => c != this.ScrollBar && !c.IsHidden, true);
|
||||
childrenHeight = lowestChild.GetTotalCoveredArea(false).Bottom - firstChild.Area.Top;
|
||||
childrenHeight = lowestChild.GetTotalCoveredArea(false).Bottom - highestValidChild.Area.Top;
|
||||
} else {
|
||||
// if we only have one child (the scroll bar), then the children take up no visual height
|
||||
childrenHeight = 0;
|
||||
|
|
Loading…
Reference in a new issue