mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
Don't unnecessarily set areas dirty when removing a root element from the ui
This commit is contained in:
parent
0293ea435e
commit
0fab7fe859
4 changed files with 9 additions and 8 deletions
|
@ -35,6 +35,7 @@ Additions
|
||||||
Improvements
|
Improvements
|
||||||
- Allow scrolling panels to contain other scrolling panels
|
- Allow scrolling panels to contain other scrolling panels
|
||||||
- Allow dropdowns to have scrolling panels
|
- Allow dropdowns to have scrolling panels
|
||||||
|
- Don't unnecessarily set areas dirty when removing a root element from the ui
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
- Fixed panels updating their relevant children too much when the scroll bar is hidden
|
- Fixed panels updating their relevant children too much when the scroll bar is hidden
|
||||||
|
|
|
@ -588,10 +588,12 @@ 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 => e.AddedToUi(this.System, this.Root));
|
element.AndChildren(e => {
|
||||||
|
e.SetAreaDirty();
|
||||||
|
e.AddedToUi(this.System, this.Root);
|
||||||
|
});
|
||||||
this.OnChildAdded?.Invoke(this, element);
|
this.OnChildAdded?.Invoke(this, element);
|
||||||
this.SetSortedChildrenDirty();
|
this.SetSortedChildrenDirty();
|
||||||
element.SetAreaDirty();
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ namespace MLEM.Ui.Elements {
|
||||||
private void SetTextDirty() {
|
private void SetTextDirty() {
|
||||||
this.tokenizedText = null;
|
this.tokenizedText = null;
|
||||||
// only set our area dirty if our size changed as a result of this action
|
// only set our area dirty if our size changed as a result of this action
|
||||||
if (!this.AreaDirty && !this.CalcActualSize(this.ParentArea).Equals(this.DisplayArea.Size, Element.Epsilon))
|
if (!this.AreaDirty && (this.System == null || !this.CalcActualSize(this.ParentArea).Equals(this.DisplayArea.Size, Element.Epsilon)))
|
||||||
this.SetAreaDirty();
|
this.SetAreaDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -352,8 +352,8 @@ namespace MLEM.Ui {
|
||||||
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.SetAreaDirty();
|
||||||
|
e.AddedToUi(this, root);
|
||||||
});
|
});
|
||||||
this.OnRootAdded?.Invoke(root);
|
this.OnRootAdded?.Invoke(root);
|
||||||
root.InvokeOnAddedToUi(this);
|
root.InvokeOnAddedToUi(this);
|
||||||
|
@ -371,10 +371,8 @@ namespace MLEM.Ui {
|
||||||
return;
|
return;
|
||||||
this.rootElements.Remove(root);
|
this.rootElements.Remove(root);
|
||||||
this.Controls.SelectElement(root, null);
|
this.Controls.SelectElement(root, null);
|
||||||
root.Element.AndChildren(e => {
|
// we don't need to set dirty here since re-adding to a ui will cause dirty state anyway
|
||||||
e.RemovedFromUi();
|
root.Element.AndChildren(e => e.RemovedFromUi());
|
||||||
e.SetAreaDirty();
|
|
||||||
});
|
|
||||||
this.OnRootRemoved?.Invoke(root);
|
this.OnRootRemoved?.Invoke(root);
|
||||||
root.InvokeOnRemovedFromUi(this);
|
root.InvokeOnRemovedFromUi(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue