Fix mouse button mapping:
[mplayer/greg.git] / libmenu / menu.h
blob8690d4a57913b0c72fcdb134f2004dbdebdad759
2 struct menu_priv_s;
3 typedef struct menu_s menu_t;
5 typedef struct menu_def_st menu_def_t;
7 struct m_struct_st;
9 struct menu_s {
10 struct MPContext *ctx;
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);
15 struct m_struct_st* priv_st;
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;
20 menu_def_t *type;
23 typedef struct menu_info_s {
24 const char *info;
25 const char *name;
26 const char *author;
27 const char *comment;
28 struct m_struct_st priv_st; // Config struct definition
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;
36 #define MENU_CMD_UP 0
37 #define MENU_CMD_DOWN 1
38 #define MENU_CMD_OK 2
39 #define MENU_CMD_CANCEL 3
40 #define MENU_CMD_LEFT 4
41 #define MENU_CMD_RIGHT 5
42 #define MENU_CMD_ACTION 6
43 #define MENU_CMD_HOME 7
44 #define MENU_CMD_END 8
45 #define MENU_CMD_PAGE_UP 9
46 #define MENU_CMD_PAGE_DOWN 10
48 /// Global init/uninit
49 int menu_init(struct MPContext *mpctx, char* cfg_file);
50 void menu_uninit(void);
52 /// Open a menu defined in the config file
53 menu_t* menu_open(char *name);
55 void menu_draw(menu_t* menu,mp_image_t* mpi);
56 void menu_read_cmd(menu_t* menu,int cmd);
57 void menu_close(menu_t* menu);
58 void menu_read_key(menu_t* menu,int cmd);
60 //// Default implementation
61 int menu_dflt_read_key(menu_t* menu,int cmd);
63 /////////// Helpers
65 #define MENU_TEXT_TOP (1<<0)
66 #define MENU_TEXT_VCENTER (1<<1)
67 #define MENU_TEXT_BOT (1<<2)
68 #define MENU_TEXT_VMASK (MENU_TEXT_TOP|MENU_TEXT_VCENTER|MENU_TEXT_BOT)
69 #define MENU_TEXT_LEFT (1<<3)
70 #define MENU_TEXT_HCENTER (1<<4)
71 #define MENU_TEXT_RIGHT (1<<5)
72 #define MENU_TEXT_HMASK (MENU_TEXT_LEFT|MENU_TEXT_HCENTER|MENU_TEXT_RIGHT)
73 #define MENU_TEXT_CENTER (MENU_TEXT_VCENTER|MENU_TEXT_HCENTER)
75 void menu_draw_text(mp_image_t* mpi, char* txt, int x, int y);
76 int menu_text_length(char* txt);
77 int menu_text_num_lines(char* txt, int max_width);
79 void menu_text_size(char* txt,int max_width,
80 int vspace, int warp,
81 int* _w, int* _h);
83 void menu_draw_text_full(mp_image_t* mpi,char* txt,
84 int x, int y,int w, int h,
85 int vspace, int warp, int align, int anchor);
87 void menu_draw_box(mp_image_t* mpi, unsigned char grey, unsigned char alpha, int x, int y, int w, int h);