diff --git a/Sources/OvUI/include/OvUI/Core/UIManager.h b/Sources/OvUI/include/OvUI/Core/UIManager.h index 1c4e44d91..9517342eb 100644 --- a/Sources/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/OvUI/include/OvUI/Core/UIManager.h @@ -96,6 +96,12 @@ namespace OvUI::Core */ void EnableDocking(bool p_value); + /** + * Enable DPI scaling + * @param p_value + */ + void EnableDPIScaling(bool p_value); + /** * Reset the UI layout to the given configuration file * @param p_config diff --git a/Sources/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/OvUI/src/OvUI/Core/UIManager.cpp index c2d757c7a..bbfe352e8 100644 --- a/Sources/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/OvUI/src/OvUI/Core/UIManager.cpp @@ -33,6 +33,8 @@ OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_sty ImGui::CreateContext(); ImGui::GetIO().ConfigWindowsMoveFromTitleBarOnly = true; /* Disable moving windows by dragging another thing than the title bar */ + + EnableDPIScaling(true); EnableDocking(false); ApplyStyle(p_style); @@ -139,7 +141,23 @@ void OvUI::Core::UIManager::EnableDocking(bool p_value) ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_DockingEnable; } -void OvUI::Core::UIManager::ResetLayout(const std::string& p_config) const +void OvUI::Core::UIManager::EnableDPIScaling(bool p_value) +{ + ImGuiIO& io = ImGui::GetIO(); + + const auto dpiScalingFlags = ImGuiConfigFlags_DpiEnableScaleViewports | ImGuiConfigFlags_DpiEnableScaleFonts; + + if (p_value) + { + io.ConfigFlags |= dpiScalingFlags; + } + else + { + io.ConfigFlags &= ~dpiScalingFlags; + } +} + +void OvUI::Core::UIManager::ResetLayout(const std::string &p_config) const { ImGui::LoadIniSettingsFromDisk(p_config.c_str()); }