diff options
author | quou <quou@disroot.org> | 2024-06-01 12:19:16 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-06-01 12:20:17 +1000 |
commit | ea7cd94f7aeb177618db3907a6c86b7252e018f0 (patch) | |
tree | e972f9cf590ef756c2e41f3eac5b03e16db08300 /main.c |
Initial commit.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 67 |
1 files changed, 67 insertions, 0 deletions
@@ -0,0 +1,67 @@ +#include "memory.h" +#include "plat.h" +#include "rcache.h" +#include "ui.h" +#include "library.h" + +UI* ui; +Library* lib; + +Font* ffont; +void prog_init(void* memory) { + Heap* fh; + unsigned char* bin; + int bin_size; + int fhs = 1024 * 1024 * 4; + Font* font; + memory_init(memory); + rc_init(); + fh = galloc(sizeof *fh); + init_heap(fh, galloc(fhs), fhs); + bin = load_binary(default_font_location, &bin_size); + font = new_font(fh, bin, default_font_size); + ui = stack_alloc(sizeof *ui); + init_ui(ui, font); + lib = stack_alloc(sizeof *lib); + init_library(lib); + build_library(lib, library_folder); +} + +void prog_update(void) { + Rectangle l, r, lc, list; + int h, i, c; + rc_begin(); + ui_begin(ui, &l); + rc_add_cmd_rect(&l, theme_background_colour); + + r = rectcut_right(&l, l.w / 2); + h = font_height(ui->font) + theme_padding * 2; + c = lib->song_count; + lc.x = 0; + lc.y = 0; + lc.w = r.w - theme_padding * 2; + lc.h = h * c + theme_padding * (c - 1); + ui_container( + ui, + &r, + &lc, + &lc + ); + list = lc; + list.h = h; + for (i = 0; i < max_songs; i++) { + Song* song = &lib->songs[i]; + if (song->file[0]) { + ui_button(ui, &list, song->name); + list.y += list.h + theme_padding; + } + } + rc_add_cmd_reset_clip(); + + ui_end(ui); + rc_flush(); +} + +void prog_deinit(void) { + +} |