Browse Source

Docs and tweaking.

scenegraph-after-breakage
Steven Kirk 10 years ago
parent
commit
cef5ffed90
  1. 2
      src/Avalonia.Visuals/Avalonia.Visuals.csproj
  2. 2
      src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs
  3. 12
      src/Avalonia.Visuals/Rendering/SceneGraph/IDrawNode.cs
  4. 24
      src/Avalonia.Visuals/Rendering/SceneGraph/IGeometryNode.cs
  5. 7
      src/Avalonia.Visuals/Rendering/SceneGraph/ISceneNode.cs
  6. 39
      src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs
  7. 2
      src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs
  8. 2
      src/Avalonia.Visuals/Rendering/SceneGraph/LineNode.cs
  9. 2
      src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs
  10. 2
      src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs
  11. 49
      src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs

2
src/Avalonia.Visuals/Avalonia.Visuals.csproj

@ -115,7 +115,7 @@
<Compile Include="Rendering\DefaultRenderLoop.cs" />
<Compile Include="Rendering\SceneGraph\DeferredDrawingContextImpl.cs" />
<Compile Include="Rendering\SceneGraph\GeometryNode.cs" />
<Compile Include="Rendering\SceneGraph\IDrawNode.cs" />
<Compile Include="Rendering\SceneGraph\IGeometryNode.cs" />
<Compile Include="Rendering\SceneGraph\ImageNode.cs" />
<Compile Include="Rendering\SceneGraph\ISceneNode.cs" />
<Compile Include="Rendering\SceneGraph\IVisualNode.cs" />

2
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)
{

12
src/Avalonia.Visuals/Rendering/SceneGraph/IDrawNode.cs

@ -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);
}
}

24
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
{
/// <summary>
/// Represents a node in the low-level scene graph that represents geometry.
/// </summary>
public interface IGeometryNode : ISceneNode
{
/// <summary>
/// Hit test the geometry in this node.
/// </summary>
/// <param name="p">The point in global coordinates.</param>
/// <returns>True if the point hits the node's geometry; otherwise false.</returns>
/// <remarks>
/// This method does not recurse to child <see cref="IVisualNode"/>s, if you want
/// to hit test children they must be hit tested manually.
/// </remarks>
bool HitTest(Point p);
}
}

7
src/Avalonia.Visuals/Rendering/SceneGraph/ISceneNode.cs

@ -6,8 +6,15 @@ using Avalonia.Media;
namespace Avalonia.Rendering.SceneGraph
{
/// <summary>
/// Represents a node in the low-level scene graph.
/// </summary>
public interface ISceneNode
{
/// <summary>
/// Renders the node to a drawing context.
/// </summary>
/// <param name="context">The drawing context.</param>
void Render(IDrawingContextImpl context);
}
}

39
src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs

@ -7,15 +7,54 @@ using Avalonia.VisualTree;
namespace Avalonia.Rendering.SceneGraph
{
/// <summary>
/// Represents a node in the low-level scene graph representing an <see cref="IVisual"/>.
/// </summary>
public interface IVisualNode : ISceneNode
{
/// <summary>
/// Gets the visual to which the node relates.
/// </summary>
IVisual Visual { get; }
/// <summary>
/// Gets the parent scene graph node.
/// </summary>
IVisualNode Parent { get; }
/// <summary>
/// Gets the transform for the node from global to control coordinates.
/// </summary>
Matrix Transform { get; }
/// <summary>
/// Gets the clip bounds for the node in global coordinates.
/// </summary>
/// <remarks>
/// This clip does not take into account parent clips, to find the absolute clip bounds
/// it is necessary to traverse the tree.
/// </remarks>
Rect ClipBounds { get; }
/// <summary>
/// Whether the node is clipped to <see cref="ClipBounds"/>.
/// </summary>
bool ClipToBounds { get; }
/// <summary>
/// Gets the child scene graph nodes.
/// </summary>
IReadOnlyList<ISceneNode> Children { get; }
/// <summary>
/// Hit test the geometry in this node.
/// </summary>
/// <param name="p">The point in global coordinates.</param>
/// <returns>True if the point hits the node's geometry; otherwise false.</returns>
/// <remarks>
/// This method does not recurse to child <see cref="IVisualNode"/>s, if you want
/// to hit test children they must be hit tested manually.
/// </remarks>
bool HitTest(Point p);
}
}

2
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)
{

2
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)
{

2
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)
{

2
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)
{

49
src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs

@ -8,10 +8,20 @@ using Avalonia.VisualTree;
namespace Avalonia.Rendering.SceneGraph
{
/// <summary>
/// A node in the low-level scene graph representing an <see cref="IVisual"/>.
/// </summary>
public class VisualNode : IVisualNode
{
/// <summary>
/// Initializes a new instance of the <see cref="VisualNode"/> class.
/// </summary>
/// <param name="visual">The visual that this node represents.</param>
/// <param name="parent">The parent scene graph node, if any.</param>
public VisualNode(IVisual visual, IVisualNode parent)
{
Contract.Requires<ArgumentNullException>(visual != null);
if (parent == null && visual.VisualParent != null)
{
throw new AvaloniaInternalException(
@ -23,19 +33,53 @@ namespace Avalonia.Rendering.SceneGraph
Children = new List<ISceneNode>();
}
/// <inheritdoc/>
public IVisual Visual { get; }
/// <inheritdoc/>
public IVisualNode Parent { get; }
/// <inheritdoc/>
public Matrix Transform { get; set; }
/// <inheritdoc/>
public Rect ClipBounds { get; set; }
/// <inheritdoc/>
public bool ClipToBounds { get; set; }
/// <inheritdoc/>
public Geometry GeometryClip { get; set; }
/// <summary>
/// Gets or sets the opacity of the scnee graph node.
/// </summary>
public double Opacity { get; set; }
/// <summary>
/// Gets or sets the opacity mask for the scnee graph node.
/// </summary>
public IBrush OpacityMask { get; set; }
/// <summary>
/// Gets the child scene graph nodes.
/// </summary>
public List<ISceneNode> Children { get; }
/// <summary>
/// Gets a value indicating whether this node in the scene graph has already
/// been updated in the current update pass.
/// </summary>
public bool SubTreeUpdated { get; set; }
/// <inheritdoc/>
IReadOnlyList<ISceneNode> IVisualNode.Children => Children;
/// <summary>
/// Makes a copy of the node
/// </summary>
/// <param name="parent">The new parent node.</param>
/// <returns>A cloned node.</returns>
public VisualNode Clone(IVisualNode parent)
{
return new VisualNode(Visual, parent)
@ -49,13 +93,14 @@ namespace Avalonia.Rendering.SceneGraph
};
}
/// <inheritdoc/>
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;
}

Loading…
Cancel
Save