From f1d4b920bc24137ee9870f7329b73baeb69f07f0 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 12 May 2021 20:18:06 -0500 Subject: [PATCH] fix reverse gear alert text cutoff (#20888) * fix reverse gear alert text cutoff * offset removed old-commit-hash: ff16145f4de95b67815104596ec46da09b3f704a --- selfdrive/ui/qt/onroad.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/selfdrive/ui/qt/onroad.cc b/selfdrive/ui/qt/onroad.cc index 4310ea6fc7..c285c07282 100644 --- a/selfdrive/ui/qt/onroad.cc +++ b/selfdrive/ui/qt/onroad.cc @@ -115,17 +115,15 @@ void OnroadAlerts::stopSounds() { void OnroadAlerts::paintEvent(QPaintEvent *event) { QPainter p(this); + if (alert_size == cereal::ControlsState::AlertSize::NONE) { + return; + } static std::map alert_sizes = { - {cereal::ControlsState::AlertSize::NONE, 0}, {cereal::ControlsState::AlertSize::SMALL, 271}, {cereal::ControlsState::AlertSize::MID, 420}, {cereal::ControlsState::AlertSize::FULL, height()}, }; int h = alert_sizes[alert_size]; - if (h == 0) { - return; - } - QRect r = QRect(0, height() - h, width(), h); // draw background + gradient @@ -158,10 +156,9 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) { configFont(p, "Open Sans", 66, "Regular"); p.drawText(QRect(0, c.y() + 21, width(), 90), Qt::AlignHCenter, text2); } else if (alert_size == cereal::ControlsState::AlertSize::FULL) { - // TODO: offset from center to match old NVG UI, but why was it this way? bool l = text1.length() > 15; configFont(p, "Open Sans", l ? 132 : 177, "Bold"); - p.drawText(QRect(0, r.y() + (l ? 240 : 270), width(), 350), Qt::AlignHCenter | Qt::TextWordWrap, text1); + p.drawText(QRect(0, r.y() + (l ? 240 : 270), width(), 600), Qt::AlignHCenter | Qt::TextWordWrap, text1); configFont(p, "Open Sans", 88, "Regular"); p.drawText(QRect(0, r.height() - (l ? 361 : 420), width(), 300), Qt::AlignHCenter | Qt::TextWordWrap, text2); }