ui: fix label text eliding to account for icon width (#36539)

fix label text eliding to account for icon width
This commit is contained in:
Dean Lee
2025-11-04 03:21:20 +08:00
committed by GitHub
parent 1c0b087105
commit 9ce9920ff7

View File

@@ -145,6 +145,8 @@ class Label(Widget):
# Elide text to fit within the rectangle
text_size = measure_text_cached(self._font, text, self._font_size)
content_width = self._rect.width - self._text_padding * 2
if self._icon:
content_width -= self._icon.width + ICON_PADDING
if text_size.x > content_width:
_ellipsis = "..."
left, right = 0, len(text)