annotate libmenu/menu_pt.c @ 8440:8c13820df036

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