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

Method show_exit_confirmation

pager/pager_display.py:1034–1139  ·  view source on GitHub ↗

Show pause menu. Returns: None=back, 99=main menu, 42=handoff, 0=exit.

(self)

Source from the content-addressed store, hash-verified

1032 # ------------------------------------------------------------------
1033
1034 def show_exit_confirmation(self):
1035 """Show pause menu. Returns: None=back, 99=main menu, 42=handoff, 0=exit."""
1036 self.dialog_showing = True
1037 time.sleep(0.2)
1038
1039 current_brightness = self.pager.get_brightness()
1040 if current_brightness < 0:
1041 current_brightness = self.screen_brightness
1042
1043 green_color = self.pager.rgb(0, 150, 0)
1044 yellow_color = self.pager.rgb(180, 150, 0)
1045 blue_color = self.pager.rgb(50, 100, 220)
1046 red_color = self.pager.rgb(200, 0, 0)
1047
1048 options = [
1049 ("BACK", green_color, None),
1050 ("Main Menu", yellow_color, 99),
1051 ]
1052
1053 launchers = discover_launchers()
1054 for title, path in launchers:
1055 options.append((f"> {title}", blue_color, (42, path)))
1056
1057 options.append(("Exit Ragnar", red_color, 0))
1058
1059 num_options = len(options)
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

Callers 1

handle_input_loopMethod · 0.95

Calls 7

discover_launchersFunction · 0.85
appendMethod · 0.80
sleepMethod · 0.45
get_brightnessMethod · 0.45
rgbMethod · 0.45
wait_buttonMethod · 0.45
set_brightnessMethod · 0.45

Tested by

no test coverage detected