1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-16 22:28:46 +02:00

added events for when a root element is added or removed from a ui

This commit is contained in:
Ell 2021-06-08 21:36:42 +02:00
parent b0d146849d
commit 2cc77f42cd

View file

@ -268,6 +268,7 @@ namespace MLEM.Ui {
e.SetAreaDirty(); e.SetAreaDirty();
}); });
this.OnRootAdded?.Invoke(root); this.OnRootAdded?.Invoke(root);
root.OnAddedToUi?.Invoke(this);
this.SortRoots(); this.SortRoots();
return root; return root;
} }
@ -289,6 +290,7 @@ namespace MLEM.Ui {
e.SetAreaDirty(); e.SetAreaDirty();
}); });
this.OnRootRemoved?.Invoke(root); this.OnRootRemoved?.Invoke(root);
root.OnRemovedFromUi?.Invoke(this);
} }
/// <summary> /// <summary>
@ -417,9 +419,17 @@ namespace MLEM.Ui {
/// </summary> /// </summary>
public Element.GenericCallback OnElementAdded; public Element.GenericCallback OnElementAdded;
/// <summary> /// <summary>
/// Even that is invoked when a <see cref="Element"/> is removed rom this root element of any of its children. /// Event that is invoked when a <see cref="Element"/> is removed rom this root element of any of its children.
/// </summary> /// </summary>
public Element.GenericCallback OnElementRemoved; public Element.GenericCallback OnElementRemoved;
/// <summary>
/// Event that is invoked when this <see cref="RootElement"/> gets added to a <see cref="UiSystem"/> in <see cref="UiSystem.Add"/>
/// </summary>
public Action<UiSystem> OnAddedToUi;
/// <summary>
/// Event that is invoked when this <see cref="RootElement"/> gets removed from a <see cref="UiSystem"/> in <see cref="UiSystem.Remove"/>
/// </summary>
public Action<UiSystem> OnRemovedFromUi;
internal RootElement(string name, Element element, UiSystem system) { internal RootElement(string name, Element element, UiSystem system) {
this.Name = name; this.Name = name;