diff options
Diffstat (limited to 'apps/tree.c')
-rw-r--r-- | apps/tree.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/apps/tree.c b/apps/tree.c index 1f1c924ef6..a07a520955 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -69,10 +69,10 @@ void browse_root(void) | |||
69 | 69 | ||
70 | #ifdef HAVE_LCD_BITMAP | 70 | #ifdef HAVE_LCD_BITMAP |
71 | 71 | ||
72 | #define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH-LINE_Y) | 72 | #define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH) |
73 | #define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */ | 73 | #define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */ |
74 | 74 | ||
75 | #define MARGIN_Y 0 /* Y pixel margin */ | 75 | #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) /* Y pixel margin */ |
76 | #define MARGIN_X 10 /* X pixel margin */ | 76 | #define MARGIN_X 10 /* X pixel margin */ |
77 | #define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */ | 77 | #define LINE_Y (global_settings.statusbar ? 1 : 0) /* Y position the entry-list starts at */ |
78 | #define LINE_X 0 /* X position the entry-list starts at */ | 78 | #define LINE_X 0 /* X position the entry-list starts at */ |
@@ -167,7 +167,7 @@ static int showdir(char *path, int start) | |||
167 | int fh; | 167 | int fh; |
168 | unsigned char *font = lcd_getcurrentldfont(); | 168 | unsigned char *font = lcd_getcurrentldfont(); |
169 | fh = ajf_get_fontheight(font); | 169 | fh = ajf_get_fontheight(font); |
170 | tree_max_on_screen = ((LCD_HEIGHT-MARGIN_Y)/fh)-LINE_Y; | 170 | tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; |
171 | line_height = fh; | 171 | line_height = fh; |
172 | #else | 172 | #else |
173 | tree_max_on_screen = TREE_MAX_ON_SCREEN; | 173 | tree_max_on_screen = TREE_MAX_ON_SCREEN; |
@@ -273,7 +273,7 @@ static int showdir(char *path, int start) | |||
273 | icon_type = File; | 273 | icon_type = File; |
274 | } | 274 | } |
275 | lcd_bitmap(bitmap_icons_6x8[icon_type], | 275 | lcd_bitmap(bitmap_icons_6x8[icon_type], |
276 | 4, MARGIN_Y+(LINE_Y+i-start)*line_height, 6, 8, true); | 276 | 4, MARGIN_Y+(i-start)*line_height, 6, 8, true); |
277 | #endif | 277 | #endif |
278 | 278 | ||
279 | 279 | ||
@@ -283,11 +283,11 @@ static int showdir(char *path, int start) | |||
283 | { | 283 | { |
284 | char temp = dircache[i].name[len-4]; | 284 | char temp = dircache[i].name[len-4]; |
285 | dircache[i].name[len-4] = 0; | 285 | dircache[i].name[len-4] = 0; |
286 | lcd_puts(LINE_X, LINE_Y+i-start, dircache[i].name); | 286 | lcd_puts(LINE_X, i-start, dircache[i].name); |
287 | dircache[i].name[len-4] = temp; | 287 | dircache[i].name[len-4] = temp; |
288 | } | 288 | } |
289 | else | 289 | else |
290 | lcd_puts(LINE_X, LINE_Y+i-start, dircache[i].name); | 290 | lcd_puts(LINE_X, i-start, dircache[i].name); |
291 | } | 291 | } |
292 | 292 | ||
293 | status_draw(); | 293 | status_draw(); |
@@ -411,7 +411,7 @@ bool dirbrowse(char *root) | |||
411 | int fh; | 411 | int fh; |
412 | unsigned char *font = lcd_getcurrentldfont(); | 412 | unsigned char *font = lcd_getcurrentldfont(); |
413 | fh = ajf_get_fontheight(font); | 413 | fh = ajf_get_fontheight(font); |
414 | tree_max_on_screen = ((LCD_HEIGHT-MARGIN_Y)/fh)-LINE_Y; | 414 | tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; |
415 | #else | 415 | #else |
416 | tree_max_on_screen = TREE_MAX_ON_SCREEN; | 416 | tree_max_on_screen = TREE_MAX_ON_SCREEN; |
417 | #endif | 417 | #endif |
@@ -424,7 +424,7 @@ bool dirbrowse(char *root) | |||
424 | if (numentries == -1) | 424 | if (numentries == -1) |
425 | return -1; /* root is not a directory */ | 425 | return -1; /* root is not a directory */ |
426 | 426 | ||
427 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | 427 | put_cursorxy(0, CURSOR_Y + dircursor, true); |
428 | 428 | ||
429 | while(1) { | 429 | while(1) { |
430 | bool restore = false; | 430 | bool restore = false; |
@@ -545,29 +545,29 @@ bool dirbrowse(char *root) | |||
545 | case BUTTON_VOL_UP: | 545 | case BUTTON_VOL_UP: |
546 | if(filesindir) { | 546 | if(filesindir) { |
547 | if(dircursor) { | 547 | if(dircursor) { |
548 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false); | 548 | put_cursorxy(0, CURSOR_Y + dircursor, false); |
549 | dircursor--; | 549 | dircursor--; |
550 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | 550 | put_cursorxy(0, CURSOR_Y + dircursor, true); |
551 | } | 551 | } |
552 | else { | 552 | else { |
553 | if (start) { | 553 | if (start) { |
554 | start--; | 554 | start--; |
555 | numentries = showdir(currdir, start); | 555 | numentries = showdir(currdir, start); |
556 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | 556 | put_cursorxy(0, CURSOR_Y + dircursor, true); |
557 | } | 557 | } |
558 | else { | 558 | else { |
559 | if (numentries < tree_max_on_screen) { | 559 | if (numentries < tree_max_on_screen) { |
560 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | 560 | put_cursorxy(0, CURSOR_Y + dircursor, |
561 | false); | 561 | false); |
562 | dircursor = numentries - 1; | 562 | dircursor = numentries - 1; |
563 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | 563 | put_cursorxy(0, CURSOR_Y + dircursor, |
564 | true); | 564 | true); |
565 | } | 565 | } |
566 | else { | 566 | else { |
567 | start = numentries - tree_max_on_screen; | 567 | start = numentries - tree_max_on_screen; |
568 | dircursor = tree_max_on_screen - 1; | 568 | dircursor = tree_max_on_screen - 1; |
569 | numentries = showdir(currdir, start); | 569 | numentries = showdir(currdir, start); |
570 | put_cursorxy(0, CURSOR_Y + LINE_Y + | 570 | put_cursorxy(0, CURSOR_Y + |
571 | tree_max_on_screen - 1, true); | 571 | tree_max_on_screen - 1, true); |
572 | } | 572 | } |
573 | } | 573 | } |
@@ -583,28 +583,28 @@ bool dirbrowse(char *root) | |||
583 | { | 583 | { |
584 | if (dircursor + start + 1 < numentries ) { | 584 | if (dircursor + start + 1 < numentries ) { |
585 | if(dircursor+1 < tree_max_on_screen) { | 585 | if(dircursor+1 < tree_max_on_screen) { |
586 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | 586 | put_cursorxy(0, CURSOR_Y + dircursor, |
587 | false); | 587 | false); |
588 | dircursor++; | 588 | dircursor++; |
589 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | 589 | put_cursorxy(0, CURSOR_Y + dircursor, true); |
590 | } | 590 | } |
591 | else { | 591 | else { |
592 | start++; | 592 | start++; |
593 | numentries = showdir(currdir, start); | 593 | numentries = showdir(currdir, start); |
594 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | 594 | put_cursorxy(0, CURSOR_Y + dircursor, true); |
595 | } | 595 | } |
596 | } | 596 | } |
597 | else { | 597 | else { |
598 | if(numentries < tree_max_on_screen) { | 598 | if(numentries < tree_max_on_screen) { |
599 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, | 599 | put_cursorxy(0, CURSOR_Y + dircursor, |
600 | false); | 600 | false); |
601 | start = dircursor = 0; | 601 | start = dircursor = 0; |
602 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | 602 | put_cursorxy(0, CURSOR_Y + dircursor, true); |
603 | } | 603 | } |
604 | else { | 604 | else { |
605 | start = dircursor = 0; | 605 | start = dircursor = 0; |
606 | numentries = showdir(currdir, start); | 606 | numentries = showdir(currdir, start); |
607 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | 607 | put_cursorxy(0, CURSOR_Y + dircursor, true); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | lcd_update(); | 610 | lcd_update(); |
@@ -614,14 +614,8 @@ bool dirbrowse(char *root) | |||
614 | case TREE_MENU: { | 614 | case TREE_MENU: { |
615 | bool lastfilter = global_settings.mp3filter; | 615 | bool lastfilter = global_settings.mp3filter; |
616 | bool lastsortcase = global_settings.sort_case; | 616 | bool lastsortcase = global_settings.sort_case; |
617 | #ifdef HAVE_LCD_BITMAP | ||
618 | bool laststate=statusbar(false); | ||
619 | #endif | ||
620 | lcd_stop_scroll(); | 617 | lcd_stop_scroll(); |
621 | main_menu(); | 618 | main_menu(); |
622 | #ifdef HAVE_LCD_BITMAP | ||
623 | statusbar(laststate); | ||
624 | #endif | ||
625 | /* do we need to rescan dir? */ | 619 | /* do we need to rescan dir? */ |
626 | if ( lastfilter != global_settings.mp3filter || | 620 | if ( lastfilter != global_settings.mp3filter || |
627 | lastsortcase != global_settings.sort_case) | 621 | lastsortcase != global_settings.sort_case) |
@@ -650,13 +644,18 @@ bool dirbrowse(char *root) | |||
650 | 644 | ||
651 | #ifdef HAVE_RECORDER_KEYPAD | 645 | #ifdef HAVE_RECORDER_KEYPAD |
652 | case BUTTON_F3: | 646 | case BUTTON_F3: |
653 | #endif | ||
654 | #ifdef HAVE_LCD_BITMAP | 647 | #ifdef HAVE_LCD_BITMAP |
655 | global_settings.statusbar = !global_settings.statusbar; | 648 | global_settings.statusbar = !global_settings.statusbar; |
656 | settings_save(); | 649 | settings_save(); |
650 | #ifdef LOADABLE_FONTS | ||
651 | tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; | ||
652 | #else | ||
653 | tree_max_on_screen = TREE_MAX_ON_SCREEN; | ||
654 | #endif | ||
657 | restore = true; | 655 | restore = true; |
658 | #endif | 656 | #endif |
659 | break; | 657 | break; |
658 | #endif | ||
660 | 659 | ||
661 | #ifndef SIMULATOR | 660 | #ifndef SIMULATOR |
662 | case SYS_USB_CONNECTED: { | 661 | case SYS_USB_CONNECTED: { |
@@ -694,7 +693,7 @@ bool dirbrowse(char *root) | |||
694 | dircursor--; | 693 | dircursor--; |
695 | } | 694 | } |
696 | numentries = showdir(currdir, start); | 695 | numentries = showdir(currdir, start); |
697 | put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); | 696 | put_cursorxy(0, CURSOR_Y + dircursor, true); |
698 | } | 697 | } |
699 | 698 | ||
700 | if ( numentries ) { | 699 | if ( numentries ) { |
@@ -711,12 +710,12 @@ bool dirbrowse(char *root) | |||
711 | int len = strlen(dircache[i].name); | 710 | int len = strlen(dircache[i].name); |
712 | char temp = dircache[i].name[len-4]; | 711 | char temp = dircache[i].name[len-4]; |
713 | dircache[i].name[len-4] = 0; | 712 | dircache[i].name[len-4] = 0; |
714 | lcd_puts_scroll(LINE_X, LINE_Y+dircursor, | 713 | lcd_puts_scroll(LINE_X, dircursor, |
715 | dircache[i].name); | 714 | dircache[i].name); |
716 | dircache[i].name[len-4] = temp; | 715 | dircache[i].name[len-4] = temp; |
717 | } | 716 | } |
718 | else | 717 | else |
719 | lcd_puts_scroll(LINE_X, LINE_Y+dircursor, | 718 | lcd_puts_scroll(LINE_X, dircursor, |
720 | dircache[i].name); | 719 | dircache[i].name); |
721 | } | 720 | } |
722 | } | 721 | } |