mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Added Element.OnAddedToUi and Element.OnRemovedFromUi
This commit is contained in:
parent
df2d102d8e
commit
55735b4c64
3 changed files with 15 additions and 2 deletions
|
@ -29,6 +29,7 @@ Fixes
|
|||
Additions
|
||||
- Added some extension methods for querying Anchor types
|
||||
- Added Element.AutoSizeAddedAbsolute to allow for more granular control of auto-sizing
|
||||
- Added Element.OnAddedToUi and Element.OnRemovedFromUi
|
||||
|
||||
Improvements
|
||||
- Allow elements to auto-adjust their size even when their children are aligned oddly
|
||||
|
|
|
@ -407,14 +407,22 @@ namespace MLEM.Ui.Elements {
|
|||
/// </summary>
|
||||
public GamepadNextElementCallback GetGamepadNextElement;
|
||||
/// <summary>
|
||||
/// Event that is called when a child is added to this element using <see cref="AddChild{T}"/>
|
||||
/// Event that is called when a child or any level of grandchild is added to this element using <see cref="AddChild{T}"/>
|
||||
/// </summary>
|
||||
public OtherElementCallback OnChildAdded;
|
||||
/// <summary>
|
||||
/// Event that is called when a child is removed from this element using <see cref="RemoveChild"/>
|
||||
/// Event that is called when a child or any level of grandchild is removed from this element using <see cref="RemoveChild"/>
|
||||
/// </summary>
|
||||
public OtherElementCallback OnChildRemoved;
|
||||
/// <summary>
|
||||
/// Event that is called when this element is added to a <see cref="UiSystem"/>, that is, when this element's <see cref="System"/> is set to a non-<see langword="null"/> value.
|
||||
/// </summary>
|
||||
public GenericCallback OnAddedToUi;
|
||||
/// <summary>
|
||||
/// Event that is called when this element is removed from a <see cref="UiSystem"/>, that is, when this element's <see cref="System"/> is set to <see langword="null"/>.
|
||||
/// </summary>
|
||||
public GenericCallback OnRemovedFromUi;
|
||||
/// <summary>
|
||||
/// Event that is called when this element's <see cref="Dispose"/> method is called, which also happens in <see cref="Finalize"/>.
|
||||
/// This event is useful for unregistering global event handlers when this object should be destroyed.
|
||||
/// </summary>
|
||||
|
@ -497,6 +505,7 @@ namespace MLEM.Ui.Elements {
|
|||
element.AndChildren(e => {
|
||||
e.Root = this.Root;
|
||||
e.System = this.System;
|
||||
e.OnAddedToUi?.Invoke(e);
|
||||
this.Root?.InvokeOnElementAdded(e);
|
||||
this.OnChildAdded?.Invoke(this, e);
|
||||
});
|
||||
|
@ -520,6 +529,7 @@ namespace MLEM.Ui.Elements {
|
|||
element.AndChildren(e => {
|
||||
e.Root = null;
|
||||
e.System = null;
|
||||
e.OnRemovedFromUi?.Invoke(e);
|
||||
this.Root?.InvokeOnElementRemoved(e);
|
||||
this.OnChildRemoved?.Invoke(this, e);
|
||||
});
|
||||
|
|
|
@ -347,6 +347,7 @@ namespace MLEM.Ui {
|
|||
root.Element.AndChildren(e => {
|
||||
e.Root = root;
|
||||
e.System = this;
|
||||
e.OnAddedToUi?.Invoke(e);
|
||||
root.InvokeOnElementAdded(e);
|
||||
e.SetAreaDirty();
|
||||
});
|
||||
|
@ -369,6 +370,7 @@ namespace MLEM.Ui {
|
|||
root.Element.AndChildren(e => {
|
||||
e.Root = null;
|
||||
e.System = null;
|
||||
e.OnRemovedFromUi?.Invoke(e);
|
||||
root.InvokeOnElementRemoved(e);
|
||||
e.SetAreaDirty();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue