From 8545901c0c3be079feded38bed05db1fa57fbe5f Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Mon, 6 Dec 2021 13:06:47 +0800 Subject: [PATCH] UI: draw header gradient in OnroadHud (#23137) --- selfdrive/ui/paint.cc | 11 ----------- selfdrive/ui/qt/onroad.cc | 6 ++++++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index aa53f4d527..a8023801ca 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.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) { diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 41c0012a11..8902e436c9 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -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));