refactor ui flags

This commit is contained in:
Krzosa Karol
2025-01-16 08:55:00 +01:00
parent 6a1bb5a881
commit 947ac4bdf1
7 changed files with 100 additions and 59 deletions

View File

@@ -46,20 +46,13 @@ struct ui_size_t {
f32 strictness;
};
#define flag1(flag) set_bit(flag)
#define flag2(a, b) (set_bit(a) | set_bit(b))
#define flag3(a, b, c) (set_bit(a) | set_bit(b) | set_bit(c))
#define flag4(a, b, c, d) (set_bit(a) | set_bit(b) | set_bit(c) | set_bit(d))
#define is_flag_set(x, FLAG) ((x) & flag1(FLAG))
#define set_flag1(x, FLAG) ((x) |= flag1(FLAG))
typedef struct ui_box_flags_t ui_box_flags_t;
struct ui_box_flags_t {
b8 draw_border : 1;
b8 draw_text : 1;
b8 draw_rect : 1;
typedef u32 ui_box_flag_t;
enum {
ui_box_flag_draw_border,
ui_box_flag_draw_text,
ui_box_flag_draw_rect,
ui_box_flag_scroll,
b8 scroll : 1;
};
typedef struct ui_box_t ui_box_t;
@@ -72,7 +65,7 @@ struct ui_box_t {
ui_box_t *last;
i32 node_count;
ui_box_flag_t flags;
ui_box_flags_t flags;
s8_t string;
ui_size_t semantic_size[ui_axis2_count];
ui_axis2_t grow_axis;
@@ -112,11 +105,12 @@ struct ui_signal_t {
// b8 hovering;
};
typedef enum {
ui_id_strategy_use_hierarchy,
ui_id_strategy_use_code_loc,
ui_id_strategy_use_string,
} ui_id_strategy_t;
typedef struct ui_id_flags_t ui_id_flags_t;
struct ui_id_flags_t {
b8 use_hierarchy;
b8 use_code_loc;
b8 use_string;
};
typedef struct ui_t ui_t;
struct ui_t {
@@ -138,7 +132,8 @@ struct ui_t {
// STACK(ui_id_t, 256) id_stack;
int indent_stack;
ui_id_strategy_t id_strategy;
ui_id_flags_t id_flags;
};
gb ui_t *ui = NULL;