mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-28 14:20:30 +00:00
FullscreenUI: Eliminate last of layout height constants
This commit is contained in:
parent
88a63f04be
commit
7b03b54539
@ -90,8 +90,6 @@ using ImGuiFullscreen::LAYOUT_LARGE_FONT_SIZE;
|
|||||||
using ImGuiFullscreen::LAYOUT_LARGE_POPUP_PADDING;
|
using ImGuiFullscreen::LAYOUT_LARGE_POPUP_PADDING;
|
||||||
using ImGuiFullscreen::LAYOUT_LARGE_POPUP_ROUNDING;
|
using ImGuiFullscreen::LAYOUT_LARGE_POPUP_ROUNDING;
|
||||||
using ImGuiFullscreen::LAYOUT_MEDIUM_FONT_SIZE;
|
using ImGuiFullscreen::LAYOUT_MEDIUM_FONT_SIZE;
|
||||||
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT;
|
|
||||||
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY;
|
|
||||||
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_SPACING;
|
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_SPACING;
|
||||||
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_X_PADDING;
|
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_X_PADDING;
|
||||||
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING;
|
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING;
|
||||||
@ -2107,9 +2105,8 @@ bool FullscreenUI::ShouldOpenToGameList()
|
|||||||
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 =
|
const ImVec2 heading_size = ImVec2(
|
||||||
ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
|
io.DisplaySize.x, UIStyle.LargeFontSize + (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
|
||||||
(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));
|
||||||
|
|
||||||
@ -2127,7 +2124,7 @@ void FullscreenUI::DrawLandingTemplate(ImVec2* menu_pos, ImVec2* menu_size)
|
|||||||
// draw branding
|
// draw branding
|
||||||
{
|
{
|
||||||
const ImVec2 logo_pos = LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING);
|
const ImVec2 logo_pos = LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING);
|
||||||
const ImVec2 logo_size = LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
const ImVec2 logo_size = ImVec2(UIStyle.LargeFontSize, UIStyle.LargeFontSize);
|
||||||
dl->AddImage(s_state.app_icon_texture.get(), logo_pos, logo_pos + logo_size);
|
dl->AddImage(s_state.app_icon_texture.get(), logo_pos, logo_pos + logo_size);
|
||||||
|
|
||||||
const std::string_view heading_text = "DuckStation";
|
const std::string_view heading_text = "DuckStation";
|
||||||
@ -2169,8 +2166,7 @@ void FullscreenUI::DrawLandingTemplate(ImVec2* menu_pos, ImVec2* menu_size)
|
|||||||
s_state.achievements_user_badge_path = Achievements::GetLoggedInUserBadgePath();
|
s_state.achievements_user_badge_path = Achievements::GetLoggedInUserBadgePath();
|
||||||
if (!s_state.achievements_user_badge_path.empty()) [[likely]]
|
if (!s_state.achievements_user_badge_path.empty()) [[likely]]
|
||||||
{
|
{
|
||||||
const ImVec2 badge_size =
|
const ImVec2 badge_size = ImVec2(UIStyle.LargeFontSize, UIStyle.LargeFontSize);
|
||||||
LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY, LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
|
||||||
const ImVec2 badge_pos =
|
const ImVec2 badge_pos =
|
||||||
ImVec2(name_pos.x - badge_size.x - LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING), time_pos.y);
|
ImVec2(name_pos.x - badge_size.x - LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING), time_pos.y);
|
||||||
|
|
||||||
@ -3283,9 +3279,7 @@ void FullscreenUI::DrawIntSpinBoxSetting(SettingsInterface* bsi, std::string_vie
|
|||||||
ImVec2 button_pos(ImGui::GetCursorPos());
|
ImVec2 button_pos(ImGui::GetCursorPos());
|
||||||
|
|
||||||
// Align value text in middle.
|
// Align value text in middle.
|
||||||
ImGui::SetCursorPosY(
|
ImGui::SetCursorPosY(button_pos.y + ((UIStyle.LargeFontSize + padding.y * 2.0f) - UIStyle.LargeFontSize) * 0.5f);
|
||||||
button_pos.y +
|
|
||||||
((LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) + padding.y * 2.0f) - UIStyle.LargeFontSize) * 0.5f);
|
|
||||||
ImGui::TextUnformatted(str_value);
|
ImGui::TextUnformatted(str_value);
|
||||||
|
|
||||||
s32 step = 0;
|
s32 step = 0;
|
||||||
@ -3314,7 +3308,7 @@ void FullscreenUI::DrawIntSpinBoxSetting(SettingsInterface* bsi, std::string_vie
|
|||||||
dlg_value_changed = true;
|
dlg_value_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SetCursorPosY(button_pos.y + (padding.y * 2.0f) + LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + 10.0f));
|
ImGui::SetCursorPosY(button_pos.y + (padding.y * 2.0f) + UIStyle.LargeFontSize + LayoutScale(10.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dlg_value_changed)
|
if (dlg_value_changed)
|
||||||
@ -3795,9 +3789,8 @@ void FullscreenUI::DoClearGameSettings()
|
|||||||
void FullscreenUI::DrawSettingsWindow()
|
void FullscreenUI::DrawSettingsWindow()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
const ImVec2 heading_size =
|
const ImVec2 heading_size = ImVec2(
|
||||||
ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
|
io.DisplaySize.x, UIStyle.LargeFontSize + (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
|
||||||
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
|
|
||||||
|
|
||||||
const float target_bg_alpha = GetBackgroundAlpha();
|
const float target_bg_alpha = GetBackgroundAlpha();
|
||||||
s_state.settings_last_bg_alpha = (target_bg_alpha < s_state.settings_last_bg_alpha) ?
|
s_state.settings_last_bg_alpha = (target_bg_alpha < s_state.settings_last_bg_alpha) ?
|
||||||
@ -5845,17 +5838,10 @@ void FullscreenUI::DrawPostProcessingSettingsPage()
|
|||||||
{
|
{
|
||||||
if (!opt.help_text.empty())
|
if (!opt.help_text.empty())
|
||||||
{
|
{
|
||||||
const float width = ImGui::GetCurrentWindow()->WorkRect.GetWidth();
|
str.format("##help_{}{}", stage_index, opt.name);
|
||||||
const ImVec2 text_size = UIStyle.Font->CalcTextSizeA(UIStyle.MediumFontSize, UIStyle.NormalFontWeight, FLT_MAX,
|
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
|
||||||
width, IMSTR_START_END(opt.help_text));
|
MenuButton(str, opt.help_text, false);
|
||||||
ImVec2 pos, size;
|
ImGui::PopStyleColor();
|
||||||
ImGuiFullscreen::GetMenuButtonFrameBounds(LayoutUnscale(text_size.y), &pos, &size);
|
|
||||||
const ImVec2& frame_padding = ImGui::GetStyle().FramePadding;
|
|
||||||
const ImRect rect = ImRect(pos + frame_padding, pos + size - frame_padding);
|
|
||||||
ImGui::ItemSize(size);
|
|
||||||
RenderShadowedTextClipped(UIStyle.Font, UIStyle.MediumFontSize, UIStyle.NormalFontWeight, rect.Min, rect.Max,
|
|
||||||
ImGui::GetColorU32(ImGuiCol_TextDisabled), opt.help_text, &text_size,
|
|
||||||
ImVec2(0.0f, 0.0f), width, &rect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt.ShouldHide())
|
if (opt.ShouldHide())
|
||||||
@ -6636,9 +6622,8 @@ void FullscreenUI::DrawPatchesOrCheatsSettingsPage(bool cheats)
|
|||||||
ImVec2 button_pos(ImGui::GetCursorPos());
|
ImVec2 button_pos(ImGui::GetCursorPos());
|
||||||
|
|
||||||
// Align value text in middle.
|
// Align value text in middle.
|
||||||
ImGui::SetCursorPosY(
|
ImGui::SetCursorPosY(button_pos.y +
|
||||||
button_pos.y +
|
((UIStyle.LargeFontSize + padding.y * 2.0f) - UIStyle.LargeFontSize) * 0.5f);
|
||||||
((LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) + padding.y * 2.0f) - UIStyle.LargeFontSize) * 0.5f);
|
|
||||||
ImGui::TextUnformatted(visible_value.c_str(), visible_value.end_ptr());
|
ImGui::TextUnformatted(visible_value.c_str(), visible_value.end_ptr());
|
||||||
|
|
||||||
s32 step = 0;
|
s32 step = 0;
|
||||||
@ -6663,8 +6648,7 @@ void FullscreenUI::DrawPatchesOrCheatsSettingsPage(bool cheats)
|
|||||||
range_value_changed = true;
|
range_value_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SetCursorPosY(button_pos.y + (padding.y * 2.0f) +
|
ImGui::SetCursorPosY(button_pos.y + (padding.y * 2.0f) + UIStyle.LargeFontSize + LayoutScale(10.0f));
|
||||||
LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY + 10.0f));
|
|
||||||
|
|
||||||
if (range_value_changed)
|
if (range_value_changed)
|
||||||
{
|
{
|
||||||
@ -7253,9 +7237,8 @@ void FullscreenUI::DrawSaveStateSelector()
|
|||||||
};
|
};
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
const ImVec2 heading_size =
|
const ImVec2 heading_size = ImVec2(
|
||||||
ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
|
io.DisplaySize.x, UIStyle.LargeFontSize + (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
|
||||||
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
|
|
||||||
|
|
||||||
bool closed = false;
|
bool closed = false;
|
||||||
|
|
||||||
@ -7712,9 +7695,8 @@ void FullscreenUI::DrawGameListWindow()
|
|||||||
PopulateGameListEntryList();
|
PopulateGameListEntryList();
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
const ImVec2 heading_size =
|
const ImVec2 heading_size = ImVec2(
|
||||||
ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
|
io.DisplaySize.x, UIStyle.LargeFontSize + (LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
|
||||||
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
|
|
||||||
|
|
||||||
if (BeginFullscreenWindow(ImVec2(0.0f, 0.0f), heading_size, "gamelist_view",
|
if (BeginFullscreenWindow(ImVec2(0.0f, 0.0f), heading_size, "gamelist_view",
|
||||||
MulAlpha(UIStyle.PrimaryColor, GetBackgroundAlpha())))
|
MulAlpha(UIStyle.PrimaryColor, GetBackgroundAlpha())))
|
||||||
|
@ -1363,26 +1363,6 @@ float ImGuiFullscreen::GetMenuButtonAvailableWidth()
|
|||||||
return MenuButtonBounds::CalcAvailWidth();
|
return MenuButtonBounds::CalcAvailWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGuiFullscreen::IsNextMenuButtonClipped(std::string_view str_id, bool has_summary,
|
|
||||||
float y_padding /*= LAYOUT_MENU_BUTTON_Y_PADDING*/)
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
|
||||||
const ImGuiID id = window->GetID(IMSTR_START_END(str_id));
|
|
||||||
const ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
const ImVec2 guessed_pos = window->DC.CursorPos;
|
|
||||||
const ImRect gussed_bb =
|
|
||||||
ImRect(guessed_pos, guessed_pos + ImVec2(style.FramePadding.x * 2.0f,
|
|
||||||
style.FramePadding.y * 2.0f +
|
|
||||||
(has_summary ? MenuButtonBounds::GetSummaryLineHeight(y_padding) :
|
|
||||||
MenuButtonBounds::GetSingleLineHeight(y_padding))));
|
|
||||||
if (!ImGui::IsClippedEx(gussed_bb, id))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// still record it
|
|
||||||
ImGui::ItemSize(gussed_bb.GetSize());
|
|
||||||
return ImGui::ItemAdd(gussed_bb, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGuiFullscreen::MenuButtonFrame(std::string_view str_id, float height, bool enabled, ImRect* item_bb,
|
bool ImGuiFullscreen::MenuButtonFrame(std::string_view str_id, float height, bool enabled, ImRect* item_bb,
|
||||||
bool* visible, bool* hovered, ImGuiButtonFlags flags /*= 0*/,
|
bool* visible, bool* hovered, ImGuiButtonFlags flags /*= 0*/,
|
||||||
float alpha /*= 1.0f*/)
|
float alpha /*= 1.0f*/)
|
||||||
@ -1419,13 +1399,6 @@ void ImGuiFullscreen::DrawWindowTitle(std::string_view title)
|
|||||||
dl->AddLine(line_start, line_end, IM_COL32(255, 255, 255, 255), line_thickness);
|
dl->AddLine(line_start, line_end, IM_COL32(255, 255, 255, 255), line_thickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiFullscreen::GetMenuButtonFrameBounds(float height, ImVec2* pos, ImVec2* size)
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = ImGui::GetCurrentWindowRead();
|
|
||||||
*pos = window->DC.CursorPos;
|
|
||||||
*size = ImVec2(window->WorkRect.GetWidth(), LayoutScale(height) + ImGui::GetStyle().FramePadding.y * 2.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImGuiFullscreen::MenuButtonFrame(std::string_view str_id, bool enabled, const ImRect& bb, bool* visible,
|
bool ImGuiFullscreen::MenuButtonFrame(std::string_view str_id, bool enabled, const ImRect& bb, bool* visible,
|
||||||
bool* hovered, ImGuiButtonFlags flags, float hover_alpha)
|
bool* hovered, ImGuiButtonFlags flags, float hover_alpha)
|
||||||
{
|
{
|
||||||
@ -1548,9 +1521,10 @@ void ImGuiFullscreen::MenuButtonBounds::SetValueSize(const ImVec2& size)
|
|||||||
|
|
||||||
void ImGuiFullscreen::MenuButtonBounds::CalcTitleSize(const std::string_view& title)
|
void ImGuiFullscreen::MenuButtonBounds::CalcTitleSize(const std::string_view& title)
|
||||||
{
|
{
|
||||||
title_size = title.empty() ? ImVec2() :
|
const std::string_view real_title = ImGuiFullscreen::RemoveHash(title);
|
||||||
UIStyle.Font->CalcTextSizeA(UIStyle.LargeFontSize, UIStyle.BoldFontWeight, FLT_MAX,
|
title_size = real_title.empty() ? ImVec2() :
|
||||||
available_non_value_width, IMSTR_START_END(title));
|
UIStyle.Font->CalcTextSizeA(UIStyle.LargeFontSize, UIStyle.BoldFontWeight, FLT_MAX,
|
||||||
|
available_non_value_width, IMSTR_START_END(real_title));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiFullscreen::MenuButtonBounds::CalcSummarySize(const std::string_view& summary)
|
void ImGuiFullscreen::MenuButtonBounds::CalcSummarySize(const std::string_view& summary)
|
||||||
@ -1831,7 +1805,7 @@ bool ImGuiFullscreen::MenuHeadingButton(std::string_view title, std::string_view
|
|||||||
|
|
||||||
const MenuButtonBounds bb(title, value, {});
|
const MenuButtonBounds bb(title, value, {});
|
||||||
bool visible, hovered;
|
bool visible, hovered;
|
||||||
const bool pressed = MenuButtonFrame(title, false, bb.frame_bb, &visible, &hovered);
|
const bool pressed = MenuButtonFrame(title, enabled, bb.frame_bb, &visible, &hovered);
|
||||||
if (!visible)
|
if (!visible)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -36,8 +36,6 @@ static constexpr float LAYOUT_SCREEN_HEIGHT = 720.0f;
|
|||||||
static constexpr float LAYOUT_LARGE_FONT_SIZE = 26.0f;
|
static constexpr float LAYOUT_LARGE_FONT_SIZE = 26.0f;
|
||||||
static constexpr float LAYOUT_MEDIUM_FONT_SIZE = 16.0f;
|
static constexpr float LAYOUT_MEDIUM_FONT_SIZE = 16.0f;
|
||||||
static constexpr float LAYOUT_SMALL_FONT_SIZE = 10.0f;
|
static constexpr float LAYOUT_SMALL_FONT_SIZE = 10.0f;
|
||||||
static constexpr float LAYOUT_MENU_BUTTON_HEIGHT = 50.0f;
|
|
||||||
static constexpr float LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY = 26.0f;
|
|
||||||
static constexpr float LAYOUT_MENU_BUTTON_X_PADDING = 15.0f;
|
static constexpr float LAYOUT_MENU_BUTTON_X_PADDING = 15.0f;
|
||||||
static constexpr float LAYOUT_MENU_BUTTON_Y_PADDING = 10.0f;
|
static constexpr float LAYOUT_MENU_BUTTON_Y_PADDING = 10.0f;
|
||||||
static constexpr float LAYOUT_MENU_BUTTON_SPACING = 6.0f;
|
static constexpr float LAYOUT_MENU_BUTTON_SPACING = 6.0f;
|
||||||
@ -167,7 +165,7 @@ ALWAYS_INLINE static u32 MulAlpha(u32 col32, u32 a)
|
|||||||
|
|
||||||
ALWAYS_INLINE static std::string_view RemoveHash(std::string_view s)
|
ALWAYS_INLINE static std::string_view RemoveHash(std::string_view s)
|
||||||
{
|
{
|
||||||
const std::string_view::size_type pos = s.find('#');
|
const std::string_view::size_type pos = s.find("##");
|
||||||
return (pos != std::string_view::npos) ? s.substr(0, pos) : s;
|
return (pos != std::string_view::npos) ? s.substr(0, pos) : s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,8 +279,6 @@ void BeginMenuButtons(u32 num_items = 0, float y_align = 0.0f, float x_padding =
|
|||||||
float y_spacing = LAYOUT_MENU_BUTTON_SPACING, bool prerender_frame = true);
|
float y_spacing = LAYOUT_MENU_BUTTON_SPACING, bool prerender_frame = true);
|
||||||
void EndMenuButtons();
|
void EndMenuButtons();
|
||||||
float GetMenuButtonAvailableWidth();
|
float GetMenuButtonAvailableWidth();
|
||||||
bool IsNextMenuButtonClipped(std::string_view str_id, bool has_summary, float y_padding = LAYOUT_MENU_BUTTON_Y_PADDING);
|
|
||||||
void GetMenuButtonFrameBounds(float height, ImVec2* pos, ImVec2* size);
|
|
||||||
bool MenuButtonFrame(std::string_view str_id, float height, bool enabled, ImRect* item_bb, bool* visible, bool* hovered,
|
bool MenuButtonFrame(std::string_view str_id, float height, bool enabled, ImRect* item_bb, bool* visible, bool* hovered,
|
||||||
ImGuiButtonFlags flags = 0, float alpha = 1.0f);
|
ImGuiButtonFlags flags = 0, float alpha = 1.0f);
|
||||||
void DrawMenuButtonFrame(const ImVec2& p_min, const ImVec2& p_max, ImU32 fill_col, bool border = true);
|
void DrawMenuButtonFrame(const ImVec2& p_min, const ImVec2& p_max, ImU32 fill_col, bool border = true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user