MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / draw_menu

Method draw_menu

pager/pager_display.py:1062–1105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1060 selected = 0
1061
1062 def draw_menu():
1063 self.pager.fill_rect(0, 0, self.width, self.height, self.WHITE)
1064 box_y = int(self.height * 0.10)
1065 box_h = int(self.height * 0.80)
1066 self.pager.fill_rect(10, box_y, self.width - 20, box_h, self.WHITE)
1067 self.pager.rect(10, box_y, self.width - 20, box_h, self.BLACK)
1068 self.pager.rect(12, box_y + 2, self.width - 24, box_h - 4, self.BLACK)
1069
1070 title_y = box_y + 15
1071 self.pager.draw_ttf_centered(title_y, "MENU", self.BLACK, self.font_viking, 24)
1072
1073 bright_y = box_y + 60
1074 self.pager.draw_ttf_centered(bright_y, "BRIGHTNESS", self.BLACK, self.font_arial, 16)
1075
1076 bar_y = bright_y + 30
1077 bar_x = 30
1078 bar_w = self.width - 60
1079 bar_h = 20
1080 self.pager.fill_rect(bar_x, bar_y, bar_w, bar_h, self.GRAY)
1081 fill_w = int(bar_w * current_brightness / 100)
1082 self.pager.fill_rect(bar_x, bar_y, fill_w, bar_h, self.BLACK)
1083 self.pager.rect(bar_x, bar_y, bar_w, bar_h, self.BLACK)
1084
1085 pct_y = bar_y + bar_h + 5
1086 self.pager.draw_ttf_centered(pct_y, f"{current_brightness}%", self.BLACK, self.font_arial, 16)
1087
1088 btn_w = 140
1089 btn_h = 32
1090 btn_x = (self.width - btn_w) // 2
1091 btn_gap = 10
1092 font_size = 16
1093 first_btn_y = pct_y + 30
1094
1095 for i, (label, color, _action) in enumerate(options):
1096 btn_y = first_btn_y + i * (btn_h + btn_gap)
1097 if i == selected:
1098 self.pager.fill_rect(btn_x - 4, btn_y - 4, btn_w + 8, btn_h + 8, self.BLACK)
1099 self.pager.fill_rect(btn_x, btn_y, btn_w, btn_h, color)
1100 text_w = self.pager.ttf_width(label, self.font_arial, font_size)
1101 text_x = btn_x + (btn_w - text_w) // 2
1102 text_y = btn_y + (btn_h - font_size) // 2
1103 self.pager.draw_ttf(text_x, text_y, label, self.WHITE, self.font_arial, font_size)
1104
1105 self.pager.flip()
1106
1107 draw_menu()
1108

Callers

nothing calls this directly

Calls 6

fill_rectMethod · 0.45
rectMethod · 0.45
draw_ttf_centeredMethod · 0.45
ttf_widthMethod · 0.45
draw_ttfMethod · 0.45
flipMethod · 0.45

Tested by

no test coverage detected