|
|
@ -174,12 +174,12 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sorts the <see cref="Children"/> collection according to the order of the visual's
|
|
|
/// Sorts the <see cref="Children"/> collection according to the order of the visual's
|
|
|
/// children and their z-index.
|
|
|
/// children and their z-index and removes controls that are no longer children.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="scene">The scene that the node is a part of.</param>
|
|
|
/// <param name="scene">The scene that the node is a part of.</param>
|
|
|
public void SortChildren(Scene scene) |
|
|
public void UpdateChildren(Scene scene) |
|
|
{ |
|
|
{ |
|
|
if (_children == null || _children.Count <= 1) |
|
|
if (_children == null || _children.Count == 0) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
@ -193,9 +193,12 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
keys.Add(((long)zIndex << 32) + i); |
|
|
keys.Add(((long)zIndex << 32) + i); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var toRemove = _children.ToList(); |
|
|
|
|
|
|
|
|
keys.Sort(); |
|
|
keys.Sort(); |
|
|
_children.Clear(); |
|
|
_children.Clear(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var i in keys) |
|
|
foreach (var i in keys) |
|
|
{ |
|
|
{ |
|
|
var child = Visual.VisualChildren[(int)(i & 0xffffffff)]; |
|
|
var child = Visual.VisualChildren[(int)(i & 0xffffffff)]; |
|
|
@ -204,8 +207,14 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
if (node != null) |
|
|
if (node != null) |
|
|
{ |
|
|
{ |
|
|
_children.Add(node); |
|
|
_children.Add(node); |
|
|
|
|
|
toRemove.Remove(node); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (var node in toRemove) |
|
|
|
|
|
{ |
|
|
|
|
|
scene.Remove(node); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
|