From 00a31ce264399452e27e2fb272b4a02a8b1bce71 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sat, 16 Dec 2023 07:50:39 +0000 Subject: [PATCH] ui: Full Screen Navigation --- CHANGELOGS.md | 4 ++++ .../ui/qt/offroad/sunnypilot/visuals_settings.cc | 10 ++++++++++ selfdrive/ui/qt/onroad.cc | 12 ++++++++++-- selfdrive/ui/qt/onroad.h | 2 ++ selfdrive/ui/ui.cc | 1 + selfdrive/ui/ui.h | 2 ++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGELOGS.md b/CHANGELOGS.md index f3523a410d..36630a042b 100644 --- a/CHANGELOGS.md +++ b/CHANGELOGS.md @@ -5,6 +5,10 @@ sunnypilot - 0.9.6.1 (2023-xx-xx) * UPDATED: Vision-based Turn Speed Control (V-TSC) implementation * Refactored implementation thanks to pfeiferj! * More accurate and consistent velocity calculation to achieve smoother longitudinal control in curves +* UI updates + * RE-ENABLED: Navigation: Full screen support + * Display the map view in full screen + * To switch back to driving view, tap on the border edge\ * Hyundai Bayon Non-SCC 2019 support thanks to polein78! sunnypilot - 0.9.5.2 (2023-12-07) diff --git a/selfdrive/ui/qt/offroad/sunnypilot/visuals_settings.cc b/selfdrive/ui/qt/offroad/sunnypilot/visuals_settings.cc index 0dfe86b317..f75b98ac9e 100644 --- a/selfdrive/ui/qt/offroad/sunnypilot/visuals_settings.cc +++ b/selfdrive/ui/qt/offroad/sunnypilot/visuals_settings.cc @@ -45,6 +45,12 @@ VisualsPanel::VisualsPanel(QWidget *parent) : ListWidget(parent) { tr("Enable this will display an icon that appears when the End-to-end model decides to start or stop."), "../assets/offroad/icon_blank.png", }, + { + "MapboxFullScreen", + tr("Navigation: Display in Full Screen"), + QString(tr("Enable this will display the built-in navigation in full screen.
To switch back to driving view, tap on the border edge.")), + "../assets/offroad/icon_blank.png", + }, { "Map3DBuildings", tr("Map: Display 3D Buildings"), @@ -101,4 +107,8 @@ VisualsPanel::VisualsPanel(QWidget *parent) : ListWidget(parent) { // trigger offroadTransition when going onroad/offroad connect(uiState(), &UIState::offroadTransition, [=](bool offroad) { }); + + QObject::connect(toggles["MapboxFullScreen"], &ToggleControl::toggleFlipped, [=](bool state) { + toggles["MapboxFullScreen"]->showDescription(); + }); } diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 88813d7767..4416e58338 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -109,7 +109,7 @@ void OnroadWindow::updateState(const UIState &s) { Alert alert = Alert::get(*(s.sm), s.scene.started_frame, s.scene.display_debug_alert_frame); alerts->updateAlert(alert); - if (s.scene.map_on_left) { + if (s.scene.map_on_left || s.scene.mapbox_fullscreen) { split->setDirection(QBoxLayout::LeftToRight); } else { split->setDirection(QBoxLayout::RightToLeft); @@ -208,6 +208,7 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) { // Switch between map and sidebar when using navigate on openpilot bool sidebarVisible = geometry().x() > 0; bool show_map = uiState()->scene.navigate_on_openpilot ? sidebarVisible : !sidebarVisible; + updateMapSize(scene); map->setVisible(show_map && !map->isVisible()); } } @@ -236,7 +237,8 @@ void OnroadWindow::offroadTransition(bool offroad) { QObject::connect(nvg->map_settings_btn, &MapSettingsButton::clicked, m, &MapPanel::toggleMapSettings); nvg->map_settings_btn->setEnabled(true); - m->setFixedWidth(topWidget(this)->width() / 2 - UI_BORDER_SIZE); + m->setFixedWidth(uiState()->scene.mapbox_fullscreen ? topWidget(this)->width() : + topWidget(this)->width() / 2 - UI_BORDER_SIZE); split->insertWidget(0, m); // hidden by default, made visible when navRoute is published @@ -263,6 +265,12 @@ void OnroadWindow::offroadTransition(bool offroad) { alerts->updateAlert({}); } +void OnroadWindow::updateMapSize(const UIScene &scene) { + map->setFixedWidth(scene.mapbox_fullscreen ? topWidget(this)->width() : + topWidget(this)->width() / 2 - UI_BORDER_SIZE); + split->insertWidget(0, map); +} + void OnroadWindow::primeChanged(bool prime) { #ifdef ENABLE_MAPS if (map && (!prime && MAPBOX_TOKEN.isEmpty())) { diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index d534471746..8b444002e7 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -306,9 +306,11 @@ private: QHBoxLayout* split; QWidget *onroad_settings = nullptr; + Params params; private slots: void offroadTransition(bool offroad); void primeChanged(bool prime); void updateState(const UIState &s); + void updateMapSize(const UIScene &scene); }; diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 6162957919..d688954d34 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -253,6 +253,7 @@ void ui_update_params(UIState *s) { s->scene.live_torque_toggle = params.getBool("LiveTorque"); s->scene.torqued_override = params.getBool("TorquedOverride"); s->scene.speed_limit_control_engage_type = std::atoi(params.get("SpeedLimitEngageType").c_str()); + s->scene.mapbox_fullscreen = params.getBool("MapboxFullScreen"); // Handle Onroad Screen Off params if (s->scene.onroadScreenOff > 0) { diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 6a6dab5a7d..3cb9bc3368 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -241,6 +241,8 @@ typedef struct UIScene { QRect sl_sign_rect; int speed_limit_control_engage_type; + + bool mapbox_fullscreen; } UIScene; class UIState : public QObject {