diff --git a/src/Avalonia.Visuals/Avalonia.Visuals.csproj b/src/Avalonia.Visuals/Avalonia.Visuals.csproj
index bc41f646d9..83c65c34a5 100644
--- a/src/Avalonia.Visuals/Avalonia.Visuals.csproj
+++ b/src/Avalonia.Visuals/Avalonia.Visuals.csproj
@@ -115,7 +115,7 @@
-
+
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs
index fa40eb04ed..ce7e6f9b1d 100644
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs
@@ -7,7 +7,7 @@ using Avalonia.Platform;
namespace Avalonia.Rendering.SceneGraph
{
- public class GeometryNode : IDrawNode
+ public class GeometryNode : IGeometryNode
{
public GeometryNode(Matrix transform, IBrush brush, Pen pen, IGeometryImpl geometry)
{
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/IDrawNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/IDrawNode.cs
deleted file mode 100644
index 0b4507bccb..0000000000
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/IDrawNode.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright (c) The Avalonia Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-using System;
-
-namespace Avalonia.Rendering.SceneGraph
-{
- public interface IDrawNode : ISceneNode
- {
- bool HitTest(Point p);
- }
-}
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/IGeometryNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/IGeometryNode.cs
new file mode 100644
index 0000000000..4a9daf0ec9
--- /dev/null
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/IGeometryNode.cs
@@ -0,0 +1,24 @@
+// Copyright (c) The Avalonia Project. All rights reserved.
+// Licensed under the MIT license. See licence.md file in the project root for full license information.
+
+using System;
+
+namespace Avalonia.Rendering.SceneGraph
+{
+ ///
+ /// Represents a node in the low-level scene graph that represents geometry.
+ ///
+ public interface IGeometryNode : ISceneNode
+ {
+ ///
+ /// Hit test the geometry in this node.
+ ///
+ /// The point in global coordinates.
+ /// True if the point hits the node's geometry; otherwise false.
+ ///
+ /// This method does not recurse to child s, if you want
+ /// to hit test children they must be hit tested manually.
+ ///
+ bool HitTest(Point p);
+ }
+}
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/ISceneNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/ISceneNode.cs
index f6586c1980..37fa5a9463 100644
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/ISceneNode.cs
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/ISceneNode.cs
@@ -6,8 +6,15 @@ using Avalonia.Media;
namespace Avalonia.Rendering.SceneGraph
{
+ ///
+ /// Represents a node in the low-level scene graph.
+ ///
public interface ISceneNode
{
+ ///
+ /// Renders the node to a drawing context.
+ ///
+ /// The drawing context.
void Render(IDrawingContextImpl context);
}
}
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs
index a402af100d..b52872d9c2 100644
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs
@@ -7,15 +7,54 @@ using Avalonia.VisualTree;
namespace Avalonia.Rendering.SceneGraph
{
+ ///
+ /// Represents a node in the low-level scene graph representing an .
+ ///
public interface IVisualNode : ISceneNode
{
+ ///
+ /// Gets the visual to which the node relates.
+ ///
IVisual Visual { get; }
+
+ ///
+ /// Gets the parent scene graph node.
+ ///
IVisualNode Parent { get; }
+
+ ///
+ /// Gets the transform for the node from global to control coordinates.
+ ///
Matrix Transform { get; }
+
+ ///
+ /// Gets the clip bounds for the node in global coordinates.
+ ///
+ ///
+ /// This clip does not take into account parent clips, to find the absolute clip bounds
+ /// it is necessary to traverse the tree.
+ ///
Rect ClipBounds { get; }
+
+ ///
+ /// Whether the node is clipped to .
+ ///
bool ClipToBounds { get; }
+
+ ///
+ /// Gets the child scene graph nodes.
+ ///
IReadOnlyList Children { get; }
+ ///
+ /// Hit test the geometry in this node.
+ ///
+ /// The point in global coordinates.
+ /// True if the point hits the node's geometry; otherwise false.
+ ///
+ /// This method does not recurse to child s, if you want
+ /// to hit test children they must be hit tested manually.
+ ///
bool HitTest(Point p);
}
}
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs
index 3d861279c3..557476636d 100644
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs
@@ -7,7 +7,7 @@ using Avalonia.Platform;
namespace Avalonia.Rendering.SceneGraph
{
- public class ImageNode : IDrawNode
+ public class ImageNode : IGeometryNode
{
public ImageNode(Matrix transform, IBitmapImpl source, double opacity, Rect sourceRect, Rect destRect)
{
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/LineNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/LineNode.cs
index 84f08b0efe..d49b75c370 100644
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/LineNode.cs
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/LineNode.cs
@@ -6,7 +6,7 @@ using Avalonia.Media;
namespace Avalonia.Rendering.SceneGraph
{
- public class LineNode : IDrawNode
+ public class LineNode : IGeometryNode
{
public LineNode(Matrix transform, Pen pen, Point p1, Point p2)
{
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs
index f059c1c2d6..4e8da4d461 100644
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs
@@ -6,7 +6,7 @@ using Avalonia.Media;
namespace Avalonia.Rendering.SceneGraph
{
- public class RectangleNode : IDrawNode
+ public class RectangleNode : IGeometryNode
{
public RectangleNode(Matrix transform, IBrush brush, Pen pen, Rect rect, float cornerRadius)
{
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs
index c7fae32769..fbe9bb7176 100644
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs
@@ -7,7 +7,7 @@ using Avalonia.Platform;
namespace Avalonia.Rendering.SceneGraph
{
- public class TextNode : IDrawNode
+ public class TextNode : IGeometryNode
{
public TextNode(Matrix transform, IBrush foreground, Point origin, IFormattedTextImpl text)
{
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs
index 1dbf30a7b9..9faaefa2aa 100644
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs
@@ -8,10 +8,20 @@ using Avalonia.VisualTree;
namespace Avalonia.Rendering.SceneGraph
{
+ ///
+ /// A node in the low-level scene graph representing an .
+ ///
public class VisualNode : IVisualNode
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The visual that this node represents.
+ /// The parent scene graph node, if any.
public VisualNode(IVisual visual, IVisualNode parent)
{
+ Contract.Requires(visual != null);
+
if (parent == null && visual.VisualParent != null)
{
throw new AvaloniaInternalException(
@@ -23,19 +33,53 @@ namespace Avalonia.Rendering.SceneGraph
Children = new List();
}
+ ///
public IVisual Visual { get; }
+
+ ///
public IVisualNode Parent { get; }
+
+ ///
public Matrix Transform { get; set; }
+
+ ///
public Rect ClipBounds { get; set; }
+
+ ///
public bool ClipToBounds { get; set; }
+
+ ///
public Geometry GeometryClip { get; set; }
+
+ ///
+ /// Gets or sets the opacity of the scnee graph node.
+ ///
public double Opacity { get; set; }
+
+ ///
+ /// Gets or sets the opacity mask for the scnee graph node.
+ ///
public IBrush OpacityMask { get; set; }
+
+ ///
+ /// Gets the child scene graph nodes.
+ ///
public List Children { get; }
+
+ ///
+ /// Gets a value indicating whether this node in the scene graph has already
+ /// been updated in the current update pass.
+ ///
public bool SubTreeUpdated { get; set; }
+ ///
IReadOnlyList IVisualNode.Children => Children;
+ ///
+ /// Makes a copy of the node
+ ///
+ /// The new parent node.
+ /// A cloned node.
public VisualNode Clone(IVisualNode parent)
{
return new VisualNode(Visual, parent)
@@ -49,13 +93,14 @@ namespace Avalonia.Rendering.SceneGraph
};
}
+ ///
public bool HitTest(Point p)
{
foreach (var child in Children)
{
- var drawNode = child as IDrawNode;
+ var geometry = child as IGeometryNode;
- if (drawNode?.HitTest(p) == true)
+ if (geometry?.HitTest(p) == true)
{
return true;
}