1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-25 22:18:34 +01:00

don't notify when moving to back or front

This commit is contained in:
Ellpeck 2019-12-07 18:41:58 +01:00
parent d3dc40600e
commit 7118e323b3

View file

@ -125,15 +125,17 @@ namespace MLEM.Ui {
public RootElement Add(string name, Element element) { public RootElement Add(string name, Element element) {
var root = new RootElement(name, element, this); var root = new RootElement(name, element, this);
return !this.Add(root) ? null : root; return !this.Add(root, true) ? null : root;
} }
internal bool Add(RootElement root, int index = -1) { internal bool Add(RootElement root, bool notify, int index = -1) {
if (this.IndexOf(root.Name) >= 0) if (this.IndexOf(root.Name) >= 0)
return false; return false;
if (index < 0 || index > this.rootElements.Count) if (index < 0 || index > this.rootElements.Count)
index = this.rootElements.Count; index = this.rootElements.Count;
this.rootElements.Insert(index, root); this.rootElements.Insert(index, root);
if (!notify)
return true;
root.Element.AndChildren(e => { root.Element.AndChildren(e => {
e.Root = root; e.Root = root;
e.System = this; e.System = this;
@ -144,10 +146,16 @@ namespace MLEM.Ui {
} }
public void Remove(string name) { public void Remove(string name) {
this.Remove(name, true);
}
internal void Remove(string name, bool notify) {
var root = this.Get(name); var root = this.Get(name);
if (root == null) if (root == null)
return; return;
this.rootElements.Remove(root); this.rootElements.Remove(root);
if (!notify)
return;
root.SelectElement(null); root.SelectElement(null);
root.Element.AndChildren(e => { root.Element.AndChildren(e => {
e.Root = null; e.Root = null;
@ -222,13 +230,13 @@ namespace MLEM.Ui {
} }
public void MoveToFront() { public void MoveToFront() {
this.System.Remove(this.Name); this.System.Remove(this.Name, false);
this.System.Add(this); this.System.Add(this, false);
} }
public void MoveToBack() { public void MoveToBack() {
this.System.Remove(this.Name); this.System.Remove(this.Name, false);
this.System.Add(this, 0); this.System.Add(this, false, 0);
} }
} }