diff options
author | Eric Linenberg <elinenbe@umich.edu> | 2002-08-06 18:11:00 +0000 |
---|---|---|
committer | Eric Linenberg <elinenbe@umich.edu> | 2002-08-06 18:11:00 +0000 |
commit | 9e91b95c7a1e0be8d9cb6c71be4b34ff0df53a5a (patch) | |
tree | 7e3f81d448ad3ecffbbc1a90852ccfa0dfae0333 | |
parent | e4b8c04788dd71b69f7703345eb10e3f3bc52a6c (diff) | |
download | rockbox-9e91b95c7a1e0be8d9cb6c71be4b34ff0df53a5a.tar.gz rockbox-9e91b95c7a1e0be8d9cb6c71be4b34ff0df53a5a.zip |
added a speedup for browsing long directories
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1565 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/tree.c | 121 |
1 files changed, 116 insertions, 5 deletions
diff --git a/apps/tree.c b/apps/tree.c index 308ea9c649..54e0b75551 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -266,6 +266,8 @@ bool dirbrowse(char *root) | |||
266 | int i; | 266 | int i; |
267 | int rc; | 267 | int rc; |
268 | int button; | 268 | int button; |
269 | int browse_speed = 0; | ||
270 | |||
269 | 271 | ||
270 | memcpy(currdir,root,sizeof(currdir)); | 272 | memcpy(currdir,root,sizeof(currdir)); |
271 | numentries = showdir(root, start); | 273 | numentries = showdir(root, start); |
@@ -335,6 +337,7 @@ bool dirbrowse(char *root) | |||
335 | #ifdef HAVE_RECORDER_KEYPAD | 337 | #ifdef HAVE_RECORDER_KEYPAD |
336 | case BUTTON_PLAY: | 338 | case BUTTON_PLAY: |
337 | #endif | 339 | #endif |
340 | browse_speed = 0; | ||
338 | if ( !numentries ) | 341 | if ( !numentries ) |
339 | break; | 342 | break; |
340 | if ((currdir[0]=='/') && (currdir[1]==0)) { | 343 | if ((currdir[0]=='/') && (currdir[1]==0)) { |
@@ -386,11 +389,63 @@ bool dirbrowse(char *root) | |||
386 | } | 389 | } |
387 | restore = true; | 390 | restore = true; |
388 | break; | 391 | break; |
389 | 392 | ||
390 | case TREE_PREV: | ||
391 | case TREE_PREV | BUTTON_REPEAT: | 393 | case TREE_PREV | BUTTON_REPEAT: |
392 | if(filesindir) | 394 | browse_speed++; /* increase the browse speed every time we get here */ |
393 | { | 395 | if(filesindir) { |
396 | if(dircursor) { | ||
397 | if (browse_speed < 7) { | ||
398 | /* moving the cursor up through a full screen */ | ||
399 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | ||
400 | false); | ||
401 | dircursor--; | ||
402 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | ||
403 | } | ||
404 | else { | ||
405 | /* if we have wrapped from the bottom we want to keep up the speed */ | ||
406 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | ||
407 | false); | ||
408 | dircursor=0; | ||
409 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | ||
410 | } | ||
411 | } | ||
412 | else { | ||
413 | if (start) { | ||
414 | /* leaving the cursor at top line and moving screen down */ | ||
415 | if (browse_speed >=7) | ||
416 | start = start - 7; | ||
417 | else | ||
418 | start--; | ||
419 | if (start<0) | ||
420 | start=0; | ||
421 | numentries = showdir(currdir, start); | ||
422 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | ||
423 | } | ||
424 | else { | ||
425 | /* wrapping to the top in a directory that is not full */ | ||
426 | if (numentries < TREE_MAX_ON_SCREEN) { | ||
427 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | ||
428 | false); | ||
429 | dircursor = numentries - 1; | ||
430 | browse_speed=0; | ||
431 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | ||
432 | true); | ||
433 | } | ||
434 | else { | ||
435 | /* starting at the very bottom after a wrap */ | ||
436 | start = numentries - TREE_MAX_ON_SCREEN; | ||
437 | dircursor = TREE_MAX_ON_SCREEN - 1; | ||
438 | numentries = showdir(currdir, start); | ||
439 | put_cursorxy(0, CURSOR_Y + LINE_Y + | ||
440 | TREE_MAX_ON_SCREEN - 1, true); | ||
441 | } | ||
442 | } | ||
443 | } | ||
444 | } | ||
445 | break; | ||
446 | case TREE_PREV: | ||
447 | browse_speed = 0; | ||
448 | if(filesindir) { | ||
394 | if(dircursor) { | 449 | if(dircursor) { |
395 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false); | 450 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false); |
396 | dircursor--; | 451 | dircursor--; |
@@ -422,9 +477,63 @@ bool dirbrowse(char *root) | |||
422 | lcd_update(); | 477 | lcd_update(); |
423 | } | 478 | } |
424 | break; | 479 | break; |
480 | case TREE_NEXT | BUTTON_REPEAT: | ||
481 | browse_speed++; /* increase the browse speed every time we get here */ | ||
482 | if(filesindir) | ||
483 | { | ||
484 | if (dircursor + start + 1 < numentries ) { | ||
485 | if(dircursor+1 < TREE_MAX_ON_SCREEN) { | ||
486 | if (browse_speed < 7) { | ||
487 | /* moving the cursor down through a full screen */ | ||
488 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | ||
489 | false); | ||
490 | dircursor++; | ||
491 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | ||
492 | } | ||
493 | else { | ||
494 | /* if we have wrapped from the bottom we want to keep up the speed */ | ||
495 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | ||
496 | false); | ||
497 | dircursor=7; | ||
498 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | ||
499 | } | ||
500 | |||
501 | } | ||
502 | else { | ||
503 | /* leaving the cursor at bottom line and moving screen up */ | ||
504 | if (browse_speed >= TREE_MAX_ON_SCREEN-1) | ||
505 | /* make sure we do not go past the end of the directory */ | ||
506 | if (start + TREE_MAX_ON_SCREEN - 1 < numentries-TREE_MAX_ON_SCREEN) | ||
507 | start = start + TREE_MAX_ON_SCREEN -1; | ||
508 | else | ||
509 | start = numentries-TREE_MAX_ON_SCREEN; | ||
510 | else | ||
511 | start++; | ||
512 | numentries = showdir(currdir, start); | ||
513 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | ||
514 | } | ||
515 | } | ||
516 | else { | ||
517 | /* restarting at the top when there is less than 7 files */ | ||
518 | if(numentries < TREE_MAX_ON_SCREEN) { | ||
519 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | ||
520 | false); | ||
521 | start = dircursor = browse_speed = 0; | ||
522 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | ||
523 | } | ||
524 | else { | ||
525 | /* restarting at the top when the screen scrolls */ | ||
526 | start = dircursor = 0 ; | ||
527 | numentries = showdir(currdir, start); | ||
528 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | ||
529 | } | ||
530 | } | ||
531 | lcd_update(); | ||
532 | } | ||
533 | break; | ||
425 | 534 | ||
426 | case TREE_NEXT: | 535 | case TREE_NEXT: |
427 | case TREE_NEXT | BUTTON_REPEAT: | 536 | browse_speed = 0; |
428 | if(filesindir) | 537 | if(filesindir) |
429 | { | 538 | { |
430 | if (dircursor + start + 1 < numentries ) { | 539 | if (dircursor + start + 1 < numentries ) { |
@@ -458,6 +567,7 @@ bool dirbrowse(char *root) | |||
458 | break; | 567 | break; |
459 | 568 | ||
460 | case TREE_MENU: { | 569 | case TREE_MENU: { |
570 | browse_speed = 0; | ||
461 | bool lastfilter = global_settings.mp3filter; | 571 | bool lastfilter = global_settings.mp3filter; |
462 | bool lastsortcase = global_settings.sort_case; | 572 | bool lastsortcase = global_settings.sort_case; |
463 | lcd_stop_scroll(); | 573 | lcd_stop_scroll(); |
@@ -471,6 +581,7 @@ bool dirbrowse(char *root) | |||
471 | } | 581 | } |
472 | 582 | ||
473 | case BUTTON_ON: | 583 | case BUTTON_ON: |
584 | browse_speed = 0; | ||
474 | /* The mpeg thread may have stopped playing, so we'd | 585 | /* The mpeg thread may have stopped playing, so we'd |
475 | better update our status */ | 586 | better update our status */ |
476 | if(!mpeg_is_playing()) | 587 | if(!mpeg_is_playing()) |