annotate libmenu/vf_menu.c @ 15318:f03d971abf30

synced with 1.74
author gabrov
date Sun, 01 May 2005 22:04:57 +0000
parents 39bdfbbc4216
children 931bdbc37ee0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
1
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
2 #include "../config.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
3
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
4 #include <stdio.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
5 #include <stdlib.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
6 #include <string.h>
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
7
8623
440301fef3fe Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents: 8251
diff changeset
8 #ifdef HAVE_MALLOC_H
440301fef3fe Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents: 8251
diff changeset
9 #include <malloc.h>
440301fef3fe Added/reordered #includes to silence warnings about "implicit declaration".
rathann
parents: 8251
diff changeset
10 #endif
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
11
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
12 #include "../mp_msg.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
13
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
14 #include "../libmpcodecs/img_format.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
15 #include "../libmpcodecs/mp_image.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
16 #include "../libmpcodecs/vf.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
17
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
18 #include "../libvo/fastmemcpy.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
19 #include "../libvo/video_out.h"
8224
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
20 #include "../libvo/font_load.h"
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
21 #include "../input/input.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
22 #include "../m_struct.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
23 #include "menu.h"
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
24
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
25 extern vo_functions_t* video_out;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
26
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
27
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
28 static struct vf_priv_s* st_priv = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
29
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
30 static mp_image_t* pause_mpi = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
31 static int go2pause = 0;
13344
0d96af97ec00 option to display menu at startup, patch by Aurelien Jacobs <aurel at gnuage.org>
faust3
parents: 10397
diff changeset
32 /// if nonzero display menu at startup
13528
39bdfbbc4216 support newer gcc
faust3
parents: 13344
diff changeset
33 int attribute_used menu_startup = 0;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
34
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
35 struct vf_priv_s {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
36 menu_t* root;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
37 menu_t* current;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
38 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
39
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
40 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
41
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
42 static mp_image_t* alloc_mpi(int w, int h, uint32_t fmt) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
43 mp_image_t* mpi = new_mp_image(w,h);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
44
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
45 mp_image_setfmt(mpi,fmt);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
46 // IF09 - allocate space for 4. plane delta info - unused
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
47 if (mpi->imgfmt == IMGFMT_IF09)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
48 {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
49 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
50 mpi->chroma_width*mpi->chroma_height);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
51 /* delta table, just for fun ;) */
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
52 mpi->planes[3]=mpi->planes[0]+2*(mpi->chroma_width*mpi->chroma_height);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
53 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
54 else
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
55 mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
56 if(mpi->flags&MP_IMGFLAG_PLANAR){
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
57 // YV12/I420/YVU9/IF09. feel free to add other planar formats here...
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
58 if(!mpi->stride[0]) mpi->stride[0]=mpi->width;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
59 if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->chroma_width;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
60 if(mpi->flags&MP_IMGFLAG_SWAPPED){
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
61 // I420/IYUV (Y,U,V)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
62 mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
63 mpi->planes[2]=mpi->planes[1]+mpi->chroma_width*mpi->chroma_height;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
64 } else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
65 // YV12,YVU9,IF09 (Y,V,U)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
66 mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
67 mpi->planes[1]=mpi->planes[2]+mpi->chroma_width*mpi->chroma_height;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
68 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
69 } else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
70 if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
71 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
72 mpi->flags|=MP_IMGFLAG_ALLOCATED;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
73
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
74 return mpi;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
75 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
76
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
77 void vf_menu_pause_update(struct vf_instance_s* vf) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
78 if(pause_mpi) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
79 put_image(vf,pause_mpi);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
80 // Don't draw the osd atm
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
81 //vf->control(vf,VFCTRL_DRAW_OSD,NULL);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
82 video_out->flip_page();
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
83 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
84 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
85
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
86 static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
87
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
88 switch(cmd->id) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
89 case MP_CMD_PAUSE :
9903
7d70e56f317a 10l fix by Vladimir Mosgalin <mosgalin@VM10124.spb.edu>
alex
parents: 9755
diff changeset
90 #if 0 // http://mplayerhq.hu/pipermail/mplayer-dev-eng/2003-March/017331.html
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
91 if(!paused && !go2pause) { // Initial pause cmd -> wait the next put_image
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
92 go2pause = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
93 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
94 }
9903
7d70e56f317a 10l fix by Vladimir Mosgalin <mosgalin@VM10124.spb.edu>
alex
parents: 9755
diff changeset
95 #endif
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
96 if(go2pause == 2) // Msg resent by put_image after saving the image
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
97 go2pause = 0;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
98 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
99 case MP_CMD_MENU : { // Convert txt cmd from the users into libmenu stuff
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
100 char* arg = cmd->args[0].v.s;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
101
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
102 if(!priv->current->show)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
103 priv->current->show = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
104 else if(strcmp(arg,"up") == 0)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
105 menu_read_cmd(priv->current,MENU_CMD_UP);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
106 else if(strcmp(arg,"down") == 0)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
107 menu_read_cmd(priv->current,MENU_CMD_DOWN);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
108 else if(strcmp(arg,"ok") == 0)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
109 menu_read_cmd(priv->current,MENU_CMD_OK);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
110 else if(strcmp(arg,"cancel") == 0)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
111 menu_read_cmd(priv->current,MENU_CMD_CANCEL);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
112 else if(strcmp(arg,"hide") == 0)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
113 priv->current->show = 0;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
114 else
10397
6180d7558f75 output typo fixes: unknow --> unknown
diego
parents: 9903
diff changeset
115 printf("Unknown menu command: '%s'\n",arg);
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
116 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
117 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
118 case MP_CMD_SET_MENU : {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
119 char* menu = cmd->args[0].v.s;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
120 menu_t* l = priv->current;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
121 priv->current = menu_open(menu);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
122 if(!priv->current) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
123 printf("Failed to open menu '%s'\n",menu);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
124 priv->current = l;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
125 priv->current->show = 0;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
126 } else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
127 priv->current->show = 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
128 priv->current->parent = l;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
129 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
130 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
131 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
132 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
133 return 0;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
134 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
135
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
136 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
137 mp_image_t *dmpi;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
138
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
139 if(mpi->type == MP_IMGTYPE_TEMP && (!(mpi->flags&MP_IMGFLAG_PRESERVE)) ) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
140 dmpi = vf_get_image(vf->next,mpi->imgfmt,mpi->type, mpi->flags, mpi->w, mpi->h);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
141 memcpy(mpi->planes,dmpi->planes,MP_MAX_PLANES*sizeof(unsigned char*));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
142 memcpy(mpi->stride,dmpi->stride,MP_MAX_PLANES*sizeof(unsigned int));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
143 mpi->flags|=MP_IMGFLAG_DIRECT;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
144 mpi->priv=(void*)dmpi;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
145 return;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
146 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
147 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
148
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
149 static void key_cb(int code) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
150 menu_read_key(st_priv->current,code);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
151 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
152
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
153
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
154
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
155 inline static void copy_mpi(mp_image_t *dmpi, mp_image_t *mpi) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
156 if(mpi->flags&MP_IMGFLAG_PLANAR){
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
157 memcpy_pic(dmpi->planes[0],mpi->planes[0], mpi->w, mpi->h,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
158 dmpi->stride[0],mpi->stride[0]);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
159 memcpy_pic(dmpi->planes[1],mpi->planes[1], mpi->chroma_width, mpi->chroma_height,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
160 dmpi->stride[1],mpi->stride[1]);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
161 memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->chroma_width, mpi->chroma_height,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
162 dmpi->stride[2],mpi->stride[2]);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
163 } else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
164 memcpy_pic(dmpi->planes[0],mpi->planes[0],
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
165 mpi->w*(dmpi->bpp/8), mpi->h,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
166 dmpi->stride[0],mpi->stride[0]);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
167 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
168 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
169
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
170
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
171
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
172 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
173 mp_image_t *dmpi = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
174
8251
3d74366d947e better fix for my previous 10l
colin
parents: 8244
diff changeset
175 if(vf->priv->current->show
3d74366d947e better fix for my previous 10l
colin
parents: 8244
diff changeset
176 || (vf->priv->current->parent && vf->priv->current->parent->show)) {
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
177 // Close all menu who requested it
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
178 while(vf->priv->current->cl && vf->priv->current != vf->priv->root) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
179 menu_t* m = vf->priv->current;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
180 vf->priv->current = m->parent ? m->parent : vf->priv->root;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
181 menu_close(m);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
182 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
183
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
184 // Step 1 : save the picture
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
185 while(go2pause == 1) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
186 static char delay = 0; // Hack : wait the 2 frame to be sure to show the right picture
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
187 delay ^= 1; // after a seek
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
188 if(!delay) break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
189
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
190 if(pause_mpi && (mpi->w != pause_mpi->w || mpi->h != pause_mpi->h ||
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
191 mpi->imgfmt != pause_mpi->imgfmt)) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
192 free_mp_image(pause_mpi);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
193 pause_mpi = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
194 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
195 if(!pause_mpi)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
196 pause_mpi = alloc_mpi(mpi->w,mpi->h,mpi->imgfmt);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
197 copy_mpi(pause_mpi,mpi);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
198 mp_input_queue_cmd(mp_input_parse_cmd("pause"));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
199 go2pause = 2;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
200 break;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
201 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
202
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
203 // Grab // Ungrab the keys
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
204 if(!mp_input_key_cb && vf->priv->current->show)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
205 mp_input_key_cb = key_cb;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
206 if(mp_input_key_cb && !vf->priv->current->show)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
207 mp_input_key_cb = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
208
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
209 if(mpi->flags&MP_IMGFLAG_DIRECT)
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
210 dmpi = mpi->priv;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
211 else {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
212 dmpi = vf_get_image(vf->next,mpi->imgfmt,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
213 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
214 mpi->w,mpi->h);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
215 copy_mpi(dmpi,mpi);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
216 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
217 menu_draw(vf->priv->current,dmpi);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
218
8244
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
219 } else {
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
220 if(mp_input_key_cb)
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
221 mp_input_key_cb = NULL;
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
222 dmpi = vf_get_image(vf->next,mpi->imgfmt,
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
223 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
224 mpi->w,mpi->h);
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
225
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
226 dmpi->stride[0] = mpi->stride[0];
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
227 dmpi->stride[1] = mpi->stride[1];
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
228 dmpi->stride[2] = mpi->stride[2];
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
229 dmpi->planes[0] = mpi->planes[0];
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
230 dmpi->planes[1] = mpi->planes[1];
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
231 dmpi->planes[2] = mpi->planes[2];
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
232 dmpi->priv = mpi->priv;
64352fb332b6 don't fully-copy the planes if the menu doesn't show (faster)
colin
parents: 8224
diff changeset
233 }
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
234 return vf_next_put_image(vf,dmpi);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
235 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
236
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
237 static void uninit(vf_instance_t *vf) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
238 vf->priv=NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
239 if(pause_mpi) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
240 free_mp_image(pause_mpi);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
241 pause_mpi = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
242 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
243 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
244
8224
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
245 static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height,
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
246 unsigned int flags, unsigned int outfmt) {
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
247 #ifdef HAVE_FREETYPE
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
248 // here is the right place to get screen dimensions
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
249 if (force_load_font) {
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
250 force_load_font = 0;
8635
81dbd28ef7c0 these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents: 8623
diff changeset
251 load_font_ft(width,height);
8224
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
252 }
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
253 #endif
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
254 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
255 }
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
256 static int open(vf_instance_t *vf, char* args){
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
257 if(!st_priv) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
258 st_priv = calloc(1,sizeof(struct vf_priv_s));
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
259 st_priv->root = st_priv->current = menu_open(args);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
260 if(!st_priv->current) {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
261 free(st_priv);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
262 st_priv = NULL;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
263 return 0;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
264 }
13344
0d96af97ec00 option to display menu at startup, patch by Aurelien Jacobs <aurel at gnuage.org>
faust3
parents: 10397
diff changeset
265 st_priv->root->show = menu_startup;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
266 mp_input_add_cmd_filter((mp_input_cmd_filter)cmd_filter,st_priv);
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
267 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
268
8224
fefc56153615 Fix freetype. Freetype is highly recommended for a nice output ;)
albeu
parents: 8197
diff changeset
269 vf->config = config;
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
270 vf->put_image = put_image;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
271 vf->get_image = get_image;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
272 vf->uninit=uninit;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
273 vf->priv=st_priv;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
274 go2pause=0;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
275
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
276 return 1;
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
277 }
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
278
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
279
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
280 vf_info_t vf_info_menu = {
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
281 "Internal filter for libmenu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
282 "menu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
283 "Albeu",
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
284 "",
9755
6b7710f78c32 10L forgot this filter.
albeu
parents: 8635
diff changeset
285 open,
6b7710f78c32 10L forgot this filter.
albeu
parents: 8635
diff changeset
286 NULL
8197
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
287 };
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
288
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
289
b31caec933e9 OSD menus initial version
albeu
parents:
diff changeset
290