fix(overview): size the Export-Key modal to its content, not 85% of the window

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) <noreply@anthropic.com>
This commit is contained in:
2026-07-14 20:10:49 -05:00
parent 1a41dec8d8
commit a5d44c8aca

View File

@@ -85,9 +85,20 @@ void KeyExportDialog::render(App* app)
(void)keyDisplay; (void)keyDisplay;
(void)copyBtn; (void)copyBtn;
// Modal scales to 85% of the window width. BeginOverlayDialog multiplies the width by // Size the card to the address field's own natural width — the widest deterministic element before
// Layout::dpiScale(); divide it out here so the final card is exactly 85% at any font scale. // the key is revealed — so the field fills the card and sits under its left-aligned "Address:" label
const float cardW = (0.85f * ImGui::GetMainViewport()->Size.x) / Layout::dpiScale(); // 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; material::OverlayDialogSpec ov;
ov.title = title; ov.p_open = &s_open; ov.title = title; ov.p_open = &s_open;
ov.style = material::OverlayStyle::BlurFloat; ov.style = material::OverlayStyle::BlurFloat;