annotate gui/mplayer/common.c @ 23077:17bf4f4b0715

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