Skip to content
Snippets Groups Projects
Commit 55817704 authored by rahix's avatar rahix
Browse files

fix(simple-menu): Properly draw menu entries


Instead of an ugly hack where spaces are used to pad the entries
background colors, properly draw a rectangle and the text above
it.  No visual change.

Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 839c1344
No related branches found
No related tags found
No related merge requests found
Pipeline #4440 passed
......@@ -222,22 +222,24 @@ class Menu:
"""
string = self.entry2name(value)
if offset != 20 or len(string) < 10:
string = " " + string + " " * 9
else:
if offset == 20 and len(string) >= 10:
# Slowly scroll entry to the side
time_offset = (utime.time_ms() - self.select_time) // int(
self.scroll_speed * 1000
)
time_offset = time_offset % (len(string) - 7) - 1
time_offset = min(len(string) - 10, max(0, time_offset))
string = " " + string[time_offset:]
string = string[time_offset:]
self.disp.rect(
0,
offset,
180,
offset + 20,
col=self.color_1 if index % 2 == 0 else self.color_2,
)
self.disp.print(
string,
posy=offset,
fg=self.color_text,
bg=self.color_1 if index % 2 == 0 else self.color_2,
string, posx=14, posy=offset, fg=self.color_text, bg=None,
)
def draw_menu(self, offset=0):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment