Mercurial > mplayer.hg
annotate Gui/mplayer/common.c @ 22492:b5da5f794b35
Merge clean and dirclean targets.
author | diego |
---|---|
date | Sun, 11 Mar 2007 16:07:36 +0000 |
parents | a7e5b99ac083 |
children | 8c2056711a2a |
rev | line source |
---|---|
8973 | 1 |
2 // main window | |
3 | |
4 #include <stdlib.h> | |
5 #include <stdio.h> | |
6 #include <inttypes.h> | |
7 #include <sys/stat.h> | |
8 #include <unistd.h> | |
9 | |
17144 | 10 #include "app.h" |
11 #include "skin/font.h" | |
12 #include "skin/skin.h" | |
13 #include "wm/ws.h" | |
8973 | 14 |
17144 | 15 #include "../config.h" |
16 #include "../help_mp.h" | |
17 #include "../libvo/x11_common.h" | |
18 #include "../libvo/fastmemcpy.h" | |
8973 | 19 |
19271
64d82a45a05d
introduce new 'stream' directory for all stream layer related components and split them from libmpdemux
ben
parents:
18976
diff
changeset
|
20 #include "../stream/stream.h" |
17144 | 21 #include "../mixer.h" |
22 #include "../libvo/sub.h" | |
23 #include "../mplayer.h" | |
8973 | 24 |
17144 | 25 #include "../libmpdemux/demuxer.h" |
26 #include "../libmpdemux/stheader.h" | |
27 #include "../codec-cfg.h" | |
8973 | 28 |
29 | |
30 #include "play.h" | |
31 #include "widgets.h" | |
32 | |
33 extern unsigned int GetTimerMS( void ); | |
34 | |
12646 | 35 inline void TranslateFilename( int c,char * tmp,size_t tmplen ) |
8973 | 36 { |
37 int i; | |
12646 | 38 char * p; |
39 | |
8973 | 40 switch ( guiIntfStruct.StreamType ) |
41 { | |
42 case STREAMTYPE_STREAM: | |
12646 | 43 strlcpy(tmp, guiIntfStruct.Filename, tmplen); |
8973 | 44 break; |
45 case STREAMTYPE_FILE: | |
46 if ( ( guiIntfStruct.Filename )&&( guiIntfStruct.Filename[0] ) ) | |
47 { | |
13181 | 48 if ( (p = strrchr(guiIntfStruct.Filename, '/')) ) |
12646 | 49 strlcpy(tmp, p + 1, tmplen); |
50 else | |
51 strlcpy(tmp, guiIntfStruct.Filename, tmplen); | |
8973 | 52 if ( tmp[strlen( tmp ) - 4] == '.' ) tmp[strlen( tmp ) - 4]=0; |
53 if ( tmp[strlen( tmp ) - 5] == '.' ) tmp[strlen( tmp ) - 5]=0; | |
12646 | 54 } else strlcpy( tmp,MSGTR_NoFileLoaded,tmplen ); |
8973 | 55 break; |
56 #ifdef USE_DVDREAD | |
57 case STREAMTYPE_DVD: | |
12646 | 58 if ( guiIntfStruct.DVD.current_chapter ) snprintf(tmp,tmplen,MSGTR_Chapter,guiIntfStruct.DVD.current_chapter ); |
59 else strlcat( tmp,MSGTR_NoChapter,tmplen ); | |
8973 | 60 break; |
61 #endif | |
62 #ifdef HAVE_VCD | |
63 case STREAMTYPE_VCD: | |
12646 | 64 snprintf( tmp,tmplen,MSGTR_VCDTrack,guiIntfStruct.Track ); |
8973 | 65 break; |
66 #endif | |
12646 | 67 default: strlcpy( tmp,MSGTR_NoMediaOpened,tmplen ); |
8973 | 68 } |
69 if ( c ) | |
70 { | |
71 for ( i=0;i < (int)strlen( tmp );i++ ) | |
72 { | |
73 int t=0; | |
74 if ( c == 1 ) { if ( ( tmp[i] >= 'A' )&&( tmp[i] <= 'Z' ) ) t=32; } | |
75 if ( c == 2 ) { if ( ( tmp[i] >= 'a' )&&( tmp[i] <= 'z' ) ) t=-32; } | |
76 tmp[i]=(char)( tmp[i] + t ); | |
77 } | |
78 } | |
79 } | |
80 | |
12646 | 81 /* Unsafe! Pass only null-terminated strings as (char *)str. */ |
8973 | 82 char * Translate( char * str ) |
83 { | |
22286 | 84 mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); |
8973 | 85 static char trbuf[512]; |
86 char tmp[512]; | |
87 int i,c; | |
88 int t; | |
12646 | 89 int strsize = 0; |
8973 | 90 memset( trbuf,0,512 ); |
91 memset( tmp,0,128 ); | |
12646 | 92 strsize = strlen(str); |
93 for ( c=0,i=0;i < strsize;i++ ) | |
8973 | 94 { |
95 if ( str[i] != '$' ) { trbuf[c++]=str[i]; trbuf[c]=0; } | |
96 else | |
97 { | |
98 switch ( str[++i] ) | |
99 { | |
12646 | 100 case 't': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.Track ); |
101 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
102 case 'o': TranslateFilename( 0,tmp,sizeof( tmp ) ); | |
103 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
104 case 'f': TranslateFilename( 1,tmp,sizeof( tmp ) ); | |
105 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
106 case 'F': TranslateFilename( 2,tmp,sizeof( tmp ) ); | |
107 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
8973 | 108 case '6': t=guiIntfStruct.LengthInSec; goto calclengthhhmmss; |
109 case '1': t=guiIntfStruct.TimeSec; | |
110 calclengthhhmmss: | |
12646 | 111 snprintf( tmp,sizeof( tmp ),"%02d:%02d:%02d",t/3600,t/60%60,t%60 ); |
112 strlcat( trbuf,tmp,sizeof( trbuf ) ); | |
8973 | 113 break; |
114 case '7': t=guiIntfStruct.LengthInSec; goto calclengthmmmmss; | |
115 case '2': t=guiIntfStruct.TimeSec; | |
116 calclengthmmmmss: | |
12646 | 117 snprintf( tmp,sizeof( tmp ),"%04d:%02d",t/60,t%60 ); |
118 strlcat( trbuf,tmp,sizeof( trbuf ) ); | |
8973 | 119 break; |
12646 | 120 case '3': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec / 3600 ); |
121 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
122 case '4': snprintf( tmp,sizeof( tmp ),"%02d",( ( guiIntfStruct.TimeSec / 60 ) % 60 ) ); | |
123 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
124 case '5': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec % 60 ); | |
125 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
126 case '8': snprintf( tmp,sizeof( tmp ),"%01d:%02d:%02d",guiIntfStruct.TimeSec / 3600,( guiIntfStruct.TimeSec / 60 ) % 60,guiIntfStruct.TimeSec % 60 ); strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
127 case 'v': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Volume ); | |
128 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
129 case 'V': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Volume ); | |
130 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
131 case 'b': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Balance ); | |
132 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
133 case 'B': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Balance ); | |
134 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
135 case 'd': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.FrameDrop ); | |
136 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
137 case 'x': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieWidth ); | |
138 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
139 case 'y': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieHeight ); | |
140 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
141 case 'C': snprintf( tmp,sizeof( tmp ),"%s", guiIntfStruct.sh_video? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : ""); | |
142 strlcat( trbuf,tmp,sizeof( trbuf ) ); break; | |
143 case 's': if ( guiIntfStruct.Playing == 0 ) strlcat( trbuf,"s",sizeof( trbuf ) ); break; | |
144 case 'l': if ( guiIntfStruct.Playing == 1 ) strlcat( trbuf,"p",sizeof( trbuf ) ); break; | |
145 case 'e': if ( guiIntfStruct.Playing == 2 ) strlcat( trbuf,"e",sizeof( trbuf ) ); break; | |
8973 | 146 case 'a': |
22286 | 147 if ( mixer->muted ) { strlcat( trbuf,"n",sizeof( trbuf ) ); break; } |
8973 | 148 switch ( guiIntfStruct.AudioType ) |
149 { | |
12646 | 150 case 0: strlcat( trbuf,"n",sizeof( trbuf ) ); break; |
151 case 1: strlcat( trbuf,"m",sizeof( trbuf ) ); break; | |
152 case 2: strlcat( trbuf,"t",sizeof( trbuf ) ); break; | |
8973 | 153 } |
154 break; | |
155 case 'T': | |
156 switch ( guiIntfStruct.StreamType ) | |
157 { | |
12646 | 158 case STREAMTYPE_FILE: strlcat( trbuf,"f",sizeof( trbuf ) ); break; |
8973 | 159 #ifdef HAVE_VCD |
12646 | 160 case STREAMTYPE_VCD: strlcat( trbuf,"v",sizeof( trbuf ) ); break; |
8973 | 161 #endif |
12646 | 162 case STREAMTYPE_STREAM: strlcat( trbuf,"u",sizeof( trbuf ) ); break; |
8973 | 163 #ifdef USE_DVDREAD |
12646 | 164 case STREAMTYPE_DVD: strlcat( trbuf,"d",sizeof( trbuf ) ); break; |
8973 | 165 #endif |
12646 | 166 default: strlcat( trbuf," ",sizeof( trbuf ) ); break; |
8973 | 167 } |
168 break; | |
12646 | 169 case '$': strlcat( trbuf,"$",sizeof( trbuf ) ); break; |
8973 | 170 default: continue; |
171 } | |
172 c=strlen( trbuf ); | |
173 } | |
174 } | |
175 return trbuf; | |
176 } | |
177 | |
178 static char * image_buffer = NULL; | |
179 static int image_width = 0; | |
180 | |
181 void PutImage( txSample * bf,int x,int y,int max,int ofs ) | |
182 { | |
183 int i=0,ix,iy; | |
184 uint32_t * buf = NULL; | |
185 uint32_t * drw = NULL; | |
186 register uint32_t tmp; | |
187 register uint32_t yc; | |
188 | |
189 if ( ( !bf )||( bf->Image == NULL ) ) return; | |
190 | |
191 i=( bf->Width * ( bf->Height / max ) ) * ofs; | |
192 buf=(uint32_t *)image_buffer; | |
193 drw=(uint32_t *)bf->Image; | |
194 | |
9191 | 195 #if 1 |
8973 | 196 for ( iy=y;iy < (int)(y+bf->Height / max);iy++ ) |
197 for ( ix=x;ix < (int)(x+bf->Width);ix++ ) | |
198 { | |
199 tmp=drw[i++]; | |
200 if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp; | |
201 } | |
202 #else | |
203 yc=y * image_width; | |
204 for ( iy=y;iy < (int)(y+bf->Height / max);iy++ ) | |
205 { | |
206 for ( ix=x;ix < (int)(x+bf->Width);ix++ ) | |
207 { | |
208 tmp=drw[i++]; | |
209 if ( tmp != 0x00ff00ff ) buf[yc + ix]=tmp; | |
210 } | |
211 yc+=image_width; | |
212 } | |
213 #endif | |
214 } | |
215 | |
12693
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
216 void SimplePotmeterPutImage( txSample * bf,int x,int y,float frac ) |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
217 { |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
218 int i=0,w,r,ix,iy; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
219 uint32_t * buf = NULL; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
220 uint32_t * drw = NULL; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
221 register uint32_t tmp; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
222 |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
223 if ( ( !bf )||( bf->Image == NULL ) ) return; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
224 |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
225 buf=(uint32_t *)image_buffer; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
226 drw=(uint32_t *)bf->Image; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
227 w=bf->Width*frac; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
228 r=bf->Width-w; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
229 for ( iy=y;iy < (int)(y+bf->Height);iy++ ) |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
230 { |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
231 for ( ix=x;ix < (int)(x+w);ix++ ) |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
232 { |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
233 tmp=drw[i++]; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
234 if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
235 } |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
236 i+=r; |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
237 } |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
238 } |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
239 |
8973 | 240 void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size ) |
241 { | |
242 wItem * item; | |
243 txSample * image = NULL; | |
18976
6a08d0dabca8
Remove unused variables, patch by Stefan Huehner, stefan ##at## huehner org.
diego
parents:
17254
diff
changeset
|
244 int i; |
8973 | 245 |
246 image_buffer=db; | |
247 image_width=window->Width; | |
248 | |
249 for( i=0;i < nrItems + 1;i++ ) | |
250 { | |
251 item=&Items[i]; | |
252 switch( item->type ) | |
253 { | |
254 case itButton: | |
255 PutImage( &item->Bitmap,item->x,item->y,3,item->pressed ); | |
256 break; | |
257 case itPotmeter: | |
12693
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
258 if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f ); |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
259 else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) ); |
8973 | 260 break; |
261 case itHPotmeter: | |
12693
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
262 if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f ); |
eb996ecdfcd5
simple, smooth, ram-saving dynamic potmeter, which feature is required by the tvisor skin, patch by Andre Kuhne
alex
parents:
12691
diff
changeset
|
263 else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) ); |
8973 | 264 PutImage( &item->Mask,item->x + (int)( ( item->width - item->psx ) * item->value / 100.0f ),item->y,3,item->pressed ); |
265 break; | |
266 case itVPotmeter: | |
267 PutImage( &item->Bitmap, | |
268 item->x,item->y, | |
269 item->phases, | |
17254 | 270 item->phases * ( 1. - item->value / 100.0f ) ); |
8973 | 271 PutImage( &item->Mask, |
17254 | 272 item->x,item->y + (int)( ( item->height - item->psy ) * ( 1. - item->value / 100.0f ) ), |
8973 | 273 3,item->pressed ); |
274 break; | |
275 case itSLabel: | |
276 image=fntRender( item,0,"%s",item->label ); | |
277 if ( image ) PutImage( image,item->x,item->y,1,0 ); | |
278 case itDLabel: | |
279 { | |
280 char * t = Translate( item->label ); | |
281 int l = fntTextWidth( item->fontid,t ); | |
12685
b4587790a399
scroll strings from the left to right, patch by Andre Kuhne
alex
parents:
12646
diff
changeset
|
282 l=(l?l:item->width); |
b4587790a399
scroll strings from the left to right, patch by Andre Kuhne
alex
parents:
12646
diff
changeset
|
283 image=fntRender( item,l-(GetTimerMS() / 20)%l,"%s",t ); |
8973 | 284 } |
285 if ( image ) PutImage( image,item->x,item->y,1,0 ); | |
286 break; | |
287 } | |
288 } | |
289 wsConvert( window,db,size ); | |
290 } |