#include #include "config.h" #include "library.h" #include "luigi.h" #include "memory.h" Library lib; int libtab_msg( UIElement *el, UIMessage msg, int di, void *dp ) { if (msg == UI_MSG_TABLE_GET_ITEM) { UITableGetItem *m = (UITableGetItem*)dp; Song* song; song = &lib.songs[lib.indices[m->index]]; m->isSelected = 0; switch (m->column) { case 0: return snprintf( m->buffer, m->bufferBytes, "%s", song->name ); case 1: return snprintf( m->buffer, m->bufferBytes, "%s", song->artist ); case 2: return snprintf( m->buffer, m->bufferBytes, "%s", song->album ); case 3: return snprintf( m->buffer, m->bufferBytes, "%s", song->path ); default: return 0; } } return 0; } int prog_main(void* mem) { Arena liba; UIWindow* wi; UISplitPane* split1, * split2, * split3; UIPanel* plib, * pctrl, * plist, * pqueue; UITable* libtab; memory_init(mem); init_arena( &liba, galloc(library_memory_size), library_memory_size ); build_library(&liba, &lib, library_path); UIInitialise(); wi = UIWindowCreate( 0, 0, app_name, default_window_w, default_window_h ); split1 = UISplitPaneCreate( &wi->e, 0, 0.3f ); split3 = UISplitPaneCreate( &split1->e, UI_SPLIT_PANE_VERTICAL, 0.5f ); split2 = UISplitPaneCreate( &split1->e, 0, 0.5f ); pctrl = UIPanelCreate(&split3->e, UI_PANEL_GRAY); pctrl->gap = 5; pctrl->border = UI_RECT_1(5); pqueue = UIPanelCreate(&split3->e, UI_PANEL_GRAY); pqueue->gap = 5; pqueue->border = UI_RECT_1(5); UILabelCreate( &pqueue->e, 0, "Queue", 5 ); plist = UIPanelCreate(&split2->e, UI_PANEL_GRAY); plist->gap = 5; plist->border = UI_RECT_1(5); UILabelCreate( &plist->e, 0, "Playlist", 8 ); plib = UIPanelCreate(&split2->e, UI_PANEL_GRAY); plib->gap = 5; plib->border = UI_RECT_1(5); UILabelCreate( &plib->e, 0, "Library", 7 ); libtab = UITableCreate( &plib->e, UI_ELEMENT_H_FILL | UI_ELEMENT_V_FILL, "Track\tArtist\tAlbum\tFilename" ); libtab->itemCount = lib.cnt; libtab->e.messageUser = libtab_msg; UITableResizeColumns(libtab); return UIMessageLoop(); }