mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
fixed newly added Panel children not scrolling correctly since f6bc206
This commit is contained in:
parent
a119db553f
commit
7720ab0ea5
1 changed files with 7 additions and 1 deletions
|
@ -55,6 +55,7 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly List<Element> relevantChildren = new List<Element>();
|
private readonly List<Element> relevantChildren = new List<Element>();
|
||||||
|
private readonly HashSet<Element> scrolledChildren = new HashSet<Element>();
|
||||||
private readonly bool scrollOverflow;
|
private readonly bool scrollOverflow;
|
||||||
|
|
||||||
private RenderTarget2D renderTarget;
|
private RenderTarget2D renderTarget;
|
||||||
|
@ -336,11 +337,16 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollChildren() {
|
private void ScrollChildren() {
|
||||||
|
this.scrolledChildren.RemoveWhere(c => !c.GetParentTree().Contains(this));
|
||||||
if (!this.scrollOverflow)
|
if (!this.scrollOverflow)
|
||||||
return;
|
return;
|
||||||
// we ignore false grandchildren so that the children of the scroll bar stay in place
|
// we ignore false grandchildren so that the children of the scroll bar stay in place
|
||||||
foreach (var child in this.GetChildren(c => c != this.ScrollBar, true, true))
|
foreach (var child in this.GetChildren(c => c != this.ScrollBar, true, true)) {
|
||||||
|
// if a child was newly added later, the last scroll offset was never applied
|
||||||
|
if (this.scrolledChildren.Add(child))
|
||||||
|
child.ScrollOffset.Y -= this.lastScrollOffset;
|
||||||
child.ScrollOffset.Y += (this.lastScrollOffset - this.ScrollBar.CurrentValue);
|
child.ScrollOffset.Y += (this.lastScrollOffset - this.ScrollBar.CurrentValue);
|
||||||
|
}
|
||||||
this.lastScrollOffset = this.ScrollBar.CurrentValue;
|
this.lastScrollOffset = this.ScrollBar.CurrentValue;
|
||||||
this.relevantChildrenDirty = true;
|
this.relevantChildrenDirty = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue