Skip to content

Commit e712772

Browse files
committed
Remove TextArea.allow_text_overflow
1 parent bd4b2a8 commit e712772

File tree

7 files changed

+9
-42
lines changed

7 files changed

+9
-42
lines changed

src/seedsigner/gui/components.py

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ class TextArea(BaseComponent):
387387
is_text_centered: bool = True
388388
supersampling_factor: int = 2 # 1 = disabled; 2 = default, double sample (4px square rendered for 1px)
389389
auto_line_break: bool = True
390-
allow_text_overflow: bool = False
391390
is_horizontal_scrolling_enabled: bool = False
392391
horizontal_scroll_speed: int = 40 # px per sec
393392
horizontal_scroll_begin_hold_secs: float = 2.0
@@ -399,10 +398,6 @@ def __post_init__(self):
399398
if self.is_horizontal_scrolling_enabled and self.auto_line_break:
400399
raise Exception("TextArea: Cannot have auto_line_break and horizontal scrolling enabled at the same time")
401400

402-
if self.is_horizontal_scrolling_enabled and not self.allow_text_overflow:
403-
self.allow_text_overflow = True
404-
logger.warning("TextArea: allow_text_overflow gets overridden to True when horizontal scrolling is enabled")
405-
406401
if not self.font_name:
407402
self.font_name = GUIConstants.get_body_font_name()
408403
if not self.font_size:
@@ -459,7 +454,6 @@ def __post_init__(self):
459454
width=self.width - 2*self.edge_padding,
460455
font_name=self.font_name,
461456
font_size=self.font_size,
462-
allow_text_overflow=self.allow_text_overflow,
463457
)
464458

465459
# Other components, like IconTextLine will need to know how wide the actual
@@ -486,14 +480,9 @@ def __post_init__(self):
486480

487481
else:
488482
if total_text_height > self.height:
489-
if not self.allow_text_overflow:
490-
# For now, early into the l10n rollout, we can't enforce strict
491-
# conformance here. Too many screens will just break if this is were
492-
# to raise an exception.
493-
logger.warning(f"Text cannot fit in target rect with this font/size\n\ttotal_text_height: {total_text_height} | self.height: {self.height}")
494-
else:
495-
# Just let it render past the bottom edge
496-
pass
483+
# Let it render past the bottom edge. Will be up to the dev or translator
484+
# to review the screenshot and revise the text as needed.
485+
logger.warning(f"Text cannot fit in target rect with this font/size\n\ttotal_text_height: {total_text_height} | self.height: {self.height}")
497486

498487
else:
499488
# Vertically center the text's starting point
@@ -746,7 +735,6 @@ class ScrollableTextLine(TextArea):
746735
def __post_init__(self):
747736
self.auto_line_break = False
748737
self.is_horizontal_scrolling_enabled = True
749-
self.allow_text_overflow = True
750738
super().__post_init__()
751739

752740

@@ -808,7 +796,6 @@ class IconTextLine(BaseComponent):
808796
font_size: int = None
809797
is_text_centered: bool = False
810798
auto_line_break: bool = False
811-
allow_text_overflow: bool = True
812799
screen_x: int = 0
813800
screen_y: int = 0
814801

@@ -851,7 +838,6 @@ def __post_init__(self):
851838
auto_line_break=False,
852839
screen_x=text_screen_x,
853840
screen_y=self.screen_y,
854-
allow_text_overflow=False,
855841
)
856842
else:
857843
self.label_textarea = None
@@ -871,7 +857,6 @@ def __post_init__(self):
871857
edge_padding=0,
872858
is_text_centered=self.is_text_centered if not self.icon_name else False,
873859
auto_line_break=self.auto_line_break,
874-
allow_text_overflow=self.allow_text_overflow,
875860
screen_x=text_screen_x,
876861
screen_y=value_textarea_screen_y,
877862
)
@@ -1521,7 +1506,6 @@ def __post_init__(self):
15211506
button_kwargs["text"] = self.text
15221507
button_kwargs["font_color"] = self.font_color
15231508
button_kwargs["background_color"] = self.background_color
1524-
button_kwargs["allow_text_overflow"] = True
15251509
button_kwargs["auto_line_break"] = False
15261510
del button_kwargs["horizontal_scroll_begin_hold_secs"]
15271511
del button_kwargs["horizontal_scroll_end_hold_secs"]
@@ -1826,8 +1810,7 @@ def calc_bezier_curve(p1: Tuple[int,int], p2: Tuple[int,int], p3: Tuple[int,int]
18261810
def reflow_text_for_width(text: str,
18271811
width: int,
18281812
font_name=GUIConstants.get_body_font_name(),
1829-
font_size=GUIConstants.get_body_font_size(),
1830-
allow_text_overflow: bool=False) -> list[dict]:
1813+
font_size=GUIConstants.get_body_font_size()) -> list[dict]:
18311814
"""
18321815
Reflows text to fit within `width` by breaking long lines up.
18331816
@@ -1854,9 +1837,6 @@ def reflow_text_for_width(text: str,
18541837
SettingsConstants.LOCALE__JAPANESE,
18551838
SettingsConstants.LOCALE__KOREAN,
18561839
]
1857-
if treat_chars_as_words:
1858-
# Relax UI constraints even if the result isn't optimal
1859-
allow_text_overflow = True
18601840

18611841
# Stores each line of text and its rendering starting x-coord
18621842
text_lines = []
@@ -1904,9 +1884,9 @@ def _binary_len_search(min_index, max_index, word_spacer):
19041884
# Candidate line is possibly shorter than necessary.
19051885
return _binary_len_search(min_index=index, max_index=max_index, word_spacer=word_spacer)
19061886

1907-
if len(text.split()) == 1 and not allow_text_overflow and not treat_chars_as_words:
1908-
# No whitespace chars to split on!
1909-
raise TextDoesNotFitException("Text cannot fit in target rect with this font+size")
1887+
if len(text.split()) == 1 and not treat_chars_as_words:
1888+
# No whitespace chars to split on! Warn but proceed anyway.
1889+
logger.warning("Text cannot fit in target rect with this font+size")
19101890

19111891
# Now we're ready to go line-by-line into our line break binary search!
19121892
for line in text.split("\n"):
@@ -1946,8 +1926,7 @@ def reflow_text_into_pages(text: str,
19461926
height: int,
19471927
font_name=GUIConstants.get_body_font_name(),
19481928
font_size=GUIConstants.get_body_font_size(),
1949-
line_spacer: int = GUIConstants.BODY_LINE_SPACING,
1950-
allow_text_overflow: bool=False) -> list[str]:
1929+
line_spacer: int = GUIConstants.BODY_LINE_SPACING) -> list[str]:
19511930
"""
19521931
Invokes `reflow_text_for_width` above to convert long text into width-limited
19531932
individual text lines and then calculates how many lines will fit on a "page" and
@@ -1958,8 +1937,7 @@ def reflow_text_into_pages(text: str,
19581937
reflowed_lines_dicts = reflow_text_for_width(text=text,
19591938
width=width,
19601939
font_name=font_name,
1961-
font_size=font_size,
1962-
allow_text_overflow=allow_text_overflow)
1940+
font_size=font_size)
19631941

19641942
lines = []
19651943
for line_dict in reflowed_lines_dicts:

src/seedsigner/gui/screens/psbt_screens.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ def __post_init__(self):
722722
text=self.op_return_data.decode(errors="strict"), # "strict" is a good enough heuristic to decide if it's human readable
723723
font_size=GUIConstants.get_top_nav_title_font_size(),
724724
is_text_centered=True,
725-
allow_text_overflow=True,
726725
screen_y=self.top_nav.height + GUIConstants.COMPONENT_PADDING,
727726
height=self.buttons[0].screen_y - self.top_nav.height - 2*GUIConstants.COMPONENT_PADDING,
728727
))

src/seedsigner/gui/screens/screen.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,6 @@ def render_brightness_tip(self, image: Image.Image) -> None:
786786
width=int(rectangle_width/2),
787787
screen_x=chevron_up_icon.screen_x + GUIConstants.ICON_INLINE_FONT_SIZE,
788788
screen_y=chevron_up_icon.screen_y - 2, # -2 to account for Icon's positioning
789-
allow_text_overflow=False
790789
).render()
791790

792791
# TRANSLATOR_NOTE: Decrease QR code screen brightness
@@ -804,7 +803,6 @@ def render_brightness_tip(self, image: Image.Image) -> None:
804803
width=int(rectangle_width/2),
805804
screen_x=chevron_down_icon.screen_x + GUIConstants.ICON_INLINE_FONT_SIZE,
806805
screen_y=chevron_down_icon.screen_y - 2, # -2 to account for Icon's positioning
807-
allow_text_overflow=False
808806
).render()
809807

810808
# Write our temp Image onto the main image
@@ -906,7 +904,6 @@ class LargeIconStatusScreen(ButtonListScreen):
906904
text: str = "" # The body text of the screen
907905
text_edge_padding: int = GUIConstants.EDGE_PADDING
908906
button_data: list = None
909-
allow_text_overflow: bool = False
910907

911908

912909
def __post_init__(self):

src/seedsigner/gui/screens/seed_screens.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,6 @@ def __post_init__(self):
11291129
font_color="orange",
11301130
is_text_centered=True,
11311131
screen_y=screen_y,
1132-
allow_text_overflow=True
11331132
))
11341133
screen_y += char_height + 2
11351134

@@ -1641,7 +1640,6 @@ def __post_init__(self):
16411640
text=self.sign_message_data["message"],
16421641
width=renderer.canvas_width - 2*GUIConstants.EDGE_PADDING,
16431642
height=message_height,
1644-
allow_text_overflow=True,
16451643
)
16461644
self.sign_message_data["paged_message"] = paged
16471645

@@ -1660,7 +1658,6 @@ def __post_init__(self):
16601658
message_display = TextArea(
16611659
text=self.sign_message_data["paged_message"][self.page_num],
16621660
is_text_centered=False,
1663-
allow_text_overflow=True,
16641661
screen_y=start_y,
16651662
)
16661663
self.components.append(message_display)

src/seedsigner/gui/toast.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def __post_init__(self):
4545
auto_line_break=True,
4646
width=self.canvas_width - icon_delta_x - 2 * GUIConstants.COMPONENT_PADDING - 2 * self.outline_thickness,
4747
screen_x=icon_delta_x + GUIConstants.COMPONENT_PADDING,
48-
allow_text_overflow=False,
4948
height_ignores_below_baseline=True,
5049
)
5150

src/seedsigner/views/view.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ def run(self):
357357
title=_("System Error"),
358358
status_headline=self.error[0],
359359
text=self.error[1] + "\n" + self.error[2],
360-
allow_text_overflow=True, # Fit what we can, let the rest go off the edges
361360
)
362361

363362
return Destination(MainMenuView, clear_history=True)
@@ -389,7 +388,6 @@ def run(self):
389388
text=self.error_msg,
390389
button_data=button_data,
391390
show_back_button=False,
392-
allow_text_overflow=True, # Fit what we can, let the rest go off the edges
393391
)
394392

395393
if button_data[selected_menu_num] == self.UPDATE_SETTING:

tests/test_flows_seed.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,6 @@ def inject_mesage_as_paged_message(self, view: View):
519519
text=self.controller.sign_message_data["message"],
520520
width=240 - 2*GUIConstants.EDGE_PADDING,
521521
height=240 - GUIConstants.TOP_NAV_HEIGHT - 3*GUIConstants.EDGE_PADDING - GUIConstants.BUTTON_HEIGHT,
522-
allow_text_overflow=True,
523522
)
524523
self.controller.sign_message_data["paged_message"] = paged
525524

0 commit comments

Comments
 (0)