summaryrefslogtreecommitdiff
path: root/apps/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tree.c')
-rw-r--r--apps/tree.c97
1 files changed, 66 insertions, 31 deletions
diff --git a/apps/tree.c b/apps/tree.c
index 733545aa17..68b893c78f 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -65,12 +65,12 @@ void browse_root(void)
65 65
66#ifdef HAVE_LCD_BITMAP 66#ifdef HAVE_LCD_BITMAP
67 67
68#define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH) 68#define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH-LINE_Y)
69#define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */ 69#define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */
70 70
71#define MARGIN_Y 0 /* Y pixel margin */ 71#define MARGIN_Y 0 /* Y pixel margin */
72#define MARGIN_X 12 /* X pixel margin */ 72#define MARGIN_X 12 /* X pixel margin */
73#define LINE_Y 0 /* Y position the entry-list starts at */ 73#define LINE_Y (global_settings.statusbar&&statusbar_enabled?1:0) /* Y position the entry-list starts at */
74#define LINE_X 2 /* X position the entry-list starts at */ 74#define LINE_X 2 /* X position the entry-list starts at */
75#define LINE_HEIGTH 8 /* pixels for each text line */ 75#define LINE_HEIGTH 8 /* pixels for each text line */
76 76
@@ -226,7 +226,7 @@ static int showdir(char *path, int start)
226 icon_type = File; 226 icon_type = File;
227 } 227 }
228 lcd_bitmap(bitmap_icons_6x8[icon_type], 228 lcd_bitmap(bitmap_icons_6x8[icon_type],
229 6, MARGIN_Y+(i-start)*LINE_HEIGTH, 6, 8, true); 229 6, MARGIN_Y+(LINE_Y+i-start)*LINE_HEIGTH, 6, 8, true);
230#endif 230#endif
231 231
232 /* if MP3 filter is on, cut off the extension */ 232 /* if MP3 filter is on, cut off the extension */
@@ -264,6 +264,7 @@ bool dirbrowse(char *root)
264{ 264{
265 char buf[MAX_PATH]; 265 char buf[MAX_PATH];
266 int i; 266 int i;
267 int lasti=-1;
267 int rc; 268 int rc;
268 int button; 269 int button;
269 int browse_speed = 0; 270 int browse_speed = 0;
@@ -274,33 +275,12 @@ bool dirbrowse(char *root)
274 if (numentries == -1) 275 if (numentries == -1)
275 return -1; /* root is not a directory */ 276 return -1; /* root is not a directory */
276 277
277 put_cursorxy(0, CURSOR_Y + dircursor, true); 278 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
278 279
279 while(1) { 280 while(1) {
280 bool restore = false; 281 bool restore = false;
281 282
282 if ( numentries ) { 283 button = button_get_w_tmo(HZ/5);
283 i = start+dircursor;
284
285 /* if MP3 filter is on, cut off the extension */
286 if (global_settings.mp3filter &&
287 (dircacheptr[i]->attr &
288 (TREE_ATTR_M3U|TREE_ATTR_MP3)))
289 {
290 int len = strlen(dircacheptr[i]->name);
291 char temp = dircacheptr[i]->name[len-4];
292 dircacheptr[i]->name[len-4] = 0;
293 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
294 dircacheptr[i]->name);
295 dircacheptr[i]->name[len-4] = temp;
296 }
297 else
298 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
299 dircacheptr[i]->name);
300 }
301 lcd_update();
302
303 button = button_get(true);
304 switch ( button ) { 284 switch ( button ) {
305 case TREE_EXIT: 285 case TREE_EXIT:
306 i=strlen(currdir); 286 i=strlen(currdir);
@@ -327,6 +307,8 @@ bool dirbrowse(char *root)
327 case BUTTON_OFF: 307 case BUTTON_OFF:
328 mpeg_stop(); 308 mpeg_stop();
329 status_set_playmode(STATUS_STOP); 309 status_set_playmode(STATUS_STOP);
310 status_draw();
311 restore = true;
330 break; 312 break;
331#endif 313#endif
332 314
@@ -389,7 +371,7 @@ bool dirbrowse(char *root)
389 if (browse_speed < TREE_MAX_ON_SCREEN - 1) { 371 if (browse_speed < TREE_MAX_ON_SCREEN - 1) {
390 /* moving the cursor up through a full screen */ 372 /* moving the cursor up through a full screen */
391 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, 373 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor,
392 false); 374 false);
393 dircursor--; 375 dircursor--;
394 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); 376 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
395 } 377 }
@@ -489,7 +471,7 @@ bool dirbrowse(char *root)
489 dircursor=7; 471 dircursor=7;
490 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); 472 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
491 } 473 }
492 474
493 } 475 }
494 else { 476 else {
495 /* leaving the cursor at bottom line and moving screen up */ 477 /* leaving the cursor at bottom line and moving screen up */
@@ -561,9 +543,15 @@ bool dirbrowse(char *root)
561 case TREE_MENU: { 543 case TREE_MENU: {
562 bool lastfilter = global_settings.mp3filter; 544 bool lastfilter = global_settings.mp3filter;
563 bool lastsortcase = global_settings.sort_case; 545 bool lastsortcase = global_settings.sort_case;
546#ifdef HAVE_LCD_BITMAP
547 bool laststate=statusbar(false);
548#endif
564 browse_speed = 0; 549 browse_speed = 0;
565 lcd_stop_scroll(); 550 lcd_stop_scroll();
566 main_menu(); 551 main_menu();
552#ifdef HAVE_LCD_BITMAP
553 statusbar(laststate);
554#endif
567 /* do we need to rescan dir? */ 555 /* do we need to rescan dir? */
568 if ( lastfilter != global_settings.mp3filter || 556 if ( lastfilter != global_settings.mp3filter ||
569 lastsortcase != global_settings.sort_case) 557 lastsortcase != global_settings.sort_case)
@@ -591,8 +579,26 @@ bool dirbrowse(char *root)
591 } 579 }
592 break; 580 break;
593 581
582#ifdef HAVE_RECORDER_KEYPAD
583 case BUTTON_F3:
584#endif
585#ifdef HAVE_LCD_BITMAP
586 if(global_settings.statusbar) {
587 statusbar_toggle();
588 if(CURSOR_Y+LINE_Y+dircursor>TREE_MAX_ON_SCREEN) {
589 start++;
590 dircursor--;
591 }
592 restore = true;
593 }
594#endif
595 break;
596
594#ifndef SIMULATOR 597#ifndef SIMULATOR
595 case SYS_USB_CONNECTED: 598 case SYS_USB_CONNECTED: {
599#ifdef HAVE_LCD_BITMAP
600 bool laststate=statusbar(false);
601#endif
596 /* Tell the USB thread that we are safe */ 602 /* Tell the USB thread that we are safe */
597 DEBUGF("dirbrowse got SYS_USB_CONNECTED\n"); 603 DEBUGF("dirbrowse got SYS_USB_CONNECTED\n");
598 usb_acknowledge(SYS_USB_CONNECTED_ACK); 604 usb_acknowledge(SYS_USB_CONNECTED_ACK);
@@ -607,7 +613,11 @@ bool dirbrowse(char *root)
607 dirlevel = 0; 613 dirlevel = 0;
608 dircursor = 0; 614 dircursor = 0;
609 start = 0; 615 start = 0;
610 break; 616#ifdef HAVE_LCD_BITMAP
617 statusbar(laststate);
618#endif
619 }
620 break;
611#endif 621#endif
612 } 622 }
613 623
@@ -617,7 +627,32 @@ bool dirbrowse(char *root)
617 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); 627 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
618 } 628 }
619 629
620 lcd_stop_scroll(); 630 if ( numentries ) {
631 i = start+dircursor;
632
633 /* if MP3 filter is on, cut off the extension */
634 if(lasti!=i || restore) {
635 lasti=i;
636 lcd_stop_scroll();
637 if (global_settings.mp3filter &&
638 (dircacheptr[i]->attr &
639 (TREE_ATTR_M3U|TREE_ATTR_MP3)))
640 {
641 int len = strlen(dircacheptr[i]->name);
642 char temp = dircacheptr[i]->name[len-4];
643 dircacheptr[i]->name[len-4] = 0;
644 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
645 dircacheptr[i]->name);
646 dircacheptr[i]->name[len-4] = temp;
647 }
648 else
649 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
650 dircacheptr[i]->name);
651 }
652 }
653 status_draw();
654 lcd_update();
655
621 } 656 }
622 657
623 return false; 658 return false;