tooltip: clamp box width to client on narrow panels; add narrow-client test

This commit is contained in:
2026-07-27 00:05:14 -04:00
parent 7cd0771e45
commit 3876d2d822
3 changed files with 22 additions and 1 deletions
+4 -1
View File
@@ -18,7 +18,10 @@ TooltipBox computeTooltip(int anchorX, int anchorY, int anchorW, int anchorH,
TooltipBox box;
if (textW <= 0 || textH <= 0 || clientW <= 0 || clientH <= 0) return box;
const int boxW = textW + 2 * spec.padX;
// Clamp boxW so it never exceeds the available client span; then clamp x so the (possibly
// reduced) box always sits within [margin, clientW - margin].
const int maxBoxW = clientW - 2 * spec.margin;
const int boxW = (textW + 2 * spec.padX < maxBoxW) ? textW + 2 * spec.padX : maxBoxW;
const int boxH = textH + 2 * spec.padY;
// Horizontal: centre on the anchor, then clamp within [margin, clientW - margin - boxW].