96 lines
2.4 KiB
C
96 lines
2.4 KiB
C
#include "core/core_inc.h"
|
|
#include "app/app.h"
|
|
|
|
#include "core/core_inc.c"
|
|
#include "app/app.c"
|
|
#include "gfx2d/gfx2d.c"
|
|
|
|
#include "ui.c"
|
|
|
|
/*
|
|
** UI Design:
|
|
** - keyboard friendly (not in the windows sense, more console sense)
|
|
**
|
|
**
|
|
** [ ]
|
|
**
|
|
**
|
|
*/
|
|
|
|
typedef struct globals_t globals_t;
|
|
struct globals_t {
|
|
gfx_t *gfx;
|
|
app_event_t event;
|
|
};
|
|
gb globals_t *globals;
|
|
|
|
|
|
fn void app_init(void) {
|
|
ui_test_iterators();
|
|
|
|
ma_arena_t *perm = &tcx._perm;
|
|
globals = ma_push_type(perm, globals_t);
|
|
globals->gfx = ma_push_type(perm, gfx_t);
|
|
ui_init(perm);
|
|
}
|
|
|
|
|
|
fn b32 app_update(app_event_list_t events) {
|
|
for (app_event_t *ev = events.first; ev; ev = ev->next) {
|
|
if (globals->event.kind == app_event_kind_null) {
|
|
globals->event = *ev;
|
|
}
|
|
|
|
#if 0
|
|
// ui_struct()
|
|
type_t *ti = type(app_event_t);
|
|
|
|
ui_push_list("▼ %S: struct", ti->name);
|
|
for (type_member_t *tm = ti->members; tm < ti->members + ti->count; tm += 1) {
|
|
if (tm->kind == type_kind_struct) {
|
|
ui_list_struct(tm->type, ti_get_member_offset(tm, p)
|
|
} else {
|
|
ui_list_item("%-20S: %S = %S", tm->name, ti_serial_type(tcx.temp, tm->type), ti_serial_data(p, type));
|
|
}
|
|
}
|
|
ui_pop_list();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
// These steps should be totally optional!!
|
|
{
|
|
app_event_t *ev = events.last;
|
|
f64 delta = app_get_anim_delta_time();
|
|
f64 time = app_get_anim_time();
|
|
f64 font_height = get_font_height();
|
|
|
|
// animate
|
|
// render
|
|
gfx_begin(globals->gfx, ev);
|
|
gfx_clear(globals->gfx, white_color_global);
|
|
gfx_textf(globals->gfx, (v2f64_t){0,ev->window_size.y - font_height}, black_color_global, "delta: %f, time: %f", delta, time);
|
|
|
|
|
|
// ►
|
|
type_t *ti = type(app_event_t);
|
|
f64 xoffset = measure_text("--");
|
|
|
|
|
|
v2f64_t p = {0, 0};
|
|
gfx_textf(globals->gfx, p, black_color_global, "▼ %S: struct", ti->name);
|
|
p.x += xoffset; p.y += font_height + 5;
|
|
|
|
for (type_member_t *tm = ti->members; tm < ti->members + ti->count; tm += 1) {
|
|
s8_t value = ti__serial_data(tcx.temp, ti_extract_member(&globals->event, tm), tm->type);
|
|
gfx_textf(globals->gfx, p, black_color_global, "%-20S: %-20S = %S", tm->name, ti_serial_type(tcx.temp, tm->type), value);
|
|
p.y += font_height + 5;
|
|
}
|
|
|
|
gfx_end(globals->gfx);
|
|
}
|
|
|
|
return false;
|
|
}
|