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: Rahix's avatarRahix <rahix@rahix.de>
parent 839c1344
Pipeline #4440 passed with stages
in 2 minutes and 14 seconds
......@@ -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):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment