hot reload working

This commit is contained in:
Krzosa Karol
2025-01-26 11:54:31 +01:00
parent 7831cc51d6
commit f98c8e3dfa
31 changed files with 415 additions and 219 deletions

View File

@@ -1,15 +1,17 @@
fn void mt_ui_colors(ma_arena_t *arena, sb8_t *c, sb8_t *h) {
ast_t *table = mtt_parse(arena, __FILE__, S8_CODE(
{ name color }
{ rect_color `v4f32_hsla_to_rgba((v4f32_t){0.0f, 0.2f, 0.95f, 1.0f})` }
{ rect_hot_color `v4f32_hsla_to_rgba((v4f32_t){0.0f, 0.5f, 0.95f, 1.0f})` }
{ rect_active_color `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.5f, 0.95f, 1.0f})` }
{ border_color `v4f32_hsla_to_rgba((v4f32_t){0.0f, 0.2f, 0.70f, 1.0f})` }
{ text_color `v4f32_hsla_to_rgba((v4f32_t){0.0f, 0.2f, 0.70f, 1.0f})` }
{ text_hot_color `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.4f, 0.70f, 1.0f})` }
{ text_active_color `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.5f, 0.70f, 1.0f})` }
{ focused_rect_color `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.6f, 0.95f, 1.0f})` }
{ scroller_color `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.6f, 0.95f, 1.0f})` }
{ name color }
{ rect `v4f32_hsla_to_rgba((v4f32_t){0.0f, 0.2f, 0.95f, 1.0f})` }
{ rect_hot `v4f32_hsla_to_rgba((v4f32_t){0.0f, 0.5f, 0.95f, 1.0f})` }
{ rect_active `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.5f, 0.95f, 1.0f})` }
{ border `v4f32_hsla_to_rgba((v4f32_t){0.0f, 0.2f, 0.70f, 1.0f})` }
{ text `v4f32_hsla_to_rgba((v4f32_t){0.0f, 0.2f, 0.70f, 1.0f})` }
{ text_hot `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.4f, 0.70f, 1.0f})` }
{ text_active `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.5f, 0.70f, 1.0f})` }
{ focused_rect `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.6f, 0.95f, 1.0f})` }
{ scroller `ui_color_table[ui_color_text]` }
{ scroller_hot `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.2f, 0.7f, 1.0f})` }
{ scroller_active `v4f32_hsla_to_rgba((v4f32_t){0.1f, 0.2f, 0.5f, 1.0f})` }
));
mtt_serial_enum(c, h, table, s8_lit("ui_color"));
@@ -38,13 +40,13 @@ fn void mt_ui_stacks(ma_arena_t *arena, sb8_t *c, sb8_t *h) {
{ f32 required_size 0 x }
{ f32 padding 0 x }
{ f32 string_pos_offset 0 0 }
{ v4f32_t background_color 0 `ui_color_table[ui_color_rect_color]` }
{ v4f32_t bg_hot_color 0 `ui_color_table[ui_color_rect_hot_color]` }
{ v4f32_t bg_active_color 0 `ui_color_table[ui_color_rect_active_color]` }
{ v4f32_t border_color 0 `ui_color_table[ui_color_border_color]` }
{ v4f32_t text_color 0 `ui_color_table[ui_color_text_color]` }
{ v4f32_t text_hot_color 0 `ui_color_table[ui_color_text_hot_color]` }
{ v4f32_t text_active_color 0 `ui_color_table[ui_color_text_active_color]` }
{ v4f32_t background_color 0 `ui_color_table[ui_color_rect]` }
{ v4f32_t bg_hot_color 0 `ui_color_table[ui_color_rect_hot]` }
{ v4f32_t bg_active_color 0 `ui_color_table[ui_color_rect_active]` }
{ v4f32_t border_color 0 `ui_color_table[ui_color_border]` }
{ v4f32_t text_color 0 `ui_color_table[ui_color_text]` }
{ v4f32_t text_hot_color 0 `ui_color_table[ui_color_text_hot]` }
{ v4f32_t text_active_color 0 `ui_color_table[ui_color_text_active]` }
));
///////////////////////////////
@@ -98,7 +100,7 @@ fn void mt_ui_stacks(ma_arena_t *arena, sb8_t *c, sb8_t *h) {
///////////////////////////////
// generate stack functions
for (ast_t *it = table->first; it; it = it->next) {
mt_sbprintf(c, it, "fn void ui_push_@name(@type v) { @node *n = ma_push_type(tcx.temp, @node); n->value = v; SLLS_PUSH(ui->@stack, n); }\n"
mt_sbprintf(c, it, "fn void ui_push_@name(@type v) { @node *n = ma_push_type(tcx->temp, @node); n->value = v; SLLS_PUSH(ui->@stack, n); }\n"
"fn void ui_pop_@name(void) { SLLS_POP(ui->@stack); }\n"
"fn @type ui_top_@name(void) { return ui->@stack->value; }\n"
"#define ui_set_@name(x) defer_block(ui_push_@name(x), ui_pop_@name())\n");