summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorKjell Ericson <kjell@haxx.se>2003-01-29 08:26:11 +0000
committerKjell Ericson <kjell@haxx.se>2003-01-29 08:26:11 +0000
commit5cd393c772ce6d9f8f7eff5dc97b007b8249d9f6 (patch)
treece2387d895c12fc84dcf4fe9f9373742ab3edd74 /apps
parent2ba4fedd6400cb74c604ba4c9e3c56c6e2f79e78 (diff)
downloadrockbox-5cd393c772ce6d9f8f7eff5dc97b007b8249d9f6.tar.gz
rockbox-5cd393c772ce6d9f8f7eff5dc97b007b8249d9f6.zip
New onplay-menu for the Player.
The menu_run() function is split into two functions, where the new menu_run() works like before, and the new function menu_show() returns the menu item number you selected. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3180 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/menu.c34
-rw-r--r--apps/menu.h8
-rw-r--r--apps/tree.c110
3 files changed, 138 insertions, 14 deletions
diff --git a/apps/menu.c b/apps/menu.c
index 9cedbebed8..4f15b4b8ae 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -231,7 +231,7 @@ void menu_exit(int m)
231 inuse[m] = false; 231 inuse[m] = false;
232} 232}
233 233
234bool menu_run(int m) 234int menu_show(int m)
235{ 235{
236 bool exit = false; 236 bool exit = false;
237 237
@@ -289,17 +289,7 @@ bool menu_run(int m)
289 case BUTTON_PLAY: 289 case BUTTON_PLAY:
290 /* Erase current display state */ 290 /* Erase current display state */
291 lcd_clear_display(); 291 lcd_clear_display();
292 292 return menus[m].cursor;
293 /* if a child returns that USB was used,
294 we return immediately */
295 if (menus[m].items[menus[m].cursor].function()) {
296 lcd_stop_scroll(); /* just in case */
297 return true;
298 }
299
300 /* Return to previous display state */
301 menu_draw(m);
302 break;
303 293
304#ifdef HAVE_RECORDER_KEYPAD 294#ifdef HAVE_RECORDER_KEYPAD
305 case BUTTON_LEFT: 295 case BUTTON_LEFT:
@@ -331,11 +321,27 @@ bool menu_run(int m)
331#ifdef HAVE_LCD_CHARCELLS 321#ifdef HAVE_LCD_CHARCELLS
332 status_set_param(false); 322 status_set_param(false);
333#endif 323#endif
334 return true; 324 return MENU_ATTACHED_USB;
335 } 325 }
336 326
337 status_draw(); 327 status_draw();
338 } 328 }
329 return MENU_SELECTED_EXIT;
330}
331
339 332
340 return false; 333bool menu_run(int m)
334{
335 bool stop=false;
336 while (!stop) {
337 int result=menu_show(m);
338 if (result == MENU_SELECTED_EXIT)
339 return false;
340 else if (result == MENU_ATTACHED_USB)
341 return true;
342 if (menus[m].items[menus[m].cursor].function()) {
343 return true;
344 }
345 }
346 return false;
341} 347}
diff --git a/apps/menu.h b/apps/menu.h
index a21d07a7ee..632db87e4b 100644
--- a/apps/menu.h
+++ b/apps/menu.h
@@ -32,6 +32,14 @@ void menu_exit(int menu);
32 32
33void put_cursorxy(int x, int y, bool on); 33void put_cursorxy(int x, int y, bool on);
34 34
35 /* Returns below define, or number of selected menu item*/
36int menu_show(int m);
37#define MENU_ATTACHED_USB -1
38#define MENU_SELECTED_EXIT -2
39
35bool menu_run(int menu); 40bool menu_run(int menu);
36 41
37#endif /* End __MENU_H__ */ 42#endif /* End __MENU_H__ */
43
44
45
diff --git a/apps/tree.c b/apps/tree.c
index a918ecd8fa..43bd5e6f5c 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -642,6 +642,7 @@ void set_current_file(char *path)
642 } 642 }
643} 643}
644 644
645#ifdef HAVE_LCD_BITMAP
645static int onplay_screen(char* dir, char* file) 646static int onplay_screen(char* dir, char* file)
646{ 647{
647 bool exit = false; 648 bool exit = false;
@@ -789,6 +790,115 @@ static int onplay_screen(char* dir, char* file)
789 return false; 790 return false;
790} 791}
791 792
793#else
794
795static int onplay_screen(char* dir, char* file)
796{
797 bool exit = false;
798 bool playing = mpeg_status() & MPEG_STATUS_PLAY;
799 char buf[MAX_PATH];
800 struct entry* f = &dircache[dirstart + dircursor];
801 bool isdir = f->attr & ATTR_DIRECTORY;
802 struct menu_items items[3];
803 int ids[3];
804 int lastitem=0;
805 int m_handle;
806 int selected;
807
808 if ((dir[0]=='/') && (dir[1]==0))
809 snprintf(buf, sizeof buf, "%s%s", dir, file);
810 else
811 snprintf(buf, sizeof buf, "%s/%s", dir, file);
812
813 if (playing) {
814 items[lastitem].desc=str(LANG_QUEUE);
815 ids[lastitem]=1;
816 lastitem++;
817 }
818
819 items[lastitem].desc=str(LANG_RENAME);
820 ids[lastitem]=2;
821 lastitem++;
822
823 /* don't delete directories */
824 if (!isdir) {
825 items[lastitem].desc=str(LANG_DELETE);
826 ids[lastitem]=3;
827 lastitem++;
828 }
829 m_handle=menu_init(items, lastitem);
830
831 selected=menu_show(m_handle);
832 if (selected>=0) {
833 switch(ids[selected]) {
834 case 1:
835 if (playing)
836 queue_add(buf);
837 break;
838 case 2:
839 {
840 char newname[MAX_PATH];
841 char* ptr = strrchr(buf, '/') + 1;
842 int pathlen = (ptr - buf);
843 strncpy(newname, buf, sizeof newname);
844 if (!kbd_input(newname + pathlen, (sizeof newname)-pathlen)) {
845 if (rename(buf, newname) < 0) {
846 lcd_clear_display();
847 lcd_puts(0,0,str(LANG_RENAME));
848 lcd_puts(0,1,str(LANG_FAILED));
849 lcd_update();
850 sleep(HZ*2);
851 }
852 else
853 reload_dir = true;
854 }
855 }
856 break;
857 case 3:
858 lcd_clear_display();
859#ifdef HAVE_LCD_CHARCELLS
860 lcd_puts(0,0,file);
861 lcd_puts(0,1,str(LANG_REALLY_DELETE));
862#else
863 lcd_puts(0,0,str(LANG_REALLY_DELETE));
864 lcd_puts(0,1,file);
865 lcd_puts(0,3,str(LANG_RESUME_CONFIRM_RECORDER));
866 lcd_puts(0,4,str(LANG_RESUME_CANCEL_RECORDER));
867#endif
868 lcd_update();
869 {
870 while (!exit) {
871 int btn = button_get(true);
872 switch (btn) {
873 case BUTTON_PLAY:
874 case BUTTON_PLAY | BUTTON_REL:
875 if (!remove(buf)) {
876 reload_dir = true;
877 lcd_clear_display();
878 lcd_puts(0,0,file);
879 lcd_puts(0,1,str(LANG_DELETED));
880 lcd_update();
881 sleep(HZ);
882 exit = true;
883 break;
884 }
885
886 default:
887 /* ignore button releases */
888 if (!(btn & BUTTON_REL))
889 exit = true;
890 break;
891 }
892 }
893 }
894 break;
895 }
896 }
897 menu_exit(m_handle);
898 return false;
899}
900#endif
901
792 902
793 903
794static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen) 904static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen)