From 2b3fcd427a63a567e7e5ba40f335c48ffa70aeb1 Mon Sep 17 00:00:00 2001 From: jdgordon Date: Tue, 24 Jun 2008 10:20:22 +0000 Subject: [PATCH] pictureflow update: fix FS#8347 and FS#8425 - track order is incorrrect also: center the track list in the screen, and show the track number if its available git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17781 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugin.c | 6 +++-- apps/plugin.h | 5 +++- apps/plugins/pictureflow.c | 58 +++++++++++++++++++++++++++++++++++----------- 3 files changed, 53 insertions(+), 16 deletions(-) diff --git a/apps/plugin.c b/apps/plugin.c index 21f6d178e..bc1e8cbb7 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -601,8 +601,10 @@ static const struct plugin_api rockbox_api = { #endif /* new stuff at the end, sort into place next time - the API gets incompatible */ - + the API gets incompatible */ +#ifdef HAVE_TAGCACHE + tagcache_get_numeric, +#endif }; int plugin_load(const char* plugin, const void* parameter) diff --git a/apps/plugin.h b/apps/plugin.h index 4be76adfd..9bc009962 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -124,7 +124,7 @@ void* plugin_get_buffer(size_t *buffer_size); #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 117 +#define PLUGIN_API_VERSION 118 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any @@ -753,6 +753,9 @@ struct plugin_api { /* new stuff at the end, sort into place next time the API gets incompatible */ +#ifdef HAVE_TAGCACHE + long (*tagcache_get_numeric)(const struct tagcache_search *tcs, int tag); +#endif }; diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index bea028ead..53bcaa416 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c @@ -419,33 +419,57 @@ int create_track_index(const int slide_index) return -1; int ret = 0; + char temp_titles[MAX_TRACKS][AVG_TRACK_NAME_LENGTH*4]; + int temp_seeks[MAX_TRACKS]; rb->tagcache_search_add_filter(&tcs, tag_album, album[slide_index].seek); track_count=0; - int l, old_l = 0; - tracks[0].name_idx = 0; + int string_index = 0; + int l, track_num, heighest_index = 0; + for(l=0;ltagcache_get_next(&tcs) && track_count < MAX_TRACKS) { - l = rb->strlen(tcs.result) + 1; - if ( track_count > 0 ) - tracks[track_count].name_idx = tracks[track_count-1].name_idx + old_l; - - if ( (tracks[track_count].name_idx + l) > MAX_TRACKS * AVG_TRACK_NAME_LENGTH ) + track_num = rb->tagcache_get_numeric(&tcs, tag_tracknumber) - 1; + if (track_num >= 0) { - /* not enough memory */ - ret = ERROR_BUFFER_FULL; - break; + rb->snprintf(temp_titles[track_num],sizeof(temp_titles[track_num]), "%d: %s", + track_num+1, tcs.result); + temp_seeks[track_num] = tcs.result_seek; } - rb->strcpy(track_names + tracks[track_count].name_idx, tcs.result); - tracks[track_count].seek = tcs.result_seek; - old_l = l; + else + { + track_num = 0; + while (temp_titles[track_num][0] != '\0') + track_num++; + rb->strcpy(temp_titles[track_num], tcs.result); + temp_seeks[track_num] = tcs.result_seek; + } + if (track_num > heighest_index) + heighest_index = track_num; track_count++; } rb->tagcache_search_finish(&tcs); track_index = slide_index; + /* now fix the track list order */ + l = 0; + track_count = 0; + while (l < heighest_index && + string_index < MAX_TRACKS*AVG_TRACK_NAME_LENGTH) + { + if (temp_titles[l][0] != '\0') + { + rb->strcpy(track_names + string_index, temp_titles[l]); + tracks[track_count].name_idx = string_index; + tracks[track_count].seek = temp_seeks[l]; + string_index += rb->strlen(temp_titles[l]) + 1; + track_count++; + } + l++; + } if (ret != 0) return ret; else @@ -1759,6 +1783,14 @@ void show_track_list(void) } static int titletxt_w, titletxt_h, titletxt_y, titletxt_x, i, color; titletxt_y = 0; + if (track_list_visible_entries >= track_count) + { + int albumtxt_h; + const char* albumtxt = get_album_name(center_index); + rb->lcd_getstringsize(albumtxt, NULL, &albumtxt_h); + titletxt_y = ((LCD_HEIGHT-albumtxt_h-10)-(track_count*albumtxt_h))/2; + } + int track_i; for (i=0; i < track_list_visible_entries; i++) { track_i = i+start_index_track_list; -- 2.11.4.GIT