Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/OvUI/include/OvUI/Core/UIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion Sources/OvUI/src/OvUI/Core/UIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
}
Expand Down