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

old-commit-hash: 906208504363457172d951ae99b8dac99d3400e1
This commit is contained in:
Dean Lee
2021-11-17 04:13:16 +08:00
committed by GitHub
parent 6493034aea
commit dce66df5ef
4 changed files with 10 additions and 7 deletions
+1
View File
@@ -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);
+6
View File
@@ -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();
}
+1
View File
@@ -34,6 +34,7 @@ public:
protected:
void paintGL() override;
void initializeGL() override;
void showEvent(QShowEvent *event) override;
double prev_draw_t = 0;
};
+2 -7
View File
@@ -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);