-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix alignment of number pad buttons #2240
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
Hi @leduyquang753, thank you for starting this PR. I've seen that the problem of misalignment buttons is being mitigated a lot in your source branch. However, there are still some cases can reproduce the issue. For example: Do you have any ideas to improve the fix? |
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.
suggest improving the fix since the bug can still be reproduced.
Thank you for the suggestion, @Will-J-Bailey. |
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.
LGTM as a temporary solution.
Thank you all for reporting the issue and working on the fix. Actually, the buttons appear to be aligned as expected on my device. I'm not sure if the discrepancy stems from operating system differences, but it appears more like a WinUI issue rather than a problem with the Calculator. This workaround looks pretty "complex" for simple UI like this. I'd suggest addressing this issue within WinUI rather than making changes to the Calculator. |
I have been very busy lately, but I did spend an amount of time looking further into this and unfortunately I had yet to find the deeper cause.
So indeed this is really something from WinUI's layout system itself, specifically the rounding to the nearest screen pixel part. At the current state of this fix, the misalignment seems to only manifest itself when Windows scaling is at non-multiples of 100% (so 125%; 150%;...). Therefore I think there are three paths we can take:
|
Your investigation and effort are really appreciated. Unfortunately, I still cannot repro it at both 125 and 150 scale. I'd prefer to report this to WinUI at first as the root cause is unclear and the mitigation is kind of heavy. @tian-lt What's your opinion? |
Fixes another instance of #127
Description of the changes
ExtraColumns
property toNumberPad
control.NumberPad
control instances in standard, scientific and programmer button panels.Additional information
The
NumberPad
control is placed as sort of a "subgrid" within the button panels' grids, on a subset of columns. This causes slight differences in how the column widths are computed in the outer button panel and in the number pad control (seeCGrid::DistributeStarSpace
) and makes the number pad buttons slightly misaligned with the surrounding buttons. Adding extra empty columns to the right of theNumberPad
so that it reaches the right side of the button panel fixes this inconsistency.How changes were validated
Manual testing.