From 0fd3d214a417d67c071cb8e103d4cb19693c01b2 Mon Sep 17 00:00:00 2001 From: DanS Date: Fri, 17 Jul 2026 22:35:02 -0500 Subject: [PATCH] fix(ui): clip & left-align overflowing SegmentedControl labels material::SegmentedControl drew each label centred with no clip, so long non-English labels (Russian/German, etc.) overflowed their cell and overlapped neighbours. Left-align on overflow and clip per cell (mirroring the chat modal's segmented helper); the fits-case is visually unchanged. Benefits every caller (contacts, receive, wallets, market). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/ui/material/draw_helpers.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ui/material/draw_helpers.h b/src/ui/material/draw_helpers.h index 3e4d29c..422d541 100644 --- a/src/ui/material/draw_helpers.h +++ b/src/ui/material/draw_helpers.h @@ -1347,10 +1347,17 @@ inline int SegmentedControl(ImDrawList* dl, ImVec2 origin, float totalW, float h ImVec2(cMax.x - 2.0f * dp, cMax.y - 2.0f * dp), WithAlpha(Primary(), 210), (height - 4.0f * dp) * 0.5f); ImVec2 ts = font->CalcTextSizeA(font->LegacySize, FLT_MAX, 0, labels[i]); + // Center when the label fits; otherwise left-align with a small pad (so a long translation clips + // on the right, not on BOTH sides). Clip to the cell so no label can bleed into a neighbouring + // segment or past the rounded track — English fits, but de/es/fr/pt/ru labels can overrun. + const float lpad = 4.0f * dp; + const float tx = (ts.x <= cellW - 2.0f * lpad) ? (cellW - ts.x) * 0.5f : lpad; + dl->PushClipRect(cMin, cMax, true); dl->AddText(font, font->LegacySize, - ImVec2(cMin.x + (cellW - ts.x) * 0.5f, cMin.y + (height - ts.y) * 0.5f), + ImVec2(cMin.x + tx, cMin.y + (height - ts.y) * 0.5f), active ? IM_COL32(255, 255, 255, 255) : (hov ? OnSurface() : OnSurfaceMedium()), labels[i]); + dl->PopClipRect(); ImGui::PushID(i); ImGui::SetCursorScreenPos(cMin); if (ImGui::InvisibleButton(idBase, ImVec2(cellW, height))) clicked = i;