Avalonia
Avalonia copied to clipboard
[DO NOT MERGE] Include Adorners in matrix calculations in VisualExtensions
What does the pull request do?
This PR changes VisualExtensions::TransformToVisual
to support adorners.
What is the current behavior?
Currently VisualExtensions::TransformToVisual
doesn't work correctly when one of the controls is inside an Adorner Layer. Adorned element is not on a path to root from adorner element. So it is not included in calculations. Adorners are rendered correctly, because the renderer has special handling for adorners. Hence TransformToVisual
needs some special handling too.
What is the updated/expected behavior with this PR?
VisualExtensions::TransformToVisual
should correctly take into account adorners.
How was the solution implemented (if it's not obvious)?
Unfortunately, adorners are defined in Avalonia.Controls
while VisualExtensions
is in Avalonia.Base
, so VisualExtensions
doesn't know what adorners are. Therefore, this PR adds AdornerLayerBase
with AdornedElementProperty
and an empty IAdornerLayer
to Avalonia.Base
so that this information is available. This is far from perfect, but I don't know how to do it in a cleaner way.
Besides, the obvious downside of the solution is additional computation complexity in VisualExtensions::TransformToVisual
. Each time this method is called, an adorned element needs to be found via calling GetValue(AdornedElementProperty) on each element on path to root.
Checklist
- [x] Added unit tests (if possible)?
- [ ] Added XML documentation to any related classes?
- [ ] Consider submitting a PR to https://github.com/AvaloniaUI/avalonia-docs with user documentation
Breaking changes
Obsoletions / Deprecations
Fixed issues
Fixes #15480
You can test this PR using the following package version. 11.2.999-cibuild0047604-alpha
. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]
As per @kekekeks, whole situation with "adorner transformation processed on composition thread" should be changed to be done on UI thread. So, I am not sure how we should process with this PR (and previous already merged).
I understand. However, until it is properly fixed, I would appreciate if this PR could remain open, as I use adorners a lot in my app (and it worked fine in Avalonia 0.10), thus for now I can use nightly builds produced by this PR.
You can test this PR using the following package version. 11.2.999-cibuild0047725-alpha
. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]
@BAndysc we can leave it open, but I'd like to mark it as draft and won't merged for now, just in case
You can test this PR using the following package version. 11.2.999-cibuild0048166-alpha
. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]
You can test this PR using the following package version. 11.1.3-cibuild0051668-beta
. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]
- [x] All contributors have signed the CLA.
Oh my, sorry for all the pings, I just needed to rebase this PR on top of 11.3, but it wouldn't build until I merged it with master, hence the mess, sorry again.
@cla-avalonia agree
@cla-avalonia agree
@cla-avalonia agree
Please rebuild your commit tree to only have your commits.
@emmauss Latest master has some problems which prevent me from using it (https://github.com/AvaloniaUI/Avalonia/issues/16754) that's why I rebased it on top of 11.1, but CI wouldn't build until all conflicts with master were solved (the PR destination branch is master and I can't change it). Sorry for the mess again. Maybe you could remove the bot comment so that people will not reply agree here?
@emmauss Latest master has some problems which prevent me from using it (#16754) that's why I rebased it on top of 11.1, but CI wouldn't build until all conflicts with master were solved (the PR destination branch is master and I can't change it). Sorry for the mess again. Maybe you could remove the bot comment so that people will not reply agree here?
Don't worry. It auto updates when a new commit is pushed. It has fixed itself.
You can test this PR using the following package version. 11.2.999-cibuild0051678-alpha
. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]