ImGuiOverlays: Add blur background to save state selector

This commit is contained in:
Stenzek
2026-04-03 12:57:30 +10:00
parent ffb33c281d
commit 9eaa6735ca
3 changed files with 48 additions and 3 deletions
+36
View File
@@ -1902,6 +1902,42 @@ void FullscreenUI::SetWindowNavWrapping(bool allow_wrap_x /*= false*/, bool allo
}
}
bool FullscreenUI::BeginBlurWindow(const char* name, bool* p_open /* = nullptr */, ImGuiWindowFlags flags /* = 0 */,
bool blur /* = true */)
{
const ImVec4& background = GImGui->Style.Colors[ImGuiCol_WindowBg];
const bool actually_blur = (blur && UIStyle.BlurMenuBackground && CanBlurBackground());
const bool has_background = (background.w != 0.0f);
const bool res = ImGui::Begin(name, nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoBringToFrontOnFocus |
((!has_background || actually_blur) ? ImGuiWindowFlags_NoBackground : 0) | flags);
if (res && actually_blur)
{
ImDrawList* const dl = ImGui::GetWindowDrawList();
ImGuiWindow* const win = ImGui::GetCurrentWindow();
const ImVec2& bg_min = win->Pos;
const ImVec2& bg_max = win->Pos + win->Size;
if (BeginBlurBackground(dl, bg_min, bg_max))
{
if (has_background)
{
dl->AddRectFilled(bg_min, bg_max,
ImGui::GetColorU32(ImVec4(background.x * background.w, background.y * background.w,
background.z * background.w, 1.0f)), win->WindowRounding);
}
EndBlurBackground(dl);
}
else if (has_background)
{
dl->AddRectFilled(bg_min, bg_max, ImGui::GetColorU32(background), win->WindowRounding);
}
}
return res;
}
bool FullscreenUI::IsGamepadInputSource()
{
return (ImGui::GetCurrentContext()->NavInputSource == ImGuiInputSource_Gamepad);
+8
View File
@@ -197,6 +197,13 @@ ALWAYS_INLINE std::string_view RemoveHash(std::string_view s)
return (pos != std::string_view::npos) ? s.substr(0, pos) : s;
}
#if 0
ALWAYS_INLINE ImVec2 ApplyPivot(const ImVec2& pos, const ImVec2& size, const ImVec2& pivot)
{
return ImVec2(pos.x - size.x * pivot.x, pos.y - size.y * pivot.y);
}
#endif
/// Localization support.
#define FSUI_TR_CONTEXT std::string_view("FullscreenUI")
@@ -361,6 +368,7 @@ bool BeginFullscreenWindow(const ImVec2& position, const ImVec2& size, const cha
const ImVec2& padding = ImVec2(), ImGuiWindowFlags flags = 0, bool blur = false);
void EndFullscreenWindow(bool allow_wrap_x = false, bool allow_wrap_y = true);
void SetWindowNavWrapping(bool allow_wrap_x = false, bool allow_wrap_y = true);
bool BeginBlurWindow(const char* name, bool* p_open = nullptr, ImGuiWindowFlags flags = 0, bool blur = true);
bool IsGamepadInputSource();
std::string_view GetControllerIconMapping(std::string_view icon);
+4 -3
View File
@@ -1225,9 +1225,10 @@ void SaveStateSelectorUI::Draw()
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always,
ImVec2(0.5f, 0.5f));
if (ImGui::Begin("##save_state_selector", nullptr,
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar |
ImGuiWindowFlags_NoScrollbar))
if (FullscreenUI::BeginBlurWindow("##save_state_selector", nullptr,
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoInputs |
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar,
UIStyle.BlurMenuBackground))
{
// Leave 2 lines for the legend
const ImGuiStyle& style = ImGui::GetStyle();