summaryrefslogtreecommitdiff
path: root/apps/screens.c
diff options
context:
space:
mode:
authorKevin Ferrare <kevin@rockbox.org>2005-11-22 03:38:07 +0000
committerKevin Ferrare <kevin@rockbox.org>2005-11-22 03:38:07 +0000
commit74b6af93b1436dc61e8f10b3aff3c79face5faba (patch)
treef5d17c6b0adb9f6cc448a112b309a6dff7451a76 /apps/screens.c
parent8042640ce967014f10dbc0e3f382cd1876310b66 (diff)
downloadrockbox-74b6af93b1436dc61e8f10b3aff3c79face5faba.tar.gz
rockbox-74b6af93b1436dc61e8f10b3aff3c79face5faba.zip
Added multi-screen support for quickscreen (mostly rewritten from scratch) and USB screen ; just looking at the hour makes me think it could be buggy
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8039 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/screens.c')
-rw-r--r--apps/screens.c420
1 files changed, 155 insertions, 265 deletions
diff --git a/apps/screens.c b/apps/screens.c
index acfcd01dbe..eea06785cb 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -49,6 +49,8 @@
49#include "gwps-common.h" 49#include "gwps-common.h"
50#include "splash.h" 50#include "splash.h"
51#include "statusbar.h" 51#include "statusbar.h"
52#include "screen_access.h"
53#include "quickscreen.h"
52 54
53#if defined(HAVE_LCD_BITMAP) 55#if defined(HAVE_LCD_BITMAP)
54#include "widgets.h" 56#include "widgets.h"
@@ -101,25 +103,25 @@ static const unsigned char usb_logo[] = {
101}; 103};
102#endif 104#endif
103 105
104void usb_display_info(void) 106void usb_display_info(struct screen * display)
105{ 107{
106 lcd_clear_display(); 108 display->clear_display();
107 109
108#ifdef HAVE_LCD_BITMAP 110#ifdef HAVE_LCD_BITMAP
109 /* Center bitmap on screen */ 111 /* Center bitmap on screen */
110 lcd_mono_bitmap(usb_logo, LCD_WIDTH/2-BMPWIDTH_usb_logo/2, 112 display->mono_bitmap(usb_logo,
111 LCD_HEIGHT/2-BMPHEIGHT_usb_logo/2, BMPWIDTH_usb_logo, 113 display->width/2-BMPWIDTH_usb_logo/2,
112 BMPHEIGHT_usb_logo); 114 display->height/2-BMPHEIGHT_usb_logo/2,
113 gui_syncstatusbar_draw(&statusbars, true); 115 BMPWIDTH_usb_logo,
114 lcd_update(); 116 BMPHEIGHT_usb_logo);
117 display->update();
115#else 118#else
116 lcd_double_height(false); 119 display->double_height(false);
117 lcd_puts(0, 0, "[USB Mode]"); 120 display->puts(0, 0, "[USB Mode]");
118 status_set_param(false); 121#ifdef SIMULATOR
119 status_set_audio(false); 122 display->update();
120 status_set_usb(true); 123#endif /* SIMULATOR */
121 gui_syncstatusbar_draw(&statusbars, false); 124#endif /* HAVE_LCD_BITMAP */
122#endif
123} 125}
124 126
125void usb_screen(void) 127void usb_screen(void)
@@ -127,28 +129,35 @@ void usb_screen(void)
127#ifdef USB_NONE 129#ifdef USB_NONE
128 /* nothing here! */ 130 /* nothing here! */
129#else 131#else
130#ifndef SIMULATOR 132 int i;
131 backlight_on(); 133 FOR_NB_SCREENS(i) {
134 screens[i].backlight_on();
135 usb_display_info(&screens[i]);
136 }
137#ifdef HAVE_LCD_CHARCELLS
138 status_set_param(false);
139 status_set_audio(false);
140 status_set_usb(true);
141#endif /* HAVE_LCD_BITMAP */
142 gui_syncstatusbar_draw(&statusbars, true);
143#ifdef SIMULATOR
144 while (button_get(true) & BUTTON_REL);
145#else
132 usb_acknowledge(SYS_USB_CONNECTED_ACK); 146 usb_acknowledge(SYS_USB_CONNECTED_ACK);
133 usb_display_info();
134 while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) { 147 while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) {
135 if(usb_inserted()) { 148 if(usb_inserted()) {
136
137#ifdef HAVE_MMC /* USB-MMC bridge can report activity */ 149#ifdef HAVE_MMC /* USB-MMC bridge can report activity */
138
139 led(mmc_usb_active(HZ)); 150 led(mmc_usb_active(HZ));
140 151#endif /* HAVE_MMC */
141#endif
142
143 gui_syncstatusbar_draw(&statusbars, false); 152 gui_syncstatusbar_draw(&statusbars, false);
144 } 153 }
145 } 154 }
155#endif /* SIMULATOR */
146#ifdef HAVE_LCD_CHARCELLS 156#ifdef HAVE_LCD_CHARCELLS
147 status_set_usb(false); 157 status_set_usb(false);
148#endif 158#endif /* HAVE_LCD_CHARCELLS */
149 159 FOR_NB_SCREENS(i)
150 backlight_on(); 160 screens[i].backlight_on();
151#endif
152#endif /* USB_NONE */ 161#endif /* USB_NONE */
153} 162}
154 163
@@ -157,7 +166,8 @@ int mmc_remove_request(void)
157{ 166{
158 struct event ev; 167 struct event ev;
159 168
160 lcd_clear_display(); 169 FOR_NB_SCREENS(i)
170 screens[i].clear_display();
161 gui_syncsplash(1, true, str(LANG_REMOVE_MMC)); 171 gui_syncsplash(1, true, str(LANG_REMOVE_MMC));
162 if (global_settings.talk_menu) 172 if (global_settings.talk_menu)
163 talk_id(LANG_REMOVE_MMC, false); 173 talk_id(LANG_REMOVE_MMC, false);
@@ -520,257 +530,137 @@ int pitch_screen(void)
520 530
521#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD) ||\ 531#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD) ||\
522 (CONFIG_KEYPAD == IRIVER_H300_PAD) 532 (CONFIG_KEYPAD == IRIVER_H300_PAD)
523bool quick_screen(int context, int button) 533#define bool_to_int(b)\
524{ 534 b?1:0
525 bool exit = false; 535#define int_to_bool(i)\
526 bool used = false; 536 i==0?false:true
527 int w, h, key;
528 char buf[32];
529 int oldrepeat = global_settings.repeat_mode;
530 537
531 /* just to stop compiler warning */ 538void quick_screen_quick_apply(struct gui_quickscreen *qs)
532 context = context; 539{
533 lcd_setfont(FONT_SYSFIXED); 540 global_settings.playlist_shuffle=int_to_bool(option_select_get_selected(qs->left_option));
534 541 global_settings.dirfilter=option_select_get_selected(qs->bottom_option);
535 lcd_getstringsize("A",&w,&h); 542 global_settings.repeat_mode=option_select_get_selected(qs->right_option);
536 543}
537 while (!exit) {
538 char* ptr=NULL;
539
540 lcd_clear_display();
541
542 switch(button)
543 {
544#if CONFIG_KEYPAD == RECORDER_PAD
545 case SCREENS_QUICK:
546#endif
547#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
548 case SCREENS_QUICK | BUTTON_REPEAT:
549#endif
550 /* Shuffle mode */
551 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE));
552 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE));
553 lcd_putsxy(0, LCD_HEIGHT/2,
554 global_settings.playlist_shuffle ?
555 str(LANG_ON) : str(LANG_OFF));
556
557 /* Directory Filter */
558 switch ( global_settings.dirfilter ) {
559 case SHOW_ALL:
560 ptr = str(LANG_FILTER_ALL);
561 break;
562
563 case SHOW_SUPPORTED:
564 ptr = str(LANG_FILTER_SUPPORTED);
565 break;
566
567 case SHOW_MUSIC:
568 ptr = str(LANG_FILTER_MUSIC);
569 break;
570
571 case SHOW_PLAYLIST:
572 ptr = str(LANG_FILTER_PLAYLIST);
573 break;
574
575 case SHOW_ID3DB:
576 ptr = str(LANG_FILTER_ID3DB);
577 break;
578 }
579
580 snprintf(buf, sizeof buf, "%s:", str(LANG_FILTER));
581 lcd_getstringsize(buf,&w,&h);
582 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
583 lcd_getstringsize(ptr,&w,&h);
584 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
585
586 /* Repeat Mode */
587 switch ( global_settings.repeat_mode ) {
588 case REPEAT_OFF:
589 ptr = str(LANG_OFF);
590 break;
591
592 case REPEAT_ALL:
593 ptr = str(LANG_REPEAT_ALL);
594 break;
595
596 case REPEAT_ONE:
597 ptr = str(LANG_REPEAT_ONE);
598 break;
599
600 case REPEAT_SHUFFLE:
601 ptr = str(LANG_SHUFFLE);
602 break;
603 544
545bool quick_screen_quick(void)
546{
547 bool res, oldrepeat;
548 struct option_select left_option;
549 struct option_select bottom_option;
550 struct option_select right_option;
551 struct opt_items left_items[] = {
552 [0]={ STR(LANG_OFF) },
553 [1]={ STR(LANG_ON) }
554 };
555 struct opt_items bottom_items[] = {
556 [SHOW_ALL]={ STR(LANG_FILTER_ALL) },
557 [SHOW_SUPPORTED]={ STR(LANG_FILTER_SUPPORTED) },
558 [SHOW_MUSIC]={ STR(LANG_FILTER_MUSIC) },
559 [SHOW_PLAYLIST]={ STR(LANG_FILTER_PLAYLIST) },
560 [SHOW_ID3DB]={ STR(LANG_FILTER_ID3DB) }
561 };
562 struct opt_items right_items[] = {
563 [REPEAT_OFF]={ STR(LANG_OFF) },
564 [REPEAT_ALL]={ STR(LANG_REPEAT_ALL) },
565 [REPEAT_ONE]={ STR(LANG_REPEAT_ONE) },
566 [REPEAT_SHUFFLE]={ STR(LANG_SHUFFLE) },
604#ifdef AB_REPEAT_ENABLE 567#ifdef AB_REPEAT_ENABLE
605 case REPEAT_AB: 568 [REPEAT_AB]={ STR(LANG_REPEAT_AB) }
606 ptr = str(LANG_REPEAT_AB);
607 break;
608#endif 569#endif
609 } 570 };
610 571 struct gui_quickscreen qs;
611 lcd_getstringsize(str(LANG_REPEAT),&w,&h); 572
612 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, str(LANG_REPEAT)); 573 option_select_init_items(&left_option,
613 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F2_MODE)); 574 str(LANG_SHUFFLE),
614 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr); 575 bool_to_int(global_settings.playlist_shuffle),
615 break; 576 left_items,
616#ifdef BUTTON_F3 577 2);
617 case BUTTON_F3: 578 option_select_init_items(&bottom_option,
618 /* Scrollbar */ 579 str(LANG_FILTER),
619 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_F3_SCROLL)); 580 global_settings.dirfilter,
620 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F3_BAR)); 581 bottom_items,
621 lcd_putsxy(0, LCD_HEIGHT/2, 582 sizeof(bottom_items)/sizeof(struct opt_items));
622 global_settings.scrollbar ? str(LANG_ON) : str(LANG_OFF)); 583 option_select_init_items(&right_option,
623 584 str(LANG_REPEAT),
624 /* Status bar */ 585 global_settings.repeat_mode,
625 ptr = str(LANG_F3_STATUS); 586 right_items,
626 lcd_getstringsize(ptr,&w,&h); 587 sizeof(right_items)/sizeof(struct opt_items));
627 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr); 588
628 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F3_BAR)); 589 gui_quickscreen_init(&qs, &left_option, &bottom_option, &right_option,
629 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, 590 str(LANG_F2_MODE), &quick_screen_quick_apply);
630 global_settings.statusbar ? str(LANG_ON) : str(LANG_OFF)); 591 oldrepeat=global_settings.repeat_mode;
631 592 res=gui_syncquickscreen_run(&qs);
632 /* Flip */ 593 if(!res)
633 ptr = str(LANG_FLIP_DISPLAY); 594 {
634 lcd_getstringsize(ptr,&w,&h); 595 if ( oldrepeat != global_settings.repeat_mode &&
635 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, str(LANG_FLIP_DISPLAY)); 596 (audio_status() & AUDIO_STATUS_PLAY) )
636 ptr = global_settings.flip_display ? 597 audio_flush_and_reload_tracks();
637 str(LANG_SET_BOOL_YES) : str(LANG_SET_BOOL_NO); 598 if(global_settings.playlist_shuffle
638 lcd_getstringsize(ptr,&w,&h); 599 && audio_status() & AUDIO_STATUS_PLAY)
639 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); 600 {
640 break;
641#endif
642 }
643
644 lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
645 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
646 lcd_mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
647 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
648 lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
649 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
650
651 lcd_update();
652 key = button_get(true);
653
654 /*
655 * This is a temporary kludge so that the F2 & F3 menus operate in exactly
656 * the same manner up until the full F2/F3 configurable menus are complete
657 */
658
659 if( key == BUTTON_LEFT || key == BUTTON_RIGHT || key == BUTTON_DOWN || key == ( BUTTON_LEFT | BUTTON_REPEAT ) || key == ( BUTTON_RIGHT | BUTTON_REPEAT ) || key == ( BUTTON_DOWN | BUTTON_REPEAT ) )
660 key = button | key;
661
662 switch (key) {
663 case SCREENS_QUICK | BUTTON_LEFT:
664 case SCREENS_QUICK | BUTTON_LEFT | BUTTON_REPEAT:
665 global_settings.playlist_shuffle =
666 !global_settings.playlist_shuffle;
667
668 if(audio_status() & AUDIO_STATUS_PLAY)
669 {
670#if CONFIG_CODEC == SWCODEC 601#if CONFIG_CODEC == SWCODEC
671 dsp_set_replaygain(true); 602 dsp_set_replaygain(true);
672#endif
673
674 if (global_settings.playlist_shuffle)
675 playlist_randomise(NULL, current_tick, true);
676 else
677 playlist_sort(NULL, true);
678 }
679 used = true;
680 break;
681
682 case SCREENS_QUICK | BUTTON_DOWN:
683 case SCREENS_QUICK | BUTTON_DOWN | BUTTON_REPEAT:
684 global_settings.dirfilter++;
685 if ( global_settings.dirfilter >= NUM_FILTER_MODES )
686 global_settings.dirfilter = 0;
687 used = true;
688 break;
689
690 case SCREENS_QUICK | BUTTON_RIGHT:
691 case SCREENS_QUICK | BUTTON_RIGHT | BUTTON_REPEAT:
692 global_settings.repeat_mode++;
693 if ( global_settings.repeat_mode >= NUM_REPEAT_MODES )
694 global_settings.repeat_mode = 0;
695 used = true;
696 break;
697
698#ifdef BUTTON_F3
699 case BUTTON_F3 | BUTTON_LEFT:
700 case BUTTON_F3 | BUTTON_LEFT | BUTTON_REPEAT:
701 global_settings.scrollbar = !global_settings.scrollbar;
702 used = true;
703 break;
704
705 case BUTTON_F3 | BUTTON_RIGHT:
706 case BUTTON_F3 | BUTTON_RIGHT | BUTTON_REPEAT:
707 global_settings.statusbar = !global_settings.statusbar;
708 used = true;
709 break;
710
711 case BUTTON_F3 | BUTTON_DOWN:
712 case BUTTON_F3 | BUTTON_DOWN | BUTTON_REPEAT:
713 case BUTTON_F3 | BUTTON_UP:
714 case BUTTON_F3 | BUTTON_UP | BUTTON_REPEAT:
715 global_settings.flip_display = !global_settings.flip_display;
716 button_set_flip(global_settings.flip_display);
717 lcd_set_flip(global_settings.flip_display);
718 used = true;
719 break;
720
721 case BUTTON_F3 | BUTTON_REL:
722#endif 603#endif
723 case SCREENS_QUICK | BUTTON_REL: 604 if (global_settings.playlist_shuffle)
724 605 playlist_randomise(NULL, current_tick, true);
725 if( used ) 606 else
726 exit = true; 607 playlist_sort(NULL, true);
727
728 used = true;
729
730 break;
731
732 case BUTTON_OFF | BUTTON_REL:
733 lcd_setfont(FONT_UI);
734 return false;
735
736 default:
737 if(default_event_handler(key) == SYS_USB_CONNECTED)
738 return true;
739 break;
740 } 608 }
609 settings_save();
741 } 610 }
611 return(res);
612}
742 613
743 settings_save(); 614void quick_screen_f3_apply(struct gui_quickscreen *qs)
744 615{
745 switch( button ) 616 global_settings.scrollbar=int_to_bool(option_select_get_selected(qs->left_option));
746 {
747#if CONFIG_KEYPAD == RECORDER_PAD
748 case SCREENS_QUICK:
749#endif
750#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
751 case SCREENS_QUICK | BUTTON_REPEAT:
752#endif
753
754 if ( oldrepeat != global_settings.repeat_mode &&
755 (audio_status() & AUDIO_STATUS_PLAY) )
756 audio_flush_and_reload_tracks();
757 617
758 break; 618 global_settings.flip_display=int_to_bool(option_select_get_selected(qs->bottom_option));
759#ifdef BUTTON_F3 619 button_set_flip(global_settings.flip_display);
760 case BUTTON_F3: 620 lcd_set_flip(global_settings.flip_display);
761 621
762 if (global_settings.statusbar) 622 global_settings.statusbar=int_to_bool(option_select_get_selected(qs->right_option));
763 lcd_setmargins(0, STATUSBAR_HEIGHT); 623 gui_syncstatusbar_draw(&statusbars, true);
764 else 624}
765 lcd_setmargins(0, 0);
766
767 break;
768#endif
769 }
770 625
771 lcd_setfont(FONT_UI); 626bool quick_screen_f3(void)
627{
628 bool res;
629 struct option_select left_option;
630 struct option_select bottom_option;
631 struct option_select right_option;
632 struct opt_items onoff_items[] = {
633 [0]={ STR(LANG_OFF) },
634 [1]={ STR(LANG_ON) }
635 };
636 struct opt_items yesno_items[] = {
637 [0]={ STR(LANG_SET_BOOL_NO) },
638 [1]={ STR(LANG_SET_BOOL_YES) }
639 };
772 640
773 return false; 641 struct gui_quickscreen qs;
642
643 option_select_init_items(&left_option,
644 str(LANG_F3_SCROLL),
645 bool_to_int(global_settings.scrollbar),
646 onoff_items,
647 2);
648 option_select_init_items(&bottom_option,
649 str(LANG_FLIP_DISPLAY),
650 bool_to_int(global_settings.flip_display),
651 yesno_items,
652 2);
653 option_select_init_items(&right_option,
654 str(LANG_F3_STATUS),
655 bool_to_int(global_settings.statusbar),
656 onoff_items,
657 2);
658 gui_quickscreen_init(&qs, &left_option, &bottom_option, &right_option,
659 str(LANG_F3_BAR), &quick_screen_f3_apply);
660 res=gui_syncquickscreen_run(&qs);
661 if(!res)
662 settings_save();
663 return(res);
774} 664}
775#endif 665#endif
776 666