diff --git a/selfdrive/ui/qt/offroad/onboarding.cc b/selfdrive/ui/qt/offroad/onboarding.cc index 7fcae65aeb6944..f9f8972b8eccd5 100644 --- a/selfdrive/ui/qt/offroad/onboarding.cc +++ b/selfdrive/ui/qt/offroad/onboarding.cc @@ -12,14 +12,15 @@ void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) { - //qDebug() << e->x() << ", " << e->y(); + QPoint touch = QPoint(e->x(), e->y()) - imageCorner; + //qDebug() << touch.x() << ", " << touch.y(); // Check for restart - if (currentIndex == (boundingBox.size() - 1) && 200 <= e->x() && e->x() <= 920 && - 760 <= e->y() && e->y() <= 960) { + if (currentIndex == (boundingBox.size() - 1) && 200 <= touch.x() && touch.x() <= 920 && + 760 <= touch.y() && touch.y() <= 960) { currentIndex = 0; - } else if (boundingBox[currentIndex][0] <= e->x() && e->x() <= boundingBox[currentIndex][1] && - boundingBox[currentIndex][2] <= e->y() && e->y() <= boundingBox[currentIndex][3]) { + } else if (boundingBox[currentIndex][0] <= touch.x() && touch.x() <= boundingBox[currentIndex][1] && + boundingBox[currentIndex][2] <= touch.y() && touch.y() <= boundingBox[currentIndex][3]) { currentIndex += 1; } @@ -39,17 +40,17 @@ void TrainingGuide::showEvent(QShowEvent *event) { void TrainingGuide::paintEvent(QPaintEvent *event) { QPainter painter(this); - QRect devRect(0, 0, painter.device()->width(), painter.device()->height()); - QBrush bgBrush("#072339"); - painter.fillRect(devRect, bgBrush); + QRect bg(0, 0, painter.device()->width(), painter.device()->height()); + QBrush bgBrush("#000000"); + painter.fillRect(bg, bgBrush); QRect rect(image.rect()); - rect.moveCenter(devRect.center()); + rect.moveCenter(bg.center()); painter.drawImage(rect.topLeft(), image); + imageCorner = rect.topLeft(); } TermsPage::TermsPage(QWidget *parent) : QFrame(parent){ - QVBoxLayout *main_layout = new QVBoxLayout; main_layout->setMargin(40); main_layout->setSpacing(40); diff --git a/selfdrive/ui/qt/offroad/onboarding.hpp b/selfdrive/ui/qt/offroad/onboarding.hpp index eb067478cf36b5..227090fd3a26c3 100644 --- a/selfdrive/ui/qt/offroad/onboarding.hpp +++ b/selfdrive/ui/qt/offroad/onboarding.hpp @@ -22,6 +22,7 @@ class TrainingGuide : public QFrame { private: QImage image; + QPoint imageCorner; int currentIndex = 0; // Bounding boxes for the a given training guide step