-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added fixes for Margin, Padding and Thickness properties with UseLayo… #7867
Conversation
…utRounding = true.
You can test this PR using the following package version. |
You can test this PR using the following package version. |
@AndrejBunjac this looks great! I wonder if we can have any tests to check this on CI? |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
…resenter and implemented minor review fixes.
…c/Avalonia into ResolutionScalingFix
Also to reply to a comment from @jmacato. I would most likely want to add a ScreenShot test but I would need a way to be able to force the scaling to certain values for the test to make sense. I don't think that other type of test would make sense as this is a very visual issue visible only on a scaling different from 1. Maybe I can do something with the TestRoot but I have to think about it. |
And moved fields to live with other field.
Agreed, and the problem with render tests is that they either have to be pixel perfect, or have to do a fuzzy match. The pixel perfect checks can fail on different machines, and the fuzzy tests aren't going to pick up such issues, so I'm fine with leaving this without render tests. |
@AndrejBunjac hope you don't mind - I updated and fixed a merge error and made a small change too (moved some fields to the top of the class in Border). |
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 looks great! I've confirmed the problem on master and this seems to fix it well, and all the code looks good to me.
Great! Looking forward to seeing the changes in action! |
You can test this PR using the following package version. |
Probably for the release after next, 0.10.15 - I wanted to leave some time to get some testing, and indeed we've found an issue as reported above ;) |
Hmmmm, I will also try to figure it out in parallel with you guys as soon as I catch a breather from my regular work. |
If I had to bet on something - I think the size of the popup might not be updated correctly with these changes. I'll look into it. |
Thanks @AndrejBunjac - I've opened an issue with my initial findings here #8092 |
Added fixes to resolve issues I raised in the issue #7798.
Even though Avalonia supports UseLayoutRounding - the pixel perfect positions were incorrectly calculated when scaling was present with objects that use Margins, Padding and Borders.
Margin was previously included in the calculation but the rounding was done after doing "availableSize = size - margin" and since rounding function is not linear the relation F(a) + F(b) == F(a + b) does not hold. That means that margin rounding to pixel perfect positions sometimes resulted in one pixel offset (visible in sample images).
The same treatment was never given to Padding and BorderThickness so I included those.
The goal of this fix is to support this layout rounding for all current and future users and I'm willing to make further fixes if needed.
List of Changes:
Layoutable.ArrangeCore - added separate rounding for Margin before any calculation.
LayoutHelper - added RoundLayoutThickness method
LayoutHelper.ArrangeChild - included a calculation of the rounding for padding and thickness if the parent uses LayoutRounding.
Border and ContentPresenter - added LayoutThickness private property that's passed to the renderer instead of BorderThickness. The LayoutThickness is calculated once and then cached. It makes sure that thickness will always be pixel perfect with UseLayoutRounding rather than having blurry edges in higher scales (to avoid borders looking blurry in 4k for example).