Mercurial > mplayer.hg
annotate libmenu/menu_pt.c @ 25899:9d4121fa508a
Split osd related stuff from mp_core.h into new header file mp_osd.h.
author | ulion |
---|---|
date | Wed, 30 Jan 2008 07:21:05 +0000 |
parents | 605d4e3e403f |
children | 15b870cf3592 |
rev | line source |
---|---|
8197 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
8623
440301fef3fe
Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents:
8197
diff
changeset
|
4 #include <string.h> |
9102 | 5 //#include <libgen.h> |
8197 | 6 |
16862 | 7 #include "config.h" |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
8 #include "mp_msg.h" |
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
9 #include "help_mp.h" |
8197 | 10 |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18817
diff
changeset
|
11 #include "libmpcodecs/img_format.h" |
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
18817
diff
changeset
|
12 #include "libmpcodecs/mp_image.h" |
8197 | 13 |
16862 | 14 #include "m_struct.h" |
15 #include "m_option.h" | |
8197 | 16 #include "menu.h" |
17 #include "menu_list.h" | |
18 | |
19 | |
16862 | 20 #include "playtree.h" |
21 #include "input/input.h" | |
22284 | 22 #include "access_mpcontext.h" |
8197 | 23 |
9102 | 24 #define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1)) |
8197 | 25 |
26 struct list_entry_s { | |
27 struct list_entry p; | |
28 play_tree_t* pt; | |
29 }; | |
30 | |
31 | |
32 struct menu_priv_s { | |
33 menu_list_priv_t p; | |
34 char* title; | |
35 }; | |
36 | |
37 static struct menu_priv_s cfg_dflt = { | |
38 MENU_LIST_PRIV_DFLT, | |
39 "Jump to" | |
40 }; | |
41 | |
42 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m) | |
43 | |
44 static m_option_t cfg_fields[] = { | |
45 MENU_LIST_PRIV_FIELDS, | |
46 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
47 { NULL, NULL, NULL, 0,0,0,NULL } | |
48 }; | |
49 | |
50 #define mpriv (menu->priv) | |
51 | |
52 static void read_cmd(menu_t* menu,int cmd) { | |
53 switch(cmd) { | |
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
16862
diff
changeset
|
54 case MENU_CMD_RIGHT: |
8197 | 55 case MENU_CMD_OK: { |
56 int d = 1; | |
57 char str[15]; | |
58 play_tree_t* i; | |
59 mp_cmd_t* c; | |
22284 | 60 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx); |
8197 | 61 |
62 if(playtree_iter->tree == mpriv->p.current->pt) | |
63 break; | |
64 | |
65 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent) | |
66 snprintf(str,15,"pt_up_step 1"); | |
67 else { | |
68 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) { | |
69 if(i == mpriv->p.current->pt) | |
70 break; | |
71 d++; | |
72 } | |
73 if(i == NULL) { | |
74 d = -1; | |
75 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) { | |
76 if(i == mpriv->p.current->pt) | |
77 break; | |
78 d--; | |
79 } | |
80 if(i == NULL) { | |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
81 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem); |
8197 | 82 break; |
83 } | |
84 } | |
85 snprintf(str,15,"pt_step %d",d); | |
86 } | |
87 c = mp_input_parse_cmd(str); | |
88 if(c) | |
89 mp_input_queue_cmd(c); | |
90 else | |
17994
6927fabaef92
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents:
17945
diff
changeset
|
91 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str); |
8197 | 92 } break; |
93 default: | |
94 menu_list_read_cmd(menu,cmd); | |
95 } | |
96 } | |
97 | |
25502
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
98 static int read_key(menu_t* menu,int c){ |
25263
96d0992c7920
Remove hardcoded key->cmd bindings in libmenu, support custom key bindings
ulion
parents:
22284
diff
changeset
|
99 if (menu_dflt_read_key(menu, c)) |
25502
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
100 return 1; |
605d4e3e403f
From now on, libmenu does not steal all input keys from input modules.
ulion
parents:
25263
diff
changeset
|
101 return menu_list_jump_to_key(menu, c); |
8197 | 102 } |
103 | |
18817
a2b064a48775
declaring static functions with the same name than libc ones was not the best idea ever
ben
parents:
17994
diff
changeset
|
104 static void close_menu(menu_t* menu) { |
8197 | 105 menu_list_uninit(menu,NULL); |
106 } | |
107 | |
108 static int op(menu_t* menu, char* args) { | |
109 play_tree_t* i; | |
110 list_entry_t* e; | |
22284 | 111 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx); |
112 | |
8197 | 113 args = NULL; // Warning kill |
114 | |
115 menu->draw = menu_list_draw; | |
116 menu->read_cmd = read_cmd; | |
117 menu->read_key = read_key; | |
18817
a2b064a48775
declaring static functions with the same name than libc ones was not the best idea ever
ben
parents:
17994
diff
changeset
|
118 menu->close = close_menu; |
8197 | 119 |
120 menu_list_init(menu); | |
121 | |
122 mpriv->p.title = mpriv->title; | |
123 | |
124 if(playtree_iter->tree->parent != playtree_iter->root) { | |
125 e = calloc(1,sizeof(list_entry_t)); | |
126 e->p.txt = ".."; | |
127 e->pt = playtree_iter->tree->parent; | |
128 menu_list_add_entry(menu,e); | |
129 } | |
130 | |
131 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev) | |
132 /* NOP */; | |
133 for( ; i != NULL ; i = i->next ) { | |
134 e = calloc(1,sizeof(list_entry_t)); | |
135 if(i->files) | |
9102 | 136 e->p.txt = mp_basename(i->files[0]); |
8197 | 137 else |
138 e->p.txt = "Group ..."; | |
139 e->pt = i; | |
140 menu_list_add_entry(menu,e); | |
141 } | |
142 | |
143 return 1; | |
144 } | |
145 | |
146 const menu_info_t menu_info_pt = { | |
147 "Playtree menu", | |
148 "pt", | |
149 "Albeu", | |
150 "", | |
151 { | |
152 "pt_cfg", | |
153 sizeof(struct menu_priv_s), | |
154 &cfg_dflt, | |
155 cfg_fields | |
156 }, | |
157 op | |
158 }; |