Browse Source

Merge branch 'master' into datagrid-integration

pull/2109/head
Jumar Macato 7 years ago
committed by GitHub
parent
commit
ebd6bdd0c4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs
  2. 25
      tests/Avalonia.Visuals.UnitTests/Rendering/SceneGraph/TextNodeTests.cs

2
src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs

@ -27,7 +27,7 @@ namespace Avalonia.Rendering.SceneGraph
Point origin,
IFormattedTextImpl text,
IDictionary<IVisual, Scene> childScenes = null)
: base(text.Bounds, transform, null)
: base(text.Bounds.Translate(origin), transform, null)
{
Transform = transform;
Foreground = foreground?.ToImmutable();

25
tests/Avalonia.Visuals.UnitTests/Rendering/SceneGraph/TextNodeTests.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
using Avalonia.Platform;
using Avalonia.Rendering.SceneGraph;
using Moq;
using Xunit;
namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph
{
public class TextNodeTests
{
[Fact]
public void Bounds_Should_Be_Offset_By_Origin()
{
var target = new TextNode(
Matrix.Identity,
null,
new Point(10, 10),
Mock.Of<IFormattedTextImpl>(x => x.Bounds == new Rect(5, 5, 50, 50)));
Assert.Equal(new Rect(15, 15, 50, 50), target.Bounds);
}
}
}
Loading…
Cancel
Save