GUI: Allow scaling dialog and widget sizes in constructors #4840
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
GUIObject::resize()function has a flag indicating that the given values need to be scaled with the HiDPI scaling factor. The constructor however does not have this flag, and does not do the scaling. This causes:scummvm/engines/testbed/config.cpp
Lines 178 to 179 in 3c7b7b4
In this pull request a
scaleis added to constructors of the dialog, and many widgets. Using it means we no longer have to call resize() to get the correct size. Also this makes more explicit that by default the sizes may not be scaled.However the default value for this new flag is
false(while it istrueby default inresize()). The main reason for this is to avoid breaking all the existing code. Also in many cases the dimensions come from theThemeEngineand it provides already scaled values. So the flag is mostly useful when we hardcode some values, as is done in the testbed engine code.This pull request also fixes the size of some dialogs in testbed, and simplifies some code, to demonstrate the usefulness of the GUI changes.
A note on the implementation: for consistency I decided to add the flag just after the size parameters in all the constructors. Also it makes it easier in code that want to pass a flag to do it than if the flag had been added as the last argument, after several other arguments that have default values. And to avoid having to update a lot of existing code, I did not modify the existing constructors but added new ones instead. Fortunately the constructor delegation possible in C++11 limits the code duplication.