feat(chat): footer buttons never overflow the card at large scale / long locales (F088)

UX audit (deferred HiDPI item, choice a): instead of a one-off 1.5x spot-check, the chat overlay
dialogs now fit their footer buttons at runtime. New material::OverlayFooterFitScale() returns 1.0
when the fixed-width buttons already fit the card's content width (so English/short layouts are
unchanged) and shrinks them proportionally only when they would overflow — e.g. long de/ru labels
at font_scale 1.5. Wired into all five chat dialog footers (new-conversation, export-confirm,
verify, delete-conversation 3-button, sensitive-vault). Overflow is now impossible at any scale.

Build + tests + hygiene green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 17:49:26 -06:00
co-authored by Claude Opus 4.8
parent f73d6a2f4c
commit 23a5aafe99
2 changed files with 22 additions and 6 deletions
+11
View File
@@ -1781,6 +1781,17 @@ inline void PlaceOverlayDialogActions(float totalWidth)
ImGui::SetCursorPosX(rowStartX + std::max(0.0f, (contentW - totalWidth) * 0.5f));
}
// Proportional shrink factor so a footer's fixed-width buttons never overflow the card's content width
// (e.g. long de/ru labels at a large font scale). Returns 1.0 when they already fit, so short/English
// layouts are unchanged. Multiply each button width by the result before BeginOverlayDialogFooter. (F088)
inline float OverlayFooterFitScale(float buttonWidthSum, float gapSum)
{
const float avail = ImGui::GetContentRegionAvail().x;
const float budget = avail - gapSum;
if (buttonWidthSum <= 0.0f || budget <= 0.0f || buttonWidthSum <= budget) return 1.0f;
return budget / buttonWidthSum;
}
inline void BeginOverlayDialogFooter(float totalActionWidth, bool drawSeparator = true)
{
ImGui::Spacing();
+11 -6
View File
@@ -2314,9 +2314,10 @@ void RenderChatTab(App* app)
ImGui::Dummy(ImVec2(0, Layout::spacingMd()));
const bool canSend = newAddrIsZ && s_new_msg[0] != '\0';
const float actionW = std::max(130.0f * dp,
float actionW = std::max(130.0f * dp,
ImGui::CalcTextSize(TR("chat_new_send")).x + ImGui::GetStyle().FramePadding.x * 2.0f + 24.0f * dp);
const float actionGap = Layout::spacingSm();
actionW *= material::OverlayFooterFitScale(actionW * 2.0f, actionGap); // F088
material::BeginOverlayDialogFooter(actionW * 2.0f + actionGap, /*drawSeparator=*/false);
if (!canSend) ImGui::BeginDisabled();
@@ -2372,6 +2373,7 @@ void RenderChatTab(App* app)
const float egap = ImGui::GetStyle().ItemSpacing.x;
float wExp = std::max(110.0f * edp, ImGui::CalcTextSize(TR("chat_export_confirm_btn")).x + 24.0f * edp);
float wCan = std::max(90.0f * edp, ImGui::CalcTextSize(TR("chat_cancel")).x + 24.0f * edp);
{ float fit = material::OverlayFooterFitScale(wExp + wCan, egap); wExp *= fit; wCan *= fit; } // F088
material::BeginOverlayDialogFooter(wExp + wCan + egap, false);
if (material::TactileButton(TR("chat_export_confirm_btn"), ImVec2(wExp, 0))) {
// Human-readable title is translated; the machine-readable cid: line stays English. (F075)
@@ -2432,6 +2434,7 @@ void RenderChatTab(App* app)
const float fgap = ImGui::GetStyle().ItemSpacing.x;
float wCopy = std::max(110.0f * fdp, ImGui::CalcTextSize(TR("chat_verify_copy")).x + 24.0f * fdp);
float wClose = std::max(90.0f * fdp, ImGui::CalcTextSize(TR("chat_cancel")).x + 24.0f * fdp);
{ float fit = material::OverlayFooterFitScale(wCopy + wClose, fgap); wCopy *= fit; wClose *= fit; } // F088
material::BeginOverlayDialogFooter(wCopy + wClose + fgap, false);
if (material::TactileButton(TR("chat_verify_copy"), ImVec2(wCopy, 0))) {
ImGui::SetClipboardText(fp->peerPubKey.c_str());
@@ -2549,9 +2552,10 @@ void RenderChatTab(App* app)
return ImGui::CalcTextSize(t).x + ImGui::GetStyle().FramePadding.x * 2.0f + 20.0f * dp;
};
const float gap2 = Layout::spacingSm();
const float wDel = std::max(100.0f * dp, textW(TR("chat_delete_confirm")));
const float wBlk = std::max(130.0f * dp, textW(TR("chat_delete_block")));
const float wCan = std::max(90.0f * dp, textW(TR("chat_cancel")));
float wDel = std::max(100.0f * dp, textW(TR("chat_delete_confirm")));
float wBlk = std::max(130.0f * dp, textW(TR("chat_delete_block")));
float wCan = std::max(90.0f * dp, textW(TR("chat_cancel")));
{ float fit = material::OverlayFooterFitScale(wDel + wBlk + wCan, gap2 * 2.0f); wDel *= fit; wBlk *= fit; wCan *= fit; } // F088
material::BeginOverlayDialogFooter(wDel + wBlk + wCan + gap2 * 2.0f, /*drawSeparator=*/false);
// Cancel first with primary emphasis — the safe default no longer looks like a delete button. (F041)
@@ -2810,8 +2814,9 @@ void RenderChatTab(App* app)
};
const float gap2 = Layout::spacingSm();
const float wAct = std::max(160.0f * dp, ImGui::CalcTextSize(actLabel).x + 40.0f * dp);
const float wCan = std::max(90.0f * dp, ImGui::CalcTextSize(TR("chat_cancel")).x + 32.0f * dp);
float wAct = std::max(160.0f * dp, ImGui::CalcTextSize(actLabel).x + 40.0f * dp);
float wCan = std::max(90.0f * dp, ImGui::CalcTextSize(TR("chat_cancel")).x + 32.0f * dp);
{ float fit = material::OverlayFooterFitScale(wAct + wCan, gap2); wAct *= fit; wCan *= fit; } // F088
material::BeginOverlayDialogFooter(wAct + wCan + gap2, /*drawSeparator=*/false);
const bool doAct = material::TactileButton(actLabel, ImVec2(wAct, 0));
ImGui::SameLine(0, gap2);