mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 18:12:05 +08:00
ui: update params on the show event (#22927)
old-commit-hash: 906208504363457172d951ae99b8dac99d3400e1
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
+2
-7
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user