ui begin text box

This commit is contained in:
Krzosa Karol
2025-01-23 09:51:16 +01:00
parent 157baab5b9
commit fdbc8490c4
4 changed files with 73 additions and 25 deletions

View File

@@ -1,3 +1,5 @@
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;
@@ -54,6 +56,7 @@ struct ui_box_t {
ui_box_flags_t flags;
b8 created_new;
ui_custom_draw_t *custom_draw;
UI_DECL_BOX_MEMBERS
r2f32_t full_rect;
@@ -70,6 +73,11 @@ struct ui_box_t {
r2f32_t final_rect;
b32 expanded;
i32 ti_cursor;
char *ti_buffer;
i32 ti_buffer_len;
i32 ti_buffer_cap;
};
typedef struct ui_signal_t ui_signal_t;
@@ -100,6 +108,7 @@ struct ui_t {
// interaction
ui_id_t hot;
ui_id_t active;
ui_id_t focus;
// drawing
r2f32_t clip_rect;
@@ -115,6 +124,7 @@ fn b32 ui_is_null_id(ui_id_t id) { return id.value == 0; }
fn b32 ui_is_null_box(ui_box_t *box) { return box->id.value == 0; }
fn b32 ui_is_hot_box(ui_box_t *box) { return !ui_is_null_box(box) && box->id.value == ui->hot.value; }
fn b32 ui_is_active_box(ui_box_t *box) { return !ui_is_null_box(box) && box->id.value == ui->active.value; }
fn b32 ui_is_focused_box(ui_box_t *box) { return !ui_is_null_box(box) && box->id.value == ui->focus.value; }
#define ev_left(ev) ((ev)->mouse_button == app_mouse_button_left)
#define ev_left_up(ev) ((ev)->kind == app_event_kind_mouse_up && ev_left(ev))