11 #include "libmpcodecs/img_format.h"
12 #include "libmpcodecs/mp_image.h"
17 #include "menu_list.h"
21 #include "input/input.h"
22 #include "access_mpcontext.h"
24 #define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1))
37 static struct menu_priv_s cfg_dflt
= {
42 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m)
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
}
50 #define mpriv (menu->priv)
52 static void read_cmd(menu_t
* menu
,int cmd
) {
60 play_tree_iter_t
* playtree_iter
= mpctx_get_playtree_iter(menu
->ctx
);
62 if(playtree_iter
->tree
== mpriv
->p
.current
->pt
)
65 if(playtree_iter
->tree
->parent
&& mpriv
->p
.current
->pt
== playtree_iter
->tree
->parent
)
66 snprintf(str
,15,"pt_up_step 1");
68 for(i
= playtree_iter
->tree
->next
; i
!= NULL
; i
= i
->next
) {
69 if(i
== mpriv
->p
.current
->pt
)
75 for(i
= playtree_iter
->tree
->prev
; i
!= NULL
; i
= i
->prev
) {
76 if(i
== mpriv
->p
.current
->pt
)
81 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_CantfindTheTargetItem
);
85 snprintf(str
,15,"pt_step %d",d
);
87 c
= mp_input_parse_cmd(str
);
89 mp_input_queue_cmd(c
);
91 mp_msg(MSGT_GLOBAL
,MSGL_WARN
,MSGTR_LIBMENU_FailedToBuildCommand
,str
);
94 menu_list_read_cmd(menu
,cmd
);
98 static int read_key(menu_t
* menu
,int c
){
99 if (menu_dflt_read_key(menu
, c
))
101 return menu_list_jump_to_key(menu
, c
);
104 static void close_menu(menu_t
* menu
) {
105 menu_list_uninit(menu
,NULL
);
108 static int op(menu_t
* menu
, char* args
) {
111 play_tree_iter_t
* playtree_iter
= mpctx_get_playtree_iter(menu
->ctx
);
113 args
= NULL
; // Warning kill
115 menu
->draw
= menu_list_draw
;
116 menu
->read_cmd
= read_cmd
;
117 menu
->read_key
= read_key
;
118 menu
->close
= close_menu
;
120 menu_list_init(menu
);
122 mpriv
->p
.title
= mpriv
->title
;
124 if(playtree_iter
->tree
->parent
!= playtree_iter
->root
) {
125 e
= calloc(1,sizeof(list_entry_t
));
127 e
->pt
= playtree_iter
->tree
->parent
;
128 menu_list_add_entry(menu
,e
);
131 for(i
= playtree_iter
->tree
; i
->prev
!= NULL
; i
= i
->prev
)
133 for( ; i
!= NULL
; i
= i
->next
) {
134 e
= calloc(1,sizeof(list_entry_t
));
136 e
->p
.txt
= mp_basename(i
->files
[0]);
138 e
->p
.txt
= "Group ...";
140 menu_list_add_entry(menu
,e
);
146 const menu_info_t menu_info_pt
= {
153 sizeof(struct menu_priv_s
),