Skip to content

ui: add experimental mode toggle button with visual indicator #35446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 7, 2025

Conversation

deanlee
Copy link
Contributor

@deanlee deanlee commented Jun 4, 2025

reopen #35439 , fix issues

@github-actions github-actions bot added the ui label Jun 4, 2025
@deanlee deanlee force-pushed the pyui_exp_btn branch 5 times, most recently from ffb09c7 to c26b1e9 Compare June 4, 2025 10:40
@deanlee deanlee marked this pull request as ready for review June 4, 2025 10:46
@deanlee deanlee changed the title selfdrive/ui: add experimental mode toggle button with visual indicator ui: add experimental mode toggle button with visual indicator Jun 5, 2025
@@ -51,6 +50,7 @@ def _setup_callbacks(self):
self._layouts[MainState.SETTINGS].set_callbacks(
on_close=lambda: setattr(self, '_current_callback', self._set_mode_for_state)
)
self._layouts[MainState.ONROAD].on_click = self._on_onrad_clicked
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make a standard set_callback function or switch to setting directly?

Comment on lines +100 to +105
# Handle click events if no HUD interaction occurred
if not self._hud_renderer.handle_mouse_event():
if self.on_click and rl.is_mouse_button_pressed(rl.MouseButton.MOUSE_BUTTON_LEFT):
if rl.check_collision_point_rec(rl.get_mouse_position(), self._content_rect):
self.on_click()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to function that handles mouse clicks to prepare for base class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we can handle this better after #35489

self._engageable: bool = False

# State hold mechanism
self._hold_duration = 2.0 # seconds
Copy link
Contributor

@sshane sshane Jun 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this match qt? might be too complicated as first thing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good feature and I've tested it. Qt immediately reverts to the state read from the message, so holding this state briefly helps reduce user confusion—otherwise, it might look like the icon doesn't respond after clicking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know with replay it doesn't work, but on-device is mainly what we care about. We can keep if you don't think it's too much complexity

@deanlee
Copy link
Contributor Author

deanlee commented Jun 7, 2025

I suggest we merge this PR first—if anything comes up, we can always tweak it along the way. Going back and forth slow down progress on other parts.

@sshane sshane merged commit 2031a33 into commaai:master Jun 7, 2025
17 checks passed
@deanlee deanlee deleted the pyui_exp_btn branch June 7, 2025 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants