Allow 6 ways (up/down/left/right/ok/cancel) navigation.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17946 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
albeu 2006-03-25 17:32:10 +00:00
parent 09ae9c2ef9
commit 0e38597ae8
8 changed files with 40 additions and 9 deletions

View File

@ -185,10 +185,14 @@ void menu_dflt_read_key(menu_t* menu,int cmd) {
menu->read_cmd(menu,MENU_CMD_DOWN);
break;
case KEY_LEFT:
menu->read_cmd(menu,MENU_CMD_LEFT);
break;
case KEY_ESC:
menu->read_cmd(menu,MENU_CMD_CANCEL);
break;
case KEY_RIGHT:
menu->read_cmd(menu,MENU_CMD_RIGHT);
break;
case KEY_ENTER:
menu->read_cmd(menu,MENU_CMD_OK);
break;

View File

@ -31,6 +31,8 @@ typedef struct menu_info_s {
#define MENU_CMD_DOWN 1
#define MENU_CMD_OK 2
#define MENU_CMD_CANCEL 3
#define MENU_CMD_LEFT 4
#define MENU_CMD_RIGHT 5
/// Global init/uninit
int menu_init(char* cfg_file);

View File

@ -27,6 +27,8 @@ struct list_entry_s {
char* ok;
char* cancel;
char* left;
char* right;
};
struct menu_priv_s {
@ -47,6 +49,12 @@ static m_option_t cfg_fields[] = {
static void read_cmd(menu_t* menu,int cmd) {
switch(cmd) {
case MENU_CMD_RIGHT:
if(mpriv->p.current->right) {
mp_cmd_t* c = mp_input_parse_cmd(mpriv->p.current->right);
if(c) mp_input_queue_cmd(c);
break;
} // fallback on ok if right is not defined
case MENU_CMD_OK: {
if(mpriv->p.current->ok) {
mp_cmd_t* c = mp_input_parse_cmd(mpriv->p.current->ok);
@ -54,6 +62,12 @@ static void read_cmd(menu_t* menu,int cmd) {
mp_input_queue_cmd(c);
}
} break;
case MENU_CMD_LEFT:
if(mpriv->p.current->left) {
mp_cmd_t* c = mp_input_parse_cmd(mpriv->p.current->left);
if(c) mp_input_queue_cmd(c);
break;
} // fallback on cancel if left is not defined
case MENU_CMD_CANCEL:
if(mpriv->p.current->cancel) {
mp_cmd_t* c = mp_input_parse_cmd(mpriv->p.current->cancel);
@ -84,7 +98,7 @@ static void close(menu_t* menu) {
}
static int parse_args(menu_t* menu,char* args) {
char *element,*body, **attribs, *name, *ok, *cancel;
char *element,*body, **attribs, *name;
list_entry_t* m = NULL;
int r;
ASX_Parser_t* parser = asx_parser_new();
@ -110,12 +124,12 @@ static int parse_args(menu_t* menu,char* args) {
asx_free_attribs(attribs);
continue;
}
ok = asx_get_attrib("ok",attribs);
cancel = asx_get_attrib("cancel",attribs);
m = calloc(1,sizeof(struct list_entry_s));
m->p.txt = name;
m->ok = ok;
m->cancel = cancel;
m->ok = asx_get_attrib("ok",attribs);
m->cancel = asx_get_attrib("cancel",attribs);
m->left = asx_get_attrib("left",attribs);
m->right = asx_get_attrib("right",attribs);
menu_list_add_entry(menu,m);
free(element);

View File

@ -191,6 +191,7 @@ static void read_cmd(menu_t* menu, int cmd)
char *cmd_name;
switch(cmd)
{
case MENU_CMD_RIGHT:
case MENU_CMD_OK:
{
elem = mpriv->p.current;
@ -222,6 +223,7 @@ static void read_cmd(menu_t* menu, int cmd)
}
break;
case MENU_CMD_LEFT:
case MENU_CMD_CANCEL:
{
elem = mpriv->p.current;

View File

@ -206,6 +206,9 @@ bailout:
static void read_cmd(menu_t* menu,int cmd) {
mp_cmd_t* c = NULL;
switch(cmd) {
case MENU_CMD_LEFT:
mpriv->p.current = mpriv->p.menu; // Hack : we consider that the first entry is ../
case MENU_CMD_RIGHT:
case MENU_CMD_OK: {
// Directory
if(mpriv->p.current->d) {
@ -261,10 +264,9 @@ static void read_cmd(menu_t* menu,int cmd) {
}
static void read_key(menu_t* menu,int c){
if(c == KEY_BS) {
mpriv->p.current = mpriv->p.menu; // Hack : we consider that the first entry is ../
read_cmd(menu,MENU_CMD_OK);
} else
if(c == KEY_BS)
read_cmd(menu,MENU_CMD_LEFT);
else
menu_list_read_key(menu,c,1);
}

View File

@ -129,6 +129,7 @@ void menu_list_read_cmd(menu_t* menu,int cmd) {
} else {
mpriv->current = mpriv->menu;
} break;
case MENU_CMD_LEFT:
case MENU_CMD_CANCEL:
menu->show = 0;
menu->cl = 1;
@ -224,3 +225,4 @@ void menu_list_uninit(menu_t* menu,free_entry_t free_func) {
mpriv->menu = mpriv->current = NULL;
}

View File

@ -50,6 +50,7 @@ static m_option_t cfg_fields[] = {
static void read_cmd(menu_t* menu,int cmd) {
switch(cmd) {
case MENU_CMD_RIGHT:
case MENU_CMD_OK: {
int d = 1;
char str[15];

View File

@ -105,6 +105,10 @@ static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) {
menu_read_cmd(priv->current,MENU_CMD_UP);
else if(strcmp(arg,"down") == 0)
menu_read_cmd(priv->current,MENU_CMD_DOWN);
else if(strcmp(arg,"left") == 0)
menu_read_cmd(priv->current,MENU_CMD_LEFT);
else if(strcmp(arg,"right") == 0)
menu_read_cmd(priv->current,MENU_CMD_RIGHT);
else if(strcmp(arg,"ok") == 0)
menu_read_cmd(priv->current,MENU_CMD_OK);
else if(strcmp(arg,"cancel") == 0)