mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
Change the steering wheel icon's background color
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 ¢er, const QPixmap &img, const QBrush &bg, float opacity);
|
||||
|
||||
Reference in New Issue
Block a user