commands: finish seeks before processing other commands
[mplayer/glamo.git] / libmenu / menu.h
blob185043f8c1b61c04bc472e8a39b2acc3e5b0c4af
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 struct m_config *mconfig;
35 struct input_ctx *input_ctx;
36 void (*draw)(menu_t* menu,mp_image_t* mpi);
37 void (*read_cmd)(menu_t* menu,int cmd);
38 int (*read_key)(menu_t* menu,int cmd);
39 void (*close)(menu_t* menu);
40 struct m_struct_st* priv_st;
41 struct menu_priv_s* priv;
42 int show; // Draw it ?
43 int cl; // Close request (user sent a close cmd or
44 menu_t* parent;
45 menu_def_t *type;
48 typedef struct menu_info_s {
49 const char *info;
50 const char *name;
51 const char *author;
52 const char *comment;
53 struct m_struct_st priv_st; // Config struct definition
54 // cfg is a config struct as defined in cfg_st, it may be used as a priv struct
55 // cfg is filled from the attributs found in the cfg file
56 // the args param hold the content of the balise in the cfg file (if any)
57 int (*open)(menu_t* menu, char* args);
58 } menu_info_t;
61 #define MENU_CMD_UP 0
62 #define MENU_CMD_DOWN 1
63 #define MENU_CMD_OK 2
64 #define MENU_CMD_CANCEL 3
65 #define MENU_CMD_LEFT 4
66 #define MENU_CMD_RIGHT 5
67 #define MENU_CMD_ACTION 6
68 #define MENU_CMD_HOME 7
69 #define MENU_CMD_END 8
70 #define MENU_CMD_PAGE_UP 9
71 #define MENU_CMD_PAGE_DOWN 10
72 #define MENU_CMD_CLICK 11
74 /// Global init/uninit
75 int menu_init(struct MPContext *mpctx, struct m_config *mconfig,
76 struct input_ctx *input_ctx, char* cfg_file);
77 void menu_uninit(void);
79 /// Open a menu defined in the config file
80 menu_t* menu_open(char *name);
82 void menu_draw(menu_t* menu,mp_image_t* mpi);
83 void menu_read_cmd(menu_t* menu,int cmd);
84 void menu_close(menu_t* menu);
85 int menu_read_key(menu_t* menu,int cmd);
87 //// Default implementation
88 int menu_dflt_read_key(menu_t* menu,int cmd);
90 /// Receive mouse position events.
91 void menu_update_mouse_pos(double x, double y);
93 /////////// Helpers
95 #define MENU_TEXT_TOP (1<<0)
96 #define MENU_TEXT_VCENTER (1<<1)
97 #define MENU_TEXT_BOT (1<<2)
98 #define MENU_TEXT_VMASK (MENU_TEXT_TOP|MENU_TEXT_VCENTER|MENU_TEXT_BOT)
99 #define MENU_TEXT_LEFT (1<<3)
100 #define MENU_TEXT_HCENTER (1<<4)
101 #define MENU_TEXT_RIGHT (1<<5)
102 #define MENU_TEXT_HMASK (MENU_TEXT_LEFT|MENU_TEXT_HCENTER|MENU_TEXT_RIGHT)
103 #define MENU_TEXT_CENTER (MENU_TEXT_VCENTER|MENU_TEXT_HCENTER)
105 void menu_draw_text(mp_image_t* mpi, char* txt, int x, int y);
106 int menu_text_length(char* txt);
107 int menu_text_num_lines(char* txt, int max_width);
109 void menu_text_size(char* txt,int max_width,
110 int vspace, int warp,
111 int* _w, int* _h);
113 void menu_draw_text_full(mp_image_t* mpi,char* txt,
114 int x, int y,int w, int h,
115 int vspace, int warp, int align, int anchor);
117 void menu_draw_box(mp_image_t* mpi, unsigned char grey, unsigned char alpha, int x, int y, int w, int h);
119 struct vf_instance;
120 void vf_menu_pause_update(struct vf_instance *vf);
122 #endif /* MPLAYER_MENU_H */