From b5545a6736f7f2e1631afdb14e2b951c81cdf1be Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Tue, 13 May 2025 05:00:18 +0800 Subject: [PATCH] system/ui: confirm dialog always opens in fullscreen mode (#35192) confirm dialog always opens in fullscreen mode --- system/ui/widgets/confirm_dialog.py | 16 +++++----------- system/ui/widgets/network.py | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/system/ui/widgets/confirm_dialog.py b/system/ui/widgets/confirm_dialog.py index e5ca002ecf..7a25682e27 100644 --- a/system/ui/widgets/confirm_dialog.py +++ b/system/ui/widgets/confirm_dialog.py @@ -1,4 +1,5 @@ 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.label import gui_text_box @@ -11,10 +12,9 @@ TEXT_AREA_HEIGHT_REDUCTION = 200 BACKGROUND_COLOR = rl.Color(27, 27, 27, 255) -def confirm_dialog(rect: rl.Rectangle, message: str, confirm_text: str, cancel_text: str = "Cancel") -> int: - # Calculate dialog position and size, centered within the parent rectangle - dialog_x = rect.x + (rect.width - DIALOG_WIDTH) / 2 - dialog_y = rect.y + (rect.height - DIALOG_HEIGHT) / 2 +def confirm_dialog(message: str, confirm_text: str, cancel_text: str = "Cancel") -> int: + dialog_x = (gui_app.width - DIALOG_WIDTH) / 2 + dialog_y = (gui_app.height - DIALOG_HEIGHT) / 2 dialog_rect = rl.Rectangle(dialog_x, dialog_y, DIALOG_WIDTH, DIALOG_HEIGHT) # 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) # Draw the dialog background - rl.draw_rectangle( - int(dialog_rect.x), - int(dialog_rect.y), - int(dialog_rect.width), - int(dialog_rect.height), - BACKGROUND_COLOR, - ) + rl.draw_rectangle_rec(dialog_rect, BACKGROUND_COLOR) # 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) diff --git a/system/ui/widgets/network.py b/system/ui/widgets/network.py index 06448483aa..d94a3facb1 100644 --- a/system/ui/widgets/network.py +++ b/system/ui/widgets/network.py @@ -75,7 +75,7 @@ class WifiManagerUI: self.state = StateIdle() 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: self.forget_network(network) elif result == 0: