From e78e6261ca986d3be4845de772e4105393b06f44 Mon Sep 17 00:00:00 2001 From: Daniel Koepping Date: Tue, 14 Apr 2026 23:19:40 -0700 Subject: [PATCH] Add touch zone for alerts (#37819) * add touch zone for alerts * adjust touch zone * 200 px zones * 50/30 split * adjust zones --- selfdrive/ui/mici/layouts/home.py | 18 +++++++++++++++--- selfdrive/ui/mici/layouts/main.py | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/mici/layouts/home.py b/selfdrive/ui/mici/layouts/home.py index 16a40b6d4..19cca5f35 100644 --- a/selfdrive/ui/mici/layouts/home.py +++ b/selfdrive/ui/mici/layouts/home.py @@ -14,6 +14,8 @@ from openpilot.system.version import RELEASE_BRANCHES HEAD_BUTTON_FONT_SIZE = 40 HOME_PADDING = 8 +SETTINGS_ZONE_WIDTH = 280 +ALERTS_ZONE_WIDTH = 180 NetworkType = log.DeviceState.NetworkType @@ -112,6 +114,7 @@ class MiciHomeLayout(Widget): def __init__(self): super().__init__() self._on_settings_click: Callable | None = None + self._on_alerts_click: Callable | None = None self._alert_count_callback: Callable[[], int] | None = None self._last_refresh = 0 @@ -172,14 +175,23 @@ class MiciHomeLayout(Widget): self._last_refresh = rl.get_time() self._update_params() - def set_callbacks(self, on_settings: Callable | None = None, alert_count_callback: Callable[[], int] | None = None): + def set_callbacks(self, on_settings: Callable | None = None, on_alerts: Callable | None = None, + alert_count_callback: Callable[[], int] | None = None): self._on_settings_click = on_settings + self._on_alerts_click = on_alerts + self._alert_count_callback = alert_count_callback self._alerts_pill.set_alert_count_callback(alert_count_callback) def _handle_mouse_release(self, mouse_pos: MousePos): if not self._did_long_press: - if self._on_settings_click: - self._on_settings_click() + relative_x = mouse_pos.x - self.rect.x + has_alerts = self._alert_count_callback and self._alert_count_callback() > 0 + if relative_x < SETTINGS_ZONE_WIDTH: + if self._on_settings_click: + self._on_settings_click() + elif has_alerts and relative_x > self.rect.width - ALERTS_ZONE_WIDTH: + if self._on_alerts_click: + self._on_alerts_click() self._did_long_press = False def _get_version_text(self) -> tuple[str, str, str, str] | None: diff --git a/selfdrive/ui/mici/layouts/main.py b/selfdrive/ui/mici/layouts/main.py index b25c4af7b..0d0f6308f 100644 --- a/selfdrive/ui/mici/layouts/main.py +++ b/selfdrive/ui/mici/layouts/main.py @@ -60,6 +60,7 @@ class MiciMainLayout(Scroller): def _setup_callbacks(self): self._home_layout.set_callbacks( on_settings=lambda: gui_app.push_widget(self._settings_layout), + on_alerts=lambda: self._scroll_to(self._alerts_layout), alert_count_callback=self._alerts_layout.active_alerts, ) self._onroad_layout.set_click_callback(lambda: self._scroll_to(self._home_layout))