raylib: add experimental mode + alpha long confirmation dialog + related fixes (#36295)

* here's everything

* just the dev part

* same for exp mode!

* use rich

* fix br not working in p

* html height needs to be different than content/text rect

* fix confirmation

* fix

* fix 2.5s lag

* clean up

* use correct param

* add offroad and engaged callback too

* nl

* lint
This commit is contained in:
Shane Smiskol
2025-10-10 03:03:35 -07:00
committed by GitHub
parent 0f40afa357
commit ddbbcc6f5d
5 changed files with 92 additions and 22 deletions
+5 -3
View File
@@ -3,7 +3,7 @@ from openpilot.system.ui.lib.application import gui_app, FontWeight
from openpilot.system.ui.widgets import DialogResult
from openpilot.system.ui.widgets.button import ButtonStyle, Button
from openpilot.system.ui.widgets.label import Label
from openpilot.system.ui.widgets.html_render import HtmlRenderer
from openpilot.system.ui.widgets.html_render import HtmlRenderer, ElementType
from openpilot.system.ui.widgets import Widget
from openpilot.system.ui.widgets.scroller import Scroller
@@ -19,7 +19,7 @@ class ConfirmDialog(Widget):
def __init__(self, text: str, confirm_text: str, cancel_text: str = "Cancel", rich: bool = False):
super().__init__()
self._label = Label(text, 70, FontWeight.BOLD, text_color=rl.Color(201, 201, 201, 255))
self._html_renderer = HtmlRenderer(text=text)
self._html_renderer = HtmlRenderer(text=text, text_size={ElementType.P: 50})
self._cancel_button = Button(cancel_text, self._cancel_button_callback)
self._confirm_button = Button(confirm_text, self._confirm_button_callback, button_style=ButtonStyle.PRIMARY)
self._rich = rich
@@ -64,7 +64,9 @@ class ConfirmDialog(Widget):
if not self._rich:
self._label.render(text_rect)
else:
self._html_renderer.set_rect(text_rect)
html_rect = rl.Rectangle(text_rect.x, text_rect.y, text_rect.width,
self._html_renderer.get_total_height(int(text_rect.width)))
self._html_renderer.set_rect(html_rect)
self._scroller.render(text_rect)
if rl.is_key_pressed(rl.KeyboardKey.KEY_ENTER):
+2
View File
@@ -121,6 +121,8 @@ class HtmlRenderer(Widget):
is_start_tag, is_end_tag, tag = is_tag(token)
if tag is not None:
if tag == ElementType.BR:
# Close current tag and add a line break
close_tag()
self._add_element(ElementType.BR, "")
elif is_start_tag or is_end_tag: