From 0aa4954f105b6f418cdb2f1f23e8f9a04bee327d Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sun, 3 Apr 2016 22:29:30 +0200 Subject: Better top status bar. --- src/ui.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/ui.c b/src/ui.c index 3f2214a..2674756 100644 --- a/src/ui.c +++ b/src/ui.c @@ -6,6 +6,7 @@ struct { float color_text_light[4]; float color_background[4]; float color_main[4]; + float color_light[4]; float color_info[4]; float color_select[4]; } theme = @@ -15,6 +16,7 @@ struct { .color_text_light = {0.5, 0.5, 0.5, 1}, .color_background = {0.1, 0.1, 0.1, 1}, .color_main = {0.75, 0.75, 0.75, 1}, + .color_light = {0.85, 0.85, 0.85, 1}, .color_info = {1, 1, 1, 1}, .color_select = {1, 0, 0, 1} }; @@ -208,7 +210,7 @@ void ui_event_window(SDL_Event *event, ui_window *uiw) v2_add(sv->origin, sv->origin, delta_v); if (sv->dragging_frac) { - sv->xsection_frac += delta_v[1]; + sv->xsection_frac += delta_v[1] * -2.0f; if (sv->xsection_frac > 1.0f) sv->xsection_frac = 1.0f; @@ -430,7 +432,19 @@ void ui_draw_simview_selection(ui_window *uiw) char *ui_draw_simview_top_bar_text(ui_simview *sv) { int flags = sv->xsection_flags; + phy_field_info *fi = &sv->sim->field_info; char *rv; + size_t total; + float frac_real; + + if (flags & XSECTION_XY) + total = fi->dims[2]; + else if (flags & XSECTION_XZ) + total = fi->dims[1]; + else + total = fi->dims[0]; + + frac_real = floor(sv->xsection_frac * total) / total; rv = va("Przekrój %s płaszczyzną %s=%f", (flags & XSECTION_E ? "E" : @@ -438,7 +452,7 @@ char *ui_draw_simview_top_bar_text(ui_simview *sv) (flags & XSECTION_XY ? "Z" : flags & XSECTION_XZ ? "Y" : "X"), - sv->xsection_frac); + frac_real); return rv; } @@ -488,7 +502,7 @@ void ui_draw_simview_bars(ui_window *uiw, float dt) sv->margin_bottom += 3 * theme.font_size; r_draw_rect(uiw->rw, 0, uiw->h - 4 * theme.font_size, - uiw->w, 3 * theme.font_size, theme.color_main); + uiw->w, 3 * theme.font_size, theme.color_light); x = sv->select[0] * fi->dims[0]; y = sv->select[1] * fi->dims[1]; @@ -499,7 +513,6 @@ void ui_draw_simview_bars(ui_window *uiw, float dt) theme.font_size, va("x = [%zu %zu %zu]", x, y, z), theme.color_text, 0); - r_draw_text(uiw->rw, 0, uiw->h - 3 * theme.font_size, theme.font_size, va("E(x) = [%+E %+E %+E]", field_em->E[offs], field_em->E[offs + 1], -- cgit