mirror of
https://github.com/dolphin-emu/dolphin
synced 2025-10-06 00:13:03 +02:00
Merge pull request #13897 from TryTwo/Imgui_Font_Size
Qt/Imgui: Add SpinBox to adjust imgui font size.
This commit is contained in:
@@ -419,6 +419,7 @@ const Info<bool> MAIN_USE_HIGH_CONTRAST_TOOLTIPS{
|
||||
const Info<bool> MAIN_USE_PANIC_HANDLERS{{System::Main, "Interface", "UsePanicHandlers"}, true};
|
||||
const Info<bool> MAIN_ABORT_ON_PANIC_ALERT{{System::Main, "Interface", "AbortOnPanicAlert"}, false};
|
||||
const Info<bool> MAIN_OSD_MESSAGES{{System::Main, "Interface", "OnScreenDisplayMessages"}, true};
|
||||
const Info<int> MAIN_OSD_FONT_SIZE{{System::Main, "Settings", "OSDFontSize"}, 13};
|
||||
const Info<bool> MAIN_SKIP_NKIT_WARNING{{System::Main, "Interface", "SkipNKitWarning"}, false};
|
||||
const Info<bool> MAIN_CONFIRM_ON_STOP{{System::Main, "Interface", "ConfirmStop"}, true};
|
||||
const Info<ShowCursor> MAIN_SHOW_CURSOR{{System::Main, "Interface", "CursorVisibility"},
|
||||
|
@@ -241,6 +241,7 @@ extern const Info<bool> MAIN_USE_HIGH_CONTRAST_TOOLTIPS;
|
||||
extern const Info<bool> MAIN_USE_PANIC_HANDLERS;
|
||||
extern const Info<bool> MAIN_ABORT_ON_PANIC_ALERT;
|
||||
extern const Info<bool> MAIN_OSD_MESSAGES;
|
||||
extern const Info<int> MAIN_OSD_FONT_SIZE;
|
||||
extern const Info<bool> MAIN_SKIP_NKIT_WARNING;
|
||||
extern const Info<bool> MAIN_CONFIRM_ON_STOP;
|
||||
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
|
||||
#include "DolphinQt/Config/ConfigControls/ConfigChoice.h"
|
||||
#include "DolphinQt/Config/ConfigControls/ConfigInteger.h"
|
||||
#include "DolphinQt/Config/ConfigControls/ConfigRadio.h"
|
||||
#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h"
|
||||
#include "DolphinQt/Config/ToolTipControls/ToolTipComboBox.h"
|
||||
@@ -198,6 +199,14 @@ void InterfacePane::CreateInGame()
|
||||
new ConfigBool(tr("Use Panic Handlers"), Config::MAIN_USE_PANIC_HANDLERS);
|
||||
m_checkbox_enable_osd =
|
||||
new ConfigBool(tr("Show On-Screen Display Messages"), Config::MAIN_OSD_MESSAGES);
|
||||
|
||||
m_osd_font_size = new ConfigInteger(12, 40, Config::MAIN_OSD_FONT_SIZE);
|
||||
m_osd_font_size->setMinimumWidth(m_osd_font_size->sizeHint().width() * 2);
|
||||
auto* font_size_layout = new QHBoxLayout;
|
||||
font_size_layout->addWidget(new QLabel(tr("On-Screen Display Font Size: ")));
|
||||
font_size_layout->addWidget(m_osd_font_size);
|
||||
font_size_layout->addStretch();
|
||||
|
||||
m_checkbox_show_active_title =
|
||||
new ConfigBool(tr("Show Active Title in Window Title"), Config::MAIN_SHOW_ACTIVE_TITLE);
|
||||
m_checkbox_pause_on_focus_lost =
|
||||
@@ -228,6 +237,7 @@ void InterfacePane::CreateInGame()
|
||||
groupbox_layout->addWidget(m_checkbox_confirm_on_stop);
|
||||
groupbox_layout->addWidget(m_checkbox_use_panic_handlers);
|
||||
groupbox_layout->addWidget(m_checkbox_enable_osd);
|
||||
groupbox_layout->addLayout(font_size_layout);
|
||||
groupbox_layout->addWidget(m_checkbox_show_active_title);
|
||||
groupbox_layout->addWidget(m_checkbox_pause_on_focus_lost);
|
||||
groupbox_layout->addWidget(mouse_groupbox);
|
||||
@@ -372,6 +382,10 @@ void InterfacePane::AddDescriptions()
|
||||
QT_TR_NOOP("Shows on-screen display messages over the render window. These messages "
|
||||
"disappear after several seconds."
|
||||
"<br><br><dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>");
|
||||
static const char TR_OSD_FONT_SIZE_DESCRIPTION[] =
|
||||
QT_TR_NOOP("Changes the font size of the On Screen Display. Affects features such as the FPS"
|
||||
"display, TAS movie window, and netplay chat."
|
||||
"<br><br><dolphin_emphasis>If unsure, leave this at 13.</dolphin_emphasis>");
|
||||
static constexpr char TR_SHOW_ACTIVE_TITLE_DESCRIPTION[] =
|
||||
QT_TR_NOOP("Shows the active game title in the render window's title bar."
|
||||
"<br><br><dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>");
|
||||
@@ -421,6 +435,8 @@ void InterfacePane::AddDescriptions()
|
||||
|
||||
m_checkbox_enable_osd->SetDescription(tr(TR_ENABLE_OSD_DESCRIPTION));
|
||||
|
||||
m_osd_font_size->SetDescription(tr(TR_OSD_FONT_SIZE_DESCRIPTION));
|
||||
|
||||
m_checkbox_show_active_title->SetDescription(tr(TR_SHOW_ACTIVE_TITLE_DESCRIPTION));
|
||||
|
||||
m_checkbox_pause_on_focus_lost->SetDescription(tr(TR_PAUSE_ON_FOCUS_LOST_DESCRIPTION));
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
class ConfigBool;
|
||||
class ConfigInteger;
|
||||
class ConfigRadioInt;
|
||||
class ConfigStringChoice;
|
||||
class QLabel;
|
||||
@@ -54,6 +55,7 @@ private:
|
||||
ConfigBool* m_checkbox_confirm_on_stop;
|
||||
ConfigBool* m_checkbox_use_panic_handlers;
|
||||
ConfigBool* m_checkbox_enable_osd;
|
||||
ConfigInteger* m_osd_font_size;
|
||||
ConfigBool* m_checkbox_show_active_title;
|
||||
ConfigBool* m_checkbox_pause_on_focus_lost;
|
||||
ConfigRadioInt* m_radio_cursor_visible_movement;
|
||||
|
@@ -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