From e45fa6092bfd3e145f9544b25965365dce863fcd Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 15:21:14 -0400 Subject: [PATCH 01/13] Cleaner font-size system --- .../include/OvEditor/Settings/EFontSize.h | 30 ------------------- .../OvEditor/Settings/EditorSettings.h | 3 +- .../OvEditor/src/OvEditor/Core/Context.cpp | 12 +++----- .../OvEditor/src/OvEditor/Core/ProjectHub.cpp | 9 ++---- .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 24 ++++++++++----- .../src/OvEditor/Settings/EditorSettings.cpp | 4 +-- Sources/OvGame/src/OvGame/Core/Context.cpp | 6 ++-- Sources/OvUI/include/OvUI/Core/UIManager.h | 18 +++++++---- Sources/OvUI/src/OvUI/Core/UIManager.cpp | 9 +++++- 9 files changed, 49 insertions(+), 66 deletions(-) delete mode 100644 Sources/OvEditor/include/OvEditor/Settings/EFontSize.h diff --git a/Sources/OvEditor/include/OvEditor/Settings/EFontSize.h b/Sources/OvEditor/include/OvEditor/Settings/EFontSize.h deleted file mode 100644 index 867d03090..000000000 --- a/Sources/OvEditor/include/OvEditor/Settings/EFontSize.h +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -namespace OvEditor::Settings -{ - enum class EFontSize - { - SMALL = 0, - MEDIUM = 1, - BIG = 2, - DEFAULT = MEDIUM - }; - - constexpr std::string_view GetFontID(EFontSize p_size) - { - switch (p_size) - { - case EFontSize::SMALL: return "Small"; - case EFontSize::MEDIUM: return "Medium"; - case EFontSize::BIG: return "Big"; - } - - return {}; - } -} diff --git a/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h b/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h index 531cea012..97ed616a8 100644 --- a/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h +++ b/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h @@ -8,7 +8,6 @@ #include -#include #include #include @@ -99,7 +98,7 @@ namespace OvEditor::Settings inline static Property ScalingSnapUnit = { 1.0f }; inline static Property ColorTheme = { static_cast(OvUI::Styling::EStyle::DEFAULT_DARK) }; inline static Property ConsoleMaxLogs = { 500 }; - inline static Property FontSize = { static_cast(EFontSize::DEFAULT) }; + inline static Property FontScale = { 100 }; inline static Property CodeEditorCommand = { "code {workdir} --goto {path}" }; inline static Property RegenerateScriptingProjectFilesOnStartup = { true }; }; diff --git a/Sources/OvEditor/src/OvEditor/Core/Context.cpp b/Sources/OvEditor/src/OvEditor/Core/Context.cpp index 91de825ed..5ed073850 100644 --- a/Sources/OvEditor/src/OvEditor/Core/Context.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/Context.cpp @@ -121,20 +121,16 @@ OvEditor::Core::Context::Context(const std::filesystem::path& p_projectFolder) : static_cast(OvEditor::Settings::EditorSettings::ColorTheme.Get()) ); - const auto fontPath = editorAssetsPath / "Fonts" / "Ruda-Bold.ttf"; - if (!std::filesystem::exists(OvEditor::Utils::FileSystem::kLayoutFilePath)) { const auto defaultLayoutPath = std::filesystem::current_path() / "Config" / "layout.ini"; uiManager->ResetLayout(defaultLayoutPath.string()); } - uiManager->LoadFont(std::string{ Settings::GetFontID(Settings::EFontSize::BIG) }, fontPath.string(), 18); - uiManager->LoadFont(std::string{ Settings::GetFontID(Settings::EFontSize::MEDIUM) }, fontPath.string(), 15); - uiManager->LoadFont(std::string{ Settings::GetFontID(Settings::EFontSize::SMALL) }, fontPath.string(), 12); - uiManager->UseFont(std::string{ Settings::GetFontID( - static_cast(Settings::EditorSettings::FontSize.Get()) - ) }); + const auto fontPath = editorAssetsPath / "Fonts" / "Ruda-Bold.ttf"; + uiManager->LoadFont("Ruda-Bold", fontPath.string(), 15); + uiManager->UseFont("Ruda-Bold"); + uiManager->SetFontScale(Settings::EditorSettings::FontScale / 100.0f); uiManager->SetEditorLayoutSaveFilename(OvEditor::Utils::FileSystem::kLayoutFilePath.string()); uiManager->SetEditorLayoutAutosaveFrequency(60.0f); diff --git a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp index e3db7b4c4..50d2fbc99 100644 --- a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp @@ -287,12 +287,9 @@ void OvEditor::Core::ProjectHub::SetupContext() const auto fontPath = std::filesystem::current_path() / "Data" / "Editor" / "Fonts" / "Ruda-Bold.ttf"; - m_uiManager->LoadFont(std::string{ Settings::GetFontID(Settings::EFontSize::BIG) }, fontPath.string(), 20); - m_uiManager->LoadFont(std::string{ Settings::GetFontID(Settings::EFontSize::MEDIUM) }, fontPath.string(), 18); - m_uiManager->LoadFont(std::string{ Settings::GetFontID(Settings::EFontSize::SMALL) }, fontPath.string(), 16); - m_uiManager->UseFont(std::string{ Settings::GetFontID( - static_cast(Settings::EditorSettings::FontSize.Get()) - ) }); + m_uiManager->LoadFont("Ruda-Bold", fontPath.string(), 18); + m_uiManager->UseFont("Ruda-Bold"); + m_uiManager->SetFontScale(Settings::EditorSettings::FontScale / 100.0f); m_uiManager->EnableEditorLayoutSave(false); m_uiManager->EnableDocking(false); diff --git a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp index f91460abd..cfe9ae5ba 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -92,17 +92,27 @@ void OvEditor::Panels::MenuBar::InitializeSettingsMenu() EDITOR_CONTEXT(uiManager)->ApplyStyle(static_cast(p_value)); }; + enum class EFontScale : uint32_t + { + EXTRA_SMALL = 50, + SMALL = 75, + MEDIUM = 100, + BIG = 150, + EXTRA_BIG = 200 + }; + auto& fontSizeMenu = m_settingsMenu->CreateWidget("Font Size"); - auto& fontSizeSelector = fontSizeMenu.CreateWidget(static_cast(Settings::EditorSettings::FontSize.Get())); + auto& fontSizeSelector = fontSizeMenu.CreateWidget(static_cast(Settings::EditorSettings::FontScale.Get())); fontSizeSelector.choices = { - { static_cast(Settings::EFontSize::SMALL), "Small"}, - { static_cast(Settings::EFontSize::MEDIUM), "Medium"}, - { static_cast(Settings::EFontSize::BIG), "Big"} + { static_cast(EFontScale::EXTRA_SMALL), "Extra Small"}, + { static_cast(EFontScale::SMALL), "Small"}, + { static_cast(EFontScale::MEDIUM), "Medium"}, + { static_cast(EFontScale::BIG), "Big"}, + { static_cast(EFontScale::EXTRA_BIG), "Extra Big"}, }; fontSizeSelector.ValueChangedEvent += [this](int p_value) { - Settings::EditorSettings::FontSize = p_value; - const auto fontID = std::string{ Settings::GetFontID(static_cast(p_value)) }; - EDITOR_CONTEXT(uiManager)->UseFont(fontID); + Settings::EditorSettings::FontScale = p_value; + EDITOR_CONTEXT(uiManager)->SetFontScale(p_value / 100.0f); }; m_settingsMenu->CreateWidget("Spawn actors at origin", "", true, true).ValueChangedEvent += EDITOR_BIND(SetActorSpawnAtOrigin, std::placeholders::_1); diff --git a/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp b/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp index 124880bd1..95b97bd68 100644 --- a/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp +++ b/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp @@ -45,7 +45,7 @@ void OvEditor::Settings::EditorSettings::Save() iniFile.Add("scaling_snap_unit", ScalingSnapUnit.Get()); iniFile.Add("color_theme", ColorTheme.Get()); iniFile.Add("console_max_logs", ConsoleMaxLogs.Get()); - iniFile.Add("font_size", FontSize.Get()); + iniFile.Add("font_scale", FontScale.Get()); iniFile.Add("code_editor_command", CodeEditorCommand.Get()); iniFile.Add("always_regenerate_scripting_symbols", RegenerateScriptingProjectFilesOnStartup.Get()); iniFile.Rewrite(); @@ -66,7 +66,7 @@ void OvEditor::Settings::EditorSettings::Load() LoadIniEntry(iniFile, "scaling_snap_unit", ScalingSnapUnit); LoadIniEntry(iniFile, "color_theme", ColorTheme); LoadIniEntry(iniFile, "console_max_logs", ConsoleMaxLogs); - LoadIniEntry(iniFile, "font_size", FontSize); + LoadIniEntry(iniFile, "font_scale", FontScale); LoadIniEntry(iniFile, "code_editor_command", CodeEditorCommand); LoadIniEntry(iniFile, "always_regenerate_scripting_symbols", RegenerateScriptingProjectFilesOnStartup); } diff --git a/Sources/OvGame/src/OvGame/Core/Context.cpp b/Sources/OvGame/src/OvGame/Core/Context.cpp index f997f3618..84c3b5a1d 100644 --- a/Sources/OvGame/src/OvGame/Core/Context.cpp +++ b/Sources/OvGame/src/OvGame/Core/Context.cpp @@ -117,10 +117,8 @@ OvGame::Core::Context::Context() : const auto fontPath = engineAssetsPath / "Fonts" / "Ruda-Bold.ttf"; - uiManager->LoadFont("Ruda_Big", fontPath.string(), 16); - uiManager->LoadFont("Ruda_Small", fontPath.string(), 12); - uiManager->LoadFont("Ruda_Medium", fontPath.string(), 14); - uiManager->UseFont("Ruda_Medium"); + uiManager->LoadFont("Ruda-Bold", fontPath.string(), 15); + uiManager->UseFont("Ruda-Bold"); uiManager->EnableEditorLayoutSave(false); uiManager->EnableDocking(false); diff --git a/Sources/OvUI/include/OvUI/Core/UIManager.h b/Sources/OvUI/include/OvUI/Core/UIManager.h index f8fa7608c..29de103bd 100644 --- a/Sources/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/OvUI/include/OvUI/Core/UIManager.h @@ -63,6 +63,12 @@ namespace OvUI::Core */ void UseDefaultFont(); + /** + * Set the font size + * @param p_size + */ + void SetFontScale(float p_size); + /** * Allow the user to enable/disable .ini generation to save his editor layout * @param p_value @@ -96,11 +102,11 @@ namespace OvUI::Core */ void EnableDocking(bool p_value); - /** - * Reset the UI layout to the given configuration file - * @param p_config - */ - void ResetLayout(const std::string & p_config) const; + /** + * Reset the UI layout to the given configuration file + * @param p_config + */ + void ResetLayout(const std::string & p_config) const; /** * Enable or disable mouse input in ImGui. @@ -141,4 +147,4 @@ namespace OvUI::Core std::unordered_map m_fonts; std::string m_layoutSaveFilename = "imgui.ini"; }; -} \ No newline at end of file +} diff --git a/Sources/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/OvUI/src/OvUI/Core/UIManager.cpp index b6362b6bc..45330dd37 100644 --- a/Sources/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/OvUI/src/OvUI/Core/UIManager.cpp @@ -4,6 +4,8 @@ * @licence: MIT */ +#include "imgui.h" +#include "imgui_internal.h" #include #include @@ -99,6 +101,11 @@ void OvUI::Core::UIManager::UseDefaultFont() ImGui::GetIO().FontDefault = nullptr; } +void OvUI::Core::UIManager::SetFontScale(float p_scale) +{ + ImGui::GetIO().FontGlobalScale = p_scale; +} + void OvUI::Core::UIManager::EnableEditorLayoutSave(bool p_value) { if (p_value) @@ -186,4 +193,4 @@ void OvUI::Core::UIManager::PushCurrentFont() void OvUI::Core::UIManager::PopCurrentFont() { -} \ No newline at end of file +} From 8a35b6effadfc588d5068763b7943e2943c89bac Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 15:29:28 -0400 Subject: [PATCH 02/13] Added font DPI scaling (enabled by default) --- .../OvEditor/include/OvEditor/Settings/EditorSettings.h | 1 + Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp | 6 ++++++ Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp | 2 ++ Sources/OvUI/include/OvUI/Core/UIManager.h | 7 +++++++ Sources/OvUI/src/OvUI/Core/UIManager.cpp | 7 +++++++ 5 files changed, 23 insertions(+) diff --git a/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h b/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h index 97ed616a8..c8bb3b4d5 100644 --- a/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h +++ b/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h @@ -99,6 +99,7 @@ namespace OvEditor::Settings inline static Property ColorTheme = { static_cast(OvUI::Styling::EStyle::DEFAULT_DARK) }; inline static Property ConsoleMaxLogs = { 500 }; inline static Property FontScale = { 100 }; + inline static Property FontDpiScaling = true; inline static Property CodeEditorCommand = { "code {workdir} --goto {path}" }; inline static Property RegenerateScriptingProjectFilesOnStartup = { true }; }; diff --git a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp index cfe9ae5ba..6841eba2e 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -34,6 +34,7 @@ #include "OvEditor/Panels/SceneView.h" #include "OvEditor/Settings/EditorSettings.h" #include "OvEditor/Utils/ActorCreationMenu.h" +#include "OvUI/Widgets/Selection/CheckBox.h" using namespace OvUI::Panels; using namespace OvUI::Widgets; @@ -114,6 +115,11 @@ void OvEditor::Panels::MenuBar::InitializeSettingsMenu() Settings::EditorSettings::FontScale = p_value; EDITOR_CONTEXT(uiManager)->SetFontScale(p_value / 100.0f); }; + auto& fontDpiScaling = fontSizeMenu.CreateWidget(Settings::EditorSettings::FontDpiScaling, "Scale with DPI"); + fontDpiScaling.ValueChangedEvent += [this](bool p_value) { + Settings::EditorSettings::FontDpiScaling = p_value; + EDITOR_CONTEXT(uiManager)->EnableDPIScaling(p_value); + }; m_settingsMenu->CreateWidget("Spawn actors at origin", "", true, true).ValueChangedEvent += EDITOR_BIND(SetActorSpawnAtOrigin, std::placeholders::_1); m_settingsMenu->CreateWidget("Vertical Synchronization", "", true, true).ValueChangedEvent += [this](bool p_value) { EDITOR_CONTEXT(device)->SetVsync(p_value); }; diff --git a/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp b/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp index 95b97bd68..48ea76a34 100644 --- a/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp +++ b/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp @@ -46,6 +46,7 @@ void OvEditor::Settings::EditorSettings::Save() iniFile.Add("color_theme", ColorTheme.Get()); iniFile.Add("console_max_logs", ConsoleMaxLogs.Get()); iniFile.Add("font_scale", FontScale.Get()); + iniFile.Add("font_dpi_scaling", FontDpiScaling.Get()); iniFile.Add("code_editor_command", CodeEditorCommand.Get()); iniFile.Add("always_regenerate_scripting_symbols", RegenerateScriptingProjectFilesOnStartup.Get()); iniFile.Rewrite(); @@ -67,6 +68,7 @@ void OvEditor::Settings::EditorSettings::Load() LoadIniEntry(iniFile, "color_theme", ColorTheme); LoadIniEntry(iniFile, "console_max_logs", ConsoleMaxLogs); LoadIniEntry(iniFile, "font_scale", FontScale); + LoadIniEntry(iniFile, "font_dpi_scaling", FontDpiScaling); LoadIniEntry(iniFile, "code_editor_command", CodeEditorCommand); LoadIniEntry(iniFile, "always_regenerate_scripting_symbols", RegenerateScriptingProjectFilesOnStartup); } diff --git a/Sources/OvUI/include/OvUI/Core/UIManager.h b/Sources/OvUI/include/OvUI/Core/UIManager.h index 29de103bd..026e6d91c 100644 --- a/Sources/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/OvUI/include/OvUI/Core/UIManager.h @@ -102,6 +102,12 @@ namespace OvUI::Core */ void EnableDocking(bool p_value); + /** + * Enable DPI scaling + * @note Limited to fonts for now + */ + void EnableDPIScaling(bool p_value); + /** * Reset the UI layout to the given configuration file * @param p_config @@ -143,6 +149,7 @@ namespace OvUI::Core private: bool m_dockingState; + bool m_dpiScaling; Modules::Canvas* m_currentCanvas = nullptr; std::unordered_map m_fonts; std::string m_layoutSaveFilename = "imgui.ini"; diff --git a/Sources/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/OvUI/src/OvUI/Core/UIManager.cpp index 45330dd37..628033ab4 100644 --- a/Sources/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/OvUI/src/OvUI/Core/UIManager.cpp @@ -154,6 +154,13 @@ void OvUI::Core::UIManager::EnableDocking(bool p_value) ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_DockingEnable; } +void OvUI::Core::UIManager::EnableDPIScaling(bool p_value) +{ + m_dpiScaling = p_value; + + ImGui::GetIO().ConfigDpiScaleFonts = m_dpiScaling; +} + void OvUI::Core::UIManager::ResetLayout(const std::string& p_config) const { ImGui::LoadIniSettingsFromDisk(p_config.c_str()); From 131fa9331acf4788fb02e4a45f1c59a8a2a062f4 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 15:39:15 -0400 Subject: [PATCH 03/13] Added missing DPI enabling in OvEditor --- Sources/OvEditor/src/OvEditor/Core/Context.cpp | 1 + Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/Sources/OvEditor/src/OvEditor/Core/Context.cpp b/Sources/OvEditor/src/OvEditor/Core/Context.cpp index 5ed073850..07c93e811 100644 --- a/Sources/OvEditor/src/OvEditor/Core/Context.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/Context.cpp @@ -131,6 +131,7 @@ OvEditor::Core::Context::Context(const std::filesystem::path& p_projectFolder) : uiManager->LoadFont("Ruda-Bold", fontPath.string(), 15); uiManager->UseFont("Ruda-Bold"); uiManager->SetFontScale(Settings::EditorSettings::FontScale / 100.0f); + uiManager->EnableDPIScaling(Settings::EditorSettings::FontDpiScaling.Get()); uiManager->SetEditorLayoutSaveFilename(OvEditor::Utils::FileSystem::kLayoutFilePath.string()); uiManager->SetEditorLayoutAutosaveFrequency(60.0f); diff --git a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp index 50d2fbc99..b8cf39a47 100644 --- a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp @@ -290,6 +290,7 @@ void OvEditor::Core::ProjectHub::SetupContext() m_uiManager->LoadFont("Ruda-Bold", fontPath.string(), 18); m_uiManager->UseFont("Ruda-Bold"); m_uiManager->SetFontScale(Settings::EditorSettings::FontScale / 100.0f); + m_uiManager->EnableDPIScaling(Settings::EditorSettings::FontDpiScaling.Get()); m_uiManager->EnableEditorLayoutSave(false); m_uiManager->EnableDocking(false); From 20f7d0c69d2d56335b1ad7cd6727335e1d8041b4 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 16:42:37 -0400 Subject: [PATCH 04/13] Single 'UI Scale' option --- .../OvEditor/Settings/EditorSettings.h | 3 +- .../OvEditor/src/OvEditor/Core/Context.cpp | 12 ++++- .../OvEditor/src/OvEditor/Core/ProjectHub.cpp | 12 ++++- .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 44 ++++++++----------- .../src/OvEditor/Settings/EditorSettings.cpp | 6 +-- Sources/OvUI/include/OvUI/Core/UIManager.h | 19 ++++---- Sources/OvUI/src/OvUI/Core/UIManager.cpp | 21 +++++++-- 7 files changed, 70 insertions(+), 47 deletions(-) diff --git a/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h b/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h index c8bb3b4d5..956c9887e 100644 --- a/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h +++ b/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h @@ -98,8 +98,7 @@ namespace OvEditor::Settings inline static Property ScalingSnapUnit = { 1.0f }; inline static Property ColorTheme = { static_cast(OvUI::Styling::EStyle::DEFAULT_DARK) }; inline static Property ConsoleMaxLogs = { 500 }; - inline static Property FontScale = { 100 }; - inline static Property FontDpiScaling = true; + inline static Property UIScale = { 0 }; inline static Property CodeEditorCommand = { "code {workdir} --goto {path}" }; inline static Property RegenerateScriptingProjectFilesOnStartup = { true }; }; diff --git a/Sources/OvEditor/src/OvEditor/Core/Context.cpp b/Sources/OvEditor/src/OvEditor/Core/Context.cpp index 07c93e811..8456a3f43 100644 --- a/Sources/OvEditor/src/OvEditor/Core/Context.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/Context.cpp @@ -130,8 +130,16 @@ OvEditor::Core::Context::Context(const std::filesystem::path& p_projectFolder) : const auto fontPath = editorAssetsPath / "Fonts" / "Ruda-Bold.ttf"; uiManager->LoadFont("Ruda-Bold", fontPath.string(), 15); uiManager->UseFont("Ruda-Bold"); - uiManager->SetFontScale(Settings::EditorSettings::FontScale / 100.0f); - uiManager->EnableDPIScaling(Settings::EditorSettings::FontDpiScaling.Get()); + + const int uiScale = Settings::EditorSettings::UIScale.Get(); + if (uiScale == 0) + { + uiManager->DpiScaleUI(); + } + else + { + uiManager->SetUIScale(uiScale / 100.0f); + } uiManager->SetEditorLayoutSaveFilename(OvEditor::Utils::FileSystem::kLayoutFilePath.string()); uiManager->SetEditorLayoutAutosaveFrequency(60.0f); diff --git a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp index b8cf39a47..132e75888 100644 --- a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp @@ -289,8 +289,16 @@ void OvEditor::Core::ProjectHub::SetupContext() m_uiManager->LoadFont("Ruda-Bold", fontPath.string(), 18); m_uiManager->UseFont("Ruda-Bold"); - m_uiManager->SetFontScale(Settings::EditorSettings::FontScale / 100.0f); - m_uiManager->EnableDPIScaling(Settings::EditorSettings::FontDpiScaling.Get()); + + const int uiScale = Settings::EditorSettings::UIScale.Get(); + if (uiScale == 0) + { + m_uiManager->DpiScaleUI(); + } + else + { + m_uiManager->SetUIScale(uiScale / 100.0f); + } m_uiManager->EnableEditorLayoutSave(false); m_uiManager->EnableDocking(false); diff --git a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp index 6841eba2e..a8720ecff 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -93,32 +93,26 @@ void OvEditor::Panels::MenuBar::InitializeSettingsMenu() EDITOR_CONTEXT(uiManager)->ApplyStyle(static_cast(p_value)); }; - enum class EFontScale : uint32_t - { - EXTRA_SMALL = 50, - SMALL = 75, - MEDIUM = 100, - BIG = 150, - EXTRA_BIG = 200 - }; - - auto& fontSizeMenu = m_settingsMenu->CreateWidget("Font Size"); - auto& fontSizeSelector = fontSizeMenu.CreateWidget(static_cast(Settings::EditorSettings::FontScale.Get())); - fontSizeSelector.choices = { - { static_cast(EFontScale::EXTRA_SMALL), "Extra Small"}, - { static_cast(EFontScale::SMALL), "Small"}, - { static_cast(EFontScale::MEDIUM), "Medium"}, - { static_cast(EFontScale::BIG), "Big"}, - { static_cast(EFontScale::EXTRA_BIG), "Extra Big"}, - }; - fontSizeSelector.ValueChangedEvent += [this](int p_value) { - Settings::EditorSettings::FontScale = p_value; - EDITOR_CONTEXT(uiManager)->SetFontScale(p_value / 100.0f); + auto& uiScale = themeButton.CreateWidget(static_cast(Settings::EditorSettings::UIScale.Get())); + uiScale.choices = { + { 0, "Automatic (DPI Aware)"}, + { 100, "100%"}, + { 150, "150%"}, + { 200, "200%"}, }; - auto& fontDpiScaling = fontSizeMenu.CreateWidget(Settings::EditorSettings::FontDpiScaling, "Scale with DPI"); - fontDpiScaling.ValueChangedEvent += [this](bool p_value) { - Settings::EditorSettings::FontDpiScaling = p_value; - EDITOR_CONTEXT(uiManager)->EnableDPIScaling(p_value); + uiScale.ValueChangedEvent += [this](int p_value) { + Settings::EditorSettings::UIScale = p_value; + if (p_value == 0) + { + EDITOR_CONTEXT(uiManager)->DpiScaleUI(); + } + else + { + EDITOR_CONTEXT(uiManager)->SetUIScale(p_value / 100.0f); + } + // EDITOR_EXEC(DelayAction([p_value]() { + // EDITOR_CONTEXT(uiManager)->SetStyleScale(p_value / 100.0f); + // })); }; m_settingsMenu->CreateWidget("Spawn actors at origin", "", true, true).ValueChangedEvent += EDITOR_BIND(SetActorSpawnAtOrigin, std::placeholders::_1); diff --git a/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp b/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp index 48ea76a34..222af7251 100644 --- a/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp +++ b/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp @@ -44,9 +44,8 @@ void OvEditor::Settings::EditorSettings::Save() iniFile.Add("rotation_snap_unit", RotationSnapUnit.Get()); iniFile.Add("scaling_snap_unit", ScalingSnapUnit.Get()); iniFile.Add("color_theme", ColorTheme.Get()); + iniFile.Add("ui_scale", UIScale.Get()); iniFile.Add("console_max_logs", ConsoleMaxLogs.Get()); - iniFile.Add("font_scale", FontScale.Get()); - iniFile.Add("font_dpi_scaling", FontDpiScaling.Get()); iniFile.Add("code_editor_command", CodeEditorCommand.Get()); iniFile.Add("always_regenerate_scripting_symbols", RegenerateScriptingProjectFilesOnStartup.Get()); iniFile.Rewrite(); @@ -66,9 +65,8 @@ void OvEditor::Settings::EditorSettings::Load() LoadIniEntry(iniFile, "rotation_snap_unit", RotationSnapUnit); LoadIniEntry(iniFile, "scaling_snap_unit", ScalingSnapUnit); LoadIniEntry(iniFile, "color_theme", ColorTheme); + LoadIniEntry(iniFile, "ui_scale", UIScale); LoadIniEntry(iniFile, "console_max_logs", ConsoleMaxLogs); - LoadIniEntry(iniFile, "font_scale", FontScale); - LoadIniEntry(iniFile, "font_dpi_scaling", FontDpiScaling); LoadIniEntry(iniFile, "code_editor_command", CodeEditorCommand); LoadIniEntry(iniFile, "always_regenerate_scripting_symbols", RegenerateScriptingProjectFilesOnStartup); } diff --git a/Sources/OvUI/include/OvUI/Core/UIManager.h b/Sources/OvUI/include/OvUI/Core/UIManager.h index 026e6d91c..ee8bb32cb 100644 --- a/Sources/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/OvUI/include/OvUI/Core/UIManager.h @@ -64,10 +64,15 @@ namespace OvUI::Core void UseDefaultFont(); /** - * Set the font size - * @param p_size + * Set the UI scale + * @param p_scale */ - void SetFontScale(float p_size); + void SetUIScale(float p_scale); + + /** + * Set UI scaled based on window DPI + */ + void DpiScaleUI(); /** * Allow the user to enable/disable .ini generation to save his editor layout @@ -102,12 +107,6 @@ namespace OvUI::Core */ void EnableDocking(bool p_value); - /** - * Enable DPI scaling - * @note Limited to fonts for now - */ - void EnableDPIScaling(bool p_value); - /** * Reset the UI layout to the given configuration file * @param p_config @@ -150,6 +149,8 @@ namespace OvUI::Core private: bool m_dockingState; bool m_dpiScaling; + Styling::EStyle m_currentStyle; + float m_styleScale = 1.0f; Modules::Canvas* m_currentCanvas = nullptr; std::unordered_map m_fonts; std::string m_layoutSaveFilename = "imgui.ini"; diff --git a/Sources/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/OvUI/src/OvUI/Core/UIManager.cpp index 628033ab4..dde6e39b8 100644 --- a/Sources/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/OvUI/src/OvUI/Core/UIManager.cpp @@ -52,7 +52,11 @@ OvUI::Core::UIManager::~UIManager() void OvUI::Core::UIManager::ApplyStyle(Styling::EStyle p_style) { - ImGui::GetStyle() = GetStyle(p_style); + m_currentStyle = p_style; + auto style = GetStyle(p_style); + style.FontScaleMain = m_styleScale; + style.ScaleAllSizes(m_styleScale); + ImGui::GetStyle() = style; } bool OvUI::Core::UIManager::LoadFont(const std::string& p_id, const std::string & p_path, float p_fontSize) @@ -101,9 +105,20 @@ void OvUI::Core::UIManager::UseDefaultFont() ImGui::GetIO().FontDefault = nullptr; } -void OvUI::Core::UIManager::SetFontScale(float p_scale) +void OvUI::Core::UIManager::SetUIScale(float p_scale) { - ImGui::GetIO().FontGlobalScale = p_scale; + // FIXME: Explain that (through assert or error message?) + if (p_scale < 1.0f) return; + + m_styleScale = p_scale; + ApplyStyle(m_currentStyle); +} + +void OvUI::Core::UIManager::DpiScaleUI() +{ + SetUIScale( + ImGui::GetWindowDpiScale() + ); } void OvUI::Core::UIManager::EnableEditorLayoutSave(bool p_value) From b6a3e2840d453d9003338c9adcf96d61217e82a5 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 17:03:04 -0400 Subject: [PATCH 05/13] Code cleanup --- .../OvEditor/src/OvEditor/Core/Context.cpp | 12 +----- .../OvEditor/src/OvEditor/Core/ProjectHub.cpp | 12 +----- .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 13 +----- Sources/OvUI/include/OvUI/Core/UIManager.h | 18 +++----- Sources/OvUI/premake5.lua | 1 + Sources/OvUI/src/OvUI/Core/UIManager.cpp | 42 +++++-------------- 6 files changed, 22 insertions(+), 76 deletions(-) diff --git a/Sources/OvEditor/src/OvEditor/Core/Context.cpp b/Sources/OvEditor/src/OvEditor/Core/Context.cpp index 8456a3f43..317573571 100644 --- a/Sources/OvEditor/src/OvEditor/Core/Context.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/Context.cpp @@ -15,6 +15,7 @@ #include #include #include +#include using namespace OvCore::Global; using namespace OvCore::ResourceManagement; @@ -130,17 +131,8 @@ OvEditor::Core::Context::Context(const std::filesystem::path& p_projectFolder) : const auto fontPath = editorAssetsPath / "Fonts" / "Ruda-Bold.ttf"; uiManager->LoadFont("Ruda-Bold", fontPath.string(), 15); uiManager->UseFont("Ruda-Bold"); - const int uiScale = Settings::EditorSettings::UIScale.Get(); - if (uiScale == 0) - { - uiManager->DpiScaleUI(); - } - else - { - uiManager->SetUIScale(uiScale / 100.0f); - } - + uiManager->SetScale(uiScale == 0 ? std::nullopt : std::make_optional(uiScale / 100.0f)); uiManager->SetEditorLayoutSaveFilename(OvEditor::Utils::FileSystem::kLayoutFilePath.string()); uiManager->SetEditorLayoutAutosaveFrequency(60.0f); uiManager->EnableEditorLayoutSave(true); diff --git a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp index 132e75888..10c47ff04 100644 --- a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp @@ -289,17 +289,9 @@ void OvEditor::Core::ProjectHub::SetupContext() m_uiManager->LoadFont("Ruda-Bold", fontPath.string(), 18); m_uiManager->UseFont("Ruda-Bold"); - const int uiScale = Settings::EditorSettings::UIScale.Get(); - if (uiScale == 0) - { - m_uiManager->DpiScaleUI(); - } - else - { - m_uiManager->SetUIScale(uiScale / 100.0f); - } - + m_uiManager->SetScale(uiScale == 0 ? std::nullopt : std::make_optional(uiScale / 100.0f)); m_uiManager->EnableEditorLayoutSave(false); m_uiManager->EnableDocking(false); } + diff --git a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp index a8720ecff..71d48bc53 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "OvEditor/Core/EditorActions.h" #include "OvEditor/Panels/AssetView.h" @@ -102,17 +103,7 @@ void OvEditor::Panels::MenuBar::InitializeSettingsMenu() }; uiScale.ValueChangedEvent += [this](int p_value) { Settings::EditorSettings::UIScale = p_value; - if (p_value == 0) - { - EDITOR_CONTEXT(uiManager)->DpiScaleUI(); - } - else - { - EDITOR_CONTEXT(uiManager)->SetUIScale(p_value / 100.0f); - } - // EDITOR_EXEC(DelayAction([p_value]() { - // EDITOR_CONTEXT(uiManager)->SetStyleScale(p_value / 100.0f); - // })); + EDITOR_CONTEXT(uiManager)->SetScale(p_value == 0 ? std::nullopt : std::make_optional(p_value / 100.0f)); }; m_settingsMenu->CreateWidget("Spawn actors at origin", "", true, true).ValueChangedEvent += EDITOR_BIND(SetActorSpawnAtOrigin, std::placeholders::_1); diff --git a/Sources/OvUI/include/OvUI/Core/UIManager.h b/Sources/OvUI/include/OvUI/Core/UIManager.h index ee8bb32cb..0e332e674 100644 --- a/Sources/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/OvUI/include/OvUI/Core/UIManager.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include @@ -21,7 +22,7 @@ namespace OvUI::Core { public: /** - * Create the UI manager. Will setup ImGui internally\ + * Create the UI manager. Will setup ImGui internally * @param p_glfwWindow * @param p_style * @param p_glslVersion (Ex: #version 450) @@ -67,12 +68,7 @@ namespace OvUI::Core * Set the UI scale * @param p_scale */ - void SetUIScale(float p_scale); - - /** - * Set UI scaled based on window DPI - */ - void DpiScaleUI(); + void SetScale(std::optional p_scale = std::nullopt); /** * Allow the user to enable/disable .ini generation to save his editor layout @@ -142,15 +138,11 @@ namespace OvUI::Core */ void Render(); - private: - void PushCurrentFont(); - void PopCurrentFont(); - private: bool m_dockingState; - bool m_dpiScaling; Styling::EStyle m_currentStyle; - float m_styleScale = 1.0f; + float m_scale; + bool m_refreshStyle = false; Modules::Canvas* m_currentCanvas = nullptr; std::unordered_map m_fonts; std::string m_layoutSaveFilename = "imgui.ini"; diff --git a/Sources/OvUI/premake5.lua b/Sources/OvUI/premake5.lua index 4cc35d7f6..243992a42 100644 --- a/Sources/OvUI/premake5.lua +++ b/Sources/OvUI/premake5.lua @@ -21,6 +21,7 @@ project "OvUI" -- Overload SDK "%{wks.location}/Sources/OvMaths/include", "%{wks.location}/Sources/OvTools/include", + "%{wks.location}/Sources/OvDebug/include", -- Current Project "include" diff --git a/Sources/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/OvUI/src/OvUI/Core/UIManager.cpp index dde6e39b8..b2f53148d 100644 --- a/Sources/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/OvUI/src/OvUI/Core/UIManager.cpp @@ -4,11 +4,12 @@ * @licence: MIT */ -#include "imgui.h" -#include "imgui_internal.h" +#include #include #include +#include + namespace { ImGuiStyle GetStyle(OvUI::Styling::EStyle p_style) @@ -54,8 +55,8 @@ void OvUI::Core::UIManager::ApplyStyle(Styling::EStyle p_style) { m_currentStyle = p_style; auto style = GetStyle(p_style); - style.FontScaleMain = m_styleScale; - style.ScaleAllSizes(m_styleScale); + style.FontScaleMain = m_scale; + style.ScaleAllSizes(m_scale); ImGui::GetStyle() = style; } @@ -105,20 +106,13 @@ void OvUI::Core::UIManager::UseDefaultFont() ImGui::GetIO().FontDefault = nullptr; } -void OvUI::Core::UIManager::SetUIScale(float p_scale) +void OvUI::Core::UIManager::SetScale(std::optional p_scale) { - // FIXME: Explain that (through assert or error message?) - if (p_scale < 1.0f) return; + m_scale = p_scale.value_or(ImGui::GetWindowDpiScale()); - m_styleScale = p_scale; - ApplyStyle(m_currentStyle); -} + OVASSERT(m_scale >= 1.0f, "UI scale cannot be less than 100%"); -void OvUI::Core::UIManager::DpiScaleUI() -{ - SetUIScale( - ImGui::GetWindowDpiScale() - ); + ApplyStyle(m_currentStyle); } void OvUI::Core::UIManager::EnableEditorLayoutSave(bool p_value) @@ -169,16 +163,9 @@ void OvUI::Core::UIManager::EnableDocking(bool p_value) ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_DockingEnable; } -void OvUI::Core::UIManager::EnableDPIScaling(bool p_value) -{ - m_dpiScaling = p_value; - - ImGui::GetIO().ConfigDpiScaleFonts = m_dpiScaling; -} - void OvUI::Core::UIManager::ResetLayout(const std::string& p_config) const { - ImGui::LoadIniSettingsFromDisk(p_config.c_str()); + ImGui::LoadIniSettingsFromDisk(p_config.c_str()); } bool OvUI::Core::UIManager::IsDockingEnabled() const @@ -207,12 +194,3 @@ void OvUI::Core::UIManager::Render() } } -void OvUI::Core::UIManager::PushCurrentFont() -{ - -} - -void OvUI::Core::UIManager::PopCurrentFont() -{ - -} From aa1fe9252e48d1e41042dd739d87caecb04a50b9 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 17:39:16 -0400 Subject: [PATCH 06/13] Updated OvWindowing to support content scale --- .../OvEditor/src/OvEditor/Core/Context.cpp | 3 +- .../OvEditor/src/OvEditor/Core/ProjectHub.cpp | 3 +- .../OvEditor/src/OvEditor/Panels/Console.cpp | 1 - Sources/OvGame/src/OvGame/Core/Context.cpp | 5 +++- Sources/OvUI/include/OvUI/Core/UIManager.h | 19 +++++++++---- Sources/OvUI/premake5.lua | 1 + Sources/OvUI/src/OvUI/Core/UIManager.cpp | 28 +++++++++++++++++-- .../OvWindowing/include/OvWindowing/Window.h | 8 ++++++ .../OvWindowing/src/OvWindowing/Window.cpp | 22 +++++++++++++++ 9 files changed, 78 insertions(+), 12 deletions(-) diff --git a/Sources/OvEditor/src/OvEditor/Core/Context.cpp b/Sources/OvEditor/src/OvEditor/Core/Context.cpp index 317573571..6c50e96c9 100644 --- a/Sources/OvEditor/src/OvEditor/Core/Context.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/Context.cpp @@ -118,7 +118,8 @@ OvEditor::Core::Context::Context(const std::filesystem::path& p_projectFolder) : std::filesystem::create_directories(Utils::FileSystem::kEditorDataPath); - uiManager = std::make_unique(window->GetGlfwWindow(), + uiManager = std::make_unique( + *window, static_cast(OvEditor::Settings::EditorSettings::ColorTheme.Get()) ); diff --git a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp index 10c47ff04..76e552f34 100644 --- a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp @@ -281,7 +281,8 @@ void OvEditor::Core::ProjectHub::SetupContext() /* Graphics context creation */ m_driver = std::make_unique(OvRendering::Settings::DriverSettings{ false }); - m_uiManager = std::make_unique(m_window->GetGlfwWindow(), + m_uiManager = std::make_unique( + *m_window, static_cast(OvEditor::Settings::EditorSettings::ColorTheme.Get()) ); diff --git a/Sources/OvEditor/src/OvEditor/Panels/Console.cpp b/Sources/OvEditor/src/OvEditor/Panels/Console.cpp index 9e18832fd..e97de39e3 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/Console.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/Console.cpp @@ -56,7 +56,6 @@ OvEditor::Panels::Console::Console allowHorizontalScrollbar = true; auto& clearButton = CreateWidget("Clear"); - clearButton.size = { 50.f, 0.f }; clearButton.idleBackgroundColor = { 0.5f, 0.f, 0.f }; clearButton.ClickedEvent += std::bind(&Console::Clear, this); clearButton.lineBreak = false; diff --git a/Sources/OvGame/src/OvGame/Core/Context.cpp b/Sources/OvGame/src/OvGame/Core/Context.cpp index 84c3b5a1d..71ec0644c 100644 --- a/Sources/OvGame/src/OvGame/Core/Context.cpp +++ b/Sources/OvGame/src/OvGame/Core/Context.cpp @@ -113,7 +113,10 @@ OvGame::Core::Context::Context() : basePSO }); - uiManager = std::make_unique(window->GetGlfwWindow(), OvUI::Styling::EStyle::DEFAULT_DARK); + uiManager = std::make_unique( + *window, + OvUI::Styling::EStyle::DEFAULT_DARK + ); const auto fontPath = engineAssetsPath / "Fonts" / "Ruda-Bold.ttf"; diff --git a/Sources/OvUI/include/OvUI/Core/UIManager.h b/Sources/OvUI/include/OvUI/Core/UIManager.h index 0e332e674..9ff2dfa37 100644 --- a/Sources/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/OvUI/include/OvUI/Core/UIManager.h @@ -6,12 +6,18 @@ #pragma once +#include "OvTools/Eventing/Event.h" #include #include #include -#include "OvUI/Modules/Canvas.h" -#include "OvUI/Styling/EStyle.h" +#include +#include + +namespace OvWindowing +{ + class Window; +} namespace OvUI::Core { @@ -23,16 +29,16 @@ namespace OvUI::Core public: /** * Create the UI manager. Will setup ImGui internally - * @param p_glfwWindow + * @param p_window * @param p_style * @param p_glslVersion (Ex: #version 450) */ - UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style = Styling::EStyle::IM_DARK_STYLE, std::string_view p_glslVersion = "#version 450"); + UIManager(OvWindowing::Window& p_window, Styling::EStyle p_style = Styling::EStyle::IM_DARK_STYLE, std::string_view p_glslVersion = "#version 450"); /** * Destroy the UI manager. Will handle ImGui destruction internally */ - ~UIManager(); + virtual ~UIManager(); /** * Apply a new style to the UI elements @@ -139,9 +145,12 @@ namespace OvUI::Core void Render(); private: + OvWindowing::Window& m_window; + OvTools::Eventing::ListenerID m_contentScaleChangedListener; bool m_dockingState; Styling::EStyle m_currentStyle; float m_scale; + bool m_dpiAware; bool m_refreshStyle = false; Modules::Canvas* m_currentCanvas = nullptr; std::unordered_map m_fonts; diff --git a/Sources/OvUI/premake5.lua b/Sources/OvUI/premake5.lua index 243992a42..a3dcc968d 100644 --- a/Sources/OvUI/premake5.lua +++ b/Sources/OvUI/premake5.lua @@ -22,6 +22,7 @@ project "OvUI" "%{wks.location}/Sources/OvMaths/include", "%{wks.location}/Sources/OvTools/include", "%{wks.location}/Sources/OvDebug/include", + "%{wks.location}/Sources/OvWindowing/include", -- Current Project "include" diff --git a/Sources/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/OvUI/src/OvUI/Core/UIManager.cpp index b2f53148d..5153c51e9 100644 --- a/Sources/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/OvUI/src/OvUI/Core/UIManager.cpp @@ -7,8 +7,10 @@ #include #include #include +#include #include +#include namespace { @@ -31,7 +33,8 @@ namespace } } -OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_style, std::string_view p_glslVersion) +OvUI::Core::UIManager::UIManager(OvWindowing::Window& p_window, Styling::EStyle p_style, std::string_view p_glslVersion) : + m_window(p_window) { ImGui::CreateContext(); @@ -40,12 +43,21 @@ OvUI::Core::UIManager::UIManager(GLFWwindow* p_glfwWindow, Styling::EStyle p_sty ApplyStyle(p_style); - ImGui_ImplGlfw_InitForOpenGL(p_glfwWindow, true); + ImGui_ImplGlfw_InitForOpenGL(m_window.GetGlfwWindow(), true); ImGui_ImplOpenGL3_Init(p_glslVersion.data()); + + m_contentScaleChangedListener = m_window.ContentScaleChangedEvent += [this](float x, float y) { + if (m_dpiAware) + { + SetScale(); // Recompute scale based on content scale + } + }; } OvUI::Core::UIManager::~UIManager() { + m_window.ContentScaleChangedEvent -= m_contentScaleChangedListener; + ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImGui::DestroyContext(); @@ -108,7 +120,17 @@ void OvUI::Core::UIManager::UseDefaultFont() void OvUI::Core::UIManager::SetScale(std::optional p_scale) { - m_scale = p_scale.value_or(ImGui::GetWindowDpiScale()); + m_dpiAware = !p_scale.has_value(); + + if (m_dpiAware) + { + const auto contentScale = m_window.GetContentScale(); + m_scale = std::max(contentScale.first, contentScale.second); + } + else + { + m_scale = p_scale.value(); + } OVASSERT(m_scale >= 1.0f, "UI scale cannot be less than 100%"); diff --git a/Sources/OvWindowing/include/OvWindowing/Window.h b/Sources/OvWindowing/include/OvWindowing/Window.h index 160f6f6ce..05959315f 100644 --- a/Sources/OvWindowing/include/OvWindowing/Window.h +++ b/Sources/OvWindowing/include/OvWindowing/Window.h @@ -6,6 +6,7 @@ #pragma once +#include "OvTools/Eventing/Event.h" #include #include @@ -33,6 +34,7 @@ namespace OvWindowing /* Window events */ OvTools::Eventing::Event ResizeEvent; OvTools::Eventing::Event FramebufferResizeEvent; + OvTools::Eventing::Event ContentScaleChangedEvent; OvTools::Eventing::Event MoveEvent; OvTools::Eventing::Event CursorMoveEvent; OvTools::Eventing::Event<> MinimizeEvent; @@ -282,6 +284,11 @@ namespace OvWindowing */ int32_t GetRefreshRate() const; + /** + * Returns the window content scale (ratio between current DPI and platform's default DPI) + */ + std::pair GetContentScale() const; + /** * Return GLFW window */ @@ -296,6 +303,7 @@ namespace OvWindowing void BindScrollCallback() const; void BindResizeCallback() const; void BindFramebufferResizeCallback() const; + void BindContentScaleCallback() const; void BindCursorMoveCallback() const; void BindMoveCallback() const; void BindIconifyCallback() const; diff --git a/Sources/OvWindowing/src/OvWindowing/Window.cpp b/Sources/OvWindowing/src/OvWindowing/Window.cpp index 373f34aa2..6061e0003 100644 --- a/Sources/OvWindowing/src/OvWindowing/Window.cpp +++ b/Sources/OvWindowing/src/OvWindowing/Window.cpp @@ -315,6 +315,13 @@ int32_t OvWindowing::Window::GetRefreshRate() const return m_refreshRate; } +std::pair OvWindowing::Window::GetContentScale() const +{ + std::pair scale; + glfwGetWindowContentScale(m_glfwWindow, &scale.first, &scale.second); + return scale; +} + GLFWwindow* OvWindowing::Window::GetGlfwWindow() const { return m_glfwWindow; @@ -434,6 +441,21 @@ void OvWindowing::Window::BindFramebufferResizeCallback() const glfwSetFramebufferSizeCallback(m_glfwWindow, framebufferResizeCallback); } +void OvWindowing::Window::BindContentScaleCallback() const +{ + auto contentScaleCallback = [](GLFWwindow* p_window, float p_x, float p_y) + { + Window* windowInstance = FindInstance(p_window); + + if (windowInstance) + { + windowInstance->ContentScaleChangedEvent.Invoke(p_x, p_y); + } + }; + + glfwSetWindowContentScaleCallback(m_glfwWindow, contentScaleCallback); +} + void OvWindowing::Window::BindCursorMoveCallback() const { auto cursorMoveCallback = [](GLFWwindow* p_window, double p_x, double p_y) From 5c92c3af1a4d88e09507e0389f58ca9e4445bc93 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 17:42:47 -0400 Subject: [PATCH 07/13] Replaced assert by warning when scale is < 1.0f --- Sources/OvUI/src/OvUI/Core/UIManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/OvUI/src/OvUI/Core/UIManager.cpp index 5153c51e9..9c4d4ae50 100644 --- a/Sources/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/OvUI/src/OvUI/Core/UIManager.cpp @@ -4,6 +4,7 @@ * @licence: MIT */ +#include "OvDebug/Logger.h" #include #include #include @@ -132,7 +133,11 @@ void OvUI::Core::UIManager::SetScale(std::optional p_scale) m_scale = p_scale.value(); } - OVASSERT(m_scale >= 1.0f, "UI scale cannot be less than 100%"); + if (m_scale < 1.0f) + { + OVLOG_WARNING("UI scale values lower than 1.0f are not supported!"); + m_scale = 1.0f; + } ApplyStyle(m_currentStyle); } From 3bbe2384b27949027ab85e4194e80889c9d4e323 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 18:07:02 -0400 Subject: [PATCH 08/13] Added missing BindContentScaleCallback() invocation --- Sources/OvWindowing/src/OvWindowing/Window.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/OvWindowing/src/OvWindowing/Window.cpp b/Sources/OvWindowing/src/OvWindowing/Window.cpp index 6061e0003..6ebae6d01 100644 --- a/Sources/OvWindowing/src/OvWindowing/Window.cpp +++ b/Sources/OvWindowing/src/OvWindowing/Window.cpp @@ -48,6 +48,7 @@ OvWindowing::Window::Window(const Context::Device& p_device, const Settings::Win BindResizeCallback(); BindCursorMoveCallback(); BindFramebufferResizeCallback(); + BindContentScaleCallback(); BindMoveCallback(); BindFocusCallback(); From 9f2138d6255ff8363ac0ee4b57e5d2dbe1750256 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 18:33:00 -0400 Subject: [PATCH 09/13] Improved project hub layout adaptation --- .../OvEditor/src/OvEditor/Core/ProjectHub.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp index 76e552f34..aefe0319c 100644 --- a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp @@ -45,10 +45,14 @@ namespace OvEditor::Core SetSize({ 1000, 580 }); SetPosition({ 0.f, 0.f }); - auto& openProjectButton = CreateWidget("Open Project"); - auto& newProjectButton = CreateWidget("New Project"); - auto& pathField = CreateWidget(""); - m_goButton = &CreateWidget("GO"); + auto& actionBar = CreateWidget(); + actionBar.horizontal = true; + actionBar.stretchWidget = 2; + + auto& openProjectButton = actionBar.CreateWidget("Open Project"); + auto& newProjectButton = actionBar.CreateWidget("New Project"); + auto& pathField = actionBar.CreateWidget(""); + m_goButton = &actionBar.CreateWidget("GO"); pathField.ContentChangedEvent += [this, &pathField](std::string p_content) { pathField.content = std::filesystem::path{ @@ -118,7 +122,7 @@ namespace OvEditor::Core auto& columns = CreateWidget>(); - columns.widths = { 750, 500 }; + columns.widths = { -1, 0 }; // Sanitize the project registry before displaying it, so we avoid showing // corrupted/deleted projects. @@ -162,11 +166,8 @@ namespace OvEditor::Core void Draw() override { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 50.f, 50.f }); - ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.f); - OvUI::Panels::PanelWindow::Draw(); - - ImGui::PopStyleVar(2); + ImGui::PopStyleVar(1); } private: From 22232cff52fc3a91b651115066cc17de49f9e979 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Mon, 20 Apr 2026 19:12:00 -0400 Subject: [PATCH 10/13] Attempt to scale columns manually --- .../OvEditor/include/OvEditor/Core/EditorActions.h | 1 + .../OvEditor/src/OvEditor/Panels/AssetProperties.cpp | 6 +++--- Sources/OvEditor/src/OvEditor/Panels/Inspector.cpp | 4 ++-- .../OvEditor/src/OvEditor/Panels/MaterialEditor.cpp | 12 ++++++------ .../OvEditor/src/OvEditor/Panels/ProjectSettings.cpp | 10 +++++----- Sources/OvUI/include/OvUI/Core/UIManager.h | 5 +++++ Sources/OvUI/src/OvUI/Core/UIManager.cpp | 5 +++++ 7 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Sources/OvEditor/include/OvEditor/Core/EditorActions.h b/Sources/OvEditor/include/OvEditor/Core/EditorActions.h index 973473694..b205a9acd 100644 --- a/Sources/OvEditor/include/OvEditor/Core/EditorActions.h +++ b/Sources/OvEditor/include/OvEditor/Core/EditorActions.h @@ -19,6 +19,7 @@ #define EDITOR_EVENT(target) OvCore::Global::ServiceLocator::Get().target #define EDITOR_CONTEXT(instance) OvCore::Global::ServiceLocator::Get().GetContext().instance #define EDITOR_PANEL(type, id) OvCore::Global::ServiceLocator::Get().GetPanelsManager().GetPanelAs(id) +#define EDITOR_UI_SCALE EDITOR_CONTEXT(uiManager)->GetScale() namespace tinyxml2 { diff --git a/Sources/OvEditor/src/OvEditor/Panels/AssetProperties.cpp b/Sources/OvEditor/src/OvEditor/Panels/AssetProperties.cpp index a5712132f..e7085bb03 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/AssetProperties.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/AssetProperties.cpp @@ -56,12 +56,12 @@ OvEditor::Panels::AssetProperties::AssetProperties m_settings = &CreateWidget("Settings"); m_settings->neverDisabled = true; m_settingsColumns = &m_settings->CreateWidget>(); - m_settingsColumns->widths[0] = 150; + m_settingsColumns->widths[0] = 150 * EDITOR_UI_SCALE; m_info = &CreateWidget("Info"); m_info->neverDisabled = true; m_infoColumns = &m_info->CreateWidget>(); - m_infoColumns->widths[0] = 150; + m_infoColumns->widths[0] = 150 * EDITOR_UI_SCALE; m_settings->enabled = m_info->enabled = false; } @@ -178,7 +178,7 @@ void OvEditor::Panels::AssetProperties::CreateHeaderButtons() void OvEditor::Panels::AssetProperties::CreateAssetSelector() { auto& columns = CreateWidget>(); - columns.widths[0] = 150; + columns.widths[0] = 150 * EDITOR_UI_SCALE; m_assetSelector = &OvCore::Helpers::GUIDrawer::DrawAsset(columns, "Target", m_resource, &m_targetChanged); const auto& widgets = columns.GetWidgets(); widgets[widgets.size() - 1].first->neverDisabled = true; diff --git a/Sources/OvEditor/src/OvEditor/Panels/Inspector.cpp b/Sources/OvEditor/src/OvEditor/Panels/Inspector.cpp index a5d686a0a..6eed3e963 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/Inspector.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/Inspector.cpp @@ -346,7 +346,7 @@ void OvEditor::Panels::Inspector::_DrawComponent(AComponent& p_component, int p_ auto& columns = header.CreateWidget>(); columns.SetID("comp_" + p_component.GetName()); - columns.widths[0] = 200; + columns.widths[0] = 200 * EDITOR_UI_SCALE; p_component.OnInspector(columns); } @@ -379,7 +379,7 @@ void OvEditor::Panels::Inspector::_DrawBehaviour(Behaviour& p_behaviour, int p_i auto& columns = header.CreateWidget>(); columns.SetID("bhv_" + p_behaviour.name); - columns.widths[0] = 200; + columns.widths[0] = 200 * EDITOR_UI_SCALE; p_behaviour.OnInspector(columns); } diff --git a/Sources/OvEditor/src/OvEditor/Panels/MaterialEditor.cpp b/Sources/OvEditor/src/OvEditor/Panels/MaterialEditor.cpp index 0e7454228..204dec742 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/MaterialEditor.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/MaterialEditor.cpp @@ -263,7 +263,7 @@ void OvEditor::Panels::MaterialEditor::CreateHeaderButtons() void OvEditor::Panels::MaterialEditor::CreateMaterialSelector() { auto& columns = CreateWidget>(); - columns.widths[0] = 150; + columns.widths[0] = 150 * EDITOR_UI_SCALE; m_targetMaterialText = &GUIDrawer::DrawMaterial(columns, "Material", m_target, &m_materialDroppedEvent); const auto& widgets = columns.GetWidgets(); widgets[widgets.size() - 1].first->neverDisabled = true; @@ -273,7 +273,7 @@ void OvEditor::Panels::MaterialEditor::CreateMaterialSelector() void OvEditor::Panels::MaterialEditor::CreateShaderSelector() { auto& columns = m_settings->CreateWidget>(); - columns.widths[0] = 150; + columns.widths[0] = 150 * EDITOR_UI_SCALE; m_shaderText = &GUIDrawer::DrawShader(columns, "Shader", m_shader, &m_shaderDroppedEvent); } @@ -282,12 +282,12 @@ void OvEditor::Panels::MaterialEditor::CreateMaterialSettings() m_materialPipelineState = &m_settings->CreateWidget("Pipeline State"); m_materialPipelineState->neverDisabled = true; m_materialPipelineStateColumns = &m_materialPipelineState->CreateWidget>(); - m_materialPipelineStateColumns->widths[0] = 150; + m_materialPipelineStateColumns->widths[0] = 150 * EDITOR_UI_SCALE; m_materialSettings = &m_settings->CreateWidget("Settings"); m_materialSettings->neverDisabled = true; m_materialSettingsColumns = &m_materialSettings->CreateWidget>(); - m_materialSettingsColumns->widths[0] = 150; + m_materialSettingsColumns->widths[0] = 150 * EDITOR_UI_SCALE; } void OvEditor::Panels::MaterialEditor::CreateMaterialFeatures() @@ -295,7 +295,7 @@ void OvEditor::Panels::MaterialEditor::CreateMaterialFeatures() m_materialFeatures = &m_settings->CreateWidget("Features"); m_materialFeatures->neverDisabled = true; m_materialFeaturesColumns = &m_materialFeatures->CreateWidget>(); - m_materialFeaturesColumns->widths[0] = 150; + m_materialFeaturesColumns->widths[0] = 150 * EDITOR_UI_SCALE; } void OvEditor::Panels::MaterialEditor::CreateMaterialProperties() @@ -303,7 +303,7 @@ void OvEditor::Panels::MaterialEditor::CreateMaterialProperties() m_materialProperties = &m_settings->CreateWidget("Properties"); m_materialProperties->neverDisabled = true; m_materialPropertiesColumns = &m_materialProperties->CreateWidget>(); - m_materialPropertiesColumns->widths[0] = 150; + m_materialPropertiesColumns->widths[0] = 150 * EDITOR_UI_SCALE; } void OvEditor::Panels::MaterialEditor::GenerateMaterialSettingsContent() diff --git a/Sources/OvEditor/src/OvEditor/Panels/ProjectSettings.cpp b/Sources/OvEditor/src/OvEditor/Panels/ProjectSettings.cpp index c1bdc2b32..1cbdea3ce 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/ProjectSettings.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/ProjectSettings.cpp @@ -47,7 +47,7 @@ OvEditor::Panels::ProjectSettings::ProjectSettings(const std::string & p_title, /* Physics settings */ auto& root = CreateWidget("Physics"); auto& columns = root.CreateWidget>(); - columns.widths[0] = 125; + columns.widths[0] = 125 * EDITOR_UI_SCALE; GUIDrawer::DrawScalar(columns, "Gravity", GenerateGatherer("gravity"), GenerateProvider("gravity"), 0.1f, GUIDrawer::_MIN_FLOAT, GUIDrawer::_MAX_FLOAT); } @@ -56,7 +56,7 @@ OvEditor::Panels::ProjectSettings::ProjectSettings(const std::string & p_title, /* Build settings */ auto& generationRoot = CreateWidget("Build"); auto& columns = generationRoot.CreateWidget>(); - columns.widths[0] = 125; + columns.widths[0] = 125 * EDITOR_UI_SCALE; GUIDrawer::CreateTitle(columns, "Build Type"); auto& comboBox = columns.CreateWidget(m_projectFile.Get("build_type")); @@ -74,7 +74,7 @@ OvEditor::Panels::ProjectSettings::ProjectSettings(const std::string & p_title, /* Windowing settings */ auto& windowingRoot = CreateWidget("Windowing"); auto& columns = windowingRoot.CreateWidget>(); - columns.widths[0] = 125; + columns.widths[0] = 125 * EDITOR_UI_SCALE; GUIDrawer::DrawScalar(columns, "Resolution X", GenerateGatherer("x_resolution"), GenerateProvider("x_resolution"), 1, 0, 10000); GUIDrawer::DrawScalar(columns, "Resolution Y", GenerateGatherer("y_resolution"), GenerateProvider("y_resolution"), 1, 0, 10000); @@ -86,7 +86,7 @@ OvEditor::Panels::ProjectSettings::ProjectSettings(const std::string & p_title, /* Rendering settings */ auto& renderingRoot = CreateWidget("Rendering"); auto& columns = renderingRoot.CreateWidget>(); - columns.widths[0] = 125; + columns.widths[0] = 125 * EDITOR_UI_SCALE; GUIDrawer::DrawBoolean(columns, "Vertical Sync.", GenerateGatherer("vsync"), GenerateProvider("vsync")); GUIDrawer::DrawBoolean(columns, "Multi-sampling", GenerateGatherer("multisampling"), GenerateProvider("multisampling")); @@ -97,7 +97,7 @@ OvEditor::Panels::ProjectSettings::ProjectSettings(const std::string & p_title, /* Scene Management settings */ auto& gameRoot = CreateWidget("Scene Management"); auto& columns = gameRoot.CreateWidget>(); - columns.widths[0] = 125; + columns.widths[0] = 125 * EDITOR_UI_SCALE; GUIDrawer::DrawScene(columns, "Start scene", GenerateGatherer("start_scene"), GenerateProvider("start_scene")); } diff --git a/Sources/OvUI/include/OvUI/Core/UIManager.h b/Sources/OvUI/include/OvUI/Core/UIManager.h index 9ff2dfa37..89ae70134 100644 --- a/Sources/OvUI/include/OvUI/Core/UIManager.h +++ b/Sources/OvUI/include/OvUI/Core/UIManager.h @@ -76,6 +76,11 @@ namespace OvUI::Core */ void SetScale(std::optional p_scale = std::nullopt); + /** + * Returns the scale of the UI + */ + float GetScale() const; + /** * Allow the user to enable/disable .ini generation to save his editor layout * @param p_value diff --git a/Sources/OvUI/src/OvUI/Core/UIManager.cpp b/Sources/OvUI/src/OvUI/Core/UIManager.cpp index 9c4d4ae50..8af20252c 100644 --- a/Sources/OvUI/src/OvUI/Core/UIManager.cpp +++ b/Sources/OvUI/src/OvUI/Core/UIManager.cpp @@ -142,6 +142,11 @@ void OvUI::Core::UIManager::SetScale(std::optional p_scale) ApplyStyle(m_currentStyle); } +float OvUI::Core::UIManager::GetScale() const +{ + return m_scale; +} + void OvUI::Core::UIManager::EnableEditorLayoutSave(bool p_value) { if (p_value) From 9286641c5305532723c0fd0c7846852a6f0783df Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Tue, 21 Apr 2026 12:32:37 -0400 Subject: [PATCH 11/13] Added dialog message to warn about DPI scaling being in BETA --- .../OvEditor/Settings/EditorSettings.h | 3 ++- .../OvEditor/src/OvEditor/Core/ProjectHub.cpp | 26 +++++++++++++++++++ .../OvEditor/src/OvEditor/Panels/MenuBar.cpp | 11 ++++---- .../src/OvEditor/Settings/EditorSettings.cpp | 2 ++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h b/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h index 956c9887e..788b15213 100644 --- a/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h +++ b/Sources/OvEditor/include/OvEditor/Settings/EditorSettings.h @@ -98,7 +98,8 @@ namespace OvEditor::Settings inline static Property ScalingSnapUnit = { 1.0f }; inline static Property ColorTheme = { static_cast(OvUI::Styling::EStyle::DEFAULT_DARK) }; inline static Property ConsoleMaxLogs = { 500 }; - inline static Property UIScale = { 0 }; + inline static Property UIScale = { 100 }; + inline static Property BetaDpiAwarenessDialogPresented = { false }; inline static Property CodeEditorCommand = { "code {workdir} --goto {path}" }; inline static Property RegenerateScriptingProjectFilesOnStartup = { true }; }; diff --git a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp index aefe0319c..1081531bb 100644 --- a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp @@ -4,6 +4,7 @@ * @licence: MIT */ +#include #define _CRT_SECURE_NO_WARNINGS #include @@ -282,6 +283,31 @@ void OvEditor::Core::ProjectHub::SetupContext() /* Graphics context creation */ m_driver = std::make_unique(OvRendering::Settings::DriverSettings{ false }); + // DPI awareness BETA option + const auto windowContentScale = m_window->GetContentScale(); + const auto unifiedWindowContentScale = std::max(windowContentScale.first, windowContentScale.second); + + if (!Settings::EditorSettings::BetaDpiAwarenessDialogPresented.Get() && unifiedWindowContentScale > 1.0f) + { + Settings::EditorSettings::BetaDpiAwarenessDialogPresented.Set(true); + const auto dpiAwarenessDialog = OvWindowing::Dialogs::MessageBox( + "High DPI Monitor Detected", + "Overload has detected that you might be running the editor from a high DPI monitor.\n\n" + "Support for automatic DPI-scaling is currently in BETA and might result in weird spacings, " + "icon sizes, layouts, and window sizes.\n\n" + "Do you want to enable automatic DPI scaling anyway?\n\n" + "(You can change this setting anytime from the menu bar: Settings > Appearance)", + OvWindowing::Dialogs::MessageBox::EMessageType::QUESTION, + OvWindowing::Dialogs::MessageBox::EButtonLayout::YES_NO + ); + switch (dpiAwarenessDialog.GetUserAction()) + { + case OvWindowing::Dialogs::MessageBox::EUserAction::YES: + Settings::EditorSettings::UIScale.Set(0); + default: break; + } + } + m_uiManager = std::make_unique( *m_window, static_cast(OvEditor::Settings::EditorSettings::ColorTheme.Get()) diff --git a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp index 71d48bc53..7a8d85b55 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/MenuBar.cpp @@ -76,10 +76,10 @@ void OvEditor::Panels::MenuBar::HandleShortcuts(float p_deltaTime) void OvEditor::Panels::MenuBar::InitializeSettingsMenu() { - auto& themeButton = m_settingsMenu->CreateWidget("Editor Theme"); - themeButton.CreateWidget("Some themes may require a restart"); + auto& appearanceButton = m_settingsMenu->CreateWidget("Appearance"); + appearanceButton.CreateWidget("Some themes may require a restart"); - auto& colorTheme = themeButton.CreateWidget(static_cast(Settings::EditorSettings::ColorTheme.Get())); + auto& colorTheme = appearanceButton.CreateWidget(static_cast(Settings::EditorSettings::ColorTheme.Get())); colorTheme.choices = { { static_cast(OvUI::Styling::EStyle::IM_CLASSIC_STYLE), "ImGui Classic"}, { static_cast(OvUI::Styling::EStyle::IM_DARK_STYLE), "ImGui Dark"}, @@ -94,9 +94,9 @@ void OvEditor::Panels::MenuBar::InitializeSettingsMenu() EDITOR_CONTEXT(uiManager)->ApplyStyle(static_cast(p_value)); }; - auto& uiScale = themeButton.CreateWidget(static_cast(Settings::EditorSettings::UIScale.Get())); + auto& uiScale = appearanceButton.CreateWidget(static_cast(Settings::EditorSettings::UIScale.Get())); uiScale.choices = { - { 0, "Automatic (DPI Aware)"}, + { 0, "[BETA] Automatic (DPI Aware)"}, { 100, "100%"}, { 150, "150%"}, { 200, "200%"}, @@ -205,7 +205,6 @@ void OvEditor::Panels::MenuBar::InitializeSettingsMenu() { Settings::EditorSettings::CodeEditorCommand = p_value; }; - } void OvEditor::Panels::MenuBar::CreateFileMenu() diff --git a/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp b/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp index 222af7251..d2ebd899e 100644 --- a/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp +++ b/Sources/OvEditor/src/OvEditor/Settings/EditorSettings.cpp @@ -45,6 +45,7 @@ void OvEditor::Settings::EditorSettings::Save() iniFile.Add("scaling_snap_unit", ScalingSnapUnit.Get()); iniFile.Add("color_theme", ColorTheme.Get()); iniFile.Add("ui_scale", UIScale.Get()); + iniFile.Add("beta_dpi_awareness_dialog_presented", BetaDpiAwarenessDialogPresented.Get()); iniFile.Add("console_max_logs", ConsoleMaxLogs.Get()); iniFile.Add("code_editor_command", CodeEditorCommand.Get()); iniFile.Add("always_regenerate_scripting_symbols", RegenerateScriptingProjectFilesOnStartup.Get()); @@ -66,6 +67,7 @@ void OvEditor::Settings::EditorSettings::Load() LoadIniEntry(iniFile, "scaling_snap_unit", ScalingSnapUnit); LoadIniEntry(iniFile, "color_theme", ColorTheme); LoadIniEntry(iniFile, "ui_scale", UIScale); + LoadIniEntry(iniFile, "beta_dpi_awareness_dialog_presented", BetaDpiAwarenessDialogPresented); LoadIniEntry(iniFile, "console_max_logs", ConsoleMaxLogs); LoadIniEntry(iniFile, "code_editor_command", CodeEditorCommand); LoadIniEntry(iniFile, "always_regenerate_scripting_symbols", RegenerateScriptingProjectFilesOnStartup); From af398c8e5ab0c78d4db26578c63e60dfeea49ad1 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Tue, 21 Apr 2026 13:51:41 -0400 Subject: [PATCH 12/13] Code cleanup --- Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp index 1081531bb..2d1cb3aba 100644 --- a/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/ProjectHub.cpp @@ -4,7 +4,6 @@ * @licence: MIT */ -#include #define _CRT_SECURE_NO_WARNINGS #include From 1c23aadc4559f8750dd2a7219f8d480788fb7459 Mon Sep 17 00:00:00 2001 From: Adrien GIVRY Date: Tue, 21 Apr 2026 14:00:43 -0400 Subject: [PATCH 13/13] More code cleanup --- Sources/OvWindowing/include/OvWindowing/Window.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/OvWindowing/include/OvWindowing/Window.h b/Sources/OvWindowing/include/OvWindowing/Window.h index 05959315f..f665a6bd4 100644 --- a/Sources/OvWindowing/include/OvWindowing/Window.h +++ b/Sources/OvWindowing/include/OvWindowing/Window.h @@ -6,10 +6,11 @@ #pragma once -#include "OvTools/Eventing/Event.h" #include #include +#include + #include #include #include