Change the steering wheel icon's background color

This commit is contained in:
James
2025-12-01 12:00:00 -07:00
parent 2d426739d7
commit 2f86ec9b1e
2 changed files with 18 additions and 1 deletions
+15 -1
View File
@@ -46,14 +46,28 @@ void ExperimentalButton::updateState(const UIState &s, const FrogPilotUIState &f
// FrogPilot variables
const cereal::CarState::Reader &carState = (*s.sm)["carState"].getCarState();
updateBackgroundColor();
}
void ExperimentalButton::paintEvent(QPaintEvent *event) {
QPainter p(this);
QPixmap img = experimental_mode ? experimental_img : engage_img;
drawIcon(p, QPoint(btn_size / 2, btn_size / 2), img, QColor(0, 0, 0, 166), (isDown() || !engageable) ? 0.6 : 1.0);
drawIcon(p, QPoint(btn_size / 2, btn_size / 2), img, background_color, (isDown() || !engageable) ? 0.6 : 1.0);
}
// FrogPilot variables
void ExperimentalButton::showEvent(QShowEvent *event) {
}
void ExperimentalButton::updateBackgroundColor() {
if (isDown() || !engageable) {
background_color = QColor(0, 0, 0, 166);
} else if (frogpilot_scene.always_on_lateral_active) {
background_color = bg_colors[STATUS_ALWAYS_ON_LATERAL_ACTIVE];
} else if (experimental_mode) {
background_color = bg_colors[STATUS_EXPERIMENTAL_MODE_ENABLED];
} else {
background_color = QColor(0, 0, 0, 166);
}
}
+3
View File
@@ -31,8 +31,11 @@ private:
// FrogPilot variables
void showEvent(QShowEvent *event) override;
void updateBackgroundColor();
Params params_memory{"", true};
QColor background_color;
};
void drawIcon(QPainter &p, const QPoint &center, const QPixmap &img, const QBrush &bg, float opacity);