From a5d44c8aca666ca179b8754134a62be8565dab04 Mon Sep 17 00:00:00 2001 From: DanS Date: Tue, 14 Jul 2026 20:10:49 -0500 Subject: [PATCH] fix(overview): size the Export-Key modal to its content, not 85% of the window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Export-Key dialog sized its card to a fixed 85% of the window width. On a large monitor that's ~1570px, but the content is ~900px, and AddressCopyField centers its text-clamped box within the available width — so the address/key fields floated far from their left-aligned "Address:"/"Viewing Key:" labels and read as off-center (more visible after the warning box became a left-aligned DialogWarningHeader). Derive the card width from the address field's own natural (chunked) box width — the widest deterministic element before the key is revealed — mirroring AddressCopyField's boxW math, plus the overlay card's 28px-per-side content inset so the address sits on one line under its label. Adapts to address type (z vs t) and font scale with no magic width; bounded to 85% of the window as an upper safety limit; the revealed key+QR layout adapts to whatever width results. Width-only change — the key fetch/wipe/mask/close logic is untouched. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/ui/windows/key_export_dialog.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ui/windows/key_export_dialog.cpp b/src/ui/windows/key_export_dialog.cpp index 0222aa5..7520c3c 100644 --- a/src/ui/windows/key_export_dialog.cpp +++ b/src/ui/windows/key_export_dialog.cpp @@ -85,9 +85,20 @@ void KeyExportDialog::render(App* app) (void)keyDisplay; (void)copyBtn; - // Modal scales to 85% of the window width. BeginOverlayDialog multiplies the width by - // Layout::dpiScale(); divide it out here so the final card is exactly 85% at any font scale. - const float cardW = (0.85f * ImGui::GetMainViewport()->Size.x) / Layout::dpiScale(); + // Size the card to the address field's own natural width — the widest deterministic element before + // the key is revealed — so the field fills the card and sits under its left-aligned "Address:" label + // instead of floating centered in an over-wide card. This adapts to the address type (z vs t) and the + // font scale automatically (no magic width). Mirrors AddressCopyField's boxW math; the revealed + // key+QR layout adapts to whatever width this yields (it stacks the QR when narrow). Bounded to 85% + // of the window as an upper safety limit. BeginOverlayDialog re-applies dpiScale(), so divide it out. + const std::string chunkedAddr = widgets::ChunkString(s_address, 4); + const float addrPadX = ImGui::GetStyle().FramePadding.x + 4.0f; // matches AddressCopyField + const float addrBoxW = ImGui::CalcTextSize(chunkedAddr.c_str()).x + addrPadX * 2.0f + 2.0f; + // The BlurFloat overlay card insets content by 28px per side (draw_helpers BeginOverlayDialog); add + // that (+ a little slack) so the address box fits on one line under its label instead of wrapping. + const float wantW = addrBoxW + 28.0f * 2.0f + 12.0f; + const float maxW = 0.85f * ImGui::GetMainViewport()->Size.x; + const float cardW = (wantW < maxW ? wantW : maxW) / Layout::dpiScale(); material::OverlayDialogSpec ov; ov.title = title; ov.p_open = &s_open; ov.style = material::OverlayStyle::BlurFloat;