diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2005-08-21 19:39:05 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-08-21 19:39:05 +0000 |
commit | ef99e4e40045087e4896932f3601e39a07051ab1 (patch) | |
tree | cc59aecf12da1cfe26e10c411fff44aa8675fb2c | |
parent | d9874b266ee420e214bdc8c9c96d946c0a922203 (diff) | |
download | rockbox-ef99e4e40045087e4896932f3601e39a07051ab1.tar.gz rockbox-ef99e4e40045087e4896932f3601e39a07051ab1.zip |
Archos players doesn't have a hold switch.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7372 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/wps-display.c | 247 |
1 files changed, 211 insertions, 36 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c index 318da5a717..f6fda70377 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -98,8 +98,14 @@ static void draw_player_fullbar(char* buf, int buf_size, | |||
98 | static char map_fullbar_char(char ascii_val); | 98 | static char map_fullbar_char(char ascii_val); |
99 | #endif | 99 | #endif |
100 | 100 | ||
101 | struct align_pos { | ||
102 | char* left; | ||
103 | char* center; | ||
104 | char* right; | ||
105 | }; | ||
101 | static char format_buffer[FORMAT_BUFFER_SIZE]; | 106 | static char format_buffer[FORMAT_BUFFER_SIZE]; |
102 | static char* format_lines[MAX_LINES][MAX_SUBLINES]; | 107 | static char* format_lines[MAX_LINES][MAX_SUBLINES]; |
108 | static struct align_pos format_align[MAX_LINES][MAX_SUBLINES]; | ||
103 | static unsigned char line_type[MAX_LINES][MAX_SUBLINES]; | 109 | static unsigned char line_type[MAX_LINES][MAX_SUBLINES]; |
104 | static unsigned short time_mult[MAX_LINES][MAX_SUBLINES]; | 110 | static unsigned short time_mult[MAX_LINES][MAX_SUBLINES]; |
105 | static long subline_expire_time[MAX_LINES]; | 111 | static long subline_expire_time[MAX_LINES]; |
@@ -631,6 +637,7 @@ static char* get_tag(struct mp3entry* cid3, | |||
631 | return "b"; | 637 | return "b"; |
632 | else | 638 | else |
633 | return NULL; | 639 | return NULL; |
640 | #if CONFIG_KEYPAD == IRIVER_H100_PAD | ||
634 | case 'h': /* hold */ | 641 | case 'h': /* hold */ |
635 | *flags |= WPS_REFRESH_DYNAMIC; | 642 | *flags |= WPS_REFRESH_DYNAMIC; |
636 | if (button_hold()) | 643 | if (button_hold()) |
@@ -643,6 +650,7 @@ static char* get_tag(struct mp3entry* cid3, | |||
643 | return "r"; | 650 | return "r"; |
644 | else | 651 | else |
645 | return NULL; | 652 | return NULL; |
653 | #endif | ||
646 | } | 654 | } |
647 | break; | 655 | break; |
648 | 656 | ||
@@ -826,6 +834,7 @@ static void format_display(char* buf, | |||
826 | struct mp3entry* id3, | 834 | struct mp3entry* id3, |
827 | struct mp3entry* nid3, /* next song's id3 */ | 835 | struct mp3entry* nid3, /* next song's id3 */ |
828 | const char* fmt, | 836 | const char* fmt, |
837 | struct align_pos* align, | ||
829 | unsigned short* subline_time_mult, | 838 | unsigned short* subline_time_mult, |
830 | unsigned char* flags) | 839 | unsigned char* flags) |
831 | { | 840 | { |
@@ -838,6 +847,8 @@ static void format_display(char* buf, | |||
838 | 847 | ||
839 | /* needed for images (ifdef is to kill a warning on player)*/ | 848 | /* needed for images (ifdef is to kill a warning on player)*/ |
840 | int n; | 849 | int n; |
850 | int cur_align; | ||
851 | char* cur_align_start; | ||
841 | #ifdef HAVE_LCD_BITMAP | 852 | #ifdef HAVE_LCD_BITMAP |
842 | int ret; | 853 | int ret; |
843 | char *pos, *posn; | 854 | char *pos, *posn; |
@@ -845,8 +856,14 @@ static void format_display(char* buf, | |||
845 | char *ptr; | 856 | char *ptr; |
846 | #endif | 857 | #endif |
847 | 858 | ||
859 | cur_align_start = buf; | ||
860 | cur_align = WPS_ALIGN_LEFT; | ||
848 | *subline_time_mult = DEFAULT_SUBLINE_TIME_MULTIPLIER; | 861 | *subline_time_mult = DEFAULT_SUBLINE_TIME_MULTIPLIER; |
849 | 862 | ||
863 | align->left = 0; | ||
864 | align->center = 0; | ||
865 | align->right = 0; | ||
866 | |||
850 | while (fmt && *fmt && buf < buf_end) | 867 | while (fmt && *fmt && buf < buf_end) |
851 | { | 868 | { |
852 | switch (*fmt) | 869 | switch (*fmt) |
@@ -877,18 +894,36 @@ static void format_display(char* buf, | |||
877 | break; | 894 | break; |
878 | case 'a': | 895 | case 'a': |
879 | ++fmt; | 896 | ++fmt; |
897 | /* remember where the current aligned text started */ | ||
898 | switch (cur_align) | ||
899 | { | ||
900 | case WPS_ALIGN_LEFT: | ||
901 | align->left = cur_align_start; | ||
902 | break; | ||
903 | |||
904 | case WPS_ALIGN_CENTER: | ||
905 | align->center = cur_align_start; | ||
906 | break; | ||
907 | |||
908 | case WPS_ALIGN_RIGHT: | ||
909 | align->right = cur_align_start; | ||
910 | break; | ||
911 | } | ||
912 | /* start a new alignment */ | ||
880 | switch (*fmt) | 913 | switch (*fmt) |
881 | { | 914 | { |
882 | case 'l': | 915 | case 'l': |
883 | *flags |= WPS_ALIGN_LEFT; | 916 | cur_align = WPS_ALIGN_LEFT; |
884 | break; | 917 | break; |
885 | case 'c': | 918 | case 'c': |
886 | *flags |= WPS_ALIGN_CENTER; | 919 | cur_align = WPS_ALIGN_CENTER; |
887 | break; | 920 | break; |
888 | case 'r': | 921 | case 'r': |
889 | *flags |= WPS_ALIGN_RIGHT; | 922 | cur_align = WPS_ALIGN_RIGHT; |
890 | break; | 923 | break; |
891 | } | 924 | } |
925 | *buf++=0; | ||
926 | cur_align_start = buf; | ||
892 | ++fmt; | 927 | ++fmt; |
893 | break; | 928 | break; |
894 | case 's': | 929 | case 's': |
@@ -1013,10 +1048,26 @@ static void format_display(char* buf, | |||
1013 | } | 1048 | } |
1014 | } | 1049 | } |
1015 | 1050 | ||
1051 | /* remember where the current aligned text started */ | ||
1052 | switch (cur_align) | ||
1053 | { | ||
1054 | case WPS_ALIGN_LEFT: | ||
1055 | align->left = cur_align_start; | ||
1056 | break; | ||
1057 | |||
1058 | case WPS_ALIGN_CENTER: | ||
1059 | align->center = cur_align_start; | ||
1060 | break; | ||
1061 | |||
1062 | case WPS_ALIGN_RIGHT: | ||
1063 | align->right = cur_align_start; | ||
1064 | break; | ||
1065 | } | ||
1066 | |||
1016 | *buf = 0; | 1067 | *buf = 0; |
1017 | 1068 | ||
1018 | /* if resulting line is an empty line, set the subline time to 0 */ | 1069 | /* if resulting line is an empty line, set the subline time to 0 */ |
1019 | if (*buf_start == 0) | 1070 | if (buf - buf_start == 0) |
1020 | *subline_time_mult = 0; | 1071 | *subline_time_mult = 0; |
1021 | 1072 | ||
1022 | /* If no flags have been set, the line didn't contain any format codes. | 1073 | /* If no flags have been set, the line didn't contain any format codes. |
@@ -1118,6 +1169,7 @@ bool wps_refresh(struct mp3entry* id3, | |||
1118 | line type flags for this subline */ | 1169 | line type flags for this subline */ |
1119 | format_display(buf, sizeof(buf), id3, nid3, | 1170 | format_display(buf, sizeof(buf), id3, nid3, |
1120 | format_lines[i][curr_subline[i]], | 1171 | format_lines[i][curr_subline[i]], |
1172 | &format_align[i][curr_subline[i]], | ||
1121 | &time_mult[i][curr_subline[i]], | 1173 | &time_mult[i][curr_subline[i]], |
1122 | &line_type[i][curr_subline[i]]); | 1174 | &line_type[i][curr_subline[i]]); |
1123 | 1175 | ||
@@ -1144,8 +1196,18 @@ bool wps_refresh(struct mp3entry* id3, | |||
1144 | new_subline_refresh) | 1196 | new_subline_refresh) |
1145 | { | 1197 | { |
1146 | flags = 0; | 1198 | flags = 0; |
1199 | #ifdef HAVE_LCD_BITMAP | ||
1200 | int left_width, left_xpos; | ||
1201 | int center_width, center_xpos; | ||
1202 | int right_width, right_xpos; | ||
1203 | int space_width; | ||
1204 | int string_height; | ||
1205 | int ypos; | ||
1206 | #endif | ||
1207 | |||
1147 | format_display(buf, sizeof(buf), id3, nid3, | 1208 | format_display(buf, sizeof(buf), id3, nid3, |
1148 | format_lines[i][curr_subline[i]], | 1209 | format_lines[i][curr_subline[i]], |
1210 | &format_align[i][curr_subline[i]], | ||
1149 | &time_mult[i][curr_subline[i]], | 1211 | &time_mult[i][curr_subline[i]], |
1150 | &flags); | 1212 | &flags); |
1151 | line_type[i][curr_subline[i]] = flags; | 1213 | line_type[i][curr_subline[i]] = flags; |
@@ -1188,6 +1250,120 @@ bool wps_refresh(struct mp3entry* id3, | |||
1188 | draw_player_progress(id3, ff_rewind_count); | 1250 | draw_player_progress(id3, ff_rewind_count); |
1189 | } | 1251 | } |
1190 | #endif | 1252 | #endif |
1253 | #ifdef HAVE_LCD_BITMAP | ||
1254 | /* calculate different string sizes and positions */ | ||
1255 | lcd_getstringsize(" ", &space_width, &string_height); | ||
1256 | if (format_align[i][curr_subline[i]].left != 0) { | ||
1257 | lcd_getstringsize(format_align[i][curr_subline[i]].left, | ||
1258 | &left_width, &string_height); | ||
1259 | } | ||
1260 | else { | ||
1261 | left_width = 0; | ||
1262 | } | ||
1263 | left_xpos = 0; | ||
1264 | |||
1265 | if (format_align[i][curr_subline[i]].center != 0) { | ||
1266 | lcd_getstringsize(format_align[i][curr_subline[i]].center, | ||
1267 | ¢er_width, &string_height); | ||
1268 | } | ||
1269 | else { | ||
1270 | center_width = 0; | ||
1271 | } | ||
1272 | center_xpos=(LCD_WIDTH - center_width) / 2; | ||
1273 | |||
1274 | if (format_align[i][curr_subline[i]].right != 0) { | ||
1275 | lcd_getstringsize(format_align[i][curr_subline[i]].right, | ||
1276 | &right_width, &string_height); | ||
1277 | } | ||
1278 | else { | ||
1279 | right_width = 0; | ||
1280 | } | ||
1281 | right_xpos = (LCD_WIDTH - right_width); | ||
1282 | |||
1283 | /* Checks for overlapping strings. | ||
1284 | If needed the overlapping strings will be merged, separated by a | ||
1285 | space */ | ||
1286 | |||
1287 | /* CASE 1: left and centered string overlap */ | ||
1288 | /* there is a left string, need to merge left and center */ | ||
1289 | if ((left_width != 0 && center_width != 0) && | ||
1290 | (left_xpos + left_width + space_width > center_xpos)) { | ||
1291 | /* replace the former separator '\0' of left and | ||
1292 | center string with a space */ | ||
1293 | *(--format_align[i][curr_subline[i]].center) = ' '; | ||
1294 | /* calculate the new width and position of the merged string */ | ||
1295 | left_width = left_width + space_width + center_width; | ||
1296 | left_xpos = 0; | ||
1297 | /* there is no centered string anymore */ | ||
1298 | center_width = 0; | ||
1299 | } | ||
1300 | /* there is no left string, move center to left */ | ||
1301 | if ((left_width == 0 && center_width != 0) && | ||
1302 | (left_xpos + left_width > center_xpos)) { | ||
1303 | /* move the center string to the left string */ | ||
1304 | format_align[i][curr_subline[i]].left = format_align[i][curr_subline[i]].center; | ||
1305 | /* calculate the new width and position of the string */ | ||
1306 | left_width = center_width; | ||
1307 | left_xpos = 0; | ||
1308 | /* there is no centered string anymore */ | ||
1309 | center_width = 0; | ||
1310 | } | ||
1311 | |||
1312 | /* CASE 2: centered and right string overlap */ | ||
1313 | /* there is a right string, need to merge center and right */ | ||
1314 | if ((center_width != 0 && right_width != 0) && | ||
1315 | (center_xpos + center_width + space_width > right_xpos)) { | ||
1316 | /* replace the former separator '\0' of center and | ||
1317 | right string with a space */ | ||
1318 | *(--format_align[i][curr_subline[i]].right) = ' '; | ||
1319 | /* move the center string to the right after merge */ | ||
1320 | format_align[i][curr_subline[i]].right = format_align[i][curr_subline[i]].center; | ||
1321 | /* calculate the new width and position of the merged string */ | ||
1322 | right_width = center_width + space_width + right_width; | ||
1323 | right_xpos = (LCD_WIDTH - right_width); | ||
1324 | /* there is no centered string anymore */ | ||
1325 | center_width = 0; | ||
1326 | } | ||
1327 | /* there is no right string, move center to right */ | ||
1328 | if ((center_width != 0 && right_width == 0) && | ||
1329 | (center_xpos + center_width > right_xpos)) { | ||
1330 | /* move the center string to the right string */ | ||
1331 | format_align[i][curr_subline[i]].right = format_align[i][curr_subline[i]].center; | ||
1332 | /* calculate the new width and position of the string */ | ||
1333 | right_width = center_width; | ||
1334 | right_xpos = (LCD_WIDTH - right_width); | ||
1335 | /* there is no centered string anymore */ | ||
1336 | center_width = 0; | ||
1337 | } | ||
1338 | |||
1339 | /* CASE 3: left and right overlap | ||
1340 | There is no center string anymore, either there never | ||
1341 | was one or it has been merged in case 1 or 2 */ | ||
1342 | /* there is a left string, need to merge left and right */ | ||
1343 | if ((left_width != 0 && center_width == 0 && right_width != 0) && | ||
1344 | (left_xpos + left_width + space_width > right_xpos)) { | ||
1345 | /* replace the former separator '\0' of left and | ||
1346 | right string with a space */ | ||
1347 | *(--format_align[i][curr_subline[i]].right) = ' '; | ||
1348 | /* calculate the new width and position of the string */ | ||
1349 | left_width = left_width + space_width + right_width; | ||
1350 | left_xpos = 0; | ||
1351 | /* there is no right string anymore */ | ||
1352 | right_width = 0; | ||
1353 | } | ||
1354 | /* there is no left string, move right to left */ | ||
1355 | if ((left_width == 0 && center_width == 0 && right_width != 0) && | ||
1356 | (left_xpos + left_width > right_xpos)) { | ||
1357 | /* move the right string to the left string */ | ||
1358 | format_align[i][curr_subline[i]].left = format_align[i][curr_subline[i]].right; | ||
1359 | /* calculate the new width and position of the string */ | ||
1360 | left_width = right_width; | ||
1361 | left_xpos = 0; | ||
1362 | /* there is no right string anymore */ | ||
1363 | right_width = 0; | ||
1364 | } | ||
1365 | |||
1366 | #endif | ||
1191 | 1367 | ||
1192 | if (flags & WPS_REFRESH_SCROLL) { | 1368 | if (flags & WPS_REFRESH_SCROLL) { |
1193 | 1369 | ||
@@ -1195,34 +1371,33 @@ bool wps_refresh(struct mp3entry* id3, | |||
1195 | if ((refresh_mode & WPS_REFRESH_SCROLL) || | 1371 | if ((refresh_mode & WPS_REFRESH_SCROLL) || |
1196 | new_subline_refresh) { | 1372 | new_subline_refresh) { |
1197 | #ifdef HAVE_LCD_BITMAP | 1373 | #ifdef HAVE_LCD_BITMAP |
1198 | int strw,strh; | 1374 | ypos = (i*string_height)+lcd_getymargin(); |
1199 | int ypos,xpos; | ||
1200 | |||
1201 | lcd_getstringsize(buf, &strw, &strh); | ||
1202 | ypos = (i*strh)+lcd_getymargin(); | ||
1203 | update_line = true; | 1375 | update_line = true; |
1204 | 1376 | ||
1205 | if (strw>LCD_WIDTH) { | 1377 | if (left_width>LCD_WIDTH) { |
1206 | lcd_puts_scroll(0, i, buf); | 1378 | lcd_puts_scroll(0, i, format_align[i][curr_subline[i]].left); |
1207 | } else { | 1379 | } else { |
1208 | /* clear the line first */ | 1380 | /* clear the line first */ |
1209 | lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 1381 | lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
1210 | lcd_fillrect(0, ypos, LCD_WIDTH, strh); | 1382 | lcd_fillrect(0, ypos, LCD_WIDTH, string_height); |
1211 | lcd_set_drawmode(DRMODE_SOLID); | 1383 | lcd_set_drawmode(DRMODE_SOLID); |
1212 | 1384 | ||
1213 | /* Nasty hack: we output an empty scrolling string, | 1385 | /* Nasty hack: we output an empty scrolling string, |
1214 | which will reset the scroller for that line */ | 1386 | which will reset the scroller for that line */ |
1215 | lcd_puts_scroll(0, i, ""); | 1387 | lcd_puts_scroll(0, i, ""); |
1216 | 1388 | ||
1217 | if (flags & WPS_ALIGN_CENTER) | 1389 | /* print aligned strings */ |
1390 | if (left_width != 0) | ||
1391 | { | ||
1392 | lcd_putsxy(left_xpos, ypos, format_align[i][curr_subline[i]].left); | ||
1393 | } | ||
1394 | if (center_width != 0) | ||
1218 | { | 1395 | { |
1219 | xpos = (LCD_WIDTH - strw) / 2; | 1396 | lcd_putsxy(center_xpos, ypos, format_align[i][curr_subline[i]].center); |
1220 | lcd_putsxy(xpos, ypos, buf); | 1397 | } |
1221 | } else if (flags & WPS_ALIGN_RIGHT) { | 1398 | if (right_width != 0) |
1222 | xpos = (LCD_WIDTH - strw); | 1399 | { |
1223 | lcd_putsxy(xpos, ypos, buf); | 1400 | lcd_putsxy(right_xpos, ypos, format_align[i][curr_subline[i]].right); |
1224 | } else { | ||
1225 | lcd_putsxy(0, ypos, buf); | ||
1226 | } | 1401 | } |
1227 | } | 1402 | } |
1228 | #else | 1403 | #else |
@@ -1238,30 +1413,30 @@ bool wps_refresh(struct mp3entry* id3, | |||
1238 | new_subline_refresh) | 1413 | new_subline_refresh) |
1239 | { | 1414 | { |
1240 | #ifdef HAVE_LCD_BITMAP | 1415 | #ifdef HAVE_LCD_BITMAP |
1241 | int ypos,xpos; | 1416 | ypos = (i*string_height)+lcd_getymargin(); |
1242 | int strw,strh; | ||
1243 | |||
1244 | lcd_getstringsize(buf, &strw, &strh); | ||
1245 | ypos = (i*strh)+lcd_getymargin(); | ||
1246 | update_line = true; | 1417 | update_line = true; |
1247 | 1418 | ||
1248 | /* clear the line first */ | 1419 | /* clear the line first */ |
1249 | lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 1420 | lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
1250 | lcd_fillrect(0, ypos, LCD_WIDTH, strh); | 1421 | lcd_fillrect(0, ypos, LCD_WIDTH, string_height); |
1251 | lcd_set_drawmode(DRMODE_SOLID); | 1422 | lcd_set_drawmode(DRMODE_SOLID); |
1252 | 1423 | ||
1253 | /* Nasty hack: we output an empty scrolling string, | 1424 | /* Nasty hack: we output an empty scrolling string, |
1254 | which will reset the scroller for that line */ | 1425 | which will reset the scroller for that line */ |
1255 | lcd_puts_scroll(0, i, ""); | 1426 | lcd_puts_scroll(0, i, ""); |
1256 | 1427 | ||
1257 | if (flags & WPS_ALIGN_CENTER) { | 1428 | /* print aligned strings */ |
1258 | xpos = (LCD_WIDTH - strw) / 2; | 1429 | if (left_width != 0) |
1259 | lcd_putsxy(xpos, ypos, buf); | 1430 | { |
1260 | } else if (flags & WPS_ALIGN_RIGHT) { | 1431 | lcd_putsxy(left_xpos, ypos, format_align[i][curr_subline[i]].left); |
1261 | xpos = (LCD_WIDTH - strw); | 1432 | } |
1262 | lcd_putsxy(xpos, ypos, buf); | 1433 | if (center_width != 0) |
1263 | } else { | 1434 | { |
1264 | lcd_putsxy(0, ypos, buf); | 1435 | lcd_putsxy(center_xpos, ypos, format_align[i][curr_subline[i]].center); |
1436 | } | ||
1437 | if (right_width != 0) | ||
1438 | { | ||
1439 | lcd_putsxy(right_xpos, ypos, format_align[i][curr_subline[i]].right); | ||
1265 | } | 1440 | } |
1266 | #else | 1441 | #else |
1267 | update_line = true; | 1442 | update_line = true; |
@@ -1329,7 +1504,7 @@ bool wps_display(struct mp3entry* id3, | |||
1329 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" | 1504 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" |
1330 | "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n" | 1505 | "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n" |
1331 | "\n" | 1506 | "\n" |
1332 | "%pc/%pt [%pp:%pe]\n" | 1507 | "%al%pc/%pt%ar[%pp:%pe]\n" |
1333 | "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" | 1508 | "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n" |
1334 | "%pb\n" | 1509 | "%pb\n" |
1335 | "%pm\n"); | 1510 | "%pm\n"); |