mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-01 05:10:50 +01:00
Fixed AddedToUi and RemovedFromUi being called for freshly added or removed children whose parents are not in a ui system
This commit is contained in:
parent
50e864b94f
commit
41fb515f80
2 changed files with 7 additions and 4 deletions
|
@ -31,6 +31,7 @@ Additions
|
|||
Fixes
|
||||
- Fixed tooltips not being bounded correctly for viewports that don't start at the origin
|
||||
- Fixed a stack overflow exception when a panel's children have just enough height to cause a scroll bar to appear
|
||||
- Fixed AddedToUi and RemovedFromUi being called for freshly added or removed children whose parents are not in a ui system
|
||||
|
||||
### MLEM.Data
|
||||
Improvements
|
||||
|
|
|
@ -569,6 +569,7 @@ namespace MLEM.Ui.Elements {
|
|||
index = this.children.Count;
|
||||
this.children.Insert(index, element);
|
||||
element.Parent = this;
|
||||
if (this.System != null)
|
||||
element.AndChildren(e => e.AddedToUi(this.System, this.Root));
|
||||
this.OnChildAdded?.Invoke(this, element);
|
||||
this.SetSortedChildrenDirty();
|
||||
|
@ -588,6 +589,7 @@ namespace MLEM.Ui.Elements {
|
|||
// upwards to us if the element is auto-positioned
|
||||
element.SetAreaDirty();
|
||||
element.Parent = null;
|
||||
if (this.System != null)
|
||||
element.AndChildren(e => e.RemovedFromUi());
|
||||
this.OnChildRemoved?.Invoke(this, element);
|
||||
this.SetSortedChildrenDirty();
|
||||
|
@ -1256,7 +1258,7 @@ namespace MLEM.Ui.Elements {
|
|||
|
||||
/// <summary>
|
||||
/// Called when this element is added to a <see cref="UiSystem"/> and, optionally, a given <see cref="RootElement"/>.
|
||||
/// This method is called in <see cref="AddChild{T}"/> and <see cref="UiSystem.Add"/>.
|
||||
/// This method is called in <see cref="AddChild{T}"/> for a parent whose <see cref="System"/> is set, as well as <see cref="UiSystem.Add"/>.
|
||||
/// </summary>
|
||||
/// <param name="system">The ui system to add to.</param>
|
||||
/// <param name="root">The root element to add to.</param>
|
||||
|
@ -1269,7 +1271,7 @@ namespace MLEM.Ui.Elements {
|
|||
|
||||
/// <summary>
|
||||
/// Called when this element is removed from a <see cref="UiSystem"/> and <see cref="RootElement"/>.
|
||||
/// This method is called in <see cref="RemoveChild"/> and <see cref="UiSystem.Remove"/>.
|
||||
/// This method is called in <see cref="RemoveChild"/> for a parent whose <see cref="System"/> is set, as well as <see cref="UiSystem.Remove"/>.
|
||||
/// </summary>
|
||||
protected internal virtual void RemovedFromUi() {
|
||||
var root = this.Root;
|
||||
|
|
Loading…
Reference in a new issue