summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--src/ui.c50
2 files changed, 25 insertions, 27 deletions
diff --git a/TODO b/TODO
index 88c901b..a5963f6 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,4 @@
refactor
- ui_window.ui_simview.selected -> *.select_valid
- ui_window.ui_simview.selection -> *.select
new shit:
phy_control and shit
diff --git a/src/ui.c b/src/ui.c
index 0f4477b..feabc28 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -7,7 +7,7 @@ struct {
float color_background[4];
float color_main[4];
float color_info[4];
- float color_selection[4];
+ float color_select[4];
} theme =
{
.font_size = 20,
@@ -16,7 +16,7 @@ struct {
.color_background = {0.1, 0.1, 0.1, 1},
.color_main = {0.75, 0.75, 0.75, 1},
.color_info = {1, 1, 1, 1},
- .color_selection = {1, 0, 0, 1}
+ .color_select = {1, 0, 0, 1}
};
#define MAX_INFO 1024
@@ -25,8 +25,8 @@ typedef struct {
bool dragging;
r_xsection_type xsection_type;
float xsection_frac;
- bool selected;
- vec3_t selection;
+ bool select_valid;
+ vec3_t select;
bool info_valid;
int64_t info_time;
@@ -139,29 +139,29 @@ void ui_infof(ui_window *uiw, const char *fmt, ...)
uiw->simview.info_time = get_time();
}
-static void ui_simview_set_selection(ui_simview *sv, vec2_t sel_2d)
+static void ui_simview_set_select(ui_simview *sv, vec2_t sel_2d)
{
if (sel_2d[0] < 0.0f || sel_2d[0] > 1.0f ||
sel_2d[1] < 0.0f || sel_2d[1] > 1.0f) {
- sv->selected = false;
+ sv->select_valid = false;
return;
}
switch (sv->xsection_type) {
case XSECTION_XY:
- v3_set(sv->selection, sel_2d[0], sel_2d[1], sv->xsection_frac);
+ v3_set(sv->select, sel_2d[0], sel_2d[1], sv->xsection_frac);
break;
case XSECTION_XZ:
- v3_set(sv->selection, sel_2d[0], sv->xsection_frac, sel_2d[1]);
+ v3_set(sv->select, sel_2d[0], sv->xsection_frac, sel_2d[1]);
break;
case XSECTION_YZ:
- v3_set(sv->selection, sv->xsection_frac, sel_2d[0], sel_2d[1]);
+ v3_set(sv->select, sv->xsection_frac, sel_2d[0], sel_2d[1]);
break;
}
- sv->selected = true;
+ sv->select_valid = true;
}
void ui_event_window(SDL_Event *event, ui_window *uiw)
@@ -199,7 +199,7 @@ void ui_event_window(SDL_Event *event, ui_window *uiw)
vec2_t sel_2d;
v2_div_mst2(sel_2d, uiw->mouse, sv->tf_x2s);
- ui_simview_set_selection(sv, sel_2d);
+ ui_simview_set_select(sv, sel_2d);
}
break;
@@ -334,32 +334,32 @@ void ui_draw_window_simview(ui_window *uiw, phy_sim *sim, int64_t time,
r_xsection_draw(uiw->rw, &sv->xsection, origin_s[0], origin_s[1],
scale_s[0], scale_s[1]);
- // xsection - selection
+ // xsection - select
- if (sv->selected)
+ if (sv->select_valid)
{
- vec2_t selection_s;
+ vec2_t select_s;
switch (sv->xsection_type) {
case XSECTION_XY:
- v2_set(selection_s, sv->selection[0], sv->selection[1]);
+ v2_set(select_s, sv->select[0], sv->select[1]);
break;
case XSECTION_XZ:
- v2_set(selection_s, sv->selection[0], sv->selection[2]);
+ v2_set(select_s, sv->select[0], sv->select[2]);
break;
case XSECTION_YZ:
- v2_set(selection_s, sv->selection[1], sv->selection[2]);
+ v2_set(select_s, sv->select[1], sv->select[2]);
break;
}
- v2_mul_mst2(selection_s, selection_s, sv->tf_x2s);
+ v2_mul_mst2(select_s, select_s, sv->tf_x2s);
- r_draw_line(uiw->rw, selection_s[0], 0, selection_s[0], uiw->h,
- theme.color_selection);
- r_draw_line(uiw->rw, 0, selection_s[1], uiw->w, selection_s[1],
- theme.color_selection);
+ r_draw_line(uiw->rw, select_s[0], 0, select_s[0], uiw->h,
+ theme.color_select);
+ r_draw_line(uiw->rw, 0, select_s[1], uiw->w, select_s[1],
+ theme.color_select);
r_draw_rect(uiw->rw, 0, uiw->h - theme.font_size,
@@ -367,8 +367,8 @@ void ui_draw_window_simview(ui_window *uiw, phy_sim *sim, int64_t time,
r_draw_text(uiw->rw, 0, uiw->h - theme.font_size,
theme.font_size,
- va("x = [%f %f %f]", sv->selection[0],
- sv->selection[1], sv->selection[2]),
+ va("x = [%f %f %f]", sv->select[0],
+ sv->select[1], sv->select[2]),
theme.color_text, 0);
sv->margin_bottom = 1 * theme.font_size;
@@ -430,7 +430,7 @@ void ui_draw_window(ui_window *uiw, phy_sim *sim)
sv->xsection_type = XSECTION_XY;
sv->xsection_frac = 0.5f;
- sv->selected = false;
+ sv->select_valid = false;
sv->margin_top = theme.font_size;
sv->margin_bottom = 0;