sync with en/mplayer.1 rev. 30611
[mplayer/glamo.git] / libmenu / menu.h
bloba22dc12abf50926f53f2f61e3140b45e964220a9
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_MENU_H
20 #define MPLAYER_MENU_H
22 #include "m_struct.h"
23 #include "libmpcodecs/mp_image.h"
24 #include "libmpcodecs/vf.h"
26 struct menu_priv_s;
27 typedef struct menu_s menu_t;
29 typedef struct menu_def_st menu_def_t;
31 struct m_struct_st;
33 struct menu_s {
34 struct MPContext *ctx;
35 void (*draw)(menu_t* menu,mp_image_t* mpi);
36 void (*read_cmd)(menu_t* menu,int cmd);
37 int (*read_key)(menu_t* menu,int cmd);
38 void (*close)(menu_t* menu);
39 struct m_struct_st* priv_st;
40 struct menu_priv_s* priv;
41 int show; // Draw it ?
42 int cl; // Close request (user sent a close cmd or
43 menu_t* parent;
44 menu_def_t *type;
47 typedef struct menu_info_s {
48 const char *info;
49 const char *name;
50 const char *author;
51 const char *comment;
52 struct m_struct_st priv_st; // Config struct definition
53 // cfg is a config struct as defined in cfg_st, it may be used as a priv struct
54 // cfg is filled from the attributs found in the cfg file
55 // the args param hold the content of the balise in the cfg file (if any)
56 int (*open)(menu_t* menu, char* args);
57 } menu_info_t;
60 #define MENU_CMD_UP 0
61 #define MENU_CMD_DOWN 1
62 #define MENU_CMD_OK 2
63 #define MENU_CMD_CANCEL 3
64 #define MENU_CMD_LEFT 4
65 #define MENU_CMD_RIGHT 5
66 #define MENU_CMD_ACTION 6
67 #define MENU_CMD_HOME 7
68 #define MENU_CMD_END 8
69 #define MENU_CMD_PAGE_UP 9
70 #define MENU_CMD_PAGE_DOWN 10
71 #define MENU_CMD_CLICK 11
73 /// Global init/uninit
74 int menu_init(struct MPContext *mpctx, char* cfg_file);
75 void menu_uninit(void);
77 /// Open a menu defined in the config file
78 menu_t* menu_open(char *name);
80 void menu_draw(menu_t* menu,mp_image_t* mpi);
81 void menu_read_cmd(menu_t* menu,int cmd);
82 void menu_close(menu_t* menu);
83 int menu_read_key(menu_t* menu,int cmd);
85 //// Default implementation
86 int menu_dflt_read_key(menu_t* menu,int cmd);
88 /// Receive mouse position events.
89 void menu_update_mouse_pos(double x, double y);
91 /////////// Helpers
93 #define MENU_TEXT_TOP (1<<0)
94 #define MENU_TEXT_VCENTER (1<<1)
95 #define MENU_TEXT_BOT (1<<2)
96 #define MENU_TEXT_VMASK (MENU_TEXT_TOP|MENU_TEXT_VCENTER|MENU_TEXT_BOT)
97 #define MENU_TEXT_LEFT (1<<3)
98 #define MENU_TEXT_HCENTER (1<<4)
99 #define MENU_TEXT_RIGHT (1<<5)
100 #define MENU_TEXT_HMASK (MENU_TEXT_LEFT|MENU_TEXT_HCENTER|MENU_TEXT_RIGHT)
101 #define MENU_TEXT_CENTER (MENU_TEXT_VCENTER|MENU_TEXT_HCENTER)
103 void menu_draw_text(mp_image_t* mpi, char* txt, int x, int y);
104 int menu_text_length(char* txt);
105 int menu_text_num_lines(char* txt, int max_width);
107 void menu_text_size(char* txt,int max_width,
108 int vspace, int warp,
109 int* _w, int* _h);
111 void menu_draw_text_full(mp_image_t* mpi,char* txt,
112 int x, int y,int w, int h,
113 int vspace, int warp, int align, int anchor);
115 void menu_draw_box(mp_image_t* mpi, unsigned char grey, unsigned char alpha, int x, int y, int w, int h);
117 void vf_menu_pause_update(struct vf_instance_s* vf);
119 #endif /* MPLAYER_MENU_H */