Skip to content

Commit

Permalink
ui: add black color define (commaai#24866)
Browse files Browse the repository at this point in the history
  • Loading branch information
crwusiz authored and netadvanced committed Jun 15, 2022
1 parent 611f4d5 commit 4bea445
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
24 changes: 12 additions & 12 deletions selfdrive/ui/qt/onroad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ void NvgWindow::drawHud(QPainter &p) {
int bottom_radius = has_eu_speed_limit ? 100 : 32;

QRect set_speed_rect(60 + default_rect_width / 2 - rect_width / 2, 45, rect_width, rect_height);
p.setPen(QPen(QColor(255, 255, 255, 75), 6));
p.setBrush(QColor(0, 0, 0, 166));
p.setPen(QPen(whiteColor(75), 6));
p.setBrush(blackColor(166));
drawRoundedRect(p, set_speed_rect, top_radius, top_radius, bottom_radius, bottom_radius);

// Draw set speed
Expand All @@ -240,10 +240,10 @@ void NvgWindow::drawHud(QPainter &p) {
p.setPen(interpColor(
setSpeed,
{speedLimit + 5, speedLimit + 15, speedLimit + 25},
{QColor(0xff, 0xff, 0xff, 0xff), QColor(0xff, 0x95, 0x00, 0xff), QColor(0xff, 0x00, 0x00, 0xff)}
{whiteColor(), QColor(0xff, 0x95, 0x00, 0xff), QColor(0xff, 0x00, 0x00, 0xff)}
));
} else {
p.setPen(QColor(0xff, 0xff, 0xff, 0xff));
p.setPen(whiteColor());
}
} else {
p.setPen(QColor(0x72, 0x72, 0x72, 0xff));
Expand All @@ -257,7 +257,7 @@ void NvgWindow::drawHud(QPainter &p) {
// Draw MAX
if (is_cruise_set) {
if (status == STATUS_DISENGAGED) {
p.setPen(QColor(0xff, 0xff, 0xff, 0xff));
p.setPen(whiteColor());
} else if (status == STATUS_OVERRIDE) {
p.setPen(QColor(0x91, 0x9b, 0x95, 0xff));
} else if (speedLimit > 0) {
Expand Down Expand Up @@ -287,13 +287,13 @@ void NvgWindow::drawHud(QPainter &p) {
// White outer square
QRect sign_rect_outer(set_speed_rect.left() + 12, set_speed_rect.bottom() - 11 - sign_height, sign_width, sign_height);
p.setPen(Qt::NoPen);
p.setBrush(QColor(255, 255, 255, 255));
p.setBrush(whiteColor());
p.drawRoundedRect(sign_rect_outer, 24, 24);

// Smaller white square with black border
QRect sign_rect(sign_rect_outer.left() + 1.5 * border_width, sign_rect_outer.top() + 1.5 * border_width, sign_width - 3 * border_width, sign_height - 3 * border_width);
p.setPen(QPen(QColor(0, 0, 0, 255), border_width));
p.setBrush(QColor(255, 255, 255, 255));
p.setPen(QPen(blackColor(), border_width));
p.setBrush(whiteColor());
p.drawRoundedRect(sign_rect, 16, 16);

// "SPEED"
Expand Down Expand Up @@ -326,19 +326,19 @@ void NvgWindow::drawHud(QPainter &p) {
// Draw white circle with red border
QPoint center(set_speed_rect.center().x() + 1, set_speed_rect.top() + 204 + outer_radius);
p.setPen(Qt::NoPen);
p.setBrush(QColor(255, 255, 255, 255));
p.setBrush(whiteColor());
p.drawEllipse(center, outer_radius, outer_radius);
p.setBrush(QColor(255, 0, 0, 255));
p.drawEllipse(center, inner_radius_1, inner_radius_1);
p.setBrush(QColor(255, 255, 255, 255));
p.setBrush(whiteColor());
p.drawEllipse(center, inner_radius_2, inner_radius_2);

// Speed limit value
int font_size = (speedLimitStr.size() >= 3) ? 62 : 70;
configFont(p, "Open Sans", font_size, "Bold");
QRect speed_limit_rect = getTextRect(p, Qt::AlignCenter, speedLimitStr);
speed_limit_rect.moveCenter(center);
p.setPen(QColor(0, 0, 0, 255));
p.setPen(blackColor());
p.drawText(speed_limit_rect, Qt::AlignCenter, speedLimitStr);
}

Expand All @@ -357,7 +357,7 @@ void NvgWindow::drawHud(QPainter &p) {
// dm icon
if (!hideDM) {
drawIcon(p, radius / 2 + (bdr_s * 2), rect().bottom() - footer_h / 2,
dm_img, QColor(0, 0, 0, 70), dmActive ? 1.0 : 0.2);
dm_img, blackColor(70), dmActive ? 1.0 : 0.2);
}
p.restore();
}
Expand Down
1 change: 1 addition & 0 deletions selfdrive/ui/qt/onroad.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class NvgWindow : public CameraViewWidget {
void drawHud(QPainter &p);
inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
inline QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }
inline QColor blackColor(int alpha = 255) { return QColor(0, 0, 0, alpha); }

double prev_draw_t = 0;
FirstOrderFilter fps_filter;
Expand Down

0 comments on commit 4bea445

Please sign in to comment.