mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-27 15:08:33 +01:00
Compare commits
5 commits
0293ea435e
...
56a4833a49
Author | SHA1 | Date | |
---|---|---|---|
56a4833a49 | |||
5fcee515e2 | |||
1fa563be46 | |||
a233477b1e | |||
0fab7fe859 |
3 changed files with 13 additions and 7 deletions
|
@ -35,6 +35,7 @@ Additions
|
||||||
Improvements
|
Improvements
|
||||||
- Allow scrolling panels to contain other scrolling panels
|
- Allow scrolling panels to contain other scrolling panels
|
||||||
- Allow dropdowns to have scrolling panels
|
- Allow dropdowns to have scrolling panels
|
||||||
|
- Improved Panel performance when adding and removing a lot of children
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -245,13 +245,12 @@ namespace MLEM.Ui.Elements {
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void OnChildAreaDirty(Element child, bool grandchild) {
|
protected override void OnChildAreaDirty(Element child, bool grandchild) {
|
||||||
base.OnChildAreaDirty(child, grandchild);
|
base.OnChildAreaDirty(child, grandchild);
|
||||||
// we only need to scroll when a grandchild changes, since all of our children are forced
|
if (grandchild && !this.AreaDirty) {
|
||||||
// to be auto-anchored and so will automatically propagate their changes up to us
|
// we only need to scroll when a grandchild changes, since all of our children are forced
|
||||||
if (grandchild) {
|
// to be auto-anchored and so will automatically propagate their changes up to us
|
||||||
this.ScrollChildren();
|
this.ScrollChildren();
|
||||||
// we also need to re-setup here in case the child is involved in a special GetTotalCoveredArea
|
// we also need to re-setup here in case the child is involved in a special GetTotalCoveredArea
|
||||||
if (!this.AreaDirty)
|
this.ScrollSetup();
|
||||||
this.ScrollSetup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,16 +354,22 @@ 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;
|
||||||
|
|
||||||
|
var currentChildren = new HashSet<Element>();
|
||||||
|
// scroll all our children (and cache newly added ones)
|
||||||
// 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 a child was newly added later, the last scroll offset was never applied
|
||||||
if (this.scrolledChildren.Add(child))
|
if (this.scrolledChildren.Add(child))
|
||||||
child.ScrollOffset.Y -= this.lastScrollOffset;
|
child.ScrollOffset.Y -= this.lastScrollOffset;
|
||||||
child.ScrollOffset.Y += (this.lastScrollOffset - this.ScrollBar.CurrentValue);
|
child.ScrollOffset.Y += (this.lastScrollOffset - this.ScrollBar.CurrentValue);
|
||||||
|
currentChildren.Add(child);
|
||||||
}
|
}
|
||||||
|
// remove cached scrolled children that aren't our children anymore
|
||||||
|
this.scrolledChildren.IntersectWith(currentChildren);
|
||||||
|
|
||||||
this.lastScrollOffset = this.ScrollBar.CurrentValue;
|
this.lastScrollOffset = this.ScrollBar.CurrentValue;
|
||||||
this.relevantChildrenDirty = true;
|
this.relevantChildrenDirty = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ namespace MLEM.Ui.Elements {
|
||||||
private void SetTextDirty() {
|
private void SetTextDirty() {
|
||||||
this.tokenizedText = null;
|
this.tokenizedText = null;
|
||||||
// only set our area dirty if our size changed as a result of this action
|
// only set our area dirty if our size changed as a result of this action
|
||||||
if (!this.AreaDirty && !this.CalcActualSize(this.ParentArea).Equals(this.DisplayArea.Size, Element.Epsilon))
|
if (!this.AreaDirty && (this.System == null || !this.CalcActualSize(this.ParentArea).Equals(this.DisplayArea.Size, Element.Epsilon)))
|
||||||
this.SetAreaDirty();
|
this.SetAreaDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue