diff --git a/src/spectrogram.c b/src/spectrogram.c index ac217d9..c0026f5 100644 --- a/src/spectrogram.c +++ b/src/spectrogram.c @@ -38,7 +38,12 @@ #define BASE_WIDTH 1280 #define BASE_HEIGHT 800 -// Get uniform scale factor based on current window size +// Base resolution for proportional UI scaling. +// GetUIScale() uses logical screen (not framebuffer) dimensions so that +// layout stays based on window size alone. FLAG_WINDOW_HIGHDPI makes +// BeginDrawing() render to the framebuffer at the correct resolution, so +// every 1px drawn in layout coordinates automatically maps to the right +// physical size on any monitor. static float GetUIScale(void) { float scaleX = (float)GetScreenWidth() / BASE_WIDTH; @@ -1269,7 +1274,7 @@ static bool UpdateSlider(Rectangle bounds, float* value) int main(int argc, char* argv[]) { - SetConfigFlags(FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE); + SetConfigFlags(FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE | FLAG_WINDOW_HIGHDPI); InitWindow(1280, 800, "Spectrogram Viewer"); SetTargetFPS(60); SetTraceLogLevel(LOG_WARNING); // Suppress INFO texture logs @@ -1284,7 +1289,9 @@ int main(int argc, char* argv[]) SearchAndSetResourceDir("resources"); - // Load TTF font for crisp text at any scale + // Load TTF font at a fixed base size. Scaling is handled uniformly by + // GetUIScale() for both layout and DrawTextScaled(), so the font scales + // naturally with the window size on any DPI monitor. mainFont = LoadFontEx("fonts/DejaVuSansMono.ttf", 16, 0, 0); if (mainFont.texture.id == 0) { TraceLog(LOG_WARNING, "Failed to load TTF font, using default bitmap font"); @@ -1533,11 +1540,11 @@ int main(int argc, char* argv[]) float selTopMargin = 50 * selScale; float selBottomMargin = 10 * selScale; - Rectangle selBounds = { - selSidebarWidth + selFreqLabelWidth, - selTopMargin, - GetScreenWidth() - selSidebarWidth - selFreqLabelWidth - selVScrollbarWidth - 20, - GetScreenHeight() - selTopMargin - selBottomMargin - selLabelHeight - selScrollbarHeight - 10 + Rectangle selBounds = { + selSidebarWidth + selFreqLabelWidth, + selTopMargin, + GetScreenWidth() - selSidebarWidth - selFreqLabelWidth - selVScrollbarWidth - 20.0f * selScale, + GetScreenHeight() - selTopMargin - selBottomMargin - selLabelHeight - selScrollbarHeight - 10.0f * selScale }; Vector2 mousePos = GetMousePosition();