mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
OSD / Imgui: Add font size spinbox to Interface Pane.
Adjust some imgui windows to work better with different font sizes.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user