1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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) {
}
|