ui: update params on the show event (#22927)

pull/22935/head
Dean Lee 3 years ago committed by GitHub
parent 9f423a93cd
commit 9062085043
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      selfdrive/ui/paint.h
  2. 6
      selfdrive/ui/qt/onroad.cc
  3. 1
      selfdrive/ui/qt/onroad.h
  4. 9
      selfdrive/ui/ui.cc

@ -9,3 +9,4 @@ void ui_fill_rect(NVGcontext *vg, const Rect &r, const NVGpaint &paint, float ra
void ui_fill_rect(NVGcontext *vg, const Rect &r, const NVGcolor &color, float radius = 0);
void ui_nvg_init(UIState *s);
void ui_resize(UIState *s, int width, int height);
void ui_update_params(UIState *s);

@ -186,3 +186,9 @@ void NvgWindow::paintGL() {
}
prev_draw_t = cur_draw_t;
}
void NvgWindow::showEvent(QShowEvent *event) {
CameraViewWidget::showEvent(event);
ui_update_params(&QUIState::ui_state);
prev_draw_t = millis_since_boot();
}

@ -34,6 +34,7 @@ public:
protected:
void paintGL() override;
void initializeGL() override;
void showEvent(QShowEvent *event) override;
double prev_draw_t = 0;
};

@ -186,12 +186,8 @@ static void update_state(UIState *s) {
scene.started = sm["deviceState"].getDeviceState().getStarted() && scene.ignition;
}
static void update_params(UIState *s) {
const uint64_t frame = s->sm->frame;
UIScene &scene = s->scene;
if (frame % (5*UI_FREQ) == 0) {
scene.is_metric = Params().getBool("IsMetric");
}
void ui_update_params(UIState *s) {
s->scene.is_metric = Params().getBool("IsMetric");
}
static void update_status(UIState *s) {
@ -240,7 +236,6 @@ QUIState::QUIState(QObject *parent) : QObject(parent) {
}
void QUIState::update() {
update_params(&ui_state);
update_sockets(&ui_state);
update_state(&ui_state);
update_status(&ui_state);

Loading…
Cancel
Save