From 6a21c44d90ae4d2e5e7f479fd0e86ba79f8fbf66 Mon Sep 17 00:00:00 2001 From: Mitchell Goff Date: Fri, 30 Jun 2023 19:00:36 -0700 Subject: [PATCH] UI: Indicate when Nav on OP is enabled (#28665) * Indicate whether nav is enabled in UI * update border spacing on both enabled and navEnabled change * update less * more * cleanup * simplify * fix --------- Co-authored-by: Cameron Clough old-commit-hash: a66135665c9256b4efa1c3ebac171b847dfdceaa --- selfdrive/ui/qt/onroad.cc | 23 +++++++++++++++++++++-- selfdrive/ui/qt/onroad.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index edf0c2542e..5e943fed85 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -64,9 +64,20 @@ void OnroadWindow::updateState(const UIState &s) { nvg->updateState(s); - if (bg != bgColor) { - // repaint border + // update spacing + bool navDisabledNow = (*s.sm)["controlsState"].getControlsState().getEnabled() && + !(*s.sm)["modelV2"].getModelV2().getNavEnabled(); + if (navDisabled != navDisabledNow) { + split->setSpacing(navDisabledNow ? bdr_s * 2 : 0); + if (map) { + map->setFixedWidth(topWidget(this)->width() / 2 - bdr_s * (navDisabledNow ? 2 : 1)); + } + } + + // repaint border + if (bg != bgColor || navDisabled != navDisabledNow) { bg = bgColor; + navDisabled = navDisabledNow; update(); } } @@ -79,6 +90,7 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) { return; } map->setVisible(!sidebarVisible && !map->isVisible()); + update(); } #endif // propagation event to parent(HomeWindow) @@ -109,6 +121,13 @@ void OnroadWindow::offroadTransition(bool offroad) { void OnroadWindow::paintEvent(QPaintEvent *event) { QPainter p(this); p.fillRect(rect(), QColor(bg.red(), bg.green(), bg.blue(), 255)); + + if (isMapVisible() && navDisabled) { + QRect map_r = uiState()->scene.map_on_left + ? QRect(0, 0, width() / 2, height()) + : QRect(width() / 2, 0, width() / 2, height()); + p.fillRect(map_r, bg_colors[STATUS_DISENGAGED]); + } } // ***** onroad widgets ***** diff --git a/selfdrive/ui/qt/onroad.h b/selfdrive/ui/qt/onroad.h index 33a192166a..2df35dc19f 100644 --- a/selfdrive/ui/qt/onroad.h +++ b/selfdrive/ui/qt/onroad.h @@ -128,6 +128,7 @@ private: QColor bg = bg_colors[STATUS_DISENGAGED]; QWidget *map = nullptr; QHBoxLayout* split; + bool navDisabled = false; private slots: void offroadTransition(bool offroad);