Skip to content
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

Switch auto UI scale to use screen DPI #672

Merged
merged 7 commits into from
Apr 20, 2024

Conversation

Kiisu-Master
Copy link
Contributor

@Kiisu-Master Kiisu-Master commented Apr 19, 2024

  • This makes auto scaling use screen DPI.
  • Limits scale to a calculated max scale to avoid glitches when min size would be bigger than usable screen size.

This has to be tested on more devices. @aaronfranke
I only tested this on my phone and laptop, which both have low resolution screens. Different DPI though so it's tested a little bit and seems to work.

Previously it was making the default experience on phone even worse, because it made UI even smaller than it already was without automatic scale. I know phones arent really supported anyways, but I hope this fix also makes it better on desktop.

Edit: I did some testing on my laptop (1366x768, DPI 96). Previous implementation would make UI too small on it. New one seems to work well. Also tested with the AMD virtual resulution to set it to higher resolutions (FHD, DPI 120), and it still works well.

@Kiisu-Master Kiisu-Master marked this pull request as ready for review April 19, 2024 15:09
src/GlobalSettings.gd Outdated Show resolved Hide resolved
Comment on lines 289 to 298
if dpi < 72:
return 0.75
elif dpi <= 96:
return 1.0
elif dpi <=160:
return 1.25
elif dpi <= 240:
return 1.5
elif dpi <= 480:
return 1.75
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values are just a bit too low. DisplayServer.screen_get_dpi(screen) returns 163 on my system with 200% scaling, so I would expect 2.0 to be returned, but this code is returning 1.5.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I adjusted the values to be roughly dpi/96. That's the DPI of my laptop screen and 1.0 looks fine on it, so i used it as a base.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different perspectives I guess, I am using a high DPI desktop display.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your DPI will return 2.0 now.

I found that changing the scaling in Windows also changes the reported DPI. With that, it looks like scaling in GodSVG now roughly matches the OS scaling so it should be good now.

src/GlobalSettings.gd Outdated Show resolved Hide resolved
src/GlobalSettings.gd Outdated Show resolved Hide resolved
Co-authored-by: Aaron Franke <[email protected]>
@MewPurPur
Copy link
Owner

Thanks A TON!

@MewPurPur MewPurPur merged commit b7f580b into MewPurPur:main Apr 20, 2024
2 checks passed
@Kiisu-Master Kiisu-Master deleted the fix-auto-scale branch April 20, 2024 09:11
MewPurPur pushed a commit that referenced this pull request Jun 1, 2024
MewPurPur pushed a commit that referenced this pull request Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants