-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Scale the Cursor editor according to DPI #13830
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
Scale the Cursor editor according to DPI #13830
Conversation
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.
Pull Request Overview
This PR adds proper DPI scaling support to the Cursor editor in PropertyGrid to fix display issues on high DPI environments. The changes ensure the cursor editor renders correctly at different DPI scales by dynamically calculating dimensions instead of using hard-coded values.
- Replaces hard-coded height value with DPI-aware scaling
- Updates cursor rendering to use dynamically calculated width based on scaled icon size
- Adjusts text positioning to account for variable cursor width
src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.CursorUI.cs
Show resolved
Hide resolved
src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.CursorUI.cs
Show resolved
Hide resolved
src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.CursorUI.cs
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13830 +/- ##
===================================================
- Coverage 77.10728% 77.10643% -0.00085%
===================================================
Files 3273 3273
Lines 644882 644884 +2
Branches 47688 47689 +1
===================================================
- Hits 497251 497247 -4
- Misses 143958 143966 +8
+ Partials 3673 3671 -2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
looks good 👍
Hey @LeafShi1, Could you also take a look at the Anchor Editor, if it is related and maybe fixable in the same way? It also looks terrible in certain HighDPI scenarios. Thanks! |
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.
Looks good to me!
I submitted another PR #13853 for Anchor editor, please review it. |
<!-- Please read CONTRIBUTING.md before submitting a pull request --> Related #13830 ## Proposed changes - Update the `InitializeComponent` method to draw the Anchor Editor using the scaled size instead of hard-coding it. <!-- We are in TELL-MODE the following section must be completed --> ## Customer Impact - On High DPI environment, Anchor editor in propertyGrid can be scaled well ## Regression? - No ## Risk - Minimal <!-- end TELL-MODE --> ## Screenshots <!-- Remove this section if PR does not change UI --> ### Before In 300% DPI: <img width="1783" height="750" alt="image" src="https://github.com/user-attachments/assets/e7373f7c-db87-4b56-a370-b98e14da03aa" /> ### After In 300% DPI: <img width="1281" height="846" alt="image" src="https://github.com/user-attachments/assets/c5c7560a-fcf1-42ba-97a9-32ed69e01470" /> ## Test methodology <!-- How did you ensure quality? --> - Manually ## Test environment(s) <!-- Remove any that don't apply --> - .net 10.0.0-rc.1.25454.102 <!-- Mention language, UI scaling, or anything else that might be relevant --> ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/13853)
Fixes #9007
Proposed changes
OnDrawItem
method to draw the cursor using the scaled width instead of hard-coding it.Customer Impact
Regression?
Risk
Screenshots
Before
On High DPI environment, cursor editor in propertyGrid is not scaled well

After
On High DPI environment, cursor editor in propertyGrid can be scaled normally

Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow