diff --git a/src/ui/material/draw_helpers.h b/src/ui/material/draw_helpers.h index 60fca9a..3955a8f 100644 --- a/src/ui/material/draw_helpers.h +++ b/src/ui/material/draw_helpers.h @@ -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(); diff --git a/src/ui/windows/chat_tab.cpp b/src/ui/windows/chat_tab.cpp index 391eb56..96ca804 100644 --- a/src/ui/windows/chat_tab.cpp +++ b/src/ui/windows/chat_tab.cpp @@ -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);