|
|
@ -1,9 +1,9 @@ |
|
|
|
import pyray as rl |
|
|
|
import pyray as rl |
|
|
|
from openpilot.system.ui.lib.application import gui_app |
|
|
|
from openpilot.system.ui.lib.application import gui_app, DialogResult |
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
# Constants for dialog dimensions and styling |
|
|
|
|
|
|
|
DIALOG_WIDTH = 1520 |
|
|
|
DIALOG_WIDTH = 1520 |
|
|
|
DIALOG_HEIGHT = 600 |
|
|
|
DIALOG_HEIGHT = 600 |
|
|
|
BUTTON_HEIGHT = 160 |
|
|
|
BUTTON_HEIGHT = 160 |
|
|
@ -12,7 +12,7 @@ TEXT_AREA_HEIGHT_REDUCTION = 200 |
|
|
|
BACKGROUND_COLOR = rl.Color(27, 27, 27, 255) |
|
|
|
BACKGROUND_COLOR = rl.Color(27, 27, 27, 255) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def confirm_dialog(message: str, confirm_text: str, cancel_text: str = "Cancel") -> int: |
|
|
|
def confirm_dialog(message: str, confirm_text: str, cancel_text: str = "Cancel") -> DialogResult: |
|
|
|
dialog_x = (gui_app.width - DIALOG_WIDTH) / 2 |
|
|
|
dialog_x = (gui_app.width - DIALOG_WIDTH) / 2 |
|
|
|
dialog_y = (gui_app.height - DIALOG_HEIGHT) / 2 |
|
|
|
dialog_y = (gui_app.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) |
|
|
@ -40,18 +40,18 @@ def confirm_dialog(message: str, confirm_text: str, cancel_text: str = "Cancel") |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# Initialize result; -1 means no action taken yet |
|
|
|
# Initialize result; -1 means no action taken yet |
|
|
|
result = -1 |
|
|
|
result = DialogResult.NO_ACTION |
|
|
|
|
|
|
|
|
|
|
|
# Check for keyboard input for accessibility |
|
|
|
# Check for keyboard input for accessibility |
|
|
|
if rl.is_key_pressed(rl.KeyboardKey.KEY_ENTER): |
|
|
|
if rl.is_key_pressed(rl.KeyboardKey.KEY_ENTER): |
|
|
|
result = 1 # Confirm |
|
|
|
result = DialogResult.CONFIRM |
|
|
|
elif rl.is_key_pressed(rl.KeyboardKey.KEY_ESCAPE): |
|
|
|
elif rl.is_key_pressed(rl.KeyboardKey.KEY_ESCAPE): |
|
|
|
result = 0 # Cancel |
|
|
|
result = DialogResult.CANCEL |
|
|
|
|
|
|
|
|
|
|
|
# Check for button clicks |
|
|
|
# Check for button clicks |
|
|
|
if gui_button(yes_button, confirm_text, button_style=ButtonStyle.PRIMARY): |
|
|
|
if gui_button(yes_button, confirm_text, button_style=ButtonStyle.PRIMARY): |
|
|
|
result = 1 # Confirm |
|
|
|
result = DialogResult.CONFIRM |
|
|
|
if gui_button(no_button, cancel_text): |
|
|
|
if gui_button(no_button, cancel_text): |
|
|
|
result = 0 # Cancel |
|
|
|
result = DialogResult.CANCEL |
|
|
|
|
|
|
|
|
|
|
|
return result |
|
|
|
return result |
|
|
|