text: #pragma once
  
  #include <QStackedLayout>
  #include <QWidget>
  
  #include "selfdrive/ui/qt/widgets/cameraview.h"
  #include "selfdrive/ui/ui.h"
  
  #include <QTimer>
  #include "selfdrive/ui/qt/screenrecorder/screenrecorder.h"
  
  
  // ***** onroad widgets *****
  
  class OnroadAlerts : public QWidget {
    Q_OBJECT
  
  public:
    OnroadAlerts(QWidget *parent = 0) : QWidget(parent) {};
    void updateAlert(const Alert &a, const QColor &color);
  
  protected:
    void paintEvent(QPaintEvent*) override;
  
  private:
    QColor bg;
    Alert alert = {};
  };
  
  // container window for the NVG UI
  class NvgWindow : public CameraViewWidget {
    Q_OBJECT
  
  public:
    explicit NvgWindow(VisionStreamType type, QWidget* parent = 0) : CameraViewWidget("camerad", type, true, parent) {}
  
  protected:
    void paintGL() override;
    void initializeGL() override;
    void showEvent(QShowEvent *event) override;
    void updateFrameMat(int w, int h) override;
    void drawLaneLines(QPainter &painter, const UIScene &scene);
    void drawLead(QPainter &painter, const cereal::ModelDataV2::LeadDataV3::Reader &lead_data, const QPointF &vd, bool is_radar);
    inline QColor redColor(int alpha = 255) { return QColor(201, 34, 49, alpha); }
    inline QColor whiteColor(int alpha = 255) { return QColor(255, 255, 255, alpha); }
    double prev_draw_t = 0;
  
    // neokii
    void drawIcon(QPainter &p, int x, int y, QPixmap &img, QBrush bg, float opacity);
    void drawText(QPainter &p, int x, int y, const QString &text, int alpha = 255);
    void drawText2(QPainter &p, int x, int y, int flags, const QString &text, const QColor& color);
    void drawTextWithColor(QPainter &p, int x, int y, const QString &text, QColor& color);
    void paintEvent(QPaintEvent *event) override;
  
    const int radius = 192;
    const int img_size = (radius / 2) * 1.5;
  
    // neokii
    QPixmap ic_brake;
    QPixmap ic_autohold_warning;
    QPixmap ic_autohold_active;
    QPixmap ic_nda;
    QPixmap ic_hda;
    QPixmap ic_tire_pressure;
    QPixmap ic_turn_signal_l;
    QPixmap ic_turn_signal_r;
    QPixmap ic_satellite;
  
    void drawMaxSpeed(QPainter &p);
    void drawSpeed(QPainter &p);
    void drawBottomIcons(QPainter &p);
    void drawSpeedLimit(QPainter &p);
    void drawTurnSignals(QPainter &p);
    void drawGpsStatus(QPainter &p);
    void drawDebugText(QPainter &p);
    void drawHud(QPainter &p);
  };
  
  // container for all onroad widgets
  class OnroadWindow : public QWidget {
    Q_OBJECT
  
  public:
    OnroadWindow(QWidget* parent = 0);
    bool isMapVisible() const { return map && map->isVisible(); }
  
  protected:
    void mousePressEvent(QMouseEvent* e) override;
    void mouseReleaseEvent(QMouseEvent* e) override;
  
    void paintEvent(QPaintEvent *event) override;
  
  private:
    OnroadAlerts *alerts;
    NvgWindow *nvg;
    QColor bg = bg_colors[STATUS_DISENGAGED];
    QWidget *map = nullptr;
    QHBoxLayout* split;
  
    // neokii
  private:
    ScreenRecoder* recorder;
    std::shared_ptr<QTimer> record_timer;
    QPoint startPos;
  
  private slots:
    void offroadTransition(bool offroad);
    void updateState(const UIState &s);
  };
  