annotate libmenu/menu_pt.c @ 14207:f8670fdf6ab1

added -wid support for vo_directx.
author joey
date Tue, 21 Dec 2004 20:33:51 +0000
parents 048d0a158714
children 931bdbc37ee0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
1
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
2 #include <stdlib.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
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
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
5 //#include <libgen.h>
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
6
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
7 #include "../config.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
8
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
9 #include "img_format.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
10 #include "mp_image.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
11
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
12 #include "../m_struct.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
13 #include "../m_option.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
14 #include "menu.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
15 #include "menu_list.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
16
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
17
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
18 #include "../playtree.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
19 #include "../input/input.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
20
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
21 #define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1))
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
22
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
23 extern play_tree_iter_t* playtree_iter;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
24
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
25 struct list_entry_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
26 struct list_entry p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
27 play_tree_t* pt;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
28 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
29
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
30
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
31 struct menu_priv_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
32 menu_list_priv_t p;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
33 char* title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
34 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
35
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
36 static struct menu_priv_s cfg_dflt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
37 MENU_LIST_PRIV_DFLT,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
38 "Jump to"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
39 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
40
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
41 #define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
42
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
43 static m_option_t cfg_fields[] = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
44 MENU_LIST_PRIV_FIELDS,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
45 { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
46 { NULL, NULL, NULL, 0,0,0,NULL }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
47 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
48
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
49 #define mpriv (menu->priv)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
50
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
51 static void read_cmd(menu_t* menu,int cmd) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
52 switch(cmd) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
53 case MENU_CMD_OK: {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
54 int d = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
55 char str[15];
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
56 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
57 mp_cmd_t* c;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
58
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
59
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
60 if(playtree_iter->tree == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
61 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
62
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
63 if(playtree_iter->tree->parent && mpriv->p.current->pt == playtree_iter->tree->parent)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
64 snprintf(str,15,"pt_up_step 1");
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
65 else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
66 for(i = playtree_iter->tree->next; i != NULL ; i = i->next) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
67 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
68 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
69 d++;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
70 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
71 if(i == NULL) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
72 d = -1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
73 for(i = playtree_iter->tree->prev; i != NULL ; i = i->prev) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
74 if(i == mpriv->p.current->pt)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
75 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
76 d--;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
77 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
78 if(i == NULL) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
79 printf("Can't find the target item ????\n");
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
80 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
81 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
82 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
83 snprintf(str,15,"pt_step %d",d);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
84 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
85 c = mp_input_parse_cmd(str);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
86 if(c)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
87 mp_input_queue_cmd(c);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
88 else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
89 printf("Failed to build command %s\n",str);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
90 } break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
91 default:
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
92 menu_list_read_cmd(menu,cmd);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
93 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
94 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
95
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
96 static void read_key(menu_t* menu,int c){
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
97 menu_list_read_key(menu,c,1);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
98 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
99
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
100 static void close(menu_t* menu) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
101 menu_list_uninit(menu,NULL);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
102 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
103
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
104 static int op(menu_t* menu, char* args) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
105 play_tree_t* i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
106 list_entry_t* e;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
107 args = NULL; // Warning kill
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
108
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
109 menu->draw = menu_list_draw;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
110 menu->read_cmd = read_cmd;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
111 menu->read_key = read_key;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
112 menu->close = close;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
113
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
114 menu_list_init(menu);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
115
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
116 mpriv->p.title = mpriv->title;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
117
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
118 if(playtree_iter->tree->parent != playtree_iter->root) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
119 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
120 e->p.txt = "..";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
121 e->pt = playtree_iter->tree->parent;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
122 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
123 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
124
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
125 for(i = playtree_iter->tree ; i->prev != NULL ; i = i->prev)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
126 /* NOP */;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
127 for( ; i != NULL ; i = i->next ) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
128 e = calloc(1,sizeof(list_entry_t));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
129 if(i->files)
9102
048d0a158714 don't depend on libgen/basename()
arpi
parents: 8623
diff changeset
130 e->p.txt = mp_basename(i->files[0]);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
131 else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
132 e->p.txt = "Group ...";
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
133 e->pt = i;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
134 menu_list_add_entry(menu,e);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
135 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
136
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
137 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
138 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
139
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
140 const menu_info_t menu_info_pt = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
141 "Playtree menu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
142 "pt",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
143 "Albeu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
144 "",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
145 {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
146 "pt_cfg",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
147 sizeof(struct menu_priv_s),
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
148 &cfg_dflt,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
149 cfg_fields
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
150 },
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
151 op
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
152 };