1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-06-25 06:10:03 +02:00

Made the Element.Children collection public

This commit is contained in:
Ell 2024-06-11 18:47:22 +02:00
parent fb3b586a35
commit 3a055129b5
5 changed files with 7 additions and 6 deletions

View file

@ -33,6 +33,7 @@ Improvements
- **Include the SpriteBatchContext in OnDrawn, OnElementDrawn and OnSelectedElementDrawn**
- Allow scrolling panels to set height based on children by setting TreatSizeAsMaximum
- Track element area update recursion count in UiMetrics
- Made the Element.Children collection public
Fixes
- Fixed hidden scroll bars inhibiting scrolling on their parent panel

View file

@ -60,7 +60,7 @@ namespace Demos {
this.activeDemo = null;
selection.IsHidden = false;
e.IsHidden = true;
selection.Root.SelectElement(selection.GetChildren().First(c => c.CanBeSelected));
selection.Root.SelectElement(selection.Children.First(c => c.CanBeSelected));
},
IsHidden = true
});

View file

@ -254,9 +254,9 @@ namespace Demos {
this.root.AddChild(new VerticalSpace(3));
this.root.AddChild(new Paragraph(Anchor.AutoLeft, 1, "The code for this demo contains some examples for how to query element data. This is the output of that:"));
var children = this.root.GetChildren();
var children = this.root.Children;
var totalChildren = this.root.GetChildren(regardGrandchildren: true);
this.root.AddChild(new Paragraph(Anchor.AutoLeft, 1, $"The root has <b>{children.Count()}</b> children, but there are <b>{totalChildren.Count()}</b> when regarding children's children"));
this.root.AddChild(new Paragraph(Anchor.AutoLeft, 1, $"The root has <b>{children.Count}</b> children, but there are <b>{totalChildren.Count()}</b> when regarding children's children"));
var textFields = this.root.GetChildren<TextField>();
this.root.AddChild(new Paragraph(Anchor.AutoLeft, 1, $"The root has <b>{textFields.Count()}</b> text fields"));
@ -270,7 +270,7 @@ namespace Demos {
this.root.AddChild(new Paragraph(Anchor.AutoLeft, 1, $"The root has <b>{autoWidthChildren.Count()}</b> auto-width children, <b>{autoWidthButtons.Count()}</b> of which are buttons"));
// select the first element for auto-navigation
this.root.Root.SelectElement(this.root.GetChildren().First(c => c.CanBeSelected));
this.root.Root.SelectElement(this.root.Children.First(c => c.CanBeSelected));
}
// This method is used by the wobbling button (see above)

View file

@ -143,7 +143,7 @@ namespace MLEM.Ui.Elements {
this.GetGamepadNextElement = (dir, usualNext) => {
// Force navigate down to our first child if we're open
if (this.IsOpen && dir == Direction2.Down)
return this.Panel.GetChildren().FirstOrDefault(c => c.CanBeSelected) ?? usualNext;
return this.Panel.Children.FirstOrDefault(c => c.CanBeSelected) ?? usualNext;
return usualNext;
};
}

View file

@ -497,7 +497,7 @@ namespace MLEM.Ui.Elements {
/// A list of all of this element's direct children.
/// Use <see cref="AddChild{T}"/> or <see cref="RemoveChild"/> to manipulate this list while calling all of the necessary callbacks.
/// </summary>
protected readonly IList<Element> Children;
public readonly IList<Element> Children;
/// <summary>
/// A list of all of the <see cref="UiAnimation"/> instances that are currently playing.
/// You can modify this collection through <see cref="PlayAnimation"/> and <see cref="StopAnimation"/>.