mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
Compare commits
2 commits
3340a5024b
...
f35730ee7c
Author | SHA1 | Date | |
---|---|---|---|
f35730ee7c | |||
84bf3fa0a3 |
2 changed files with 15 additions and 4 deletions
|
@ -18,7 +18,9 @@ Jump to version:
|
||||||
|
|
||||||
## 7.1.2 (In Development)
|
## 7.1.2 (In Development)
|
||||||
|
|
||||||
No code changes
|
### MLEM.Ui
|
||||||
|
Additions
|
||||||
|
- Added Panel.IsVisible method to check if a child element is visible
|
||||||
|
|
||||||
## 7.1.1
|
## 7.1.1
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,16 @@ namespace MLEM.Ui.Elements {
|
||||||
this.ScrollBar.CurrentValue = this.ScrollBar.MaxValue;
|
this.ScrollBar.CurrentValue = this.ScrollBar.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns whether the given <paramref name="element"/> is currently visible within this panel if it scrolls overflow.
|
||||||
|
/// This method will return <see langword="true"/> on any elements whose <see cref="Element.Area"/> intersects this panel's render target area, regardless of whether it is a child or grandchild of this panel.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="element">The element to query for visibility.</param>
|
||||||
|
/// <returns>Whether the element is in this panel's visible area.</returns>
|
||||||
|
public bool IsVisible(Element element) {
|
||||||
|
return element.Area.Intersects(this.GetRenderTargetArea());
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void InitStyle(UiStyle style) {
|
protected override void InitStyle(UiStyle style) {
|
||||||
base.InitStyle(style);
|
base.InitStyle(style);
|
||||||
|
@ -369,13 +379,12 @@ namespace MLEM.Ui.Elements {
|
||||||
private void ForceUpdateRelevantChildren() {
|
private void ForceUpdateRelevantChildren() {
|
||||||
this.relevantChildrenDirty = false;
|
this.relevantChildrenDirty = false;
|
||||||
this.relevantChildren.Clear();
|
this.relevantChildren.Clear();
|
||||||
var visible = this.GetRenderTargetArea();
|
|
||||||
foreach (var child in this.SortedChildren) {
|
foreach (var child in this.SortedChildren) {
|
||||||
if (child.Area.Intersects(visible)) {
|
if (this.IsVisible(child)) {
|
||||||
this.relevantChildren.Add(child);
|
this.relevantChildren.Add(child);
|
||||||
} else {
|
} else {
|
||||||
foreach (var c in child.GetChildren(regardGrandchildren: true)) {
|
foreach (var c in child.GetChildren(regardGrandchildren: true)) {
|
||||||
if (c.Area.Intersects(visible)) {
|
if (this.IsVisible(c)) {
|
||||||
this.relevantChildren.Add(child);
|
this.relevantChildren.Add(child);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue