diff options
Diffstat (limited to 'src/ui.c')
-rw-r--r-- | src/ui.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -22,6 +22,8 @@ struct { #define MAX_INFO 1024 typedef struct { + phy_sim *sim; + bool dragging; r_xsection_type xsection_type; float xsection_frac; @@ -246,6 +248,14 @@ void ui_event_window(SDL_Event *event, ui_window *uiw) if (sv->xsection_frac < 0.0f) sv->xsection_frac = 0.0f; break; + + case SDLK_o: + itc_chan_push(&sv->sim->ctl, PHY_CMD_PAUSE, NULL); + break; + + case SDLK_p: + itc_chan_push(&sv->sim->ctl, PHY_CMD_RESUME, NULL); + break; } } } @@ -295,10 +305,10 @@ void ui_animate_exp(float *val, float targ, float lambda, float dt) *val = targ + (*val - targ) * exp(-lambda * dt); } -void ui_draw_window_simview(ui_window *uiw, phy_sim *sim, int64_t time, - float dt) +void ui_draw_window_simview(ui_window *uiw, int64_t time, float dt) { ui_simview *sv = &uiw->simview; + phy_sim *sim = sv->sim; float aspect_ratio; vec2_t origin_s, scale_s; phy_field_em *field_em = sim->fields + 2; @@ -413,7 +423,7 @@ void ui_draw_window_simview(ui_window *uiw, phy_sim *sim, int64_t time, } } -void ui_draw_window(ui_window *uiw, phy_sim *sim) +void ui_draw_window(ui_window *uiw) { ui_simview *sv = &uiw->simview; int64_t time; @@ -443,7 +453,7 @@ void ui_draw_window(ui_window *uiw, phy_sim *sim) dt = (get_time() - uiw->last_frame) * 1.0e-9; r_clear(uiw->rw, r_color_black); - ui_draw_window_simview(uiw, sim, time, dt); + ui_draw_window_simview(uiw, time, dt); r_flip(uiw->rw); uiw->last_frame = time; @@ -455,7 +465,8 @@ void ui_draw(phy_sim *sim) for (uiw = uis.windows; uiw; uiw = uiw->next) { SDL_GetWindowSize(uiw->rw->window, &uiw->w, &uiw->h); - ui_draw_window(uiw, sim); + uiw->simview.sim = sim; + ui_draw_window(uiw); uiw->frame_count++; } } |