|
|
@ -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) |
|
|
|