From cb7a3d27e2f036d90a5c359cf850d18ab20c4d5c Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Wed, 19 Jan 2005 15:01:31 +0000 Subject: Added a virtual 'Artists,Albums,Songs' root folder in ID3 browser git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5606 a1c6a512-1295-4272-9138-f99709370657 --- apps/dbtree.c | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'apps/dbtree.c') diff --git a/apps/dbtree.c b/apps/dbtree.c index 6f78e02ca2..46acfff3d5 100644 --- a/apps/dbtree.c +++ b/apps/dbtree.c @@ -39,6 +39,7 @@ #include "applimits.h" #include "dbtree.h" #include "icons.h" +#include "lang.h" #ifdef LITTLE_ENDIAN #include @@ -148,11 +149,29 @@ int db_load(struct tree_context* c) DEBUGF("db_load(%d, %x, %d)\n", table, extra, c->firstpos); if (!table) { - table = allartists; + table = root; c->currtable = table; } switch (table) { + case root: { + static const int tables[] = {allartists, allalbums, allsongs}; + char* nbuf = (char*)nptr; + char* labels[3] = { str(LANG_ID3DB_ARTISTS), + str(LANG_ID3DB_ALBUMS), + str(LANG_ID3DB_SONGS)}; + + for (i=0; i < 3; i++) { + strcpy(nbuf, labels[i]); + dptr[0] = (unsigned int)nbuf; + dptr[1] = tables[i]; + nbuf += strlen(nbuf) + 1; + dptr += 2; + } + c->dirlength = c->filesindir = i; + return i; + } + case allsongs: offset = songstart + c->firstpos * (songlen + 12); itemcount = songcount; @@ -303,34 +322,36 @@ int db_load(struct tree_context* c) void db_enter(struct tree_context* c) { + int newextra = ((int*)c->dircache)[(c->dircursor + c->dirstart)*2 + 1]; + + c->dirpos[c->dirlevel] = c->dirstart; + c->cursorpos[c->dirlevel] = c->dircursor; + c->table_history[c->dirlevel] = c->currtable; + c->extra_history[c->dirlevel] = c->currextra; + c->pos_history[c->dirlevel] = c->firstpos; + c->dirlevel++; + switch (c->currtable) { - case allartists: - case albums4artist: - c->dirpos[c->dirlevel] = c->dirstart; - c->cursorpos[c->dirlevel] = c->dircursor; - c->table_history[c->dirlevel] = c->currtable; - c->extra_history[c->dirlevel] = c->currextra; - c->pos_history[c->dirlevel] = c->firstpos; - c->dirlevel++; + case root: + c->currtable = newextra; + c->currextra = newextra; break; - - default: - break; - } - - switch (c->currtable) { + case allartists: c->currtable = albums4artist; - c->currextra = ((int*)c->dircache)[(c->dircursor + c->dirstart)*2 + 1]; + c->currextra = newextra; break; + case allalbums: case albums4artist: c->currtable = songs4album; - c->currextra = ((int*)c->dircache)[(c->dircursor + c->dirstart)*2 + 1]; + c->currextra = newextra; break; case songs4album: + case allsongs: splash(HZ,true,"No playing implemented yet"); + c->dirlevel--; #if 0 /* find filenames, build playlist, play */ playlist_create(NULL,NULL); -- cgit v1.2.3