id_stack, modifiable ui for struct based on type info!
This commit is contained in:
@@ -16,9 +16,14 @@ struct ui_box_flags_t {
|
||||
b8 draw_border: 1;
|
||||
b8 draw_text: 1;
|
||||
|
||||
b8 fully_center_text : 1;
|
||||
b8 clip_rect : 1;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ui_text_align_left,
|
||||
ui_text_align_center,
|
||||
} ui_text_align_t;
|
||||
|
||||
typedef enum {
|
||||
ui_op_cut_top,
|
||||
ui_op_cut_bottom,
|
||||
@@ -41,6 +46,7 @@ struct ui_box_t {
|
||||
|
||||
ui_box_flags_t flags;
|
||||
b8 created_new;
|
||||
ui_text_align_t text_align;
|
||||
|
||||
ui_op_t op;
|
||||
r2f32_t full_rect;
|
||||
@@ -65,19 +71,26 @@ struct ui_signal_t {
|
||||
|
||||
typedef struct ui_t ui_t;
|
||||
struct ui_t {
|
||||
ma_arena_t *box_arena;
|
||||
// building
|
||||
ui_box_t root;
|
||||
ui_box_t *top;
|
||||
|
||||
app_event_t *event;
|
||||
stack_t(ui_id_t, 32) id_stack;
|
||||
ui_text_align_t pref_text_align;
|
||||
|
||||
// allocation
|
||||
ma_arena_t *box_arena;
|
||||
i32 allocated_boxes;
|
||||
ui_box_t *free_first;
|
||||
ui_box_t *hash_first;
|
||||
ui_box_t *hash_last;
|
||||
|
||||
// interaction
|
||||
ui_id_t hot;
|
||||
ui_id_t active;
|
||||
|
||||
// drawing
|
||||
r2f32_t clip_rect;
|
||||
};
|
||||
|
||||
ui_t *ui;
|
||||
@@ -95,8 +108,6 @@ fn b32 ui_is_active_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_push_top(ui_box_t *new_top) { assert(new_top->parent == ui->top); ui->top = new_top; }
|
||||
fn void ui_pop_top(void) { ui->top = ui->top->parent; }
|
||||
fn void ui_set_rect(ui_box_t *box, r2f32_t rect) { box->rect = box->full_rect = rect; }
|
||||
|
||||
#define UILOC (ui_code_loc_t){.file = __FILE__, .line = __LINE__, .counter = __COUNTER__}
|
||||
|
||||
Reference in New Issue
Block a user