1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 04:53:29 +01:00

cleaned up element ui addition order (0fab7fe)

This commit is contained in:
Ell 2023-11-11 12:15:21 +01:00
parent 0fab7fe859
commit a233477b1e
2 changed files with 3 additions and 8 deletions

View file

@ -588,10 +588,7 @@ namespace MLEM.Ui.Elements {
index = this.children.Count; index = this.children.Count;
this.children.Insert(index, element); this.children.Insert(index, element);
element.Parent = this; element.Parent = this;
element.AndChildren(e => { element.AndChildren(e => e.AddedToUi(this.System, this.Root));
e.SetAreaDirty();
e.AddedToUi(this.System, this.Root);
});
this.OnChildAdded?.Invoke(this, element); this.OnChildAdded?.Invoke(this, element);
this.SetSortedChildrenDirty(); this.SetSortedChildrenDirty();
return element; return element;
@ -1344,6 +1341,7 @@ namespace MLEM.Ui.Elements {
protected internal virtual void AddedToUi(UiSystem system, RootElement root) { protected internal virtual void AddedToUi(UiSystem system, RootElement root) {
this.Root = root; this.Root = root;
this.System = system; this.System = system;
this.SetAreaDirty();
this.OnAddedToUi?.Invoke(this); this.OnAddedToUi?.Invoke(this);
root?.InvokeOnElementAdded(this); root?.InvokeOnElementAdded(this);
} }

View file

@ -351,10 +351,7 @@ namespace MLEM.Ui {
return null; return null;
var root = new RootElement(name, element, this); var root = new RootElement(name, element, this);
this.rootElements.Add(root); this.rootElements.Add(root);
root.Element.AndChildren(e => { root.Element.AndChildren(e => e.AddedToUi(this, root));
e.SetAreaDirty();
e.AddedToUi(this, root);
});
this.OnRootAdded?.Invoke(root); this.OnRootAdded?.Invoke(root);
root.InvokeOnAddedToUi(this); root.InvokeOnAddedToUi(this);
this.SortRoots(); this.SortRoots();