Skip to content

Commit

Permalink
Add UI scaling command line parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
superctr committed Apr 15, 2024
1 parent 627bfc7 commit e49f225
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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++;
}

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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
Expand Down Expand Up @@ -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();
}
}

//=====================================================================
Expand Down

0 comments on commit e49f225

Please sign in to comment.