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;