diff options
| author | TryTwo <taolas@gmail.com> | 2025-09-17 23:38:36 -0700 |
|---|---|---|
| committer | TryTwo <taolas@gmail.com> | 2025-09-25 16:34:04 -0700 |
| commit | f8a8ddeddfa969e77edef3349782074bcabe1ef7 (patch) | |
| tree | 319d59971ce49d112fe8684f7f5cf40446876442 /Source/Core/VideoCommon | |
| parent | fce5f7c74ed069459b3c298b6e2459dd76f987d7 (diff) | |
OSD / Imgui: Add font size spinbox to Interface Pane.
Adjust some imgui windows to work better with different font sizes.
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/OnScreenUI.cpp | 15 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/PerformanceMetrics.cpp | 60 |
2 files changed, 36 insertions, 39 deletions
diff --git a/Source/Core/VideoCommon/OnScreenUI.cpp b/Source/Core/VideoCommon/OnScreenUI.cpp index 935cec8619..4689bb6321 100644 --- a/Source/Core/VideoCommon/OnScreenUI.cpp +++ b/Source/Core/VideoCommon/OnScreenUI.cpp @@ -263,11 +263,12 @@ void OnScreenUI::DrawDebugText() { // Position under the FPS display. ImGui::SetNextWindowPos( - ImVec2(ImGui::GetIO().DisplaySize.x - 10.f * m_backbuffer_scale, 80.f * m_backbuffer_scale), + ImVec2(ImGui::GetIO().DisplaySize.x - ImGui::GetFontSize() * m_backbuffer_scale, + 80.f * m_backbuffer_scale), ImGuiCond_FirstUseEver, ImVec2(1.0f, 0.0f)); - ImGui::SetNextWindowSizeConstraints( - ImVec2(150.0f * m_backbuffer_scale, 20.0f * m_backbuffer_scale), - ImGui::GetIO().DisplaySize); + ImGui::SetNextWindowSizeConstraints(ImVec2(5.0f * ImGui::GetFontSize() * m_backbuffer_scale, + 2.1f * ImGui::GetFontSize() * m_backbuffer_scale), + ImGui::GetIO().DisplaySize); if (ImGui::Begin("Movie", nullptr, ImGuiWindowFlags_NoFocusOnAppearing)) { auto& movie = Core::System::GetInstance().GetMovie(); @@ -395,6 +396,12 @@ void OnScreenUI::Finalize() DrawChallengesAndLeaderboards(); ImGui::Render(); + // Check for font changes + ImGuiStyle& style = ImGui::GetStyle(); + const int size = Config::Get(Config::MAIN_OSD_FONT_SIZE); + if (size != style.FontSizeBase) + style.FontSizeBase = static_cast<float>(size); + // Create or update fonts. ImDrawData* draw_data = ImGui::GetDrawData(); if (draw_data->Textures != nullptr) diff --git a/Source/Core/VideoCommon/PerformanceMetrics.cpp b/Source/Core/VideoCommon/PerformanceMetrics.cpp index 0093ed4fcb..5a38e1e3c6 100644 --- a/Source/Core/VideoCommon/PerformanceMetrics.cpp +++ b/Source/Core/VideoCommon/PerformanceMetrics.cpp @@ -127,7 +127,6 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) } const float window_padding = 8.f * backbuffer_scale; - const float window_width = 93.f * backbuffer_scale; const ImVec2& display_size = ImGui::GetIO().DisplaySize; const bool display_size_changed = @@ -161,9 +160,8 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) ImGui::SetWindowPos(ImVec2(clamped_window_x, clamped_window_y), ImGuiCond_Always); }; - const float graph_width = 50.f * backbuffer_scale + 3.f * window_width + 2.f * window_padding; - const float graph_height = - std::min(200.f * backbuffer_scale, display_size.y - 85.f * backbuffer_scale); + const float graph_width = display_size.x / 4.0; + const float graph_height = display_size.y / 4.0; const bool stack_vertically = !g_ActiveConfig.bShowGraphs; @@ -171,17 +169,20 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 14.f * backbuffer_scale); if (g_ActiveConfig.bShowGraphs) { + // A font size of 13 is small enough to keep the tick numbers from overlapping too much. + ImGui::PushFont(NULL, 13.0f); + ImGui::PushStyleColor(ImGuiCol_ResizeGrip, 0); + const auto graph_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | + ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav | movable_flag | + ImGuiWindowFlags_NoFocusOnAppearing; ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 4.f * backbuffer_scale)); // Position in the top-right corner of the screen. - ImGui::SetNextWindowPos(ImVec2(window_x, window_y), set_next_position_condition, ImVec2(1.0f, 0.0f)); - ImGui::SetNextWindowSize(ImVec2(graph_width, graph_height)); + ImGui::SetNextWindowSize(ImVec2(graph_width, graph_height), ImGuiCond_FirstUseEver); ImGui::SetNextWindowBgAlpha(bg_alpha); - window_y += graph_height + window_padding; - - if (ImGui::Begin("PerformanceGraphs", nullptr, imgui_flags)) + if (ImGui::Begin("PerformanceGraphs", nullptr, graph_flags)) { static constexpr std::size_t num_ticks = 17; static constexpr std::array<double, num_ticks> tick_marks = {0.0, @@ -203,6 +204,7 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) 2000.0}; clamp_window_position(); + window_y += ImGui::GetWindowHeight(); const DT vblank_time = m_vps_counter.GetDtAvg() + 2 * m_vps_counter.GetDtStd(); const DT frame_time = m_fps_counter.GetDtAvg() + 2 * m_fps_counter.GetDtStd(); @@ -245,25 +247,23 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) ImGui::PopStyleVar(); } ImGui::End(); + ImGui::PopFont(); + ImGui::PopStyleColor(); } if (g_ActiveConfig.bShowSpeed) { // Position in the top-right corner of the screen. - float window_height = 47.f * backbuffer_scale; - ImGui::SetNextWindowPos(ImVec2(window_x, window_y), set_next_position_condition, ImVec2(1.0f, 0.0f)); - ImGui::SetNextWindowSize(ImVec2(window_width, window_height)); ImGui::SetNextWindowBgAlpha(bg_alpha); - if (stack_vertically) - window_y += window_height + window_padding; - else - window_x -= window_width + window_padding; - if (ImGui::Begin("SpeedStats", nullptr, imgui_flags)) { + if (stack_vertically) + window_y += ImGui::GetWindowHeight() + window_padding; + else + window_x -= ImGui::GetWindowWidth() + window_padding; clamp_window_position(); ImGui::TextColored(ImVec4(r, g, b, 1.0f), "Speed:%4.0lf%%", 100.0 * speed); ImGui::TextColored(ImVec4(r, g, b, 1.0f), "Max:%6.0lf%%", 100.0 * GetMaxSpeed()); @@ -273,22 +273,17 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) if (g_ActiveConfig.bShowFPS || g_ActiveConfig.bShowFTimes) { - int count = g_ActiveConfig.bShowFPS + 2 * g_ActiveConfig.bShowFTimes; - float window_height = (12.f + 17.f * count) * backbuffer_scale; - // Position in the top-right corner of the screen. ImGui::SetNextWindowPos(ImVec2(window_x, window_y), set_next_position_condition, ImVec2(1.0f, 0.0f)); - ImGui::SetNextWindowSize(ImVec2(window_width, window_height)); ImGui::SetNextWindowBgAlpha(bg_alpha); - if (stack_vertically) - window_y += window_height + window_padding; - else - window_x -= window_width + window_padding; - if (ImGui::Begin("FPSStats", nullptr, imgui_flags)) { + if (stack_vertically) + window_y += ImGui::GetWindowHeight() + window_padding; + else + window_x -= ImGui::GetWindowWidth() + window_padding; clamp_window_position(); if (g_ActiveConfig.bShowFPS) ImGui::TextColored(ImVec4(r, g, b, 1.0f), "FPS:%7.2lf", fps); @@ -305,22 +300,17 @@ void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) if (g_ActiveConfig.bShowVPS || g_ActiveConfig.bShowVTimes) { - int count = g_ActiveConfig.bShowVPS + 2 * g_ActiveConfig.bShowVTimes; - float window_height = (12.f + 17.f * count) * backbuffer_scale; - // Position in the top-right corner of the screen. ImGui::SetNextWindowPos(ImVec2(window_x, window_y), set_next_position_condition, ImVec2(1.0f, 0.0f)); - ImGui::SetNextWindowSize(ImVec2(window_width, (12.f + 17.f * count) * backbuffer_scale)); ImGui::SetNextWindowBgAlpha(bg_alpha); - if (stack_vertically) - window_y += window_height + window_padding; - else - window_x -= window_width + window_padding; - if (ImGui::Begin("VPSStats", nullptr, imgui_flags)) { + if (stack_vertically) + window_y += ImGui::GetWindowHeight() + window_padding; + else + window_x -= ImGui::GetWindowWidth() + window_padding; clamp_window_position(); if (g_ActiveConfig.bShowVPS) ImGui::TextColored(ImVec4(r, g, b, 1.0f), "VPS:%7.2lf", vps); |
