mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-23 19:43:44 +08:00
fix(mici/onroad): suppress click on outer drag and bookmark gesture
OnroadViewContainerSP nests a vertical scroller between the outer horizontal scroller and road_view/info_panel. Stock click suppression relies on a child's _touch_valid_callback being gated by its parent scroll panel — with the container in the middle, children were only gated by the inner panel, so an outer L→R drag never invalidated their touch and the click fired on release (immediately popping to home). - Chain children's touch_valid through the container's own touch_valid so outer-scroll state propagates to nested children. - Add OnroadInfoPanel._handle_mouse_release mirroring AugmentedRoadView's bookmark guard, so an R→L bookmark drag on the info panel doesn't fire the click on release.
This commit is contained in:
@@ -28,6 +28,16 @@ class OnroadViewContainerSP(ScrollerSP):
|
||||
self._scroller.set_reset_scroll_at_show(False)
|
||||
self._scroller.set_scrolling_enabled(lambda: abs(self.rect.x) < HORIZONTAL_SETTLE_PX)
|
||||
|
||||
# Inner scroller wraps children's touch_valid via inner panel only. Chain
|
||||
# container's own touch_valid (already wrapped by outer scroller) so an
|
||||
# outer-scroll drag invalidates child touches and suppresses the click —
|
||||
# matches stock behavior when road_view is a direct outer child.
|
||||
for child in (self.road_view, self.onroad_info_panel):
|
||||
inner_touch_valid = child._touch_valid_callback
|
||||
child.set_touch_valid_callback(
|
||||
lambda inner=inner_touch_valid: self._touch_valid() and (inner() if inner else True)
|
||||
)
|
||||
|
||||
def set_rect(self, rect: rl.Rectangle):
|
||||
super().set_rect(rect)
|
||||
self.road_view.set_rect(rect)
|
||||
|
||||
@@ -13,6 +13,7 @@ from openpilot.selfdrive.ui.ui_state import ui_state
|
||||
from openpilot.system.ui.lib.application import gui_app, FontWeight
|
||||
from openpilot.system.ui.lib.multilang import tr
|
||||
from openpilot.system.ui.lib.text_measure import measure_text_cached
|
||||
from openpilot.system.ui.lib.application import MousePos
|
||||
from openpilot.system.ui.widgets import Widget
|
||||
from openpilot.selfdrive.ui.mici.onroad.alert_renderer import AlertRenderer
|
||||
from openpilot.selfdrive.ui.mici.onroad.augmented_road_view import BookmarkIcon
|
||||
@@ -71,6 +72,11 @@ class OnroadInfoPanel(Widget):
|
||||
def is_swiping_left(self) -> bool:
|
||||
return self._bookmark_icon.is_swiping_left()
|
||||
|
||||
def _handle_mouse_release(self, mouse_pos: MousePos) -> None:
|
||||
# Mirror stock AugmentedRoadView: suppress click while bookmark gesture active
|
||||
if not self._bookmark_icon.interacting():
|
||||
super()._handle_mouse_release(mouse_pos)
|
||||
|
||||
def _update_state(self) -> None:
|
||||
sm = ui_state.sm
|
||||
speed_conv = CV.MS_TO_KPH if ui_state.is_metric else CV.MS_TO_MPH
|
||||
|
||||
Reference in New Issue
Block a user