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
Implement GUI scaling for HighDPI displays and accessibility (SDL2 only) #1594
Implement GUI scaling for HighDPI displays and accessibility (SDL2 only) #1594
Conversation
6699a81
to
0d4805d
Compare
859468a
to
f8d792e
Compare
I've incorporated @Spikeone's feedback and added an option to decouple scaling the game world from scaling the GUI. On HighDPI setups, some scaling is applied regardless of the setting. I want to note that I very specifically chose the term "window zoom" (inspired by VSCode) over "GUI scale" because the game world was scaled as well (I wasn't eager to figure out how not to when I started and was far less familiar with the code base than I am now). Unlike in 3D games where scaling is limited to the GUI/HUD and scaling the game world makes no sense due to the perspective projection. Arguably, this setting could be removed, "Window Zoom" be renamed to "GUI Scale," and the game world scaled depending on DPI, as is the case with the setting turned off. |
37bb52d
to
e64943e
Compare
@falbrechtskirchinger Everything works as expected except: Few screenshots: |
@Xellzul Thank you! I'm away for a few days but should be able to fix those issues over the weekend. |
Both issues should be fixed. As expected, they required minimal changes, though the line drawing could be optimized by calculating the line width only once at a higher level – sacrificing a degree of abstraction – or by implementing
|
bb56931
to
81ad0be
Compare
81ad0be
to
3ac9503
Compare
I'm making an executive decision and going ahead with the change. "Window Zoom" becomes "GUI Scale" and the DPI scale always scales the game world view. I'm also moving from using |
3ac9503
to
c51ca5f
Compare
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.
Discovered a few minor things, but otherwise am quite happy with the state of this PR.
c51ca5f
to
3ac9503
Compare
3ac9503
to
e455968
Compare
I've started using C++17 features. CI is expected to fail accordingly. |
getDpiScale() returns the average ratio between the render size and the window size.
The game world is only scaled to compensate for DPI scale.
Even though the SDL2 video driver is using SDL_GetWindowSize() and SDL_GL_GetDrawableSize() to be DPI-aware, when creating a window, HighDPI support was never actually requested.
TakeSreenshot() uses the wrong size, resulting in cropped screenshots being taken.
The separate function has outlived its usefulness and has been folded into setGuiScalePercent().
Handle each change individually and without delegation.
@Flamefire The rebase is done. Once you approve the changes a force-push should happen automatically within about a minute. |
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!
2c6e58c
to
0a39833
Compare
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.
Thanks a lot for your effort!
I just used the newest nightly(e37a322) I change the GUI zoom to 200% and.... nothing happen. I Use 3840x2160 (16:9) Whats wrong? |
@Blackpearl1 Changing the GUI scale in the options screen should have an immediate effect.
The most likely scenario is that you're using the WinAPI backend. If you didn't get a warning message when leaving the options screen, I made some mistake in determining whether the selected GUI scale is supported. |
That was my fault. I changed it to SDL2 and now it works like a charm. Thank you :D nice job. The Message that it wont work with the win...whatever comes after changing to SDL2... |
This PR implements a global scaling of the window content in the SDL2 driver (a stub has been added to the the WinAPI driver).
The window zoom can be adjusted in the options screen by selecting the desired zoom level from a combo box or by holding down Control and scrolling.
The zoom behavior in the menu screens is a little janky due to how the controls are sized.
I've not investigated this any further.After looking at #1579 again, I suspect this is related toRescaleWindowProp
/ScaleWindowPropUp
. Maybe there's something to be done?I don't own a HighDPI display myself and have only tested it on setups where
windowSize == renderSize
. Some optional improvements are under consideration for this PR and are listed in the to-do list below.Fixes #533
Closes #1579
To-do:
windowZoom
when a HighDPI setup is detected instead of always defaulting to 100%.Maybe add a(An unnecessary micro-optimization.)windowZoom
parameter toCreateScreen()
to avoid unnecessary calls at the start of the game.PointF
using alias into a separate PR. There're a few other places that could be updated but are functionally unrelated to this PR. (Done: Add using alias PointF = Point<float> and refactor #1597)iround()
and round PointF->PointInt by default #1599)Investigate(Current behavior seems fine.)RescaleWindowProp
/ScaleWindowPropUp
.(G)UI scale
andZoom Game World
be removed and always disabled?Submit separate PR.CI: Update Boost versions #1596)