FullscreenUI: Use constant width/height scale on Android

Fixes achievement notifications being differently sized
depending on the screen rotation.
This commit is contained in:
Stenzek 2025-01-20 00:01:44 +10:00
parent 7c2488c942
commit f219b47e98
No known key found for this signature in database
2 changed files with 17 additions and 2 deletions

View File

@ -2288,7 +2288,8 @@ void Achievements::DrawGameOverlays()
const auto lock = GetLock();
const float margin = std::max(ImGuiManager::GetScreenMargin(), LayoutScale(10.0f));
const float margin =
std::max(ImCeil(ImGuiManager::GetScreenMargin() * ImGuiManager::GetGlobalScale()), LayoutScale(10.0f));
const float spacing = LayoutScale(10.0f);
const float padding = LayoutScale(10.0f);
const ImVec2 image_size =

View File

@ -449,6 +449,8 @@ void ImGuiFullscreen::UploadAsyncTextures()
bool ImGuiFullscreen::UpdateLayoutScale()
{
#ifndef __ANDROID__
static constexpr float LAYOUT_RATIO = LAYOUT_SCREEN_WIDTH / LAYOUT_SCREEN_HEIGHT;
const ImGuiIO& io = ImGui::GetIO();
@ -474,7 +476,19 @@ bool ImGuiFullscreen::UpdateLayoutScale()
UIStyle.RcpLayoutScale = 1.0f / UIStyle.LayoutScale;
return UIStyle.LayoutScale != old_scale;
return (UIStyle.LayoutScale != old_scale);
#else
// On Android, treat a rotated display as always being in landscape mode for FSUI scaling.
// Makes achievement popups readable regardless of the device's orientation, and avoids layout changes.
const ImGuiIO& io = ImGui::GetIO();
const float old_scale = UIStyle.LayoutScale;
UIStyle.LayoutScale = std::max(io.DisplaySize.x, io.DisplaySize.y) / LAYOUT_SCREEN_WIDTH;
UIStyle.RcpLayoutScale = 1.0f / UIStyle.LayoutScale;
return (UIStyle.LayoutScale != old_scale);
#endif
}
ImRect ImGuiFullscreen::CenterImage(const ImVec2& fit_size, const ImVec2& image_size)