system/ui: confirm dialog always opens in fullscreen mode (#35192)

confirm dialog always opens in fullscreen mode
pull/35195/head
Dean Lee 1 week ago committed by GitHub
parent b2d414cc8b
commit b5545a6736
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      system/ui/widgets/confirm_dialog.py
  2. 2
      system/ui/widgets/network.py

@ -1,4 +1,5 @@
import pyray as rl import pyray as rl
from openpilot.system.ui.lib.application import gui_app
from openpilot.system.ui.lib.button import gui_button, ButtonStyle from openpilot.system.ui.lib.button import gui_button, ButtonStyle
from openpilot.system.ui.lib.label import gui_text_box from openpilot.system.ui.lib.label import gui_text_box
@ -11,10 +12,9 @@ TEXT_AREA_HEIGHT_REDUCTION = 200
BACKGROUND_COLOR = rl.Color(27, 27, 27, 255) BACKGROUND_COLOR = rl.Color(27, 27, 27, 255)
def confirm_dialog(rect: rl.Rectangle, message: str, confirm_text: str, cancel_text: str = "Cancel") -> int: def confirm_dialog(message: str, confirm_text: str, cancel_text: str = "Cancel") -> int:
# Calculate dialog position and size, centered within the parent rectangle dialog_x = (gui_app.width - DIALOG_WIDTH) / 2
dialog_x = rect.x + (rect.width - DIALOG_WIDTH) / 2 dialog_y = (gui_app.height - DIALOG_HEIGHT) / 2
dialog_y = rect.y + (rect.height - DIALOG_HEIGHT) / 2
dialog_rect = rl.Rectangle(dialog_x, dialog_y, DIALOG_WIDTH, DIALOG_HEIGHT) dialog_rect = rl.Rectangle(dialog_x, dialog_y, DIALOG_WIDTH, DIALOG_HEIGHT)
# Calculate button positions at the bottom of the dialog # Calculate button positions at the bottom of the dialog
@ -27,13 +27,7 @@ def confirm_dialog(rect: rl.Rectangle, message: str, confirm_text: str, cancel_t
yes_button = rl.Rectangle(yes_button_x, button_y, button_width, BUTTON_HEIGHT) yes_button = rl.Rectangle(yes_button_x, button_y, button_width, BUTTON_HEIGHT)
# Draw the dialog background # Draw the dialog background
rl.draw_rectangle( rl.draw_rectangle_rec(dialog_rect, BACKGROUND_COLOR)
int(dialog_rect.x),
int(dialog_rect.y),
int(dialog_rect.width),
int(dialog_rect.height),
BACKGROUND_COLOR,
)
# Draw the message in the dialog, centered # Draw the message in the dialog, centered
text_rect = rl.Rectangle(dialog_rect.x, dialog_rect.y, dialog_rect.width, dialog_rect.height - TEXT_AREA_HEIGHT_REDUCTION) text_rect = rl.Rectangle(dialog_rect.x, dialog_rect.y, dialog_rect.width, dialog_rect.height - TEXT_AREA_HEIGHT_REDUCTION)

@ -75,7 +75,7 @@ class WifiManagerUI:
self.state = StateIdle() self.state = StateIdle()
case StateShowForgetConfirm(network): case StateShowForgetConfirm(network):
result = confirm_dialog(rect, f'Forget Wi-Fi Network "{network.ssid}"?', "Forget") result = confirm_dialog(f'Forget Wi-Fi Network "{network.ssid}"?', "Forget")
if result == 1: if result == 1:
self.forget_network(network) self.forget_network(network)
elif result == 0: elif result == 0:

Loading…
Cancel
Save