Feature: Automatic UI and font zoom levels when supported by the OS.

This commit is contained in:
Michael Lutz
2021-01-08 22:15:06 +01:00
parent a2c3197f42
commit 22f5aeab07
8 changed files with 72 additions and 16 deletions

View File

@@ -59,6 +59,10 @@ static ReusableBuffer<uint8> _cursor_backup;
ZoomLevel _gui_zoom; ///< GUI Zoom level
ZoomLevel _font_zoom; ///< Font Zoom level
int8 _gui_zoom_cfg; ///< GUI zoom level in config.
int8 _font_zoom_cfg; ///< Font zoom level in config.
/**
* The rect for repaint.
*
@@ -1876,3 +1880,23 @@ void SortResolutions()
{
std::sort(_resolutions.begin(), _resolutions.end());
}
/**
* Resolve GUI zoom level, if auto-suggestion is requested.
*/
void UpdateGUIZoom()
{
/* Determine real GUI zoom to use. */
if (_gui_zoom_cfg == ZOOM_LVL_CFG_AUTO) {
_gui_zoom = static_cast<ZoomLevel>(Clamp(VideoDriver::GetInstance()->GetSuggestedUIZoom(), _settings_client.gui.zoom_min, _settings_client.gui.zoom_max));
} else {
_gui_zoom = static_cast<ZoomLevel>(_gui_zoom_cfg);
}
/* Determine real font zoom to use. */
if (_font_zoom_cfg == ZOOM_LVL_CFG_AUTO) {
_font_zoom = static_cast<ZoomLevel>(VideoDriver::GetInstance()->GetSuggestedUIZoom());
} else {
_font_zoom = static_cast<ZoomLevel>(_font_zoom_cfg);
}
}