From 800e3d9f9583db4a53e022b13c28e7f91d63bdd8 Mon Sep 17 00:00:00 2001 From: Jonas Otto Date: Fri, 7 Jun 2024 22:36:35 +0200 Subject: [PATCH] try dpi fixes --- CMakeLists.txt | 2 +- src/rig_reconfigure.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c859534..0f72f79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ find_package(rclcpp REQUIRED) include(FetchContent) FetchContent_Declare(imgui GIT_REPOSITORY https://github.com/ocornut/imgui.git - GIT_TAG v1.89.8-docking + GIT_TAG v1.90.8-docking CONFIGURE_COMMAND "" BUILD_COMMAND "" ) diff --git a/src/rig_reconfigure.cpp b/src/rig_reconfigure.cpp index 4d7af70..018266e 100644 --- a/src/rig_reconfigure.cpp +++ b/src/rig_reconfigure.cpp @@ -62,6 +62,18 @@ int main(int argc, char *argv[]) { glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + float highDPIscaleFactor = 1.0; + { + GLFWmonitor *monitor = glfwGetPrimaryMonitor(); + float xscale, yscale; + glfwGetMonitorContentScale(monitor, &xscale, &yscale); + if (xscale > 1 || yscale > 1) + { + highDPIscaleFactor = xscale; + glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + } + } + // Setup Dear ImGui context IMGUI_CHECKVERSION(); ImGui::CreateContext(); @@ -109,6 +121,11 @@ int main(int argc, char *argv[]) { // Setup Dear ImGui style ImGui::StyleColorsDark(); + ImGui::GetStyle().ScaleAllSizes(highDPIscaleFactor); + ImFontConfig config; + config.SizePixels = 13.0f * highDPIscaleFactor; + ImGui::GetIO().Fonts->AddFontDefault(&config); + //ImGui::GetIO().Fonts->AddFontFromFileTTF("ProggyClean.ttf", 13.0f * highDPIscaleFactor, NULL, NULL); // Setup Platform/Renderer backends ImGui_ImplGlfw_InitForOpenGL(window, true);