From e49f225ac2b2d46056b2c45a5d31c544227c4968 Mon Sep 17 00:00:00 2001 From: Ian Karlsson Date: Mon, 15 Apr 2024 18:56:41 +0200 Subject: [PATCH] Add UI scaling command line parameter --- src/main.cpp | 7 ++++++- src/main_window.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d0b0f9b..5faee94 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -106,6 +106,7 @@ int main(int argc, char* argv[]) { int driver_id = -1; int device_id = -1; + float ui_scale = 1.0f; int carg = 1; while(carg < argc) { @@ -117,6 +118,10 @@ int main(int argc, char* argv[]) { device_id = strtol(argv[++carg], NULL, 0); } + if(!std::strcmp(argv[carg], "--ui-scale") && (argc > carg)) + { + ui_scale = strtof(argv[++carg], NULL); + } carg++; } @@ -199,7 +204,7 @@ int main(int argc, char* argv[]) // Setup scaling float scale; glfwGetWindowContentScale(window, &scale, NULL); - restyle_with_scale(scale); + restyle_with_scale(scale * ui_scale); glfwSetWindowContentScaleCallback(window, [](GLFWwindow* window, float xscale, float yscale) { restyle_with_scale(xscale); diff --git a/src/main_window.cpp b/src/main_window.cpp index 57c3d8a..80ff968 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -37,6 +37,7 @@ static bool debug_imgui_metrics = false; #endif static bool debug_state_window = false; static bool debug_audio_window = false; +static bool debug_ui_window = false; static void debug_menu() { @@ -48,6 +49,7 @@ static void debug_menu() #endif ImGui::MenuItem("Select audio device", NULL, &debug_audio_window); ImGui::MenuItem("Display dump state", NULL, &debug_state_window); + ImGui::MenuItem("UI settings", NULL, &debug_ui_window); if (ImGui::MenuItem("Quit")) { // if ctrl+shift was held, stimulate a segfault @@ -128,6 +130,14 @@ static void debug_window() } ImGui::End(); } + if(debug_ui_window) + { + ImGui::Begin("UI settings", &debug_ui_window, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize); + + ImGui::DragFloat("UI scaling", &ImGui::GetIO().FontGlobalScale, 0.005f, 0.3f, 2.0f, "%.2f"); + + ImGui::End(); + } } //=====================================================================