Remove unnecessary CLEANFILES declaration. Test programs do not require it.
[mplayer/glamo.git] / libmenu / menu.h
blob09359dd1d69d143713cba028f28073ae72464f26
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"
25 struct menu_priv_s;
26 typedef struct menu_s menu_t;
28 typedef struct menu_def_st menu_def_t;
30 struct m_struct_st;
32 struct menu_s {
33 struct MPContext *ctx;
34 void (*draw)(menu_t* menu,mp_image_t* mpi);
35 void (*read_cmd)(menu_t* menu,int cmd);
36 int (*read_key)(menu_t* menu,int cmd);
37 void (*close)(menu_t* menu);
38 struct m_struct_st* priv_st;
39 struct menu_priv_s* priv;
40 int show; // Draw it ?
41 int cl; // Close request (user sent a close cmd or
42 menu_t* parent;
43 menu_def_t *type;
46 typedef struct menu_info_s {
47 const char *info;
48 const char *name;
49 const char *author;
50 const char *comment;
51 struct m_struct_st priv_st; // Config struct definition
52 // cfg is a config struct as defined in cfg_st, it may be used as a priv struct
53 // cfg is filled from the attributs found in the cfg file
54 // the args param hold the content of the balise in the cfg file (if any)
55 int (*open)(menu_t* menu, char* args);
56 } menu_info_t;
59 #define MENU_CMD_UP 0
60 #define MENU_CMD_DOWN 1
61 #define MENU_CMD_OK 2
62 #define MENU_CMD_CANCEL 3
63 #define MENU_CMD_LEFT 4
64 #define MENU_CMD_RIGHT 5
65 #define MENU_CMD_ACTION 6
66 #define MENU_CMD_HOME 7
67 #define MENU_CMD_END 8
68 #define MENU_CMD_PAGE_UP 9
69 #define MENU_CMD_PAGE_DOWN 10
70 #define MENU_CMD_CLICK 11
72 /// Global init/uninit
73 int menu_init(struct MPContext *mpctx, char* cfg_file);
74 void menu_uninit(void);
76 /// Open a menu defined in the config file
77 menu_t* menu_open(char *name);
79 void menu_draw(menu_t* menu,mp_image_t* mpi);
80 void menu_read_cmd(menu_t* menu,int cmd);
81 void menu_close(menu_t* menu);
82 int menu_read_key(menu_t* menu,int cmd);
84 //// Default implementation
85 int menu_dflt_read_key(menu_t* menu,int cmd);
87 /// Receive mouse position events.
88 void menu_update_mouse_pos(double x, double y);
90 /////////// Helpers
92 #define MENU_TEXT_TOP (1<<0)
93 #define MENU_TEXT_VCENTER (1<<1)
94 #define MENU_TEXT_BOT (1<<2)
95 #define MENU_TEXT_VMASK (MENU_TEXT_TOP|MENU_TEXT_VCENTER|MENU_TEXT_BOT)
96 #define MENU_TEXT_LEFT (1<<3)
97 #define MENU_TEXT_HCENTER (1<<4)
98 #define MENU_TEXT_RIGHT (1<<5)
99 #define MENU_TEXT_HMASK (MENU_TEXT_LEFT|MENU_TEXT_HCENTER|MENU_TEXT_RIGHT)
100 #define MENU_TEXT_CENTER (MENU_TEXT_VCENTER|MENU_TEXT_HCENTER)
102 void menu_draw_text(mp_image_t* mpi, char* txt, int x, int y);
103 int menu_text_length(char* txt);
104 int menu_text_num_lines(char* txt, int max_width);
106 void menu_text_size(char* txt,int max_width,
107 int vspace, int warp,
108 int* _w, int* _h);
110 void menu_draw_text_full(mp_image_t* mpi,char* txt,
111 int x, int y,int w, int h,
112 int vspace, int warp, int align, int anchor);
114 void menu_draw_box(mp_image_t* mpi, unsigned char grey, unsigned char alpha, int x, int y, int w, int h);
116 #endif /* MPLAYER_MENU_H */