summaryrefslogtreecommitdiff
path: root/src/ui.c
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2016-03-30 20:29:08 +0200
committerPaweł Redman <pawel.redman@gmail.com>2016-03-30 20:29:08 +0200
commit745d5a072d8669d1bc35e7c1f28b75b3484542e8 (patch)
treeecc9cbd03511764e79251ec256c81cb8796f7c36 /src/ui.c
parentbc50836fdcd20fda174df392c264cc6f03030cdf (diff)
Finish ITC; implement async sim control.
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/ui.c b/src/ui.c
index feabc28..f55f18b 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -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++;
}
}