mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 14:08:34 +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
|
Fixes
|
||||||
- Fixed panels updating their relevant children too much when the scroll bar is hidden
|
- 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 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
|
### MLEM.Extended
|
||||||
Improvements
|
Improvements
|
||||||
|
|
|
@ -223,10 +223,10 @@ namespace MLEM.Ui.Elements {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="elementY">The y coordinate to scroll to, which should have this element's <see cref="Element.Scale"/> applied.</param>
|
/// <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) {
|
public void ScrollToElement(float elementY) {
|
||||||
var firstChild = this.Children.FirstOrDefault(c => c != this.ScrollBar);
|
var highestValidChild = this.Children.FirstOrDefault(c => c != this.ScrollBar && !c.IsHidden);
|
||||||
if (firstChild == null)
|
if (highestValidChild == null)
|
||||||
return;
|
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 />
|
/// <inheritdoc />
|
||||||
|
@ -282,9 +282,9 @@ namespace MLEM.Ui.Elements {
|
||||||
|
|
||||||
float childrenHeight;
|
float childrenHeight;
|
||||||
if (this.Children.Count > 1) {
|
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);
|
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 {
|
} else {
|
||||||
// if we only have one child (the scroll bar), then the children take up no visual height
|
// if we only have one child (the scroll bar), then the children take up no visual height
|
||||||
childrenHeight = 0;
|
childrenHeight = 0;
|
||||||
|
|
Loading…
Reference in a new issue