1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-24 21:48:35 +01:00

Compare commits

..

2 commits

View file

@ -128,7 +128,7 @@ namespace MLEM.Ui.Elements {
public override void ForceUpdateSortedChildren() { public override void ForceUpdateSortedChildren() {
base.ForceUpdateSortedChildren(); base.ForceUpdateSortedChildren();
if (this.scrollOverflow) if (this.scrollOverflow)
this.relevantChildrenDirty = true; this.ForceUpdateRelevantChildren();
} }
/// <inheritdoc /> /// <inheritdoc />
@ -147,24 +147,8 @@ namespace MLEM.Ui.Elements {
protected override IList<Element> GetRelevantChildren() { protected override IList<Element> GetRelevantChildren() {
var relevant = base.GetRelevantChildren(); var relevant = base.GetRelevantChildren();
if (this.scrollOverflow) { if (this.scrollOverflow) {
if (this.relevantChildrenDirty) { if (this.relevantChildrenDirty)
this.relevantChildrenDirty = false; this.ForceUpdateRelevantChildren();
var visible = this.GetRenderTargetArea();
this.relevantChildren.Clear();
foreach (var child in this.SortedChildren) {
if (child.Area.Intersects(visible)) {
this.relevantChildren.Add(child);
} else {
foreach (var c in child.GetChildren(regardGrandchildren: true)) {
if (c.Area.Intersects(visible)) {
this.relevantChildren.Add(child);
break;
}
}
}
}
}
relevant = this.relevantChildren; relevant = this.relevantChildren;
} }
return relevant; return relevant;
@ -251,6 +235,7 @@ namespace MLEM.Ui.Elements {
if (this.renderTarget != null) if (this.renderTarget != null)
this.renderTarget.Dispose(); this.renderTarget.Dispose();
this.renderTarget = targetArea.IsEmpty ? null : new RenderTarget2D(this.System.Game.GraphicsDevice, targetArea.Width, targetArea.Height); this.renderTarget = targetArea.IsEmpty ? null : new RenderTarget2D(this.System.Game.GraphicsDevice, targetArea.Width, targetArea.Height);
this.relevantChildrenDirty = true;
} }
} }
@ -272,5 +257,23 @@ namespace MLEM.Ui.Elements {
this.ScrollBar.PositionOffset = new Vector2(-this.ScrollerSize.Value.X - 1, 0); this.ScrollBar.PositionOffset = new Vector2(-this.ScrollerSize.Value.X - 1, 0);
} }
private void ForceUpdateRelevantChildren() {
this.relevantChildrenDirty = false;
this.relevantChildren.Clear();
var visible = this.GetRenderTargetArea();
foreach (var child in this.SortedChildren) {
if (child.Area.Intersects(visible)) {
this.relevantChildren.Add(child);
} else {
foreach (var c in child.GetChildren(regardGrandchildren: true)) {
if (c.Area.Intersects(visible)) {
this.relevantChildren.Add(child);
break;
}
}
}
}
}
} }
} }