menu display fine tuning
This commit is contained in:
parent
12a9ff9033
commit
91d28312e3
@ -101,19 +101,20 @@ class SoundslabDisplay:
|
||||
if menu_data["has_next"]:
|
||||
# draw triangle pointing down
|
||||
print("drawing has_next triangle")
|
||||
menu_overlay.polygon([(floor(self.screen_size[0] / 2) - 20, self.screen_size[1] - 56), (floor(self.screen_size[0] / 2), self.screen_size[1] - 23), (floor(self.screen_size[0] / 2) + 20, self.screen_size[1] - 56)], bg_color)
|
||||
menu_overlay.polygon([(floor(self.screen_size[0] / 2) - 20, self.screen_size[1] - 56), (floor(self.screen_size[0] / 2), self.screen_size[1] - 23), (floor(self.screen_size[0] / 2) + 20, self.screen_size[1] - 56)], fill=fg_color)
|
||||
|
||||
# draw three menu rows
|
||||
offset_from_top = 61 # start at the 21st row of pixels to draw inside the outer overlay, add 40 to account for the "prev" indicator row
|
||||
font = ImageFont.truetype(font='/usr/share/fonts/truetype/hack/Hack-Bold.ttf', size=13)
|
||||
font = ImageFont.truetype(font='/usr/share/fonts/truetype/hack/Hack-Bold.ttf', size=15)
|
||||
|
||||
for idx, row in enumerate(menu_data["rows"], start=0):
|
||||
if menu_data["selected"] == idx:
|
||||
menu_overlay.rectangle([(21, offset_from_top),(self.screen_size[0] - 21, offset_from_top + 40)], fg_color) # highlight background for selected menu item
|
||||
|
||||
output_size = menu_overlay.textsize(row) # get the size of the text to draw so we can center it in our rectangle for this row
|
||||
print("output_size for " + row + " is " + str(output_size[0]) + " x " + str(output_size[1]) + " px")
|
||||
print("showing '" + row + "' at (" + str((self.screen_size[0] / 2) - floor(output_size[0] / 2)) + ", " + str(offset_from_top + 20 - floor(output_size[1])) + ")")
|
||||
menu_overlay.text(((self.screen_size[0] / 2) - floor(output_size[0] / 2) - 10, offset_from_top + (20 - floor(output_size[1]))), row, font=font, fill=bg_color if menu_data["selected"] == idx else fg_color) # draw output text in appropriate color
|
||||
menu_overlay.text(((self.screen_size[0] / 2) - floor(output_size[0] / 2) - 11, offset_from_top + (20 - floor(output_size[1]))), row, font=font, fill=bg_color if menu_data["selected"] == idx else fg_color) # draw output text in appropriate color
|
||||
offset_from_top += 40
|
||||
|
||||
# finally, set the current_menu image
|
||||
|
Loading…
Reference in New Issue
Block a user