Skip to content

Implement basic hit testing#311

Merged
wieslawsoltes merged 64 commits intomasterfrom
codex/add-hit-testing-api-for-drawables
Jul 14, 2025
Merged

Implement basic hit testing#311
wieslawsoltes merged 64 commits intomasterfrom
codex/add-hit-testing-api-for-drawables

Conversation

@wieslawsoltes
Copy link
Copy Markdown
Owner

Summary

  • enable bounding rectangle display and pointer hit tests in sample app
  • expose hit test rendering through control draw operations
  • add simple hit testing unit tests and test resource

Testing

  • dotnet build tests/Svg.Skia.UnitTests/Svg.Skia.UnitTests.csproj -c Release (fails: missing svg11.dtd resource)

https://chatgpt.com/codex/tasks/task_e_6873bc6f21848321bddcd4d6464484ae

@wieslawsoltes wieslawsoltes requested a review from Copilot July 14, 2025 08:29

This comment was marked as outdated.

@wieslawsoltes wieslawsoltes requested a review from Copilot July 14, 2025 10:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds basic SVG hit testing support and integrates it into the sample app’s UI, along with unit tests.

  • Expose HitTestElements and HitTestDrawables on SKSvg and implement their logic via a new HitTestService
  • Hook into the Avalonia control’s draw pipeline to optionally render hit‐test bounds
  • Add unit tests covering point hit testing and rectangle intersection

Reviewed Changes

Copilot reviewed 55 out of 62 changed files in this pull request and generated 2 comments.

File Description
src/Svg.Skia/SKSvg.HitTest.cs Implemented hit testing methods on SKSvg
src/Svg.Model/Services/HitTestService.cs New HitTestService for point/rect hit logic
tests/Svg.Skia.UnitTests/HitTestTests.cs Added unit tests for element hit testing
src/Svg.Controls.Skia.Avalonia/SvgSourceCustomDrawOperation.cs Updated draw op to call SKSvg.Draw and raise events
Comments suppressed due to low confidence (2)

tests/Svg.Skia.UnitTests/HitTestTests.cs:27

  • Tests currently cover point hit tests but there are no tests for rectangle-based hit tests. Consider adding a unit test for HitTestElements(SKRect) or HitTestDrawables(SKRect) to ensure that bounding‐box queries also work.
    public void HitTest_Point_OuterOnly()

samples/TestApp/Views/MainView.axaml.cs:37

  • [nitpick] If two different SKSvg instances are swapped rapidly, the old event handler may not be unsubscribed correctly. It might be safer to always check and unsubscribe from any existing instance before assigning the new one.
    private void SubscribeOnDraw()

Comment thread tests/Svg.Skia.UnitTests/HitTestTests.cs
Comment thread src/Svg.Skia/SKSvg.HitTest.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants