annotate Gui/mplayer/common.c @ 22478:3501ae650b23

Add alternative way to create command.c to svn history, created by Rathann. Having this in the repository history probably won't have much more than symbolic value but shouldn't hurt either beyond bloating history size.
author uau
date Fri, 09 Mar 2007 12:30:14 +0000
parents a7e5b99ac083
children 8c2056711a2a
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
17144
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
10 #include "app.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
11 #include "skin/font.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
12 #include "skin/skin.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
13 #include "wm/ws.h"
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
14
17144
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
15 #include "../config.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
16 #include "../help_mp.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
17 #include "../libvo/x11_common.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
18 #include "../libvo/fastmemcpy.h"
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
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
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
21 #include "../mixer.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
22 #include "../libvo/sub.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
23 #include "../mplayer.h"
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
24
17144
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
25 #include "../libmpdemux/demuxer.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
26 #include "../libmpdemux/stheader.h"
0e1471d9da74 Unify include paths, -I.. is in CFLAGS.
diego
parents: 13181
diff changeset
27 #include "../codec-cfg.h"
8973
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
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
33 extern unsigned int GetTimerMS( void );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
34
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
35 inline void TranslateFilename( int c,char * tmp,size_t tmplen )
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
36 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
37 int i;
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
38 char * p;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
39
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
40 switch ( guiIntfStruct.StreamType )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
41 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
42 case STREAMTYPE_STREAM:
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
43 strlcpy(tmp, guiIntfStruct.Filename, tmplen);
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
44 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
45 case STREAMTYPE_FILE:
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
46 if ( ( guiIntfStruct.Filename )&&( guiIntfStruct.Filename[0] ) )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
47 {
13181
12176045ccf9 small gcc warning fix
rathann
parents: 12693
diff changeset
48 if ( (p = strrchr(guiIntfStruct.Filename, '/')) )
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
49 strlcpy(tmp, p + 1, tmplen);
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
50 else
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
51 strlcpy(tmp, guiIntfStruct.Filename, tmplen);
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
52 if ( tmp[strlen( tmp ) - 4] == '.' ) tmp[strlen( tmp ) - 4]=0;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
53 if ( tmp[strlen( tmp ) - 5] == '.' ) tmp[strlen( tmp ) - 5]=0;
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
54 } else strlcpy( tmp,MSGTR_NoFileLoaded,tmplen );
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
55 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
56 #ifdef USE_DVDREAD
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
57 case STREAMTYPE_DVD:
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
58 if ( guiIntfStruct.DVD.current_chapter ) snprintf(tmp,tmplen,MSGTR_Chapter,guiIntfStruct.DVD.current_chapter );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
59 else strlcat( tmp,MSGTR_NoChapter,tmplen );
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
60 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
61 #endif
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
62 #ifdef HAVE_VCD
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
63 case STREAMTYPE_VCD:
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
64 snprintf( tmp,tmplen,MSGTR_VCDTrack,guiIntfStruct.Track );
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
65 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
66 #endif
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
67 default: strlcpy( tmp,MSGTR_NoMediaOpened,tmplen );
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
68 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
69 if ( c )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
70 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
71 for ( i=0;i < (int)strlen( tmp );i++ )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
72 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
73 int t=0;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
74 if ( c == 1 ) { if ( ( tmp[i] >= 'A' )&&( tmp[i] <= 'Z' ) ) t=32; }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
75 if ( c == 2 ) { if ( ( tmp[i] >= 'a' )&&( tmp[i] <= 'z' ) ) t=-32; }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
76 tmp[i]=(char)( tmp[i] + t );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
77 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
78 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
79 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
80
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
81 /* Unsafe! Pass only null-terminated strings as (char *)str. */
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
82 char * Translate( char * str )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
83 {
22286
a7e5b99ac083 Fix GUI compilation
uau
parents: 19271
diff changeset
84 mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext);
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
85 static char trbuf[512];
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
86 char tmp[512];
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
87 int i,c;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
88 int t;
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
89 int strsize = 0;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
90 memset( trbuf,0,512 );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
91 memset( tmp,0,128 );
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
92 strsize = strlen(str);
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
93 for ( c=0,i=0;i < strsize;i++ )
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
94 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
95 if ( str[i] != '$' ) { trbuf[c++]=str[i]; trbuf[c]=0; }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
96 else
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
97 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
98 switch ( str[++i] )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
99 {
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
100 case 't': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.Track );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
101 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
102 case 'o': TranslateFilename( 0,tmp,sizeof( tmp ) );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
103 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
104 case 'f': TranslateFilename( 1,tmp,sizeof( tmp ) );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
105 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
106 case 'F': TranslateFilename( 2,tmp,sizeof( tmp ) );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
107 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
108 case '6': t=guiIntfStruct.LengthInSec; goto calclengthhhmmss;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
109 case '1': t=guiIntfStruct.TimeSec;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
110 calclengthhhmmss:
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
111 snprintf( tmp,sizeof( tmp ),"%02d:%02d:%02d",t/3600,t/60%60,t%60 );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
112 strlcat( trbuf,tmp,sizeof( trbuf ) );
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
113 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
114 case '7': t=guiIntfStruct.LengthInSec; goto calclengthmmmmss;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
115 case '2': t=guiIntfStruct.TimeSec;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
116 calclengthmmmmss:
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
117 snprintf( tmp,sizeof( tmp ),"%04d:%02d",t/60,t%60 );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
118 strlcat( trbuf,tmp,sizeof( trbuf ) );
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
119 break;
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
120 case '3': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec / 3600 );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
121 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
122 case '4': snprintf( tmp,sizeof( tmp ),"%02d",( ( guiIntfStruct.TimeSec / 60 ) % 60 ) );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
123 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
124 case '5': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec % 60 );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
125 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
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;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
127 case 'v': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Volume );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
128 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
129 case 'V': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Volume );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
130 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
131 case 'b': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Balance );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
132 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
133 case 'B': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Balance );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
134 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
135 case 'd': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.FrameDrop );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
136 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
137 case 'x': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieWidth );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
138 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
139 case 'y': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieHeight );
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
140 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
141 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
142 strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
143 case 's': if ( guiIntfStruct.Playing == 0 ) strlcat( trbuf,"s",sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
144 case 'l': if ( guiIntfStruct.Playing == 1 ) strlcat( trbuf,"p",sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
145 case 'e': if ( guiIntfStruct.Playing == 2 ) strlcat( trbuf,"e",sizeof( trbuf ) ); break;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
146 case 'a':
22286
a7e5b99ac083 Fix GUI compilation
uau
parents: 19271
diff changeset
147 if ( mixer->muted ) { strlcat( trbuf,"n",sizeof( trbuf ) ); break; }
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
148 switch ( guiIntfStruct.AudioType )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
149 {
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
150 case 0: strlcat( trbuf,"n",sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
151 case 1: strlcat( trbuf,"m",sizeof( trbuf ) ); break;
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
152 case 2: strlcat( trbuf,"t",sizeof( trbuf ) ); break;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
153 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
154 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
155 case 'T':
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
156 switch ( guiIntfStruct.StreamType )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
157 {
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
158 case STREAMTYPE_FILE: strlcat( trbuf,"f",sizeof( trbuf ) ); break;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
159 #ifdef HAVE_VCD
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
160 case STREAMTYPE_VCD: strlcat( trbuf,"v",sizeof( trbuf ) ); break;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
161 #endif
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
162 case STREAMTYPE_STREAM: strlcat( trbuf,"u",sizeof( trbuf ) ); break;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
163 #ifdef USE_DVDREAD
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
164 case STREAMTYPE_DVD: strlcat( trbuf,"d",sizeof( trbuf ) ); break;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
165 #endif
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
166 default: strlcat( trbuf," ",sizeof( trbuf ) ); break;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
167 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
168 break;
12646
9a495bdc3a1e string handling security fixes
diego
parents: 12522
diff changeset
169 case '$': strlcat( trbuf,"$",sizeof( trbuf ) ); break;
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
170 default: continue;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
171 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
172 c=strlen( trbuf );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
173 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
174 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
175 return trbuf;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
176 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
177
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
178 static char * image_buffer = NULL;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
179 static int image_width = 0;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
180
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
181 void PutImage( txSample * bf,int x,int y,int max,int ofs )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
182 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
183 int i=0,ix,iy;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
184 uint32_t * buf = NULL;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
185 uint32_t * drw = NULL;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
186 register uint32_t tmp;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
187 register uint32_t yc;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
188
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
189 if ( ( !bf )||( bf->Image == NULL ) ) return;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
190
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
191 i=( bf->Width * ( bf->Height / max ) ) * ofs;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
192 buf=(uint32_t *)image_buffer;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
193 drw=(uint32_t *)bf->Image;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
194
9191
21920dfcc37c workaround one possible sig11
pontscho
parents: 8973
diff changeset
195 #if 1
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
196 for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
197 for ( ix=x;ix < (int)(x+bf->Width);ix++ )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
198 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
199 tmp=drw[i++];
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
200 if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
201 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
202 #else
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
203 yc=y * image_width;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
204 for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
205 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
206 for ( ix=x;ix < (int)(x+bf->Width);ix++ )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
207 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
208 tmp=drw[i++];
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
209 if ( tmp != 0x00ff00ff ) buf[yc + ix]=tmp;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
210 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
211 yc+=image_width;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
212 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
213 #endif
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
214 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
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
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
240 void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
241 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
242 wItem * item;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
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
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
245
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
246 image_buffer=db;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
247 image_width=window->Width;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
248
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
249 for( i=0;i < nrItems + 1;i++ )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
250 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
251 item=&Items[i];
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
252 switch( item->type )
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
253 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
254 case itButton:
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
255 PutImage( &item->Bitmap,item->x,item->y,3,item->pressed );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
256 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
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
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
260 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
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
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
264 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
265 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
266 case itVPotmeter:
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
267 PutImage( &item->Bitmap,
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
268 item->x,item->y,
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
269 item->phases,
17254
0e152834911a vpotmeter fix, scroll in the correct direction
ods15
parents: 17144
diff changeset
270 item->phases * ( 1. - item->value / 100.0f ) );
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
271 PutImage( &item->Mask,
17254
0e152834911a vpotmeter fix, scroll in the correct direction
ods15
parents: 17144
diff changeset
272 item->x,item->y + (int)( ( item->height - item->psy ) * ( 1. - item->value / 100.0f ) ),
8973
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
273 3,item->pressed );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
274 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
275 case itSLabel:
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
276 image=fntRender( item,0,"%s",item->label );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
277 if ( image ) PutImage( image,item->x,item->y,1,0 );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
278 case itDLabel:
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
279 {
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
280 char * t = Translate( item->label );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
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
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
284 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
285 if ( image ) PutImage( image,item->x,item->y,1,0 );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
286 break;
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
287 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
288 }
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
289 wsConvert( window,db,size );
0a665389cf2b - add playbar
pontscho
parents:
diff changeset
290 }