Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Svg.Editor.Avalonia.Forms/Svg.Editor.Avalon.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Version>3.2.0-optiq07</Version>
<Version>3.2.0-optiq08</Version>
<PackageReleaseNotes>
#3.2.0-optiq08
circle/ellipse should only select on their outline, not their bounding box
#3.2.0-optiq07
Tapping a point now only selects the top-most
#3.2.0-optiq06
Expand Down
4 changes: 3 additions & 1 deletion Svg.Editor.Avalonia.Views/Svg.Editor.Avalon.Views.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Version>3.2.0-optiq07</Version>
<Version>3.2.0-optiq08</Version>
<PackageReleaseNotes>
#3.2.0-optiq08
circle/ellipse should only select on their outline, not their bounding box
#3.2.0-optiq07
Tapping a point now only selects the top-most
#3.2.0-optiq06
Expand Down
73 changes: 73 additions & 0 deletions Svg.Editor.Core.Tests/SelectionToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,79 @@ public async Task ElementsAreSelected_AndDeleteCommandExecuted_ElementsAreRemove
Assert.AreEqual(0, Canvas.SelectedElements.Count);
}

[Test]
public async Task EllipseWithoutFillIsTappedInCenter_ShouldNotSelect()
{
// Arrange
await Canvas.EnsureInitialized();
var tool = Canvas.Tools.OfType<SelectionTool>().Single();
Canvas.ActiveTool = tool;
Canvas.ScreenWidth = 800;
Canvas.ScreenHeight = 500;

// this mirrors EllipseTool.CreateShape exactly
var ellipse = new SvgEllipse
{
Stroke = new SvgColourServer(Color.Create(0, 0, 0)),
Fill = SvgPaintServer.None,
StrokeWidth = new SvgUnit(SvgUnitType.Pixel, 5),
CenterX = new SvgUnit(SvgUnitType.Pixel, 400),
CenterY = new SvgUnit(SvgUnitType.Pixel, 250),
RadiusX = new SvgUnit(SvgUnitType.Pixel, 100),
RadiusY = new SvgUnit(SvgUnitType.Pixel, 60)
};
Canvas.Document.Children.Add(ellipse);

// Preassert
Assert.True(Canvas.Document.Children.Any(x => x == ellipse));

// Act
var pt1 = PointF.Create(400, 250);
await Canvas.OnEvent(new PointerEvent(EventType.PointerDown, pt1, pt1, pt1, 1));
await Canvas.OnEvent(new PointerEvent(EventType.PointerUp, pt1, pt1, pt1, 1));
((TestScheduler)SchedulerProvider.BackgroundScheduler).AdvanceBy(TimeSpan.FromSeconds(1).Ticks);

// Assert
Assert.AreEqual(0, Canvas.SelectedElements.Count);
}

[Test]
public async Task EllipseWithoutFillIsTappedOnBorder_ShouldSelect()
{
// Arrange
await Canvas.EnsureInitialized();
var tool = Canvas.Tools.OfType<SelectionTool>().Single();
Canvas.ActiveTool = tool;
Canvas.ScreenWidth = 800;
Canvas.ScreenHeight = 500;

// this mirrors EllipseTool.CreateShape exactly
var ellipse = new SvgEllipse
{
Stroke = new SvgColourServer(Color.Create(0, 0, 0)),
Fill = SvgPaintServer.None,
StrokeWidth = new SvgUnit(SvgUnitType.Pixel, 5),
CenterX = new SvgUnit(SvgUnitType.Pixel, 400),
CenterY = new SvgUnit(SvgUnitType.Pixel, 250),
RadiusX = new SvgUnit(SvgUnitType.Pixel, 100),
RadiusY = new SvgUnit(SvgUnitType.Pixel, 60)
};
Canvas.Document.Children.Add(ellipse);

// Preassert
Assert.True(Canvas.Document.Children.Any(x => x == ellipse));

// Act - tap on the top border of the ellipse (cy - ry)
var pt1 = PointF.Create(400, 190);
await Canvas.OnEvent(new PointerEvent(EventType.PointerDown, pt1, pt1, pt1, 1));
await Canvas.OnEvent(new PointerEvent(EventType.PointerUp, pt1, pt1, pt1, 1));
((TestScheduler)SchedulerProvider.BackgroundScheduler).AdvanceBy(TimeSpan.FromSeconds(1).Ticks);

// Assert
Assert.AreEqual(1, Canvas.SelectedElements.Count);
Assert.AreSame(ellipse, Canvas.SelectedElements.Single());
}

[Test]
public async Task PolygonIsSelectedInside_ShouldNotSelect()
{
Expand Down
4 changes: 3 additions & 1 deletion Svg.Editor.Core/Svg.Editor.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
<AssemblyName>Svg.Editor</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetFramework>net10.0</TargetFramework>
<Version>3.2.0-optiq07</Version>
<Version>3.2.0-optiq08</Version>
<LangVersion>latest</LangVersion>
<PackageReleaseNotes>
#3.2.0-optiq08
circle/ellipse should only select on their outline, not their bounding box
#3.2.0-optiq07
Tapping a point now only selects the top-most
#3.2.0-optiq06
Expand Down
Loading
Loading