ui, fix cutting bug, appearance animations, add f32_round
This commit is contained in:
21
src/ui/ui.h
21
src/ui/ui.h
@@ -1,5 +1,3 @@
|
||||
typedef void ui_custom_draw_t(struct ui_box_t *box);
|
||||
|
||||
typedef struct ui_code_loc_t ui_code_loc_t;
|
||||
struct ui_code_loc_t {
|
||||
char *file;
|
||||
@@ -17,8 +15,10 @@ struct ui_box_flags_t {
|
||||
b8 draw_rect: 1;
|
||||
b8 draw_border: 1;
|
||||
b8 draw_text: 1;
|
||||
b8 clip_rect: 1;
|
||||
|
||||
b8 clip_rect : 1;
|
||||
b8 dont_compute_rect: 1;
|
||||
b8 keyboard_nav: 1;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@@ -64,6 +64,8 @@ struct ui_text_input_t {
|
||||
};
|
||||
|
||||
typedef struct ui_box_t ui_box_t;
|
||||
typedef void ui_custom_draw_t(ui_box_t *);
|
||||
|
||||
struct ui_box_t {
|
||||
ui_box_t *next;
|
||||
ui_box_t *prev;
|
||||
@@ -75,9 +77,10 @@ struct ui_box_t {
|
||||
ui_code_loc_t loc;
|
||||
s8_t string;
|
||||
|
||||
ui_box_flags_t flags;
|
||||
b8 created_new;
|
||||
ui_box_flags_t flags;
|
||||
b8 created_new;
|
||||
ui_custom_draw_t *custom_draw;
|
||||
ui_lop_t lop;
|
||||
UI_DECL_BOX_MEMBERS
|
||||
|
||||
r2f32_t full_rect;
|
||||
@@ -89,13 +92,14 @@ struct ui_box_t {
|
||||
ui_box_t *hash_prev;
|
||||
u64 last_touched_event_id;
|
||||
|
||||
f32 appear_t;
|
||||
f32 hot_t;
|
||||
f32 active_t;
|
||||
|
||||
r2f32_t final_rect;
|
||||
b32 expanded;
|
||||
|
||||
ui_text_input_t text_input;
|
||||
ui_text_input_t *text_input;
|
||||
};
|
||||
|
||||
typedef struct ui_signal_t ui_signal_t;
|
||||
@@ -103,6 +107,7 @@ struct ui_signal_t {
|
||||
ui_box_t *box;
|
||||
b8 clicked;
|
||||
b8 dragging;
|
||||
v2f32_t drag;
|
||||
};
|
||||
|
||||
typedef struct ui_t ui_t;
|
||||
@@ -132,7 +137,7 @@ struct ui_t {
|
||||
r2f32_t clip_rect;
|
||||
};
|
||||
|
||||
ui_t *ui;
|
||||
gb ui_t *ui;
|
||||
|
||||
gb_read_only ui_id_t ui_null_id;
|
||||
gb_read_only ui_box_t ui_null_box;
|
||||
@@ -148,7 +153,7 @@ fn b32 ui_is_focused_box(ui_box_t *box) { return !ui_is_null_box(box) && box->id
|
||||
#define ev_left_up(ev) ((ev)->kind == app_event_kind_mouse_up && ev_left(ev))
|
||||
#define ev_left_down(ev) ((ev)->kind == app_event_kind_mouse_down && ev_left(ev))
|
||||
|
||||
fn void ui_set_rect(ui_box_t *box, r2f32_t rect) { box->rect = box->full_rect = rect; }
|
||||
fn void ui_set_rect(ui_box_t *box, r2f32_t rect, ui_lop_t lop) { box->rect = box->full_rect = rect; box->lop = lop; }
|
||||
|
||||
#define UILOC (ui_code_loc_t){.file = __FILE__, .line = __LINE__, .counter = __COUNTER__}
|
||||
#define ui_em(x) ((x) * rn_state.main_font->size)
|
||||
|
||||
Reference in New Issue
Block a user