Skip to content

Commit 747c0c5

Browse files
committed
Cleaned up implementation
1 parent ad68135 commit 747c0c5

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

Sources/OvUI/include/OvUI/Core/UIManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ namespace OvUI::Core
9696
*/
9797
void EnableDocking(bool p_value);
9898

99+
/**
100+
* Enable DPI scaling
101+
* @param p_value
102+
*/
103+
void EnableDPIScaling(bool p_value);
104+
99105
/**
100106
* Reset the UI layout to the given configuration file
101107
* @param p_config

Sources/OvUI/src/OvUI/Core/UIManager.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_sty
3232
{
3333
ImGui::CreateContext();
3434

35-
ImGuiIO& io = ImGui::GetIO();
36-
io.ConfigWindowsMoveFromTitleBarOnly = true; /* Disable moving windows by dragging another thing than the title bar */
37-
io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleViewports;
38-
io.ConfigFlags |= ImGuiConfigFlags_DpiEnableScaleFonts;
35+
ImGui::GetIO().ConfigWindowsMoveFromTitleBarOnly = true; /* Disable moving windows by dragging another thing than the title bar */
36+
37+
EnableDPIScaling(true);
3938
EnableDocking(false);
4039

4140
ApplyStyle(p_style);
@@ -142,7 +141,23 @@ void OvUI::Core::UIManager::EnableDocking(bool p_value)
142141
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_DockingEnable;
143142
}
144143

145-
void OvUI::Core::UIManager::ResetLayout(const std::string& p_config) const
144+
void OvUI::Core::UIManager::EnableDPIScaling(bool p_value)
145+
{
146+
ImGuiIO& io = ImGui::GetIO();
147+
148+
const auto dpiScalingFlags = ImGuiConfigFlags_DpiEnableScaleViewports | ImGuiConfigFlags_DpiEnableScaleFonts;
149+
150+
if (p_value)
151+
{
152+
io.ConfigFlags |= dpiScalingFlags;
153+
}
154+
else
155+
{
156+
io.ConfigFlags &= ~dpiScalingFlags;
157+
}
158+
}
159+
160+
void OvUI::Core::UIManager::ResetLayout(const std::string &p_config) const
146161
{
147162
ImGui::LoadIniSettingsFromDisk(p_config.c_str());
148163
}

0 commit comments

Comments
 (0)