diff --git a/build_file.c b/build_file.c index 5b091ac..bb5f65d 100644 --- a/build_file.c +++ b/build_file.c @@ -28,8 +28,8 @@ int main(int argc, char **argv) { bool run_server = false; bool core_test_target = false; + bool win32_target = false; bool wasm_target = true; - bool win32_target = true; if (execute_python_snippets) { sb8_t *sb = sb8_serial_begin(arena); @@ -73,7 +73,7 @@ int main(int argc, char **argv) { if (core_test_target) { os_delete_file(s8_lit("core_test.pdb")); ok = os_systemf( - "cl ../src/core_test/core_test_entry.c -Fe:core_test.exe -Fd:core_test.pdb" + "cl ../src/core/core_test_entry.c -Fe:core_test.exe -Fd:core_test.pdb" " -I ../src" " /Zi /FC /nologo /Oi /O2" " /WX /W3 /wd4200 /diagnostics:column" diff --git a/package/index.html b/package/index.html index 5bc2f8c..fd36878 100644 --- a/package/index.html +++ b/package/index.html @@ -212,6 +212,7 @@ const mem = new memory_t(new WebAssembly['Memory']({ initial: 2000, maximum: 655 window.requestAnimationFrame(wasm_update); } + addEventListener("resize", (event) => { wake_up(); }); addEventListener("keydown", (event) => { wasm_exports["wasm_key_down"](mem.write_string_to_cglobal("wasm_temp_buff1", event.key), event.ctrlKey, event.shiftKey, event.altKey, event.metaKey); wake_up(); diff --git a/src/app/app.gen.c b/src/app/app.gen.c index 9ef6f61..c20c63b 100644 --- a/src/app/app.gen.c +++ b/src/app/app.gen.c @@ -255,27 +255,27 @@ type_t type__app_event_kind_t = { type_kind_enum, s8_const_lit("app_event_kind_t }; type_t type__app_event_t = { type_kind_struct, s8_const_lit("app_event_t"), sizeof(app_event_t), .members = (type_member_t[]){ - {.name = s8_const_lit("next"), .type = &(type_t){type_kind_pointer, s8_const_lit("app_event_t*"), sizeof(void *), .base = &type__app_event_t}, .offset = offsetof(app_event_t, next)}, - {.name = s8_const_lit("kind"), .type = &type__app_event_kind_t, .offset = offsetof(app_event_t, kind)}, - {.name = s8_const_lit("mouse_button"), .type = &type__app_mouse_button_t, .offset = offsetof(app_event_t, mouse_button)}, - {.name = s8_const_lit("key"), .type = &type__app_key_t, .offset = offsetof(app_event_t, key)}, - {.name = s8_const_lit("text"), .type = &type__s8_t, .offset = offsetof(app_event_t, text)}, - {.name = s8_const_lit("mouse_wheel_delta"), .type = &type__v3f64_t, .offset = offsetof(app_event_t, mouse_wheel_delta)}, - {.name = s8_const_lit("ctrl"), .type = &type__b8, .offset = offsetof(app_event_t, ctrl)}, - {.name = s8_const_lit("shift"), .type = &type__b8, .offset = offsetof(app_event_t, shift)}, - {.name = s8_const_lit("alt"), .type = &type__b8, .offset = offsetof(app_event_t, alt)}, - {.name = s8_const_lit("meta"), .type = &type__b8, .offset = offsetof(app_event_t, meta)}, - {.name = s8_const_lit("dpr"), .type = &type__f64, .offset = offsetof(app_event_t, dpr)}, - {.name = s8_const_lit("window_size"), .type = &type__v2f64_t, .offset = offsetof(app_event_t, window_size)}, - {.name = s8_const_lit("mouse_pos"), .type = &type__v2f64_t, .offset = offsetof(app_event_t, mouse_pos)}, + {.name = s8_const_lit("next"), .type = &(type_t){type_kind_pointer, s8_const_lit("app_event_t*"), sizeof(void *), .base = &type__app_event_t}, .offset = offsetof(app_event_t, next), .dont_serialize = 0}, + {.name = s8_const_lit("kind"), .type = &type__app_event_kind_t, .offset = offsetof(app_event_t, kind), .dont_serialize = 0}, + {.name = s8_const_lit("mouse_button"), .type = &type__app_mouse_button_t, .offset = offsetof(app_event_t, mouse_button), .dont_serialize = 0}, + {.name = s8_const_lit("key"), .type = &type__app_key_t, .offset = offsetof(app_event_t, key), .dont_serialize = 0}, + {.name = s8_const_lit("text"), .type = &type__s8_t, .offset = offsetof(app_event_t, text), .dont_serialize = 0}, + {.name = s8_const_lit("mouse_wheel_delta"), .type = &type__v3f64_t, .offset = offsetof(app_event_t, mouse_wheel_delta), .dont_serialize = 0}, + {.name = s8_const_lit("ctrl"), .type = &type__b8, .offset = offsetof(app_event_t, ctrl), .dont_serialize = 0}, + {.name = s8_const_lit("shift"), .type = &type__b8, .offset = offsetof(app_event_t, shift), .dont_serialize = 0}, + {.name = s8_const_lit("alt"), .type = &type__b8, .offset = offsetof(app_event_t, alt), .dont_serialize = 0}, + {.name = s8_const_lit("meta"), .type = &type__b8, .offset = offsetof(app_event_t, meta), .dont_serialize = 0}, + {.name = s8_const_lit("dpr"), .type = &type__f64, .offset = offsetof(app_event_t, dpr), .dont_serialize = 0}, + {.name = s8_const_lit("window_size"), .type = &type__v2f64_t, .offset = offsetof(app_event_t, window_size), .dont_serialize = 0}, + {.name = s8_const_lit("mouse_pos"), .type = &type__v2f64_t, .offset = offsetof(app_event_t, mouse_pos), .dont_serialize = 0}, }, .count = 13, }; type_t type__app_event_list_t = { type_kind_struct, s8_const_lit("app_event_list_t"), sizeof(app_event_list_t), .members = (type_member_t[]){ - {.name = s8_const_lit("first"), .type = &(type_t){type_kind_pointer, s8_const_lit("app_event_t*"), sizeof(void *), .base = &type__app_event_t}, .offset = offsetof(app_event_list_t, first)}, - {.name = s8_const_lit("last"), .type = &(type_t){type_kind_pointer, s8_const_lit("app_event_t*"), sizeof(void *), .base = &type__app_event_t}, .offset = offsetof(app_event_list_t, last)}, - {.name = s8_const_lit("len"), .type = &type__i32, .offset = offsetof(app_event_list_t, len)}, + {.name = s8_const_lit("first"), .type = &(type_t){type_kind_pointer, s8_const_lit("app_event_t*"), sizeof(void *), .base = &type__app_event_t}, .offset = offsetof(app_event_list_t, first), .dont_serialize = 1}, + {.name = s8_const_lit("last"), .type = &(type_t){type_kind_pointer, s8_const_lit("app_event_t*"), sizeof(void *), .base = &type__app_event_t}, .offset = offsetof(app_event_list_t, last), .dont_serialize = 0}, + {.name = s8_const_lit("len"), .type = &type__i32, .offset = offsetof(app_event_list_t, len), .dont_serialize = 0}, }, .count = 3, }; \ No newline at end of file diff --git a/src/app/app.meta.c b/src/app/app.meta.c index 0c122c4..74aaaf8 100644 --- a/src/app/app.meta.c +++ b/src/app/app.meta.c @@ -182,7 +182,7 @@ void meta_app(ma_arena_t *arena) { }; struct app_event_list_t { - app_event_t *first; + app_event_t *first; @dont_serialize app_event_t *last; i32 len; }; diff --git a/src/app/app_wasm.c b/src/app/app_wasm.c index 6bf21fb..a436763 100644 --- a/src/app/app_wasm.c +++ b/src/app/app_wasm.c @@ -47,6 +47,11 @@ fn void app_init(void); fn void wasm_add_event(app_event_t event) { app_event_t *ev = ma_push_type(tcx.temp, app_event_t); + ev->alt = wasm_cached.alt; + ev->ctrl = wasm_cached.ctrl; + ev->meta = wasm_cached.meta; + ev->shift = wasm_cached.shift; + ev->mouse_pos = wasm_cached.mouse_pos; SLLQ_APPEND(wasm_event_list.first, wasm_event_list.last, ev); wasm_event_list.len += 1; } @@ -56,11 +61,6 @@ fn_wasm_export void wasm_mouse_move(f64 x, f64 y, b32 ctrl, b32 shift, b32 alt, wasm_cached.ctrl = ctrl; wasm_cached.alt = alt; wasm_cached.meta = meta; wasm_cached.shift = shift; wasm_add_event((app_event_t){ .kind = app_event_kind_mouse_move, - .mouse_pos = {x, y}, - .ctrl = ctrl, - .shift = shift, - .alt = alt, - .meta = meta, }); } @@ -71,12 +71,7 @@ fn_wasm_export void wasm_mouse_down(f64 x, f64 y, i32 button, b32 ctrl, b32 shif wasm_cached.mouse_pos = (v2f64_t){x, y}; wasm_add_event((app_event_t){ .kind = app_event_kind_mouse_down, - .mouse_pos = {x, y}, .mouse_button = button, - .ctrl = ctrl, - .shift = shift, - .alt = alt, - .meta = meta, }); } @@ -87,12 +82,7 @@ fn_wasm_export void wasm_mouse_up(f64 x, f64 y, i32 button, b32 ctrl, b32 shift, wasm_cached.mouse_pos = (v2f64_t){x, y}; wasm_add_event((app_event_t){ .kind = app_event_kind_mouse_up, - .mouse_pos = {x, y}, .mouse_button = button, - .ctrl = ctrl, - .shift = shift, - .alt = alt, - .meta = meta, }); } @@ -102,11 +92,6 @@ fn_wasm_export void wasm_mouse_wheel(f64 x, f64 y, f64 delta_x, f64 delta_y, f64 wasm_add_event((app_event_t){ .kind = app_event_kind_mouse_wheel, .mouse_wheel_delta = {delta_x, delta_y, delta_z}, - .mouse_pos = {x, y}, - .ctrl = ctrl, - .shift = shift, - .alt = alt, - .meta = meta, }); } @@ -119,12 +104,7 @@ fn_wasm_export void wasm_key_down(char *key, b32 ctrl, b32 shift, b32 alt, b32 m if (map.key != app_key_null) { wasm_add_event((app_event_t){ .kind = app_event_kind_key_down, - .mouse_pos = wasm_cached.mouse_pos, .key = map.key, - .ctrl = ctrl, - .shift = shift, - .alt = alt, - .meta = meta, }); } @@ -136,12 +116,7 @@ fn_wasm_export void wasm_key_down(char *key, b32 ctrl, b32 shift, b32 alt, b32 m s8_t text = s8_copy(tcx.temp, key8); wasm_add_event((app_event_t){ .kind = app_event_kind_text, - .mouse_pos = wasm_cached.mouse_pos, .text = text, - .ctrl = ctrl, - .shift = shift, - .alt = alt, - .meta = meta, }); } @@ -155,12 +130,7 @@ fn_wasm_export void wasm_key_up(char *key, b32 ctrl, b32 shift, b32 alt, b32 met if (map.key != app_key_null) { wasm_add_event((app_event_t){ .kind = app_event_kind_key_up, - .mouse_pos = wasm_cached.mouse_pos, .key = map.key, - .ctrl = ctrl, - .shift = shift, - .alt = alt, - .meta = meta, }); } } @@ -173,14 +143,7 @@ fn_wasm_export b32 wasm_update(f64 time, f64 width, f64 height, f64 dpr) { wasm_dpr = dpr; if (wasm_event_list.first == NULL) { - wasm_add_event((app_event_t){ - .kind = app_event_kind_update, - .mouse_pos = wasm_cached.mouse_pos, - .alt = wasm_cached.alt, - .ctrl = wasm_cached.ctrl, - .meta = wasm_cached.meta, - .shift = wasm_cached.shift, - }); + wasm_add_event((app_event_t){.kind = app_event_kind_update}); } for (app_event_t *ev = wasm_event_list.first; ev; ev = ev->next) { diff --git a/src/app/app_wasm.html b/src/app/app_wasm.html index 5bc2f8c..fd36878 100644 --- a/src/app/app_wasm.html +++ b/src/app/app_wasm.html @@ -212,6 +212,7 @@ const mem = new memory_t(new WebAssembly['Memory']({ initial: 2000, maximum: 655 window.requestAnimationFrame(wasm_update); } + addEventListener("resize", (event) => { wake_up(); }); addEventListener("keydown", (event) => { wasm_exports["wasm_key_down"](mem.write_string_to_cglobal("wasm_temp_buff1", event.key), event.ctrlKey, event.shiftKey, event.altKey, event.metaKey); wake_up(); diff --git a/src/core/core_lexer.c b/src/core/core_lexer.c index 6995dcb..87aa300 100644 --- a/src/core/core_lexer.c +++ b/src/core/core_lexer.c @@ -120,6 +120,7 @@ fn void lex_token_ex(lexer_t *lex, lex_t *token) { case ';': token->kind = lex_kind_semicolon; break; case ':': token->kind = lex_kind_colon; break; case ',': token->kind = lex_kind_comma; break; + case '@': token->kind = lex_kind_tag; break; case '"': lex_eat_string(lex, token); break; case '`': lex_eat_string(lex, token); break; case '\'': lex_eat_string(lex, token); break; @@ -314,6 +315,12 @@ fn lex_t *parser_expect(parser_t *par, lex_kind_t kind) { return token; } +fn lex_t *parser_expecti(parser_t *par, s8_t ident) { + lex_t *token = parser_matchi(par, ident); + if (!token) parser_panicf(par->at, "expected identifier: '%S'", ident); + return token; +} + fn void parser_eat_until(parser_t *par, lex_kind_t kind) { while (par->at->kind != kind && par->at->kind != lex_kind_eof) { parser_next(par); diff --git a/src/core/core_lexer.h b/src/core/core_lexer.h index de3dd9a..41f96d3 100644 --- a/src/core/core_lexer.h +++ b/src/core/core_lexer.h @@ -56,6 +56,7 @@ enum lex_kind_t { X(lex_kind_colon , "':' colon" , ":" )\ X(lex_kind_arrow , "'->' arrow" , "->" )\ X(lex_kind_question , "'?' question mark" , "?" )\ + X(lex_kind_tag , "'@' tag sign" , "@" )\ #define X(KIND, STR, SIMPLE) KIND, LEX_KIND_XLIST diff --git a/src/core/core_string.h b/src/core/core_string.h index ee84f4a..f18dd90 100644 --- a/src/core/core_string.h +++ b/src/core/core_string.h @@ -31,6 +31,7 @@ struct sb8_t { sb8_node_t *first; sb8_node_t *last; + // WARNING: remember to update typeinfo after editing this i32 indent; }; diff --git a/src/core/core_type_info.h b/src/core/core_type_info.h index e5a1b5c..3084a1f 100644 --- a/src/core/core_type_info.h +++ b/src/core/core_type_info.h @@ -46,6 +46,7 @@ struct type_member_t { type_t *type; i64 value; u64 offset; + b8 dont_serialize; }; // @@ -120,6 +121,22 @@ gb_read_only type_t type__ma_arena_t = { type_kind_struct, s8_const_lit("ma_aren } }; +gb_read_only type_t type__sb8_node_t = {type_kind_struct, s8_const_lit("sb8_node_t"), sizeof(sb8_t), .count = 2, + .members = (type_member_t[]){ + {s8_const_lit("next"), &POINTER(sb8_node_t), .offset = offsetof(sb8_node_t, next)}, + {s8_const_lit("string"), &type__s8_t, .offset = offsetof(sb8_node_t, string)}, + } +}; + +gb_read_only type_t type__sb8_t = { type_kind_struct, s8_const_lit("sb8_t"), sizeof(sb8_t), .count = 4, + .members = (type_member_t[]){ + {s8_const_lit("arena"), &POINTER(ma_arena_t), .offset = offsetof(sb8_t, arena)}, + {s8_const_lit("first"), &POINTER(sb8_node_t), .offset = offsetof(sb8_t, first)}, + {s8_const_lit("last"), &POINTER(sb8_node_t), .offset = offsetof(sb8_t, last)}, + {s8_const_lit("indent"), &type__i32, .offset = offsetof(sb8_t, first)}, + } +}; + gb_read_only type_t type__ma_temp_t = { type_kind_struct, s8_const_lit("ma_temp_t"), sizeof(ma_temp_t), .count = 2, .members = (type_member_t[]){ {s8_const_lit("arena"), &POINTER(ma_arena_t), .offset = offsetof(ma_temp_t, arena)}, diff --git a/src/core_test/core_test_entry.c b/src/core_test/core_test_entry.c deleted file mode 100644 index 52a17a2..0000000 --- a/src/core_test/core_test_entry.c +++ /dev/null @@ -1,115 +0,0 @@ -#include "core/core_inc.h" -#include "core/core_inc.c" - -void test_s8(void) { - ma_arena_t *arena = ma_create(ma_default_reserve_size); - - { - ma_temp_t temp = ma_begin_temp(arena); - sb8_t *sb = &(sb8_t){arena}; - - s8_t memes = s8_lit("memes"); - sb8_printf(sb, "%S", memes); - assert(sb->first == sb->last); - assert(sb->first->len == 5); - assert(s8_equal(sb->first->string, memes)); - - sb8_printf(sb, "%S", s8_lit("things are going fine")); - s8_t string = sb8_merge(sb); - assert(s8_equal(string, s8_lit("memesthings are going fine"))); - - ma_end_temp(temp); - } - - { - s8_t str = s8_lit("thing|another|"); - sb8_t sb = s8_split(arena, str, s8_lit("|"), s8_split_none); - - assert(s8_equal(sb.first->string, s8_lit("thing"))); - assert(s8_equal(sb.first->next->string, s8_lit("another"))); - assert(sb.first->next->next == NULL); - } - - { - s8_t str = s8_lit("thing|another|"); - sb8_t sb = s8_split(arena, str, s8_lit("|"), s8_split_inclusive); - - assert(s8_equal(sb.first->string, s8_lit("thing"))); - assert(s8_equal(sb.first->next->string, s8_lit("|"))); - assert(s8_equal(sb.first->next->next->string, s8_lit("another"))); - assert(s8_equal(sb.first->next->next->next->string, s8_lit("|"))); - assert(sb.first->next->next->next->next == NULL); - } - - { - s8_t str = s8_lit("aabaaBaa"); - sb8_t sb = s8_split(arena, str, s8_lit("b"), s8_split_inclusive | s8_split_ignore_case); - - assert(s8_equal(sb.first->string, s8_lit("aa"))); - assert(s8_equal(sb.first->next->string, s8_lit("b"))); - assert(s8_equal(sb.first->next->next->string, s8_lit("aa"))); - assert(s8_equal(sb.first->next->next->next->string, s8_lit("B"))); - assert(s8_equal(sb.first->next->next->next->next->string, s8_lit("aa"))); - assert(sb.first->next->next->next->next->next == NULL); - } - - { - s8_t str = s8_lit("aabaaBaa"); - sb8_t sb = s8_split(arena, str, s8_lit("b"), s8_split_inclusive); - - assert(s8_equal(sb.first->string, s8_lit("aa"))); - assert(s8_equal(sb.first->next->string, s8_lit("b"))); - assert(s8_equal(sb.first->next->next->string, s8_lit("aaBaa"))); - } - - { - s8_t s = s8_lit("0123456789"); - assert(s8_equal(s8_slice(s, 0, 4), s8_lit("0123"))); - assert(s8_equal(s8_slice(s, -2, -1), s8_lit("89"))); - assert(s8_equal(s8_slice(s, -2, 10), s8_lit("89"))); - assert(s8_equal(s8_slice(s, 8, 10), s8_lit("89"))); - } - - { - s8_t s = s8_lit(" a \n"); - s = s8_trim(s); - assert(s8_equal(s, s8_lit("a"))); - } - - { - s8_t s = s8_lit("C:/memes/the_thing.c"); - s8_t ss = s8_get_name_no_ext(s); - assert(s8_equal(ss, s8_lit("the_thing"))); - } - - { - s8_t s = s8_printf(arena, "%d%Sv%s", 32, s8_lit("|"), ">"); - assert(s8_equal(s, s8_lit("32|v>"))); - } - - { - s8_t s0 = s8_lit("0123456789"); - s8_t s1 = s8_cut_start(&s0, 2); - assert(s8_equal(s0, s8_lit("23456789"))); - assert(s8_equal(s1, s8_lit("01"))); - } - ma_destroy(arena); -} - -#include - -int main(int argc, char **argv) { - printf("PLATFORM_WASM = %d\n", PLATFORM_WASM); - printf("PLATFORM_WINDOWS = %d\n", PLATFORM_WINDOWS); - printf("PLATFORM_LINUX = %d\n", PLATFORM_LINUX); - printf("PLATFORM_POSIX = %d\n", PLATFORM_POSIX); - printf("PLATFORM_MAC_OS = %d\n", PLATFORM_MAC_OS); - printf("PLATFORM_CLANG = %d\n", PLATFORM_CLANG); - printf("PLATFORM_GCC = %d\n", PLATFORM_GCC); - printf("PLATFORM_CL = %d\n", PLATFORM_CL); - printf("PLATFORM_TCC = %d\n", PLATFORM_TCC); - - test_s8(); - - printf("all done!\n"); -} \ No newline at end of file diff --git a/src/meta/parser.c b/src/meta/parser.c index 595338c..3bb6be7 100644 --- a/src/meta/parser.c +++ b/src/meta/parser.c @@ -1,19 +1,20 @@ typedef enum { -#define AST_FLAG_XLIST\ - X(null)\ - X(string)\ - X(integer)\ - X(real)\ - X(binary)\ - X(enum)\ - X(enum_member)\ - X(struct)\ - X(struct_member)\ - X(var)\ - X(type_name)\ - X(type_pointer)\ - X(type_array)\ +#define AST_FLAG_XLIST \ + X(null) \ + X(string) \ + X(integer) \ + X(real) \ + X(binary) \ + X(enum) \ + X(enum_member) \ + X(struct) \ + X(struct_member) \ + X(var) \ + X(type_name) \ + X(type_pointer) \ + X(type_array) \ + X(dont_serialize) #define X(NAME) ast_flag_##NAME, AST_FLAG_XLIST @@ -259,6 +260,11 @@ ast_t *parse_decls(ma_arena_t *arena, char *file, s8_t code) { ast_append(mem, type); parser_expect(par, lex_kind_semicolon); + if (parser_match(par, lex_kind_tag)) { + if (parser_expecti(par, s8_lit("dont_serialize"))) { + mem->flags |= set_bit(ast_flag_dont_serialize); + } + } } parser_expect(par, lex_kind_close_brace); parser_expect(par, lex_kind_semicolon); diff --git a/src/meta/serialize.c b/src/meta/serialize.c index 50db61e..b1e9216 100644 --- a/src/meta/serialize.c +++ b/src/meta/serialize.c @@ -124,7 +124,8 @@ void sb8_serial_ast_to_type_info(sb8_t *sb, ast_t *n) { for (ast_t *it = n->first; it; it = it->next) { s8_t name = it->string; s8_t type_info = s8_serial_ast_type_to_type_info(sb->arena, it->first); - sb8_stmtf(sb, "{.name = s8_const_lit(\"%S\"), .type = &%S, .offset = offsetof(%S, %S)},", name, type_info, n->string, name); + b32 dont_serialize = (it->flags & set_bit(ast_flag_dont_serialize)) ? true : false; + sb8_stmtf(sb, "{.name = s8_const_lit(\"%S\"), .type = &%S, .offset = offsetof(%S, %S), .dont_serialize = %d},", name, type_info, n->string, name, dont_serialize); } sb->indent -= 1; sb8_stmtf(sb, "},"); diff --git a/src/wasm_app/main.c b/src/wasm_app/main.c index 0dd9858..7f246db 100644 --- a/src/wasm_app/main.c +++ b/src/wasm_app/main.c @@ -1,29 +1,65 @@ #include "core/core_inc.h" #include "app/app.h" -#include "os/os.h" #include "core/core_inc.c" #include "app/app.c" -#include "os/os.c" #include "gfx2d/gfx2d.c" // #include "ui.c" -gfx_t *gfx = NULL; +typedef struct ui_widget_t ui_widget_t; +struct ui_widget_t { +}; + +typedef struct ui_t ui_t; +struct ui_t { + + // update cycle data + b8 left_press; + b8 left_unpress; + b8 left_down; + v2f64_t mouse_pos; + v2f64_t window_size; + + // + +}; + +gb ui_t gb_ui = {0}; +gb gfx_t *gfx = NULL; + +gb i32 config_indent = 4; + +void ui_begin_interaction(ui_t *ui, app_event_t *ev) { + ui->mouse_pos = ev->mouse_pos; + ui->window_size = ev->window_size; + ui->left_press = false; + ui->left_unpress = false; + if (ev->kind == app_event_kind_mouse_down && ev->mouse_button == app_mouse_button_left) { + ui->left_press = true; + ui->left_down = true; + } + if (ev->kind == app_event_kind_mouse_up && ev->mouse_button == app_mouse_button_left) { + ui->left_unpress = true; + ui->left_down = false; + } +} + +void app_handle_event(app_event_t *ev) { + ui_t *ui = &gb_ui; + ui_begin_interaction(ui, ev); +} void app_init(void) { ma_arena_t *perm = &tcx._perm; gfx = ma_push_type(perm, gfx_t); - os_date_t ldate = os_local_time_now(); - os_date_t udate = os_universal_time_now(); - assert(ldate.hour == (udate.hour + 1)); } b32 app_update(app_event_list_t events) { for (app_event_t *ev = events.first; ev; ev = ev->next) { - // update + app_handle_event(ev); } // These steps should be totally optional!! diff --git a/todo.txt b/todo.txt index f3e48ee..5d94b24 100644 --- a/todo.txt +++ b/todo.txt @@ -1,28 +1,29 @@ -[ ] platform - [ ] app - [ ] sleep - [ ] ui - [ ] event playback - [ ] how to fix variable scroll? or do we not care? - [ ] win32 - [ ] hot reload / plugins - [ ] tests using yield - [ ] linux - [ ] os - [?] wasm (explore) - [ ] drag and drop - [ ] open file dialog - [ ] win32 - [ ] linux - [ ] gfx - [ ] simple 2d - [ ] revisit api - [x] change name, hard to type +[ ] app + [ ] sleep + [ ] ui + [ ] event playback + [ ] how to fix variable scroll? or do we not care? (probably need delta time) + [ ] win32 + [ ] hot reload / plugins + [ ] tests using yield + [ ] linux + [ ] wasm + [ ] drag and drop + [ ] open file dialog +[ ] os + [?] wasm (explore) + [ ] win32 + [ ] linux +[ ] gfx + [ ] simple 2d + [ ] revisit api + [x] change name, hard to type [ ] core [x] remove dates and time from core [ ] meta [x] search for python snippets and execute meta.py script on that file + [ ] somehow index properly the meta files and ignore generated files [ ] new simple format with tags [x] revisit api [ ] s8_bin