NavWidget: standardize back callback (#37479)

clean this up
This commit is contained in:
Shane Smiskol
2026-02-28 00:29:15 -08:00
committed by GitHub
parent 6266feeed2
commit b6f3692b56
11 changed files with 1 additions and 26 deletions

View File

@@ -11,7 +11,6 @@ from openpilot.selfdrive.ui.widgets.ssh_key import SshKeyAction
class DeveloperLayoutMici(NavScroller):
def __init__(self):
super().__init__()
self.set_back_callback(gui_app.pop_widget)
def github_username_callback(username: str):
if username:

View File

@@ -29,7 +29,6 @@ class MiciFccModal(NavWidget):
def __init__(self, file_path: str | None = None, text: str | None = None):
super().__init__()
self.set_back_callback(gui_app.pop_widget)
self._content = HtmlRenderer(file_path=file_path, text=text)
self._scroll_panel = GuiScrollPanel2(horizontal=False)
self._scroll_panel.set_enabled(lambda: self.enabled and not self._swiping_away)
@@ -328,10 +327,6 @@ class DeviceLayoutMici(NavScroller):
self._power_off_btn,
])
# Set up back navigation
# TODO: can this somehow be generic in widgets/__init__.py or application.py?
self.set_back_callback(gui_app.pop_widget)
def _on_regulatory(self):
if not self._fcc_dialog:
self._fcc_dialog = MiciFccModal(os.path.join(BASEDIR, "selfdrive/assets/offroad/mici_fcc.html"))

View File

@@ -223,5 +223,4 @@ class FirehoseLayout(FirehoseLayoutBase, NavWidget):
def __init__(self):
super().__init__()
self.set_back_callback(gui_app.pop_widget)
self._scroll_panel.set_enabled(lambda: self.enabled and not self._swiping_away)

View File

@@ -148,9 +148,6 @@ class NetworkLayoutMici(NavScroller):
metered = ui_state.params.get_bool("GsmMetered")
self._wifi_manager.update_gsm_settings(roaming_enabled, ui_state.params.get("GsmApn") or "", metered)
# Set up back navigation
self.set_back_callback(gui_app.pop_widget)
def _update_state(self):
super()._update_state()

View File

@@ -272,9 +272,6 @@ class WifiUIMici(NavScroller):
def __init__(self, wifi_manager: WifiManager):
super().__init__()
# Set up back navigation
self.set_back_callback(gui_app.pop_widget)
self._loading_animation = LoadingAnimation()
self._wifi_manager = wifi_manager

View File

@@ -49,7 +49,4 @@ class SettingsLayout(NavScroller):
developer_btn,
])
# Set up back navigation
self.set_back_callback(gui_app.pop_widget)
self._font_medium = gui_app.font(FontWeight.MEDIUM)

View File

@@ -12,7 +12,6 @@ PERSONALITY_TO_INT = log.LongitudinalPersonality.schema.enumerants
class TogglesLayoutMici(NavScroller):
def __init__(self):
super().__init__()
self.set_back_callback(gui_app.pop_widget)
self._personality_toggle = BigMultiParamToggle("driving personality", "LongitudinalPersonality", ["aggressive", "standard", "relaxed"])
self._experimental_btn = BigParamControl("experimental mode", "ExperimentalMode")

View File

@@ -35,7 +35,6 @@ class DriverCameraDialog(NavWidget):
if not no_escape:
# TODO: this can grow unbounded, should be given some thought
device.add_interactive_timeout_callback(gui_app.pop_widget)
self.set_back_callback(gui_app.pop_widget)
self.set_back_enabled(not no_escape)
# Load eye icons

View File

@@ -22,7 +22,6 @@ class BigDialogBase(NavWidget, abc.ABC):
def __init__(self):
super().__init__()
self.set_rect(rl.Rectangle(0, 0, gui_app.width, gui_app.height))
self.set_back_callback(gui_app.pop_widget)
class BigDialog(BigDialogBase):

View File

@@ -19,7 +19,6 @@ class PairingDialog(NavWidget):
def __init__(self):
super().__init__()
self.set_back_callback(gui_app.pop_widget)
self._params = Params()
self._qr_texture: rl.Texture | None = None
self._last_qr_generation = float("-inf")

View File

@@ -55,7 +55,6 @@ class NavWidget(Widget, abc.ABC):
def __init__(self):
super().__init__()
self._back_callback: Callable[[], None] | None = None
self._back_button_start_pos: MousePos | None = None
self._swiping_away = False # currently swiping away
self._can_swipe_away = True # swipe away is blocked after certain horizontal movement
@@ -76,9 +75,6 @@ class NavWidget(Widget, abc.ABC):
def set_back_enabled(self, enabled: bool | Callable[[], bool]) -> None:
self._back_enabled = enabled
def set_back_callback(self, callback: Callable[[], None]) -> None:
self._back_callback = callback
def _handle_mouse_event(self, mouse_event: MouseEvent) -> None:
# FIXME: disabling this widget on new push_widget still causes this widget to track mouse events without mouse down
super()._handle_mouse_event(mouse_event)
@@ -167,8 +163,7 @@ class NavWidget(Widget, abc.ABC):
new_y = self._pos_filter.x = 0.0
if new_y > self._rect.height + DISMISS_PUSH_OFFSET - 10:
if self._back_callback is not None:
self._back_callback()
gui_app.pop_widget()
self._playing_dismiss_animation = False
self._back_button_start_pos = None