2008-12-13 19:40:19 +01:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2008-02-22 10:09:46 +01:00
|
|
|
#ifndef MPLAYER_MENU_H
|
|
|
|
#define MPLAYER_MENU_H
|
2002-11-15 00:47:11 +01:00
|
|
|
|
2008-03-05 09:24:59 +01:00
|
|
|
#include "m_struct.h"
|
|
|
|
#include "libmpcodecs/mp_image.h"
|
|
|
|
|
2010-09-08 20:21:49 +02:00
|
|
|
extern double menu_mouse_x;
|
|
|
|
extern double menu_mouse_y;
|
|
|
|
extern int menu_mouse_pos_updated;
|
2010-09-08 20:34:21 +02:00
|
|
|
extern const struct vf_info vf_info_menu;
|
2010-09-08 20:21:49 +02:00
|
|
|
|
2002-11-15 00:47:11 +01:00
|
|
|
struct menu_priv_s;
|
|
|
|
typedef struct menu_s menu_t;
|
|
|
|
|
2007-12-02 12:14:50 +01:00
|
|
|
typedef struct menu_def_st menu_def_t;
|
|
|
|
|
2007-12-18 05:07:48 +01:00
|
|
|
struct m_struct_st;
|
|
|
|
|
2002-11-15 00:47:11 +01:00
|
|
|
struct menu_s {
|
2007-02-21 19:28:48 +01:00
|
|
|
struct MPContext *ctx;
|
2008-04-26 09:44:59 +02:00
|
|
|
struct m_config *mconfig;
|
2008-04-30 12:00:59 +02:00
|
|
|
struct input_ctx *input_ctx;
|
2002-11-15 00:47:11 +01:00
|
|
|
void (*draw)(menu_t* menu,mp_image_t* mpi);
|
|
|
|
void (*read_cmd)(menu_t* menu,int cmd);
|
2007-12-26 14:13:48 +01:00
|
|
|
int (*read_key)(menu_t* menu,int cmd);
|
2002-11-15 00:47:11 +01:00
|
|
|
void (*close)(menu_t* menu);
|
2007-12-18 05:07:48 +01:00
|
|
|
struct m_struct_st* priv_st;
|
2002-11-15 00:47:11 +01:00
|
|
|
struct menu_priv_s* priv;
|
|
|
|
int show; // Draw it ?
|
|
|
|
int cl; // Close request (user sent a close cmd or
|
|
|
|
menu_t* parent;
|
2007-12-02 12:14:50 +01:00
|
|
|
menu_def_t *type;
|
2002-11-15 00:47:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct menu_info_s {
|
|
|
|
const char *info;
|
|
|
|
const char *name;
|
|
|
|
const char *author;
|
|
|
|
const char *comment;
|
2007-12-18 10:44:54 +01:00
|
|
|
struct m_struct_st priv_st; // Config struct definition
|
2002-11-15 00:47:11 +01:00
|
|
|
// cfg is a config struct as defined in cfg_st, it may be used as a priv struct
|
|
|
|
// cfg is filled from the attributs found in the cfg file
|
|
|
|
// the args param hold the content of the balise in the cfg file (if any)
|
|
|
|
int (*open)(menu_t* menu, char* args);
|
|
|
|
} menu_info_t;
|
|
|
|
|
|
|
|
|
|
|
|
#define MENU_CMD_UP 0
|
|
|
|
#define MENU_CMD_DOWN 1
|
|
|
|
#define MENU_CMD_OK 2
|
|
|
|
#define MENU_CMD_CANCEL 3
|
2006-03-25 18:32:10 +01:00
|
|
|
#define MENU_CMD_LEFT 4
|
2009-07-07 01:26:13 +02:00
|
|
|
#define MENU_CMD_RIGHT 5
|
2006-08-22 21:59:53 +02:00
|
|
|
#define MENU_CMD_ACTION 6
|
2007-12-04 11:42:59 +01:00
|
|
|
#define MENU_CMD_HOME 7
|
|
|
|
#define MENU_CMD_END 8
|
|
|
|
#define MENU_CMD_PAGE_UP 9
|
|
|
|
#define MENU_CMD_PAGE_DOWN 10
|
2007-12-22 07:14:38 +01:00
|
|
|
#define MENU_CMD_CLICK 11
|
2002-11-15 00:47:11 +01:00
|
|
|
|
|
|
|
/// Global init/uninit
|
2008-04-30 12:00:59 +02:00
|
|
|
int menu_init(struct MPContext *mpctx, struct m_config *mconfig,
|
|
|
|
struct input_ctx *input_ctx, char* cfg_file);
|
2007-12-18 11:45:43 +01:00
|
|
|
void menu_uninit(void);
|
2002-11-15 00:47:11 +01:00
|
|
|
|
|
|
|
/// Open a menu defined in the config file
|
|
|
|
menu_t* menu_open(char *name);
|
|
|
|
|
|
|
|
void menu_draw(menu_t* menu,mp_image_t* mpi);
|
|
|
|
void menu_read_cmd(menu_t* menu,int cmd);
|
|
|
|
void menu_close(menu_t* menu);
|
2007-12-26 14:13:48 +01:00
|
|
|
int menu_read_key(menu_t* menu,int cmd);
|
2002-11-15 00:47:11 +01:00
|
|
|
|
|
|
|
//// Default implementation
|
2007-12-04 11:42:59 +01:00
|
|
|
int menu_dflt_read_key(menu_t* menu,int cmd);
|
2002-11-15 00:47:11 +01:00
|
|
|
|
2007-12-22 07:14:38 +01:00
|
|
|
/// Receive mouse position events.
|
|
|
|
void menu_update_mouse_pos(double x, double y);
|
|
|
|
|
2002-11-15 00:47:11 +01:00
|
|
|
/////////// Helpers
|
|
|
|
|
|
|
|
#define MENU_TEXT_TOP (1<<0)
|
|
|
|
#define MENU_TEXT_VCENTER (1<<1)
|
|
|
|
#define MENU_TEXT_BOT (1<<2)
|
|
|
|
#define MENU_TEXT_VMASK (MENU_TEXT_TOP|MENU_TEXT_VCENTER|MENU_TEXT_BOT)
|
|
|
|
#define MENU_TEXT_LEFT (1<<3)
|
|
|
|
#define MENU_TEXT_HCENTER (1<<4)
|
|
|
|
#define MENU_TEXT_RIGHT (1<<5)
|
|
|
|
#define MENU_TEXT_HMASK (MENU_TEXT_LEFT|MENU_TEXT_HCENTER|MENU_TEXT_RIGHT)
|
|
|
|
#define MENU_TEXT_CENTER (MENU_TEXT_VCENTER|MENU_TEXT_HCENTER)
|
|
|
|
|
|
|
|
void menu_draw_text(mp_image_t* mpi, char* txt, int x, int y);
|
|
|
|
int menu_text_length(char* txt);
|
|
|
|
int menu_text_num_lines(char* txt, int max_width);
|
|
|
|
|
2009-07-07 01:26:13 +02:00
|
|
|
void menu_text_size(char* txt,int max_width,
|
2002-11-15 00:47:11 +01:00
|
|
|
int vspace, int warp,
|
|
|
|
int* _w, int* _h);
|
|
|
|
|
|
|
|
void menu_draw_text_full(mp_image_t* mpi,char* txt,
|
|
|
|
int x, int y,int w, int h,
|
|
|
|
int vspace, int warp, int align, int anchor);
|
2006-03-30 04:52:54 +02:00
|
|
|
|
2006-04-22 18:22:33 +02:00
|
|
|
void menu_draw_box(mp_image_t* mpi, unsigned char grey, unsigned char alpha, int x, int y, int w, int h);
|
2008-01-01 22:35:58 +01:00
|
|
|
|
2010-04-25 20:42:43 +02:00
|
|
|
struct vf_instance;
|
2010-03-09 22:37:00 +01:00
|
|
|
void vf_menu_pause_update(struct vf_instance *vf);
|
2010-02-14 15:54:48 +01:00
|
|
|
|
2008-02-22 10:09:46 +01:00
|
|
|
#endif /* MPLAYER_MENU_H */
|