Refactor MeasureCore and fix measurement for using WindowDrawnDecorations with Styles#21572
Refactor MeasureCore and fix measurement for using WindowDrawnDecorations with Styles#21572Fachep wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR fixes a layout/measurement issue where styling (e.g., setting IsVisible=false via styles) was not applied early enough to influence measurement, particularly for drawn window decorations.
Changes:
- Added a unit test covering measurement of
WindowDrawnDecorationsContentwhen styling hides a control. - Adjusted
Layoutable.MeasureCoreto apply styling before checkingIsVisible, ensuring style-driven visibility changes are respected during measure.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/Avalonia.Controls.UnitTests/WindowTests.cs | Adds regression test ensuring styled visibility affects measurement of drawn decoration overlay content. |
| src/Avalonia.Base/Layout/Layoutable.cs | Applies styling earlier in measure so style changes (like visibility) take effect before measurement logic runs. |
|
You can test this PR using the following package version. |
|
|
@cla-avalonia agree |
d6bd477 to
be536ed
Compare
|
You can test this PR using the following package version. |
be536ed to
232d415
Compare
|
You can test this PR using the following package version. |
|
I have no idea about the failed integration test. It was the Windows test last time, after rebase to master it becomes the Mac test this time... |
232d415 to
7e7334f
Compare
|
You can test this PR using the following package version. |
|
@MrJul Can you review this pls? |
What does the pull request do?
This PR moves
ApplyStylingearlier inLayoutable.MeasureCore.What is the current behavior?
Layoutable.MeasureCorecurrently applies styling after checking visibility, even though styling may affect the control's visibility.Due to this, if a style in
Window.Stylessets theIsVisibleproperty of a control insideWindowDrawnDecorationsContenttofalse, the control is hidden but still reports its full size during the first measurement pass.What is the updated/expected behavior with this PR?
Layoutable.MeasureCorenow applies styling before performing visibility checks and measurement.Controls hidden via styles now correctly produce an empty desired size in the same scenario. A unit test has been added to verify this behavior.
Checklist
Fixed issues
Fixes #21570