Feature: Variable GUI scale.

GUI scale is now variable from 100% to 500%, and no longer restricted to
powers-of-2.
This commit is contained in:
Peter Nelson
2021-04-20 11:49:20 +01:00
committed by PeterN
parent 13d271217f
commit 9666e46739
22 changed files with 175 additions and 205 deletions

View File

@@ -1269,7 +1269,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
/** Screen the window is on changed. */
- (void)windowDidChangeBackingProperties:(NSNotification *)notification
{
bool did_adjust = AdjustGUIZoom();
bool did_adjust = AdjustGUIZoom(true);
/* Reallocate screen buffer if necessary. */
driver->AllocateBackingStore();

View File

@@ -167,15 +167,13 @@ public:
}
/**
* Get a suggested default GUI zoom taking screen DPI into account.
* Get a suggested default GUI scale taking screen DPI into account.
*/
virtual ZoomLevel GetSuggestedUIZoom()
virtual int GetSuggestedUIScale()
{
float dpi_scale = this->GetDPIScale();
if (dpi_scale >= 3.0f) return ZOOM_LVL_NORMAL;
if (dpi_scale >= 1.5f) return ZOOM_LVL_OUT_2X;
return ZOOM_LVL_OUT_4X;
return Clamp(dpi_scale * 100, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE);
}
virtual const char *GetInfoString() const

View File

@@ -675,7 +675,7 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
case WM_DPICHANGED: {
auto did_adjust = AdjustGUIZoom();
auto did_adjust = AdjustGUIZoom(true);
/* Resize the window to match the new DPI setting. */
RECT *prcNewWindow = (RECT *)lParam;