FullscreenUI: Fix gaps between some UI elements

Backport of 4d8ed49b24
69e0c1681c
This commit is contained in:
Stenzek 2024-05-15 07:03:54 +10:00 committed by Connor McLaughlin
parent 7166c04ff2
commit a0bc8e0ff8
5 changed files with 56 additions and 214 deletions

View File

@ -1240,30 +1240,30 @@ ImGuiStyle::ImGuiStyle()
// Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times. // Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times.
void ImGuiStyle::ScaleAllSizes(float scale_factor) void ImGuiStyle::ScaleAllSizes(float scale_factor)
{ {
WindowPadding = ImTrunc(WindowPadding * scale_factor + ImVec2(0.5f, 0.5f)); WindowPadding = ImVec2(ImCeil(WindowPadding.x * scale_factor), ImCeil(WindowPadding.x * scale_factor));
WindowRounding = ImTrunc(WindowRounding * scale_factor + 0.5f); WindowRounding = ImCeil(WindowRounding * scale_factor);
WindowMinSize = ImTrunc(WindowMinSize * scale_factor + ImVec2(0.5f, 0.5f)); WindowMinSize = ImVec2(ImCeil(WindowMinSize.x * scale_factor), ImCeil(WindowMinSize.y * scale_factor));
ChildRounding = ImTrunc(ChildRounding * scale_factor + 0.5f); ChildRounding = ImCeil(ChildRounding * scale_factor);
PopupRounding = ImTrunc(PopupRounding * scale_factor + 0.5f); PopupRounding = ImCeil(PopupRounding * scale_factor);
FramePadding = ImTrunc(FramePadding * scale_factor + ImVec2(0.5f, 0.5f)); FramePadding = ImVec2(ImCeil(FramePadding.x * scale_factor), ImCeil(FramePadding.y * scale_factor));
FrameRounding = ImTrunc(FrameRounding * scale_factor + 0.5f); FrameRounding = ImCeil(FrameRounding * scale_factor);
ItemSpacing = ImTrunc(ItemSpacing * scale_factor + ImVec2(0.5f, 0.5f)); ItemSpacing = ImVec2(ImCeil(ItemSpacing.x * scale_factor), ImCeil(ItemSpacing.y * scale_factor));
ItemInnerSpacing = ImTrunc(ItemInnerSpacing * scale_factor + ImVec2(0.5f, 0.5f)); ItemInnerSpacing = ImVec2(ImCeil(ItemInnerSpacing.x * scale_factor), ImCeil(ItemInnerSpacing.y * scale_factor));
CellPadding = ImTrunc(CellPadding * scale_factor + ImVec2(0.5f, 0.5f)); CellPadding = ImVec2(ImCeil(CellPadding.x * scale_factor), ImCeil(CellPadding.y * scale_factor));
TouchExtraPadding = ImTrunc(TouchExtraPadding * scale_factor + ImVec2(0.5f, 0.5f)); TouchExtraPadding = ImVec2(ImCeil(TouchExtraPadding.x * scale_factor), ImCeil(TouchExtraPadding.y * scale_factor));
IndentSpacing = ImTrunc(IndentSpacing * scale_factor + 0.5f); IndentSpacing = ImCeil(IndentSpacing * scale_factor);
ColumnsMinSpacing = ImTrunc(ColumnsMinSpacing * scale_factor + 0.5f); ColumnsMinSpacing = ImCeil(ColumnsMinSpacing * scale_factor);
ScrollbarSize = ImTrunc(ScrollbarSize * scale_factor + 0.5f); ScrollbarSize = ImCeil(ScrollbarSize * scale_factor);
ScrollbarRounding = ImTrunc(ScrollbarRounding * scale_factor + 0.5f); ScrollbarRounding = ImCeil(ScrollbarRounding * scale_factor);
GrabMinSize = ImTrunc(GrabMinSize * scale_factor + 0.5f); GrabMinSize = ImCeil(GrabMinSize * scale_factor);
GrabRounding = ImTrunc(GrabRounding * scale_factor + 0.5f); GrabRounding = ImCeil(GrabRounding * scale_factor);
LogSliderDeadzone = ImTrunc(LogSliderDeadzone * scale_factor + 0.5f); LogSliderDeadzone = ImCeil(LogSliderDeadzone * scale_factor);
TabRounding = ImTrunc(TabRounding * scale_factor + 0.5f); TabRounding = ImCeil(TabRounding * scale_factor);
TabMinWidthForCloseButton = (TabMinWidthForCloseButton != FLT_MAX) ? ImTrunc(TabMinWidthForCloseButton * scale_factor + 0.5f) : FLT_MAX; TabMinWidthForCloseButton = (TabMinWidthForCloseButton != FLT_MAX) ? ImCeil(TabMinWidthForCloseButton * scale_factor) : FLT_MAX;
SeparatorTextPadding = ImTrunc(SeparatorTextPadding * scale_factor + ImVec2(0.5f, 0.5f)); SeparatorTextPadding = ImVec2(ImCeil(SeparatorTextPadding.x * scale_factor), ImCeil(SeparatorTextPadding.y * scale_factor));
DisplayWindowPadding = ImTrunc(DisplayWindowPadding * scale_factor + ImVec2(0.5f, 0.5f)); DisplayWindowPadding = ImVec2(ImCeil(DisplayWindowPadding.x * scale_factor), ImCeil(DisplayWindowPadding.y * scale_factor));
DisplaySafeAreaPadding = ImTrunc(DisplaySafeAreaPadding * scale_factor + ImVec2(0.5f, 0.5f)); DisplaySafeAreaPadding = ImVec2(ImCeil(DisplaySafeAreaPadding.x * scale_factor), ImCeil(DisplaySafeAreaPadding.y * scale_factor));
MouseCursorScale = ImTrunc(MouseCursorScale * scale_factor + 0.5f); MouseCursorScale = ImCeil(MouseCursorScale * scale_factor);
} }
ImGuiIO::ImGuiIO() ImGuiIO::ImGuiIO()
@ -12577,7 +12577,7 @@ static void ImGui::NavUpdateWindowing()
bool apply_toggle_layer = false; bool apply_toggle_layer = false;
ImGuiWindow* modal_window = GetTopMostPopupModal(); ImGuiWindow* modal_window = GetTopMostPopupModal();
bool allow_windowing = false; // (modal_window == NULL); // FIXME: This prevent CTRL+TAB from being usable with windows that are inside the Begin-stack of that modal. bool allow_windowing = false;// (modal_window == NULL); // FIXME: This prevent CTRL+TAB from being usable with windows that are inside the Begin-stack of that modal.
if (!allow_windowing) if (!allow_windowing)
g.NavWindowingTarget = NULL; g.NavWindowingTarget = NULL;

View File

@ -122,7 +122,6 @@ using ImGuiFullscreen::BeginNavBar;
using ImGuiFullscreen::CenterImage; using ImGuiFullscreen::CenterImage;
using ImGuiFullscreen::CloseChoiceDialog; using ImGuiFullscreen::CloseChoiceDialog;
using ImGuiFullscreen::CloseFileSelector; using ImGuiFullscreen::CloseFileSelector;
using ImGuiFullscreen::DPIScale;
using ImGuiFullscreen::EndFullscreenColumns; using ImGuiFullscreen::EndFullscreenColumns;
using ImGuiFullscreen::EndFullscreenColumnWindow; using ImGuiFullscreen::EndFullscreenColumnWindow;
using ImGuiFullscreen::EndFullscreenWindow; using ImGuiFullscreen::EndFullscreenWindow;
@ -159,7 +158,6 @@ using ImGuiFullscreen::OpenInputStringDialog;
using ImGuiFullscreen::PopPrimaryColor; using ImGuiFullscreen::PopPrimaryColor;
using ImGuiFullscreen::PushPrimaryColor; using ImGuiFullscreen::PushPrimaryColor;
using ImGuiFullscreen::QueueResetFocus; using ImGuiFullscreen::QueueResetFocus;
using ImGuiFullscreen::RangeButton;
using ImGuiFullscreen::ResetFocusHere; using ImGuiFullscreen::ResetFocusHere;
using ImGuiFullscreen::RightAlignNavButtons; using ImGuiFullscreen::RightAlignNavButtons;
using ImGuiFullscreen::SetFullscreenFooterText; using ImGuiFullscreen::SetFullscreenFooterText;
@ -1181,8 +1179,9 @@ void FullscreenUI::SwitchToLanding()
void FullscreenUI::DrawLandingTemplate(ImVec2* menu_pos, ImVec2* menu_size) void FullscreenUI::DrawLandingTemplate(ImVec2* menu_pos, ImVec2* menu_size)
{ {
const ImGuiIO& io = ImGui::GetIO(); const ImGuiIO& io = ImGui::GetIO();
const ImVec2 heading_size = ImVec2( const ImVec2 heading_size =
io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + LAYOUT_MENU_BUTTON_Y_PADDING * 2.0f + 2.0f)); ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
*menu_pos = ImVec2(0.0f, heading_size.y); *menu_pos = ImVec2(0.0f, heading_size.y);
*menu_size = ImVec2(io.DisplaySize.x, io.DisplaySize.y - heading_size.y - LayoutScale(LAYOUT_FOOTER_HEIGHT)); *menu_size = ImVec2(io.DisplaySize.x, io.DisplaySize.y - heading_size.y - LayoutScale(LAYOUT_FOOTER_HEIGHT));
@ -1807,7 +1806,7 @@ void FullscreenUI::DrawIntRangeSetting(SettingsInterface* bsi, const char* title
if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font)) if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font))
ImGui::OpenPopup(title); ImGui::OpenPopup(title);
ImGui::SetNextWindowSize(LayoutScale(500.0f, 190.0f)); ImGui::SetNextWindowSize(LayoutScale(500.0f, 192.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::PushFont(g_large_font); ImGui::PushFont(g_large_font);
@ -1867,7 +1866,7 @@ void FullscreenUI::DrawIntSpinBoxSetting(SettingsInterface* bsi, const char* tit
manual_input = false; manual_input = false;
} }
ImGui::SetNextWindowSize(LayoutScale(500.0f, 190.0f)); ImGui::SetNextWindowSize(LayoutScale(500.0f, 192.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::PushFont(g_large_font); ImGui::PushFont(g_large_font);
@ -2046,7 +2045,7 @@ void FullscreenUI::DrawFloatSpinBoxSetting(SettingsInterface* bsi, const char* t
manual_input = false; manual_input = false;
} }
ImGui::SetNextWindowSize(LayoutScale(500.0f, 190.0f)); ImGui::SetNextWindowSize(LayoutScale(500.0f, 192.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f)); ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::PushFont(g_large_font); ImGui::PushFont(g_large_font);
@ -2807,8 +2806,9 @@ void FullscreenUI::DoClearGameSettings()
void FullscreenUI::DrawSettingsWindow() void FullscreenUI::DrawSettingsWindow()
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImVec2 heading_size = const ImVec2 heading_size =
ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + LAYOUT_MENU_BUTTON_Y_PADDING * 2.0f + 2.0f)); ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
const float bg_alpha = VMManager::HasValidVM() ? 0.90f : 1.0f; const float bg_alpha = VMManager::HasValidVM() ? 0.90f : 1.0f;
SettingsInterface* bsi = GetEditingSettingsInterface(); SettingsInterface* bsi = GetEditingSettingsInterface();
@ -5353,8 +5353,9 @@ void FullscreenUI::DrawSaveStateSelector(bool is_loading)
return; return;
} }
ImVec2 heading_size = const ImVec2 heading_size =
ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + LAYOUT_MENU_BUTTON_Y_PADDING * 2.0f + 2.0f)); ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
ImGui::PushStyleColor(ImGuiCol_ChildBg, ModAlpha(UIPrimaryColor, 0.9f)); ImGui::PushStyleColor(ImGuiCol_ChildBg, ModAlpha(UIPrimaryColor, 0.9f));
@ -5846,8 +5847,9 @@ void FullscreenUI::DrawGameListWindow()
PopulateGameListEntryList(); PopulateGameListEntryList();
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImVec2 heading_size = const ImVec2 heading_size =
ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + LAYOUT_MENU_BUTTON_Y_PADDING * 2.0f + 2.0f)); ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
const float bg_alpha = VMManager::HasValidVM() ? 0.90f : 1.0f; const float bg_alpha = VMManager::HasValidVM() ? 0.90f : 1.0f;
@ -6292,8 +6294,9 @@ void FullscreenUI::HandleGameListOptions(const GameList::Entry* entry)
void FullscreenUI::DrawGameListSettingsWindow() void FullscreenUI::DrawGameListSettingsWindow()
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
ImVec2 heading_size = ImVec2( const ImVec2 heading_size =
io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + LAYOUT_MENU_BUTTON_Y_PADDING * 2.0f + 2.0f)); ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
const float bg_alpha = VMManager::HasValidVM() ? 0.90f : 1.0f; const float bg_alpha = VMManager::HasValidVM() ? 0.90f : 1.0f;

View File

@ -1442,146 +1442,6 @@ bool ImGuiFullscreen::ThreeWayToggleButton(
return pressed; return pressed;
} }
bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, s32* value, s32 min, s32 max, s32 increment, const char* format,
bool enabled /*= true*/, float height /*= LAYOUT_MENU_BUTTON_HEIGHT*/, ImFont* font /*= g_large_font*/,
ImFont* summary_font /*= g_medium_font*/)
{
ImRect bb;
bool visible, hovered;
bool pressed = MenuButtonFrame(title, enabled, height, &visible, &hovered, &bb);
if (!visible)
return false;
const SmallString value_text = SmallString::from_sprintf(format, *value);
const ImVec2 value_size(ImGui::CalcTextSize(value_text.c_str()));
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
const float text_end = bb.Max.x - value_size.x;
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), ImVec2(text_end, bb.Max.y));
if (!enabled)
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetColorU32(ImGuiCol_TextDisabled));
ImGui::PushFont(font);
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), &title_bb);
ImGui::RenderTextClipped(bb.Min, bb.Max, value_text.c_str(), nullptr, nullptr, ImVec2(1.0f, 0.5f), &bb);
ImGui::PopFont();
if (summary)
{
ImGui::PushFont(summary_font);
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), &summary_bb);
ImGui::PopFont();
}
if (!enabled)
ImGui::PopStyleColor();
if (pressed)
ImGui::OpenPopup(title);
bool changed = false;
ImGui::SetNextWindowSize(LayoutScale(500.0f, 180.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::PushFont(g_large_font);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(20.0f, 20.0f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
LayoutScale(ImGuiFullscreen::LAYOUT_MENU_BUTTON_X_PADDING, ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING));
if (ImGui::BeginPopupModal(title, nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))
{
ImGui::SetNextItemWidth(LayoutScale(450.0f));
changed = ImGui::SliderInt("##value", value, min, max, format, ImGuiSliderFlags_NoInput);
BeginMenuButtons();
if (MenuButton("OK", nullptr, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
ImGui::CloseCurrentPopup();
EndMenuButtons();
ImGui::EndPopup();
}
ImGui::PopStyleVar(4);
ImGui::PopFont();
return changed;
}
bool ImGuiFullscreen::RangeButton(const char* title, const char* summary, float* value, float min, float max, float increment,
const char* format, bool enabled /*= true*/, float height /*= LAYOUT_MENU_BUTTON_HEIGHT*/, ImFont* font /*= g_large_font*/,
ImFont* summary_font /*= g_medium_font*/)
{
ImRect bb;
bool visible, hovered;
bool pressed = MenuButtonFrame(title, enabled, height, &visible, &hovered, &bb);
if (!visible)
return false;
const SmallString value_text = SmallString::from_sprintf(format, *value);
const ImVec2 value_size(ImGui::CalcTextSize(value_text.c_str()));
const float midpoint = bb.Min.y + font->FontSize + LayoutScale(4.0f);
const float text_end = bb.Max.x - value_size.x;
const ImRect title_bb(bb.Min, ImVec2(text_end, midpoint));
const ImRect summary_bb(ImVec2(bb.Min.x, midpoint), ImVec2(text_end, bb.Max.y));
if (!enabled)
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetColorU32(ImGuiCol_TextDisabled));
ImGui::PushFont(font);
ImGui::RenderTextClipped(title_bb.Min, title_bb.Max, title, nullptr, nullptr, ImVec2(0.0f, 0.0f), &title_bb);
ImGui::RenderTextClipped(bb.Min, bb.Max, value_text.c_str(), nullptr, nullptr, ImVec2(1.0f, 0.5f), &bb);
ImGui::PopFont();
if (summary)
{
ImGui::PushFont(summary_font);
ImGui::RenderTextClipped(summary_bb.Min, summary_bb.Max, summary, nullptr, nullptr, ImVec2(0.0f, 0.0f), &summary_bb);
ImGui::PopFont();
}
if (!enabled)
ImGui::PopStyleColor();
if (pressed)
ImGui::OpenPopup(title);
bool changed = false;
ImGui::SetNextWindowSize(LayoutScale(500.0f, 180.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::PushFont(g_large_font);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(20.0f, 20.0f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
LayoutScale(ImGuiFullscreen::LAYOUT_MENU_BUTTON_X_PADDING, ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING));
if (ImGui::BeginPopupModal(title, nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))
{
ImGui::SetNextItemWidth(LayoutScale(450.0f));
changed = ImGui::SliderFloat("##value", value, min, max, format, ImGuiSliderFlags_NoInput);
BeginMenuButtons();
if (MenuButton("OK", nullptr, true, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY))
ImGui::CloseCurrentPopup();
EndMenuButtons();
ImGui::EndPopup();
}
ImGui::PopStyleVar(4);
ImGui::PopFont();
return changed;
}
bool ImGuiFullscreen::MenuButtonWithValue( bool ImGuiFullscreen::MenuButtonWithValue(
const char* title, const char* summary, const char* value, bool enabled, float height, ImFont* font, ImFont* summary_font) const char* title, const char* summary, const char* value, bool enabled, float height, ImFont* font, ImFont* summary_font)
{ {
@ -1666,8 +1526,8 @@ void ImGuiFullscreen::BeginNavBar(float x_padding /*= LAYOUT_MENU_BUTTON_X_PADDI
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, LayoutScale(x_padding, y_padding)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, LayoutScale(x_padding, y_padding));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, LayoutScale(1.0f));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, LayoutScale(1.0f, 1.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, LayoutScale(1.0f, 0.0f));
PushPrimaryColor(); PushPrimaryColor();
} }
@ -2219,8 +2079,8 @@ void ImGuiFullscreen::DrawChoiceDialog()
const float width = LayoutScale(600.0f); const float width = LayoutScale(600.0f);
const float title_height = g_large_font->FontSize + ImGui::GetStyle().FramePadding.y * 2.0f + ImGui::GetStyle().WindowPadding.y * 2.0f; const float title_height = g_large_font->FontSize + ImGui::GetStyle().FramePadding.y * 2.0f + ImGui::GetStyle().WindowPadding.y * 2.0f;
const float height = std::min( const float height = std::min(LayoutScale(480.0f), title_height + (LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
LayoutScale(450.0f), title_height + LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + (LAYOUT_MENU_BUTTON_Y_PADDING * 2.0f)) * LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) *
static_cast<float>(s_choice_dialog_options.size())); static_cast<float>(s_choice_dialog_options.size()));
ImGui::SetNextWindowSize(ImVec2(width, height)); ImGui::SetNextWindowSize(ImVec2(width, height));
ImGui::SetNextWindowPos((ImGui::GetIO().DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)) * 0.5f, ImGui::SetNextWindowPos((ImGui::GetIO().DisplaySize - LayoutScale(0.0f, LAYOUT_FOOTER_HEIGHT)) * 0.5f,

View File

@ -66,30 +66,13 @@ namespace ImGuiFullscreen
extern ImVec4 UISecondaryWeakColor; extern ImVec4 UISecondaryWeakColor;
extern ImVec4 UISecondaryTextColor; extern ImVec4 UISecondaryTextColor;
static __fi float DPIScale(float v) { return ImGui::GetIO().DisplayFramebufferScale.x * v; } static __fi float LayoutScale(float v) { return ImCeil(g_layout_scale * v); }
static __fi float DPIScale(int v) { return ImGui::GetIO().DisplayFramebufferScale.x * static_cast<float>(v); } static __fi ImVec2 LayoutScale(const ImVec2& v) { return ImVec2(ImCeil(v.x * g_layout_scale), ImCeil(v.y * g_layout_scale)); }
static __fi ImVec2 LayoutScale(float x, float y) { return ImVec2(ImCeil(x * g_layout_scale), ImCeil(y * g_layout_scale)); }
static __fi ImVec2 DPIScale(const ImVec2& v) static __fi float LayoutUnscale(float v) { return ImCeil(g_rcp_layout_scale * v); }
{ static __fi ImVec2 LayoutUnscale(const ImVec2& v) { return ImVec2(ImCeil(v.x * g_rcp_layout_scale), ImCeil(v.y * g_rcp_layout_scale)); }
const ImVec2& fbs = ImGui::GetIO().DisplayFramebufferScale; static __fi ImVec2 LayoutUnscale(float x, float y) { return ImVec2(ImCeil(x * g_rcp_layout_scale), ImCeil(y * g_rcp_layout_scale)); }
return ImVec2(v.x * fbs.x, v.y * fbs.y);
}
static __fi float WindowWidthScale(float v) { return ImGui::GetWindowWidth() * v; }
static __fi float WindowHeightScale(float v) { return ImGui::GetWindowHeight() * v; }
static __fi float LayoutScale(float v) { return g_layout_scale * v; }
static __fi ImVec2 LayoutScale(const ImVec2& v) { return ImVec2(v.x * g_layout_scale, v.y * g_layout_scale); }
static __fi ImVec2 LayoutScale(float x, float y) { return ImVec2(x * g_layout_scale, y * g_layout_scale); }
static __fi ImVec2 LayoutScaleAndOffset(float x, float y)
{
return ImVec2(g_layout_padding_left + x * g_layout_scale, g_layout_padding_top + y * g_layout_scale);
}
static __fi float LayoutUnscale(float v) { return g_rcp_layout_scale * v; }
static __fi ImVec2 LayoutUnscale(const ImVec2& v) { return ImVec2(v.x * g_rcp_layout_scale, v.y * g_rcp_layout_scale); }
static __fi ImVec2 LayoutUnscale(float x, float y) { return ImVec2(x * g_rcp_layout_scale, y * g_rcp_layout_scale); }
static __fi ImVec4 ModAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, a); } static __fi ImVec4 ModAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, a); }
static __fi ImVec4 MulAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, v.w * a); } static __fi ImVec4 MulAlpha(const ImVec4& v, float a) { return ImVec4(v.x, v.y, v.z, v.w * a); }
@ -188,10 +171,6 @@ namespace ImGuiFullscreen
ImFont* font = g_large_font, ImFont* summary_font = g_medium_font); ImFont* font = g_large_font, ImFont* summary_font = g_medium_font);
bool ThreeWayToggleButton(const char* title, const char* summary, std::optional<bool>* v, bool enabled = true, bool ThreeWayToggleButton(const char* title, const char* summary, std::optional<bool>* v, bool enabled = true,
float height = LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = g_large_font, ImFont* summary_font = g_medium_font); float height = LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = g_large_font, ImFont* summary_font = g_medium_font);
bool RangeButton(const char* title, const char* summary, s32* value, s32 min, s32 max, s32 increment, const char* format = "%d",
bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = g_large_font, ImFont* summary_font = g_medium_font);
bool RangeButton(const char* title, const char* summary, float* value, float min, float max, float increment, const char* format = "%f",
bool enabled = true, float height = LAYOUT_MENU_BUTTON_HEIGHT, ImFont* font = g_large_font, ImFont* summary_font = g_medium_font);
bool EnumChoiceButtonImpl(const char* title, const char* summary, s32* value_pointer, bool EnumChoiceButtonImpl(const char* title, const char* summary, s32* value_pointer,
const char* (*to_display_name_function)(s32 value, void* opaque), void* opaque, u32 count, bool enabled, float height, ImFont* font, const char* (*to_display_name_function)(s32 value, void* opaque), void* opaque, u32 count, bool enabled, float height, ImFont* font,
ImFont* summary_font); ImFont* summary_font);

View File

@ -543,12 +543,12 @@ bool ImGuiManager::AddImGuiFonts(bool fullscreen_fonts)
if (fullscreen_fonts) if (fullscreen_fonts)
{ {
const float medium_font_size = std::ceil(ImGuiFullscreen::LayoutScale(ImGuiFullscreen::LAYOUT_MEDIUM_FONT_SIZE)); const float medium_font_size = ImGuiFullscreen::LayoutScale(ImGuiFullscreen::LAYOUT_MEDIUM_FONT_SIZE);
s_medium_font = AddTextFont(medium_font_size); s_medium_font = AddTextFont(medium_font_size);
if (!s_medium_font || !AddIconFonts(medium_font_size)) if (!s_medium_font || !AddIconFonts(medium_font_size))
return false; return false;
const float large_font_size = std::ceil(ImGuiFullscreen::LayoutScale(ImGuiFullscreen::LAYOUT_LARGE_FONT_SIZE)); const float large_font_size = ImGuiFullscreen::LayoutScale(ImGuiFullscreen::LAYOUT_LARGE_FONT_SIZE);
s_large_font = AddTextFont(large_font_size); s_large_font = AddTextFont(large_font_size);
if (!s_large_font || !AddIconFonts(large_font_size)) if (!s_large_font || !AddIconFonts(large_font_size))
return false; return false;