Mercurial > mplayer.hg
annotate libmenu/menu.h @ 25464:6f45e8b913cf
Revert to r25490, since the r25491 is not correct.
author | ulion |
---|---|
date | Sat, 22 Dec 2007 06:35:35 +0000 |
parents | 7ef04742572c |
children | 605d4e3e403f |
rev | line source |
---|---|
8197 | 1 |
2 struct menu_priv_s; | |
3 typedef struct menu_s menu_t; | |
4 | |
25208
1b3dabc8c2b8
Add type info to menu_t, now we can get the menu name and the type name of menu.
ulion
parents:
22284
diff
changeset
|
5 typedef struct menu_def_st menu_def_t; |
1b3dabc8c2b8
Add type info to menu_t, now we can get the menu name and the type name of menu.
ulion
parents:
22284
diff
changeset
|
6 |
25417
b0cd876a0c32
Remove dependency on m_struct.h when include libmenu/menu.h.
ulion
parents:
25263
diff
changeset
|
7 struct m_struct_st; |
b0cd876a0c32
Remove dependency on m_struct.h when include libmenu/menu.h.
ulion
parents:
25263
diff
changeset
|
8 |
8197 | 9 struct menu_s { |
22284 | 10 struct MPContext *ctx; |
8197 | 11 void (*draw)(menu_t* menu,mp_image_t* mpi); |
12 void (*read_cmd)(menu_t* menu,int cmd); | |
13 void (*read_key)(menu_t* menu,int cmd); | |
14 void (*close)(menu_t* menu); | |
25417
b0cd876a0c32
Remove dependency on m_struct.h when include libmenu/menu.h.
ulion
parents:
25263
diff
changeset
|
15 struct m_struct_st* priv_st; |
8197 | 16 struct menu_priv_s* priv; |
17 int show; // Draw it ? | |
18 int cl; // Close request (user sent a close cmd or | |
19 menu_t* parent; | |
25208
1b3dabc8c2b8
Add type info to menu_t, now we can get the menu name and the type name of menu.
ulion
parents:
22284
diff
changeset
|
20 menu_def_t *type; |
8197 | 21 }; |
22 | |
23 typedef struct menu_info_s { | |
24 const char *info; | |
25 const char *name; | |
26 const char *author; | |
27 const char *comment; | |
25419
59aba7a96701
Replace another m_struct_t by 'struct m_struct_st' to remove depedency
ulion
parents:
25417
diff
changeset
|
28 struct m_struct_st priv_st; // Config struct definition |
8197 | 29 // cfg is a config struct as defined in cfg_st, it may be used as a priv struct |
30 // cfg is filled from the attributs found in the cfg file | |
31 // the args param hold the content of the balise in the cfg file (if any) | |
32 int (*open)(menu_t* menu, char* args); | |
33 } menu_info_t; | |
34 | |
35 | |
36 #define MENU_CMD_UP 0 | |
37 #define MENU_CMD_DOWN 1 | |
38 #define MENU_CMD_OK 2 | |
39 #define MENU_CMD_CANCEL 3 | |
17945
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
8197
diff
changeset
|
40 #define MENU_CMD_LEFT 4 |
98f4e3704a76
Allow 6 ways (up/down/left/right/ok/cancel) navigation.
albeu
parents:
8197
diff
changeset
|
41 #define MENU_CMD_RIGHT 5 |
19490
f57977ac0394
support multiple actions in menu's file browser using key bindings
ben
parents:
18193
diff
changeset
|
42 #define MENU_CMD_ACTION 6 |
25263
96d0992c7920
Remove hardcoded key->cmd bindings in libmenu, support custom key bindings
ulion
parents:
25208
diff
changeset
|
43 #define MENU_CMD_HOME 7 |
96d0992c7920
Remove hardcoded key->cmd bindings in libmenu, support custom key bindings
ulion
parents:
25208
diff
changeset
|
44 #define MENU_CMD_END 8 |
96d0992c7920
Remove hardcoded key->cmd bindings in libmenu, support custom key bindings
ulion
parents:
25208
diff
changeset
|
45 #define MENU_CMD_PAGE_UP 9 |
96d0992c7920
Remove hardcoded key->cmd bindings in libmenu, support custom key bindings
ulion
parents:
25208
diff
changeset
|
46 #define MENU_CMD_PAGE_DOWN 10 |
25461 | 47 #define MENU_CMD_CLICK 11 |
8197 | 48 |
49 /// Global init/uninit | |
22284 | 50 int menu_init(struct MPContext *mpctx, char* cfg_file); |
25420 | 51 void menu_uninit(void); |
8197 | 52 |
53 /// Open a menu defined in the config file | |
54 menu_t* menu_open(char *name); | |
55 | |
56 void menu_draw(menu_t* menu,mp_image_t* mpi); | |
57 void menu_read_cmd(menu_t* menu,int cmd); | |
58 void menu_close(menu_t* menu); | |
59 void menu_read_key(menu_t* menu,int cmd); | |
60 | |
61 //// Default implementation | |
25263
96d0992c7920
Remove hardcoded key->cmd bindings in libmenu, support custom key bindings
ulion
parents:
25208
diff
changeset
|
62 int menu_dflt_read_key(menu_t* menu,int cmd); |
8197 | 63 |
25461 | 64 /// Receive mouse position events. |
65 void menu_update_mouse_pos(double x, double y); | |
66 | |
8197 | 67 /////////// Helpers |
68 | |
69 #define MENU_TEXT_TOP (1<<0) | |
70 #define MENU_TEXT_VCENTER (1<<1) | |
71 #define MENU_TEXT_BOT (1<<2) | |
72 #define MENU_TEXT_VMASK (MENU_TEXT_TOP|MENU_TEXT_VCENTER|MENU_TEXT_BOT) | |
73 #define MENU_TEXT_LEFT (1<<3) | |
74 #define MENU_TEXT_HCENTER (1<<4) | |
75 #define MENU_TEXT_RIGHT (1<<5) | |
76 #define MENU_TEXT_HMASK (MENU_TEXT_LEFT|MENU_TEXT_HCENTER|MENU_TEXT_RIGHT) | |
77 #define MENU_TEXT_CENTER (MENU_TEXT_VCENTER|MENU_TEXT_HCENTER) | |
78 | |
79 void menu_draw_text(mp_image_t* mpi, char* txt, int x, int y); | |
80 int menu_text_length(char* txt); | |
81 int menu_text_num_lines(char* txt, int max_width); | |
82 | |
83 void menu_text_size(char* txt,int max_width, | |
84 int vspace, int warp, | |
85 int* _w, int* _h); | |
86 | |
87 void menu_draw_text_full(mp_image_t* mpi,char* txt, | |
88 int x, int y,int w, int h, | |
89 int vspace, int warp, int align, int anchor); | |
17993
98eb966a4024
Add a function to draw flat boxes and use it to make the list
albeu
parents:
17945
diff
changeset
|
90 |
18193 | 91 void menu_draw_box(mp_image_t* mpi, unsigned char grey, unsigned char alpha, int x, int y, int w, int h); |