fix(ui): scale overlay-dialog card width with the font/DPI setting (fixes modal overflow)

Every BeginOverlayDialog is passed a raw pixel card width (550, 620, …), but the fonts and
spacing inside scale with Layout::dpiScale() — which includes the user's font-size setting. At
any non-default scale the content outgrew the fixed card, so text overflowed the card edge and
elements misaligned. Scale the card width by dpiScale() (no-op at the default 1.0 scale) and clamp
it to the viewport so a large scale can't push it off-screen. Fixes all overlay dialogs at once.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 23:47:53 -05:00
parent 2182c060e6
commit d27017daeb

View File

@@ -924,7 +924,15 @@ inline bool BeginOverlayDialog(const char* title, bool* p_open, float cardWidth
ImGuiViewport* vp = ImGui::GetMainViewport();
ImVec2 vp_pos = vp->Pos;
ImVec2 vp_size = vp->Size;
// Dialog widths are authored as raw pixels, but the fonts/spacing inside scale with
// Layout::dpiScale() (which includes the user's font-size setting). Scale the card by the same
// factor so the content doesn't outgrow a fixed card and overflow/misalign at non-default
// scales. No-op at the default scale (dpiScale() == 1). Clamped to the viewport so a large scale
// can't push the card off-screen.
cardWidth *= Layout::dpiScale();
cardWidth = std::min(cardWidth, vp_size.x - 32.0f);
// Fullscreen scrim overlay
ImGui::SetNextWindowPos(vp_pos);
ImGui::SetNextWindowSize(vp_size);