ui: cycle custom button navigation

This commit is contained in:
royjr
2026-08-16 16:27:59 -04:00
parent 5426b6af86
commit c36db99c2d
5 changed files with 16 additions and 32 deletions
+6 -11
View File
@@ -44,8 +44,7 @@ class MainLayout(Widget):
self._custom_button_callbacks = {
CustomButtonAction.BOOKMARK: self._on_bookmark_clicked,
CustomButtonAction.QUIET_MODE: self._toggle_quiet_mode,
CustomButtonAction.ONROAD_HOME: self._toggle_home,
CustomButtonAction.ONROAD_SETTINGS: self._toggle_settings,
CustomButtonAction.CYCLE_UI: self._cycle_ui,
}
self._sidebar_rect = rl.Rectangle(0, 0, 0, 0)
@@ -130,18 +129,14 @@ class MainLayout(Widget):
self._set_current_layout(MainState.ONROAD)
self._sidebar.set_visible(False)
def _toggle_home(self):
if self._current_mode == MainState.HOME:
self._show_onroad()
else:
def _cycle_ui(self):
if self._current_mode == MainState.ONROAD:
self._set_current_layout(MainState.HOME)
self._sidebar.set_visible(True)
def _toggle_settings(self):
if self._current_mode == MainState.SETTINGS:
self._show_onroad()
else:
elif self._current_mode == MainState.HOME:
self._on_settings_clicked()
else:
self._show_onroad()
def _on_bookmark_clicked(self):
for service in ('bookmarkButton', 'userBookmark'):
+7 -11
View File
@@ -39,8 +39,7 @@ class MiciMainLayout(Scroller):
self._custom_button_callbacks = {
CustomButtonAction.BOOKMARK: self._on_bookmark_clicked,
CustomButtonAction.QUIET_MODE: self._toggle_quiet_mode,
CustomButtonAction.ONROAD_HOME: self._toggle_home,
CustomButtonAction.ONROAD_SETTINGS: self._toggle_settings,
CustomButtonAction.CYCLE_UI: self._cycle_ui,
}
# Initialize widget rects
@@ -171,17 +170,14 @@ class MiciMainLayout(Scroller):
def _layout_visible(self, layout: Widget) -> bool:
return abs(layout.rect.x - self._rect.x) < self._rect.width / 2
def _toggle_home(self):
if gui_app.get_active_widget() is self and self._layout_visible(self._home_layout):
self._show_layout(self._onroad_layout)
else:
self._show_layout(self._home_layout)
def _toggle_settings(self):
def _cycle_ui(self):
if gui_app.widget_in_stack(self._settings_layout):
self._show_layout(self._onroad_layout)
elif not gui_app.widget_in_stack(self._onboarding_window):
gui_app.push_widget(self._settings_layout)
elif gui_app.get_active_widget() is self and self._layout_visible(self._home_layout):
if not gui_app.widget_in_stack(self._onboarding_window):
gui_app.push_widget(self._settings_layout)
else:
self._show_layout(self._home_layout)
def _on_body_changed(self):
self._car_onroad_layout.set_visible(not ui_state.is_body)
@@ -7,8 +7,7 @@ class CustomButtonAction(IntEnum):
NONE = 0
BOOKMARK = 1
QUIET_MODE = 2
ONROAD_HOME = 3
ONROAD_SETTINGS = 4
CYCLE_UI = 3
def handle_custom_button(sm, params, callbacks):
@@ -2192,11 +2192,7 @@
},
{
"value": 3,
"label": "Onroad / Home"
},
{
"value": 4,
"label": "Onroad / Settings"
"label": "Cycle Onroad / Home / Settings"
}
]
},
@@ -22,9 +22,7 @@ sections:
- value: 2
label: Quiet Mode
- value: 3
label: Onroad / Home
- value: 4
label: Onroad / Settings
label: Cycle Onroad / Home / Settings
- key: HyundaiLongitudinalTuning
widget: multiple_button
title: Custom Longitudinal Tuning