UI: adjust opacity instead of visibility to indicate engageability (#28765)

pull/28769/head
Adeeb Shihadeh 2 years ago committed by GitHub
parent a66135665c
commit 010ef17da5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      selfdrive/ui/qt/onroad.cc
  2. 1
      selfdrive/ui/qt/onroad.h

@ -199,7 +199,6 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
// ExperimentalButton
ExperimentalButton::ExperimentalButton(QWidget *parent) : experimental_mode(false), QPushButton(parent) {
setVisible(false);
setFixedSize(btn_size, btn_size);
params = Params();
@ -217,10 +216,11 @@ void ExperimentalButton::changeMode() {
}
void ExperimentalButton::updateState(const UIState &s) {
// button is "visible" if engageable or enabled
const auto cs = (*s.sm)["controlsState"].getControlsState();
setVisible(cs.getEngageable() || cs.getEnabled());
if (std::exchange(experimental_mode, cs.getExperimentalMode()) != experimental_mode) {
bool eng = cs.getEngageable() || cs.getEnabled();
if ((cs.getExperimentalMode() != experimental_mode) || (eng != engageable)) {
engageable = eng;
experimental_mode = cs.getExperimentalMode();
update();
}
}
@ -236,7 +236,7 @@ void ExperimentalButton::paintEvent(QPaintEvent *event) {
p.setPen(Qt::NoPen);
p.setBrush(QColor(0, 0, 0, 166));
p.drawEllipse(center, btn_size / 2, btn_size / 2);
p.setOpacity(isDown() ? 0.8 : 1.0);
p.setOpacity((isDown() || !engageable) ? 0.6 : 1.0);
p.drawPixmap((btn_size - img_size) / 2, (btn_size - img_size) / 2, img);
}

@ -44,6 +44,7 @@ private:
QPixmap engage_img;
QPixmap experimental_img;
bool experimental_mode;
bool engageable;
};
// container window for the NVG UI

Loading…
Cancel
Save