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
This commit is contained in:
Kjell Ericson 2003-01-29 08:26:11 +00:00
parent 2ba4fedd64
commit 5cd393c772
3 changed files with 139 additions and 15 deletions

View file

@ -231,7 +231,7 @@ void menu_exit(int m)
inuse[m] = false;
}
bool menu_run(int m)
int menu_show(int m)
{
bool exit = false;
@ -289,17 +289,7 @@ bool menu_run(int m)
case BUTTON_PLAY:
/* Erase current display state */
lcd_clear_display();
/* if a child returns that USB was used,
we return immediately */
if (menus[m].items[menus[m].cursor].function()) {
lcd_stop_scroll(); /* just in case */
return true;
}
/* Return to previous display state */
menu_draw(m);
break;
return menus[m].cursor;
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_LEFT:
@ -331,11 +321,27 @@ bool menu_run(int m)
#ifdef HAVE_LCD_CHARCELLS
status_set_param(false);
#endif
return true;
return MENU_ATTACHED_USB;
}
status_draw();
}
return MENU_SELECTED_EXIT;
}
bool menu_run(int m)
{
bool stop=false;
while (!stop) {
int result=menu_show(m);
if (result == MENU_SELECTED_EXIT)
return false;
else if (result == MENU_ATTACHED_USB)
return true;
if (menus[m].items[menus[m].cursor].function()) {
return true;
}
}
return false;
}

View file

@ -32,6 +32,14 @@ void menu_exit(int menu);
void put_cursorxy(int x, int y, bool on);
/* Returns below define, or number of selected menu item*/
int menu_show(int m);
#define MENU_ATTACHED_USB -1
#define MENU_SELECTED_EXIT -2
bool menu_run(int menu);
#endif /* End __MENU_H__ */

View file

@ -642,6 +642,7 @@ void set_current_file(char *path)
}
}
#ifdef HAVE_LCD_BITMAP
static int onplay_screen(char* dir, char* file)
{
bool exit = false;
@ -789,6 +790,115 @@ static int onplay_screen(char* dir, char* file)
return false;
}
#else
static int onplay_screen(char* dir, char* file)
{
bool exit = false;
bool playing = mpeg_status() & MPEG_STATUS_PLAY;
char buf[MAX_PATH];
struct entry* f = &dircache[dirstart + dircursor];
bool isdir = f->attr & ATTR_DIRECTORY;
struct menu_items items[3];
int ids[3];
int lastitem=0;
int m_handle;
int selected;
if ((dir[0]=='/') && (dir[1]==0))
snprintf(buf, sizeof buf, "%s%s", dir, file);
else
snprintf(buf, sizeof buf, "%s/%s", dir, file);
if (playing) {
items[lastitem].desc=str(LANG_QUEUE);
ids[lastitem]=1;
lastitem++;
}
items[lastitem].desc=str(LANG_RENAME);
ids[lastitem]=2;
lastitem++;
/* don't delete directories */
if (!isdir) {
items[lastitem].desc=str(LANG_DELETE);
ids[lastitem]=3;
lastitem++;
}
m_handle=menu_init(items, lastitem);
selected=menu_show(m_handle);
if (selected>=0) {
switch(ids[selected]) {
case 1:
if (playing)
queue_add(buf);
break;
case 2:
{
char newname[MAX_PATH];
char* ptr = strrchr(buf, '/') + 1;
int pathlen = (ptr - buf);
strncpy(newname, buf, sizeof newname);
if (!kbd_input(newname + pathlen, (sizeof newname)-pathlen)) {
if (rename(buf, newname) < 0) {
lcd_clear_display();
lcd_puts(0,0,str(LANG_RENAME));
lcd_puts(0,1,str(LANG_FAILED));
lcd_update();
sleep(HZ*2);
}
else
reload_dir = true;
}
}
break;
case 3:
lcd_clear_display();
#ifdef HAVE_LCD_CHARCELLS
lcd_puts(0,0,file);
lcd_puts(0,1,str(LANG_REALLY_DELETE));
#else
lcd_puts(0,0,str(LANG_REALLY_DELETE));
lcd_puts(0,1,file);
lcd_puts(0,3,str(LANG_RESUME_CONFIRM_RECORDER));
lcd_puts(0,4,str(LANG_RESUME_CANCEL_RECORDER));
#endif
lcd_update();
{
while (!exit) {
int btn = button_get(true);
switch (btn) {
case BUTTON_PLAY:
case BUTTON_PLAY | BUTTON_REL:
if (!remove(buf)) {
reload_dir = true;
lcd_clear_display();
lcd_puts(0,0,file);
lcd_puts(0,1,str(LANG_DELETED));
lcd_update();
sleep(HZ);
exit = true;
break;
}
default:
/* ignore button releases */
if (!(btn & BUTTON_REL))
exit = true;
break;
}
}
}
break;
}
}
menu_exit(m_handle);
return false;
}
#endif
static bool handle_on(int* ds, int* dc, int numentries, int tree_max_on_screen)