annotate Gui/mplayer/common.c @ 15334:bdf8d3a18cdd

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