summaryrefslogtreecommitdiff
path: root/apps/screens.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/screens.c')
-rw-r--r--apps/screens.c277
1 files changed, 105 insertions, 172 deletions
diff --git a/apps/screens.c b/apps/screens.c
index 51201525d4..99f23c55af 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -53,6 +53,7 @@
53#include "quickscreen.h" 53#include "quickscreen.h"
54#include "logo.h" 54#include "logo.h"
55#include "pcmbuf.h" 55#include "pcmbuf.h"
56#include "list.h"
56 57
57#if defined(HAVE_LCD_BITMAP) 58#if defined(HAVE_LCD_BITMAP)
58#include "widgets.h" 59#include "widgets.h"
@@ -1006,189 +1007,127 @@ bool shutdown_screen(void)
1006} 1007}
1007#endif 1008#endif
1008 1009
1009int draw_id3_item(int line, int top, int header, const char* body)
1010{
1011 if (line >= top)
1012 {
1013#if defined(HAVE_LCD_BITMAP)
1014 const int rows = LCD_HEIGHT / font_get(FONT_UI)->height;
1015#else
1016 const int rows = 2;
1017#endif
1018 int y = line - top;
1019
1020 if (y < rows)
1021 {
1022 lcd_puts(0, y, str(header));
1023 }
1024
1025 if (++y < rows)
1026 {
1027 lcd_puts_scroll(0, y,
1028 body ? (const unsigned char*) body : str(LANG_ID3_NO_INFO));
1029 }
1030 }
1031
1032 return line + 2;
1033}
1034
1035#if CONFIG_CODEC == SWCODEC 1010#if CONFIG_CODEC == SWCODEC
1036#define ID3_ITEMS 13 1011#define ID3_ITEMS 13
1037#else 1012#else
1038#define ID3_ITEMS 11 1013#define ID3_ITEMS 11
1039#endif 1014#endif
1040 1015
1041bool browse_id3(void) 1016char * id3_get_info(int selected_item, void* data, char *buffer)
1042{ 1017{
1043 char buf[64]; 1018 struct mp3entry* id3 =(struct mp3entry*)data;
1044 const struct mp3entry* id3 = audio_current_track(); 1019 int info_no=selected_item/2;
1045#if defined(HAVE_LCD_BITMAP) 1020 DEBUGF("%d : %d\n",info_no, selected_item);
1046 const int y_margin = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; 1021 if(!(selected_item%2))
1047 const int line_height = font_get(FONT_UI)->height; 1022 {/* header */
1048 const int rows = (LCD_HEIGHT - y_margin) / line_height; 1023 int headers[]=
1049 const bool show_scrollbar = global_settings.scrollbar
1050 && (ID3_ITEMS * 2 > rows);
1051#else
1052 const int rows = 2;
1053#endif
1054 const int top_max = (ID3_ITEMS * 2) - (rows & ~1);
1055 int top = 0;
1056 int button;
1057 bool exit = false;
1058
1059 if (!id3 || (!(audio_status() & AUDIO_STATUS_PLAY)))
1060 {
1061 return false;
1062 }
1063
1064#if defined(HAVE_LCD_BITMAP)
1065 lcd_setmargins(show_scrollbar ? SCROLLBAR_WIDTH : 0, y_margin);
1066#endif
1067
1068 while (!exit)
1069 {
1070 int line = 0;
1071 int old_top = top;
1072 char* body;
1073
1074 lcd_clear_display();
1075 gui_syncstatusbar_draw(&statusbars, true);
1076 line = draw_id3_item(line, top, LANG_ID3_TITLE, id3->title);
1077 line = draw_id3_item(line, top, LANG_ID3_ARTIST, id3->artist);
1078 line = draw_id3_item(line, top, LANG_ID3_ALBUM, id3->album);
1079
1080 if (id3->track_string)
1081 {
1082 body = id3->track_string;
1083 }
1084 else if (id3->tracknum)
1085 { 1024 {
1086 snprintf(buf, sizeof(buf), "%d", id3->tracknum); 1025 LANG_ID3_TITLE,
1087 body = buf; 1026 LANG_ID3_ARTIST,
1088 } 1027 LANG_ID3_ALBUM,
1089 else 1028 LANG_ID3_TRACKNUM,
1090 { 1029 LANG_ID3_GENRE,
1091 body = NULL; 1030 LANG_ID3_YEAR,
1092 } 1031 LANG_ID3_LENGTH,
1093 1032 LANG_ID3_PLAYLIST,
1094 line = draw_id3_item(line, top, LANG_ID3_TRACKNUM, body); 1033 LANG_ID3_BITRATE,
1095 1034 LANG_ID3_FRECUENCY,
1096 body = id3->genre_string ? id3->genre_string : id3_get_genre(id3);
1097 line = draw_id3_item(line, top, LANG_ID3_GENRE, body);
1098
1099 if (id3->year_string)
1100 {
1101 body = id3->year_string;
1102 }
1103 else if (id3->year)
1104 {
1105 snprintf(buf, sizeof(buf), "%d", id3->year);
1106 body = buf;
1107 }
1108 else
1109 {
1110 body = NULL;
1111 }
1112
1113 line = draw_id3_item(line, top, LANG_ID3_YEAR, body);
1114
1115 gui_wps_format_time(buf, sizeof(buf), id3->length);
1116 line = draw_id3_item(line, top, LANG_ID3_LENGTH, buf);
1117
1118 snprintf(buf, sizeof(buf), "%d/%d", playlist_get_display_index(),
1119 playlist_amount());
1120 line = draw_id3_item(line, top, LANG_ID3_PLAYLIST, buf);
1121
1122 snprintf(buf, sizeof(buf), "%d kbps%s", id3->bitrate,
1123 id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) "");
1124 line = draw_id3_item(line, top, LANG_ID3_BITRATE, buf);
1125
1126 snprintf(buf, sizeof(buf), "%ld Hz", id3->frequency);
1127 line = draw_id3_item(line, top, LANG_ID3_FRECUENCY, buf);
1128
1129#if CONFIG_CODEC == SWCODEC 1035#if CONFIG_CODEC == SWCODEC
1130 line = draw_id3_item(line, top, LANG_ID3_TRACK_GAIN, 1036 LANG_ID3_TRACK_GAIN,
1131 id3->track_gain_string); 1037 LANG_ID3_ALBUM_GAIN,
1132
1133 line = draw_id3_item(line, top, LANG_ID3_ALBUM_GAIN,
1134 id3->album_gain_string);
1135#endif
1136
1137 line = draw_id3_item(line, top, LANG_ID3_PATH, id3->path);
1138
1139#if defined(HAVE_LCD_BITMAP)
1140 if (show_scrollbar)
1141 {
1142 scrollbar(0, y_margin, SCROLLBAR_WIDTH - 1, rows * line_height,
1143 ID3_ITEMS * 2 + (rows & 1), top, top + rows, VERTICAL);
1144 }
1145#endif 1038#endif
1039 LANG_ID3_PATH,
1040 };
1041 return( str(headers[info_no]));
1042 }
1043 else
1044 {/* data */
1146 1045
1147 while (!exit && (top == old_top)) 1046 char * info=NULL;
1047 switch(info_no)
1148 { 1048 {
1149 gui_syncstatusbar_draw(&statusbars, false); 1049 case 0:/*LANG_ID3_TITLE*/
1150 lcd_update(); 1050 info=id3->title;
1151 button = button_get_w_tmo(HZ / 2); 1051 break;
1152 1052 case 1:/*LANG_ID3_ARTIST*/
1153 switch(button) 1053 info=id3->artist;
1154 { 1054 break;
1155 /* It makes more sense to have the keys mapped "backwards" when 1055 case 2:/*LANG_ID3_ALBUM*/
1156 * scrolling a list on the archos studios/players and the ipod. 1056 info=id3->album;
1157 */ 1057 break;
1158#if defined(HAVE_LCD_BITMAP) && !(CONFIG_KEYPAD == IPOD_4G_PAD) 1058 case 3:/*LANG_ID3_TRACKNUM*/
1159 case SETTINGS_INC: 1059 if (id3->track_string)
1160 case SETTINGS_INC | BUTTON_REPEAT: 1060 info = id3->track_string;
1161#else 1061 else if (id3->tracknum)
1162 case SETTINGS_DEC:
1163#endif
1164 if (top > 0)
1165 { 1062 {
1166 top -= 2; 1063 snprintf(buffer, MAX_PATH, "%d", id3->tracknum);
1064 info = buffer;
1167 } 1065 }
1168 else if (!(button & BUTTON_REPEAT)) 1066 break;
1067 case 4:/*LANG_ID3_GENRE*/
1068 info = id3_get_genre(id3);
1069 break;
1070 case 5:/*LANG_ID3_YEAR*/
1071 if (id3->year_string)
1072 info = id3->year_string;
1073 else if (id3->year)
1169 { 1074 {
1170 top = top_max; 1075 snprintf(buffer, MAX_PATH, "%d", id3->year);
1076 info = buffer;
1171 } 1077 }
1172
1173 break; 1078 break;
1174 1079 case 6:/*LANG_ID3_LENGTH*/
1175#if defined(HAVE_LCD_BITMAP) && !(CONFIG_KEYPAD == IPOD_4G_PAD) 1080 gui_wps_format_time(buffer, MAX_PATH, id3->length);
1176 case SETTINGS_DEC: 1081 info=buffer;
1177 case SETTINGS_DEC | BUTTON_REPEAT: 1082 break;
1083 case 7:/*LANG_ID3_PLAYLIST*/
1084 snprintf(buffer, MAX_PATH, "%d/%d", playlist_get_display_index(),
1085 playlist_amount());
1086 info=buffer;
1087 break;
1088 case 8:/*LANG_ID3_BITRATE*/
1089 snprintf(buffer, MAX_PATH, "%d kbps%s", id3->bitrate,
1090 id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) "");
1091 info=buffer;
1092 break;
1093 case 9:/*LANG_ID3_FRECUENCY*/
1094 snprintf(buffer, MAX_PATH, "%ld Hz", id3->frequency);
1095 info=buffer;
1096 break;
1097#if CONFIG_CODEC == SWCODEC
1098 case 10:/*LANG_ID3_TRACK_GAIN*/
1099 info=id3->track_gain_string;
1100 break;
1101 case 11:/*LANG_ID3_ALBUM_GAIN*/
1102 info=id3->album_gain_string;
1103 break;
1104 case 12:/*LANG_ID3_PATH*/
1178#else 1105#else
1179 case SETTINGS_INC: 1106 case 10:/*LANG_ID3_PATH*/
1180#endif 1107#endif
1181 if (top < top_max) 1108 info=id3->path;
1182 {
1183 top += 2;
1184 }
1185 else if (!(button & BUTTON_REPEAT))
1186 {
1187 top = 0;
1188 }
1189
1190 break; 1109 break;
1110 }
1111 if(info==NULL)
1112 return(str(LANG_ID3_NO_INFO));
1113 return(info);
1114 }
1115}
1191 1116
1117bool browse_id3(void)
1118{
1119 struct gui_synclist id3_lists;
1120 struct mp3entry* id3 = audio_current_track();
1121 int key;
1122
1123 gui_synclist_init(&id3_lists, &id3_get_info, id3, true, 2);
1124 gui_synclist_set_nb_items(&id3_lists, ID3_ITEMS*2);
1125 gui_synclist_draw(&id3_lists);
1126 while (true) {
1127 key = button_get_w_tmo(HZ/2);
1128 /* If moved, "say" the entry under the cursor */
1129 gui_synclist_do_button(&id3_lists, key);
1130 switch( key ) {
1192#ifdef SETTINGS_OK2 1131#ifdef SETTINGS_OK2
1193 case SETTINGS_OK2: 1132 case SETTINGS_OK2:
1194#endif 1133#endif
@@ -1196,23 +1135,17 @@ bool browse_id3(void)
1196 lcd_stop_scroll(); 1135 lcd_stop_scroll();
1197 /* Eat release event */ 1136 /* Eat release event */
1198 button_get(true); 1137 button_get(true);
1199 exit = true; 1138 return(false);
1200 break;
1201 1139
1202 default: 1140 default:
1203 if (default_event_handler(button) == SYS_USB_CONNECTED) 1141 if (default_event_handler(key) == SYS_USB_CONNECTED)
1204 {
1205 return true; 1142 return true;
1206 }
1207
1208 break;
1209 }
1210 } 1143 }
1144 gui_syncstatusbar_draw(&statusbars, false);
1211 } 1145 }
1212
1213 return false;
1214} 1146}
1215 1147
1148
1216bool set_rating(void) 1149bool set_rating(void)
1217{ 1150{
1218 struct mp3entry* id3 = audio_current_track(); 1151 struct mp3entry* id3 = audio_current_track();