AvaPlot: Always render to new layer#4759
Merged
swharden merged 4 commits intoScottPlot:mainfrom Feb 15, 2025
Merged
Conversation
If the plot has transparency then this ensures it's blitted properly, rather than making us and the controls beneath us transparent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #4732, and in a more permanent way than just fixing the workaround that we used to have. That workaround is no longer necessary.
What I believe happened is our
Rendermethod was permitted to overwrite the SKCanvas of controls beneath us, Avalonia was not implicitly creating new canvases for different controls and blending them during compositing according to each control's depth. Instead, we need to do that ourselves.Testing
My starting point for all of these examples is the Avalonia Sandbox project in
src/ScottPlot5/ScottPlot5 Sandbox/Sandbox.Avalonia.DesktopI replaced
MainView.axaml.cswith this:And to ensure that the background is visible through the plot I replaced
MainWindow.axamlwith this, making the MainView component cyan:As expected, it gave this result:

To ensure I didn't break anything if users wanted a truly see-through window, I also tested this
MainWindow.axaml:Which gave the expected result:
