annotate libmenu/menu_pt.c @ 36811:92dd1764392a

demuxers: remove pointless sh->ds assignments. The new_sh_* functions have been fixed a long time ago to do this.
author reimar
date Sun, 23 Feb 2014 18:14:44 +0000
parents b28f3ff37ae7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28113
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
1 /*
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
2 * This file is part of MPlayer.
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
3 *
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
5 * it under the terms of the GNU General Public License as published by
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
7 * (at your option) any later version.
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
8 *
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
12 * GNU General Public License for more details.
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
13 *
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
14 * You should have received a copy of the GNU General Public License along
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
f8b6c7045cf8 Add standard GPL headers.
diego
parents: 27072
diff changeset
17 */
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
18
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
19 #include <stdlib.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
20 #include <stdio.h>
8623
440301fef3fe Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents: 8197
diff changeset
21 #include <string.h>
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
22 //#include <libgen.h>
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
23
36582
b28f3ff37ae7 Use av_unused for unused arguments instead of various hacks.
reimar
parents: 32543
diff changeset
24 #include "libavutil/attributes.h"
b28f3ff37ae7 Use av_unused for unused arguments instead of various hacks.
reimar
parents: 32543
diff changeset
25
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
26 #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
27 #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
28 #include "help_mp.h"
32543
18338ee51c9d Export mp_basename in a function instead of duplicate macros in various places
cboesch
parents: 30957
diff changeset
29 #include "path.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
30
19431
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 18817
diff changeset
31 #include "libmpcodecs/img_format.h"
ac69ba536915 Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents: 18817
diff changeset
32 #include "libmpcodecs/mp_image.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
33
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
34 #include "m_struct.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
35 #include "m_option.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
36 #include "menu.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
37 #include "menu_list.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
38
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
39
16862
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
40 #include "playtree.h"
931bdbc37ee0 Unify include paths, -I.. is in CFLAGS.
diego
parents: 9102
diff changeset
41 #include "input/input.h"
22284
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
42 #include "access_mpcontext.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
43
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
44 struct list_entry_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
45 struct list_entry p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
46 play_tree_t* pt;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
47 };
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28113
diff changeset
48
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
49
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
50 struct menu_priv_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
51 menu_list_priv_t p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
52 char* title;
27072
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
53 int auto_close;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
54 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
55
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
56 static struct menu_priv_s cfg_dflt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
57 MENU_LIST_PRIV_DFLT,
27072
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
58 "Jump to",
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
59 0
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
60 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
61
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
62 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
63
30957
45b93bea8082 Mark cfg_fields m_option_t array as const.
diego
parents: 29263
diff changeset
64 static const m_option_t cfg_fields[] = {
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
65 MENU_LIST_PRIV_FIELDS,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
66 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL },
27072
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
67 { "auto-close", ST_OFF(auto_close), CONF_TYPE_FLAG, 0, 0, 1, NULL },
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
68 { NULL, NULL, NULL, 0,0,0,NULL }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
69 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
70
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
71 #define mpriv (menu->priv)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
72
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
73 static void read_cmd(menu_t* menu,int cmd) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
74 switch(cmd) {
17945
98f4e3704a76 Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents: 16862
diff changeset
75 case MENU_CMD_RIGHT:
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
76 case MENU_CMD_OK: {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
77 int d = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
78 char str[15];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
79 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
80 mp_cmd_t* c;
22284
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
81 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
82
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
83 if(playtree_iter->tree == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
84 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
85
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
86 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
87 snprintf(str,15,"pt_up_step 1");
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
88 else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
89 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
90 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
91 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
92 d++;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
93 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
94 if(i == NULL) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
95 d = -1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
96 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
97 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
98 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
99 d--;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
100 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
101 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
102 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
103 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
104 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
105 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
106 snprintf(str,15,"pt_step %d",d);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
107 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
108 c = mp_input_parse_cmd(str);
27072
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
109 if(c) {
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
110 if(mpriv->auto_close)
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
111 mp_input_queue_cmd(mp_input_parse_cmd("menu hide"));
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
112 mp_input_queue_cmd(c);
27072
15b870cf3592 Add auto-close option to libmenu playlist handling part.
ben
parents: 25502
diff changeset
113 }
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
114 else
17994
6927fabaef92 Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
reynaldo
parents: 17945
diff changeset
115 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
116 } break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
117 default:
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
118 menu_list_read_cmd(menu,cmd);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
119 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
120 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
121
25502
605d4e3e403f From now on, libmenu does not steal all input keys from input modules.
ulion
parents: 25263
diff changeset
122 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
123 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
124 return 1;
605d4e3e403f From now on, libmenu does not steal all input keys from input modules.
ulion
parents: 25263
diff changeset
125 return menu_list_jump_to_key(menu, c);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
126 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
127
18817
a2b064a48775 declaring static functions with the same name than libc ones was not the best idea ever
ben
parents: 17994
diff changeset
128 static void close_menu(menu_t* menu) {
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
129 menu_list_uninit(menu,NULL);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
130 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
131
36582
b28f3ff37ae7 Use av_unused for unused arguments instead of various hacks.
reimar
parents: 32543
diff changeset
132 static int op(menu_t* menu, char* av_unused args) {
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
133 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
134 list_entry_t* e;
22284
83366c8e1928 Fix menu to work with mpctx
uau
parents: 19431
diff changeset
135 play_tree_iter_t* playtree_iter = mpctx_get_playtree_iter(menu->ctx);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28113
diff changeset
136
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
137 menu->draw = menu_list_draw;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
138 menu->read_cmd = read_cmd;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
139 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
140 menu->close = close_menu;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
141
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
142 menu_list_init(menu);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
143
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
144 mpriv->p.title = mpriv->title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
145
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
146 if(playtree_iter->tree->parent != playtree_iter->root) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
147 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
148 e->p.txt = "..";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
149 e->pt = playtree_iter->tree->parent;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
150 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
151 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28113
diff changeset
152
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
153 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
154 /* NOP */;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
155 for( ; i != NULL ; i = i->next ) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
156 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
157 if(i->files)
32543
18338ee51c9d Export mp_basename in a function instead of duplicate macros in various places
cboesch
parents: 30957
diff changeset
158 e->p.txt = (char *)mp_basename(i->files[0]);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
159 else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
160 e->p.txt = "Group ...";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
161 e->pt = i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
162 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
163 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
164
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
165 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
166 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
167
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
168 const menu_info_t menu_info_pt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
169 "Playtree menu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
170 "pt",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
171 "Albeu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
172 "",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
173 {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
174 "pt_cfg",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
175 sizeof(struct menu_priv_s),
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
176 &cfg_dflt,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
177 cfg_fields
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
178 },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
179 op
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
180 };