From 92c2d6694146f164f30060d7621e19006e2fe2df Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 15 Oct 2025 02:03:09 -0700 Subject: [PATCH] Revert "add elide support to Label" This reverts commit 28c3e0e7457345083d93f7b6a909a4103bd50d55. --- system/ui/widgets/button.py | 3 +-- system/ui/widgets/label.py | 34 +++++------------------------- system/ui/widgets/option_dialog.py | 3 +-- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/system/ui/widgets/button.py b/system/ui/widgets/button.py index 25cfe0718a..141f682db0 100644 --- a/system/ui/widgets/button.py +++ b/system/ui/widgets/button.py @@ -88,7 +88,6 @@ class Button(Widget): text_alignment: TextAlignment = TextAlignment.CENTER, text_padding: int = 20, icon=None, - elide_right: bool = False, multi_touch: bool = False, ): @@ -98,7 +97,7 @@ class Button(Widget): self._background_color = BUTTON_BACKGROUND_COLORS[self._button_style] self._label = Label(text, font_size, font_weight, text_alignment, text_padding, - BUTTON_TEXT_COLOR[self._button_style], icon=icon, elide_right=elide_right) + BUTTON_TEXT_COLOR[self._button_style], icon=icon) self._click_callback = click_callback self._multi_touch = multi_touch diff --git a/system/ui/widgets/label.py b/system/ui/widgets/label.py index 52a21ac874..d995ec1b52 100644 --- a/system/ui/widgets/label.py +++ b/system/ui/widgets/label.py @@ -34,17 +34,17 @@ def gui_label( # Elide text to fit within the rectangle if elide_right and text_size.x > rect.width: - _ellipsis = "..." + ellipsis = "..." left, right = 0, len(text) while left < right: mid = (left + right) // 2 - candidate = text[:mid] + _ellipsis + candidate = text[:mid] + ellipsis candidate_size = measure_text_cached(font, candidate, font_size) if candidate_size.x <= rect.width: left = mid + 1 else: right = mid - display_text = text[: left - 1] + _ellipsis if left > 0 else _ellipsis + display_text = text[: left - 1] + ellipsis if left > 0 else ellipsis text_size = measure_text_cached(font, display_text, font_size) # Calculate horizontal position based on alignment @@ -101,8 +101,7 @@ class Label(Widget): text_alignment: TextAlignment = TextAlignment.CENTER, text_padding: int = 20, text_color: rl.Color = DEFAULT_TEXT_COLOR, - icon=None, - elide_right: bool = False + icon = None, ): super().__init__() @@ -113,7 +112,6 @@ class Label(Widget): self._text_padding = text_padding self._text_color = text_color self._icon = icon - self._elide_right = elide_right self.set_text(text) def set_text(self, text): @@ -129,29 +127,7 @@ class Label(Widget): def _update_text(self, text): self._emojis = [] self._text_size = [] - if self._elide_right: - display_text = text - - # 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 text_size.x > content_width: - _ellipsis = "..." - left, right = 0, len(text) - while left < right: - mid = (left + right) // 2 - candidate = text[:mid] + _ellipsis - candidate_size = measure_text_cached(self._font, candidate, self._font_size) - if candidate_size.x <= content_width: - left = mid + 1 - else: - right = mid - display_text = text[: left - 1] + _ellipsis if left > 0 else _ellipsis - - self._text = [display_text] - else: - self._text = wrap_text(self._font, text, self._font_size, self._rect.width - (self._text_padding * 2)) - + self._text = wrap_text(self._font, text, self._font_size, self._rect.width - (self._text_padding*2)) for t in self._text: self._emojis.append(find_emoji(t)) self._text_size.append(measure_text_cached(self._font, t, self._font_size)) diff --git a/system/ui/widgets/option_dialog.py b/system/ui/widgets/option_dialog.py index dab1116642..2034638d9a 100644 --- a/system/ui/widgets/option_dialog.py +++ b/system/ui/widgets/option_dialog.py @@ -26,8 +26,7 @@ class MultiOptionDialog(Widget): # Create scroller with option buttons self.option_buttons = [Button(option, click_callback=lambda opt=option: self._on_option_clicked(opt), - text_alignment=TextAlignment.LEFT, button_style=ButtonStyle.NORMAL, - text_padding=50, elide_right=True) for option in options] + text_alignment=TextAlignment.LEFT, button_style=ButtonStyle.NORMAL) for option in options] self.scroller = Scroller(self.option_buttons, spacing=LIST_ITEM_SPACING) # Buttons set a result; the application loop will clear the overlay and invoke the callback