-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
UniformGrid: Round measured cell sizes when UseLayoutRounding is enabled #19959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Added layout rounding for child measurements in UniformGrid.
Removed comment about measuring children in UniformGrid.
|
You can test this PR using the following package version. |
|
|
@cla-avalonia agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. This absolutely needs an unit test.
| // used for children.Measure(...) which could change how children measure themselves. | ||
| if (UseLayoutRounding) | ||
| { | ||
| if (!double.IsInfinity(maxWidth) && !double.IsNaN(maxWidth)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use !MathUtilities.IsFinite() instead (I'm leaving this once, but this applies to the 4 added if conditions).
| { | ||
| if (!double.IsInfinity(maxWidth) && !double.IsNaN(maxWidth)) | ||
| { | ||
| maxWidth = Math.Round(maxWidth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right, we normally use LayoutHelper.RoundLayoutXxx methods with a scale to adjust for the current DPI.
| } | ||
| } | ||
|
|
||
| // If layout rounding is enabled, round the measured per-cell unit size (maxWidth/maxHeight). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the comment, I understand that it's now possible for the child control size not to match the grid, which would be unexpected (controls won't be uniform anymore).
Could you please provide a sample to compare the before and after behaviors?
Plus, a matching unit test is needed.
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
|
You can test this PR using the following package version. |
What does the pull request do?
When UseLayoutRounding is enabled, round the measured cell sizes in UniformGrid to avoid pixel-alignment issues.
Reference file:
What is the current behavior?
With UseLayoutRounding set to true, UniformGrid didn't apply layout rounding during the measure pass, causing pixel alignment artifacts and small layout offsets.
What is the updated/expected behavior with this PR?
Apply layout rounding to the calculated cell width/height during measurement when UseLayoutRounding is enabled so measurements match the final layout.
How to test:
How was the solution implemented (if it's not obvious)?
Implementation notes:
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues