Skip to content

Commit

Permalink
Move fast train icon to next to status message.
Browse files Browse the repository at this point in the history
This is a bit more pleasant than having it next to the departure station.
  • Loading branch information
tomwardio committed Feb 9, 2024
1 parent ed452e5 commit b8ff55a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def __init__(
self._status_font = status_font if status_font else font
self._fast_train_icon = fast_train_icon
self._max_clock_width = self._font.calculate_bounds('00:00')[0]
if self._fast_train_icon:
# How far to offset fast train icon from right-hand side.
self._fast_train_offset = self._fast_train_icon.max_bounds()[0] + max(
self._status_font.calculate_bounds('Exp 00:00')[0],
self._status_font.calculate_bounds('Cancelled')[0],
)

self._last_departure = None

Expand All @@ -198,10 +204,7 @@ def render(
departure_time = _time_to_str(departure.departure_time)
self._font.render_text(departure_time, self._screen, x, y)

x += self._max_clock_width + 4
if departure.fast_train and self._fast_train_icon:
self._fast_train_icon.render_glyph(self._screen, x, y)
x += self._fast_train_icon.max_bounds()[0] + 2
x += self._max_clock_width + 2
self._font.render_text(departure.destination, self._screen, x, y)

if departure.cancelled:
Expand All @@ -215,6 +218,11 @@ def render(
status_w, _ = self._status_font.calculate_bounds(status)

self._status_font.render_text(status, self._screen, w - status_w, y)

if departure.fast_train and self._fast_train_icon:
self._fast_train_icon.render_glyph(
self._screen, w - self._fast_train_offset - 2, y
)
return True


Expand Down

0 comments on commit b8ff55a

Please sign in to comment.