UI: draw header gradient in OnroadHud (#23137)

pull/23140/head
Dean Lee 3 years ago committed by GitHub
parent 795bdf4c61
commit 8545901c0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      selfdrive/ui/paint.cc
  2. 6
      selfdrive/ui/qt/onroad.cc

@ -127,23 +127,12 @@ static void ui_draw_world(UIState *s) {
nvgResetScissor(s->vg);
}
static void ui_draw_vision_header(UIState *s) {
NVGpaint gradient = nvgLinearGradient(s->vg, 0, header_h - (header_h / 2.5), 0, header_h,
nvgRGBAf(0, 0, 0, 0.45), nvgRGBAf(0, 0, 0, 0));
nvgBeginPath(s->vg);
nvgRect(s->vg, 0, 0, s->fb_w, header_h);
nvgFillPaint(s->vg, gradient);
nvgFill(s->vg);
}
static void ui_draw_vision(UIState *s) {
const UIScene *scene = &s->scene;
// Draw augmented elements
if (scene->world_objects_visible) {
ui_draw_world(s);
}
// TODO: move this to Qt
ui_draw_vision_header(s);
}
void ui_draw(UIState *s, int w, int h) {

@ -198,6 +198,12 @@ void OnroadHud::paintEvent(QPaintEvent *event) {
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
// Header gradient
QLinearGradient bg(0, header_h - (header_h / 2.5), 0, header_h);
bg.setColorAt(0, QColor::fromRgbF(0, 0, 0, 0.45));
bg.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
p.fillRect(0, 0, width(), header_h, bg);
// max speed
QRect rc(bdr_s * 2, bdr_s * 1.5, 184, 202);
p.setPen(QPen(QColor(0xff, 0xff, 0xff, 100), 10));

Loading…
Cancel
Save