Browse Source

Expose IVisual.VisualRoot.

pull/472/head
Steven Kirk 10 years ago
parent
commit
e7556fbf39
  1. 17
      src/Perspex.SceneGraph/Visual.cs
  2. 6
      src/Perspex.SceneGraph/VisualTree/IVisual.cs
  3. 10
      src/Perspex.SceneGraph/VisualTree/VisualExtensions.cs

17
src/Perspex.SceneGraph/Visual.cs

@ -77,19 +77,8 @@ namespace Perspex
public static readonly StyledProperty<int> ZIndexProperty =
PerspexProperty.Register<Visual, int>(nameof(ZIndex));
/// <summary>
/// The visual's bounds relative to its parent.
/// </summary>
private Rect _bounds;
/// <summary>
/// Holds the parent of the visual.
/// </summary>
private IVisual _visualParent;
/// <summary>
/// The logger for visual-level events.
/// </summary>
private readonly ILogger _visualLogger;
/// <summary>
@ -239,6 +228,11 @@ namespace Perspex
/// </summary>
IVisual IVisual.VisualParent => _visualParent;
/// <summary>
/// Gets the root of the visual tree, if the control is attached to a visual tree.
/// </summary>
IRenderRoot IVisual.VisualRoot { get; }
/// <summary>
/// Invalidates the visual and queues a repaint.
/// </summary>
@ -483,7 +477,6 @@ namespace Perspex
_visualLogger.Verbose("Attached to visual tree");
VisualRoot = e.Root;
OnAttachedToVisualTree(e);
if (VisualChildren != null)

6
src/Perspex.SceneGraph/VisualTree/IVisual.cs

@ -4,6 +4,7 @@
using System;
using Perspex.Collections;
using Perspex.Media;
using Perspex.Rendering;
namespace Perspex.VisualTree
{
@ -80,6 +81,11 @@ namespace Perspex.VisualTree
/// </summary>
IVisual VisualParent { get; }
/// <summary>
/// Gets the root of the visual tree, if the control is attached to a visual tree.
/// </summary>
IRenderRoot VisualRoot { get; }
/// <summary>
/// Gets or sets the Z index of the node.
/// </summary>

10
src/Perspex.SceneGraph/VisualTree/VisualExtensions.cs

@ -176,15 +176,7 @@ namespace Perspex.VisualTree
{
Contract.Requires<ArgumentNullException>(visual != null);
var parent = visual.VisualParent;
while (parent != null)
{
visual = parent;
parent = visual.VisualParent;
}
return visual;
return visual.VisualRoot as IVisual;
}
/// <summary>

Loading…
Cancel
Save