ui allocation scheme

This commit is contained in:
Krzosa Karol
2025-01-10 11:14:56 +01:00
parent 74a60e812d
commit 26d8c176a0
6 changed files with 108 additions and 46 deletions

View File

@@ -34,35 +34,39 @@ gb globals_t *globals;
fn void app_init(void) {
ma_arena_t *perm = &tcx._perm;
globals = ma_push_type(perm, globals_t);
// globals->gfx = ma_push_type(perm, gfx_t);
ma_arena_t *ui_arena = ma_push_arena(perm, mib(1));
ui_init(ui_arena);
rn_init(perm);
ui_init(perm);
}
fn b32 app_update(app_frame_t *frame) {
ui_begin_frame();
assert(frame != NULL);
ui_begin_frame(frame);
defer_block(ui_begin_build(), ui_end_build()) {
defer_block(ui_push_list_container(), ui_pop_parent()) {
if (ui_push_expander("app_event_t")) {
if (ui_push_expander("mouse_wheel_delta: v3f64_t")) {
ui_label("x: f64 = value");
ui_label("y: f64 = value");
ui_label("z: f64 = value");
ui_pop_expander();
if (r2f32_contains(r2f32(0, 0, 200, 200), frame->mouse_pos)) {
if (ui_push_expander("mouse_wheel_delta: v3f64_t")) {
ui_label("x: f64 = value");
ui_label("y: f64 = value");
ui_label("z: f64 = value");
ui_pop_expander();
}
}
ui_label("kind: app_event_kind_t = value");
ui_label("ctrl: b8 = value");
ui_label("shift: b8 = value");
if (ui_push_expander("pos: v2f64_t")) {
if (ui_push_expander("inner_pos: v2f64_t")) {
ui_label("x: f64 = value");
ui_label("y: f64 = value");
ui_label("x_: f64 = value");
ui_label("y_: f64 = value");
ui_pop_expander();
}
ui_label("y: f64 = value");
if (ui_push_expander("inner_pos: v2f64_t")) {
ui_label("x: f64 = value");
ui_label("y: f64 = value");
ui_label("y__: f64 = value");
if (ui_push_expander("_inner_pos: v2f64_t")) {
ui_label("x____: f64 = value");
ui_label("y____: f64 = value");
ui_pop_expander();
}
ui_pop_expander();
@@ -82,9 +86,9 @@ fn b32 app_update(app_frame_t *frame) {
}
rn_begin();
rn_draw_stringf(&rn_state.main_font, v2f32(0,0), black_color_global, "delta: %f update: %f", frame->delta, frame->update);
ui_draw();
rn_draw_stringf(&rn_state.main_font, v2f32(0,frame->window_size.y - 100), black_color_global, "ui_boxes: %d delta: %f update: %f", ui->allocated_boxes, frame->delta, frame->update);
rn_end(frame->window_size, white_color_global);
#if 0