From f0556afd28c59267aac1ca83a15129d87b18bc99 Mon Sep 17 00:00:00 2001 From: DJ Sundog Date: Sun, 2 Aug 2020 13:14:53 -0700 Subject: [PATCH] more menu debug --- SoundslabDisplay.py | 8 +++++--- SoundslabInput.py | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SoundslabDisplay.py b/SoundslabDisplay.py index 1b00bef..26f3df3 100644 --- a/SoundslabDisplay.py +++ b/SoundslabDisplay.py @@ -72,6 +72,8 @@ class SoundslabDisplay: def updateMenu(self, menu_data=None): # always start with a transparent menu overlay image + bg_color = (200, 0, 0, 255) + fg_color = (0, 0, 0, 255) im_menu_overlay = Image.new("RGBA", self.screen_size, (0, 0, 0, 0)) menu_overlay = ImageDraw.Draw(im_menu_overlay) if self.show_menu and menu_data is not None: @@ -88,17 +90,17 @@ class SoundslabDisplay: # a translucent red background rectangle for the menu area itself - menu_overlay.rectangle([(21,21), (self.screen_size[0] - 21,self.screen_size[1] - 21)], (200, 0, 0, 200)) + menu_overlay.rectangle([(21,21), (self.screen_size[0] - 21,self.screen_size[1] - 21)], bg_color) offset_from_top = 21 # start at the 21st row of pixels to draw inside the outer overlay font = ImageFont.truetype(font='/usr/share/fonts/truetype/hack/Hack-Regular.ttf', size=14) for row in menu_data: if row["selected"]: - menu_overlay.rectangle([(21, offset_from_top),(self.screen_size[0] - 21, offset_from_top + 40)], self.bg_color) # highlight background for selected menu item + 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["output"]) # get the size of the text to draw so we can center it in our rectangle for this row print("showing '" + row["output"] + "' 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), offset_from_top + (20 - floor(output_size[1]))), row["output"], font=font, fill=self.fg_color if row["selected"] else self.bg_color) # draw output text in appropriate color + menu_overlay.text(((self.screen_size[0] / 2) - floor(output_size[0] / 2) - 10, offset_from_top + (20 - floor(output_size[1]))), row["output"], font=font, fill=bg_color if row["selected"] else fg_color) # draw output text in appropriate color offset_from_top += 40 # finally, set the current_menu image diff --git a/SoundslabInput.py b/SoundslabInput.py index e305e9f..67dbc51 100644 --- a/SoundslabInput.py +++ b/SoundslabInput.py @@ -143,6 +143,8 @@ while True: {"output": "v", "selected": False} ] ) + else: + display.updateMenu() # test album art display.updateAlbumArt() # test setting up the overlay