Mercurial > mplayer.hg
annotate gui/mplayer/gui_common.c @ 33197:17dba462c48c
Fix compilation with XvMC, only lightly tested.
author | reimar |
---|---|
date | Fri, 22 Apr 2011 07:28:44 +0000 |
parents | 5f3171d4d7a4 |
children | 49ca38147d1f |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
18 |
33123
9566100d88a1
Replace inttypes.h by stdint.h and remove inttypes.h where unneeded.
ib
parents:
32982
diff
changeset
|
19 #include <stdint.h> |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
20 #include <stdio.h> |
32963 | 21 #include <stdlib.h> |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
22 #include <string.h> |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
23 |
32952 | 24 #include "gui_common.h" |
25 #include "gui/interface.h" | |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
25603
diff
changeset
|
26 #include "gui/skin/font.h" |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
27 |
32963 | 28 #include "access_mpcontext.h" |
32982 | 29 #include "codec-cfg.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
30 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
31 #include "help_mp.h" |
32963 | 32 #include "libavutil/avstring.h" |
33 #include "libmpdemux/stheader.h" | |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
34 #include "mixer.h" |
32954 | 35 #include "osdep/timer.h" |
32963 | 36 #include "stream/stream.h" |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
37 |
32963 | 38 static char *image_buffer; |
39 static int image_width; | |
32956 | 40 |
32963 | 41 static void TranslateFilename(int c, char *tmp, size_t tmplen) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
42 { |
32963 | 43 int i; |
44 char *p; | |
45 size_t len; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
46 |
32963 | 47 switch (guiIntfStruct.StreamType) { |
48 case STREAMTYPE_STREAM: | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
49 av_strlcpy(tmp, guiIntfStruct.Filename, tmplen); |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
50 break; |
32963 | 51 |
52 case STREAMTYPE_FILE: | |
53 if (guiIntfStruct.Filename && guiIntfStruct.Filename[0]) { | |
54 p = strrchr(guiIntfStruct.Filename, '/'); | |
55 | |
56 if (p) | |
57 av_strlcpy(tmp, p + 1, tmplen); | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
58 else |
32963 | 59 av_strlcpy(tmp, guiIntfStruct.Filename, tmplen); |
60 | |
61 len = strlen(tmp); | |
62 | |
63 if (len > 3 && tmp[len - 3] == '.') | |
64 tmp[len - 3] = 0; | |
65 else if (len > 4 && tmp[len - 4] == '.') | |
66 tmp[len - 4] = 0; | |
67 else if (len > 5 && tmp[len - 5] == '.') | |
68 tmp[len - 5] = 0; | |
69 } else | |
70 av_strlcpy(tmp, MSGTR_NoFileLoaded, tmplen); | |
71 break; | |
72 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27207
diff
changeset
|
73 #ifdef CONFIG_DVDREAD |
32963 | 74 case STREAMTYPE_DVD: |
75 if (guiIntfStruct.DVD.current_chapter) | |
76 snprintf(tmp, tmplen, MSGTR_Chapter, guiIntfStruct.DVD.current_chapter); | |
77 else | |
78 av_strlcat(tmp, MSGTR_NoChapter, tmplen); | |
79 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
80 #endif |
32963 | 81 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
82 #ifdef CONFIG_VCD |
32963 | 83 case STREAMTYPE_VCD: |
84 snprintf(tmp, tmplen, MSGTR_VCDTrack, guiIntfStruct.Track); | |
85 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
86 #endif |
32963 | 87 |
88 default: | |
89 av_strlcpy(tmp, MSGTR_NoMediaOpened, tmplen); | |
32968 | 90 break; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
91 } |
32963 | 92 |
93 if (c) { | |
32979
4905f5a87357
Replace some awkward and unnecessary usages of strlen().
ib
parents:
32975
diff
changeset
|
94 for (i = 0; tmp[i]; i++) { |
32963 | 95 int t = 0; |
96 | |
97 if (c == 1) | |
98 if (tmp[i] >= 'A' && tmp[i] <= 'Z') | |
99 t = 32; | |
100 | |
101 if (c == 2) | |
102 if (tmp[i] >= 'a' && tmp[i] <= 'z') | |
103 t = -32; | |
104 | |
105 tmp[i] = (char)(tmp[i] + t); | |
106 } | |
107 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
108 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
109 |
32975
0dc9d64cd64e
Make functions static that are only used inside the file.
ib
parents:
32973
diff
changeset
|
110 static char *Translate(char *str) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
111 { |
32963 | 112 static char trbuf[512]; |
113 char tmp[512]; | |
32972 | 114 unsigned int i, c; |
32963 | 115 int t; |
32967 | 116 mixer_t *mixer; |
32963 | 117 |
32972 | 118 *trbuf = 0; |
32963 | 119 |
32972 | 120 for (c = 0, i = 0; i < strlen(str); i++) { |
32963 | 121 if (str[i] != '$') { |
32972 | 122 if (c + 1 < sizeof(trbuf)) { |
32973 | 123 trbuf[c++] = str[i]; |
124 trbuf[c] = 0; | |
32972 | 125 } |
32963 | 126 } else { |
127 switch (str[++i]) { | |
128 case 't': | |
129 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.Track); | |
130 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
131 break; | |
132 | |
133 case 'o': | |
134 TranslateFilename(0, tmp, sizeof(tmp)); | |
135 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
136 break; | |
137 | |
138 case 'f': | |
139 TranslateFilename(1, tmp, sizeof(tmp)); | |
140 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
141 break; | |
142 | |
143 case 'F': | |
144 TranslateFilename(2, tmp, sizeof(tmp)); | |
145 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
146 break; | |
147 | |
148 case '6': | |
149 t = guiIntfStruct.LengthInSec; | |
150 goto calclengthhhmmss; | |
151 | |
152 case '1': | |
153 t = guiIntfStruct.TimeSec; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
154 calclengthhhmmss: |
32963 | 155 snprintf(tmp, sizeof(tmp), "%02d:%02d:%02d", t / 3600, t / 60 % 60, t % 60); |
156 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
157 break; | |
158 | |
159 case '7': | |
160 t = guiIntfStruct.LengthInSec; | |
161 goto calclengthmmmmss; | |
162 | |
163 case '2': | |
164 t = guiIntfStruct.TimeSec; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
165 calclengthmmmmss: |
32963 | 166 snprintf(tmp, sizeof(tmp), "%04d:%02d", t / 60, t % 60); |
167 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
168 break; | |
169 | |
170 case '3': | |
171 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec / 3600); | |
172 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
173 break; | |
174 | |
175 case '4': | |
176 snprintf(tmp, sizeof(tmp), "%02d", (guiIntfStruct.TimeSec / 60) % 60); | |
177 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
178 break; | |
179 | |
180 case '5': | |
181 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec % 60); | |
182 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
183 break; | |
184 | |
185 case '8': | |
186 snprintf(tmp, sizeof(tmp), "%01d:%02d:%02d", guiIntfStruct.TimeSec / 3600, (guiIntfStruct.TimeSec / 60) % 60, guiIntfStruct.TimeSec % 60); | |
187 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
188 break; | |
189 | |
190 case 'v': | |
191 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Volume); | |
192 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
193 break; | |
194 | |
195 case 'V': | |
196 snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Volume); | |
197 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
198 break; | |
199 | |
200 case 'b': | |
201 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Balance); | |
202 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
203 break; | |
204 | |
205 case 'B': | |
206 snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Balance); | |
207 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
208 break; | |
209 | |
210 case 'd': | |
211 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.FrameDrop); | |
212 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
213 break; | |
214 | |
215 case 'x': | |
216 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieWidth); | |
217 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
218 break; | |
219 | |
220 case 'y': | |
221 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieHeight); | |
222 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
223 break; | |
224 | |
225 case 'C': | |
226 snprintf(tmp, sizeof(tmp), "%s", guiIntfStruct.sh_video ? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : ""); | |
227 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
228 break; | |
229 | |
230 case 's': | |
231 if (guiIntfStruct.Playing == 0) | |
232 av_strlcat(trbuf, "s", sizeof(trbuf)); | |
233 break; | |
234 | |
235 case 'l': | |
236 if (guiIntfStruct.Playing == 1) | |
237 av_strlcat(trbuf, "p", sizeof(trbuf)); | |
238 break; | |
239 | |
240 case 'e': | |
241 if (guiIntfStruct.Playing == 2) | |
242 av_strlcat(trbuf, "e", sizeof(trbuf)); | |
243 break; | |
244 | |
245 case 'a': | |
246 | |
32967 | 247 mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); |
248 | |
32963 | 249 if (mixer->muted) { |
250 av_strlcat(trbuf, "n", sizeof(trbuf)); | |
251 break; | |
252 } | |
253 | |
254 switch (guiIntfStruct.AudioType) { | |
255 case 0: | |
256 av_strlcat(trbuf, "n", sizeof(trbuf)); | |
257 break; | |
258 | |
259 case 1: | |
260 av_strlcat(trbuf, "m", sizeof(trbuf)); | |
261 break; | |
262 | |
263 case 2: | |
264 av_strlcat(trbuf, "t", sizeof(trbuf)); | |
265 break; | |
266 } | |
267 | |
268 break; | |
269 | |
270 case 'T': | |
271 switch (guiIntfStruct.StreamType) { | |
272 case STREAMTYPE_FILE: | |
273 av_strlcat(trbuf, "f", sizeof(trbuf)); | |
274 break; | |
275 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
276 #ifdef CONFIG_VCD |
32963 | 277 case STREAMTYPE_VCD: |
278 av_strlcat(trbuf, "v", sizeof(trbuf)); | |
279 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
280 #endif |
32963 | 281 |
282 case STREAMTYPE_STREAM: | |
283 av_strlcat(trbuf, "u", sizeof(trbuf)); | |
284 break; | |
285 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27207
diff
changeset
|
286 #ifdef CONFIG_DVDREAD |
32963 | 287 case STREAMTYPE_DVD: |
288 av_strlcat(trbuf, "d", sizeof(trbuf)); | |
289 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
290 #endif |
32963 | 291 |
292 default: | |
293 av_strlcat(trbuf, " ", sizeof(trbuf)); | |
294 break; | |
295 } | |
296 break; | |
297 | |
298 case '$': | |
299 av_strlcat(trbuf, "$", sizeof(trbuf)); | |
300 break; | |
301 | |
302 default: | |
303 continue; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
304 } |
32963 | 305 |
306 c = strlen(trbuf); | |
307 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
308 } |
32963 | 309 |
310 return trbuf; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
311 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
312 |
32975
0dc9d64cd64e
Make functions static that are only used inside the file.
ib
parents:
32973
diff
changeset
|
313 static void PutImage(txSample *bf, int x, int y, int max, int ofs) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
314 { |
32963 | 315 int i = 0, ix, iy; |
316 uint32_t *buf = NULL; | |
317 uint32_t *drw = NULL; | |
318 register uint32_t tmp; | |
319 | |
320 /* register uint32_t yc; */ | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
321 |
32963 | 322 if (!bf || (bf->Image == NULL)) |
323 return; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
324 |
32963 | 325 i = bf->Width * (bf->Height / max) * ofs; |
326 buf = (uint32_t *)image_buffer; | |
327 drw = (uint32_t *)bf->Image; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
328 |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
329 #if 1 |
32963 | 330 for (iy = y; iy < (int)(y + bf->Height / max); iy++) |
331 for (ix = x; ix < (int)(x + bf->Width); ix++) { | |
332 tmp = drw[i++]; | |
333 | |
33129 | 334 if (tmp != TRANSPARENT) |
32963 | 335 buf[iy * image_width + ix] = tmp; |
336 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
337 #else |
32963 | 338 yc = y * image_width; |
339 | |
340 for (iy = y; iy < (int)(y + bf->Height / max); iy++) { | |
341 for (ix = x; ix < (int)(x + bf->Width); ix++) { | |
342 tmp = drw[i++]; | |
343 | |
33129 | 344 if (tmp != TRANSPARENT) |
32963 | 345 buf[yc + ix] = tmp; |
346 } | |
347 | |
348 yc += image_width; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
349 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
350 #endif |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
351 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
352 |
32975
0dc9d64cd64e
Make functions static that are only used inside the file.
ib
parents:
32973
diff
changeset
|
353 static void SimplePotmeterPutImage(txSample *bf, int x, int y, float frac) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
354 { |
32963 | 355 int i = 0, w, r, ix, iy; |
356 uint32_t *buf = NULL; | |
357 uint32_t *drw = NULL; | |
358 register uint32_t tmp; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
359 |
32963 | 360 if (!bf || (bf->Image == NULL)) |
361 return; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
362 |
32963 | 363 buf = (uint32_t *)image_buffer; |
364 drw = (uint32_t *)bf->Image; | |
365 w = bf->Width * frac; | |
366 r = bf->Width - w; | |
367 | |
368 for (iy = y; iy < (int)(y + bf->Height); iy++) { | |
369 for (ix = x; ix < (int)(x + w); ix++) { | |
370 tmp = drw[i++]; | |
371 | |
33129 | 372 if (tmp != TRANSPARENT) |
32963 | 373 buf[iy * image_width + ix] = tmp; |
374 } | |
375 | |
376 i += r; | |
377 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
378 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
379 |
32963 | 380 void Render(wsTWindow *window, wItem *Items, int nrItems, char *db, int size) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
381 { |
32963 | 382 wItem *item; |
383 txSample *image = NULL; | |
384 int i, ofs; | |
385 | |
386 image_buffer = db; | |
387 image_width = window->Width; | |
388 | |
389 for (i = 0; i < nrItems + 1; i++) { | |
390 item = &Items[i]; | |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
391 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
392 switch (item->pressed) { |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
393 case btnPressed: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
394 ofs = 0; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
395 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
396 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
397 case btnReleased: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
398 ofs = 1; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
399 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
400 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
401 default: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
402 ofs = 2; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
403 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
404 } |
32963 | 405 |
406 switch (item->type) { | |
407 case itButton: | |
408 PutImage(&item->Bitmap, item->x, item->y, 3, ofs); | |
409 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
410 |
32963 | 411 case itPotmeter: |
412 if (item->numphases == 1) | |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
413 SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0); |
32963 | 414 else |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
415 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0)); |
32963 | 416 break; |
417 | |
418 case itHPotmeter: | |
419 if (item->numphases == 1) | |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
420 SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0); |
32963 | 421 else |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
422 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0)); |
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
423 PutImage(&item->Mask, item->x + (item->width - item->pwidth) * (item->value / 100.0), item->y, 3, ofs); |
32963 | 424 break; |
425 | |
426 case itVPotmeter: | |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
427 PutImage(&item->Bitmap, item->x, item->y, item->numphases, item->numphases * (1.0 - item->value / 100.0)); |
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
428 PutImage(&item->Mask, item->x, item->y + (item->height - item->pheight) * (1.0 - item->value / 100.0), 3, ofs); |
32963 | 429 break; |
430 | |
431 case itSLabel: | |
32969 | 432 if (item->width == -1) |
433 item->width = fntTextWidth(item->fontid, item->label); | |
32963 | 434 image = fntRender(item, 0, item->label); |
435 if (image) | |
436 PutImage(image, item->x, item->y, 1, 0); | |
32969 | 437 break; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
438 |
32963 | 439 case itDLabel: |
440 { | |
441 int x; | |
442 unsigned int d; | |
443 char *t = Translate(item->label); | |
444 | |
445 if (!item->text || (strcmp(item->text, t) != 0)) { | |
446 free(item->text); | |
447 item->text = strdup(t); | |
448 item->textwidth = fntTextWidth(item->fontid, t); | |
449 item->starttime = GetTimerMS(); | |
450 item->last_x = 0; | |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
451 } |
32963 | 452 |
453 d = GetTimerMS() - item->starttime; | |
454 | |
32964 | 455 if (d < DLABEL_DELAY) |
32963 | 456 x = item->last_x; // don't scroll yet |
457 else { | |
458 int l; | |
459 char c[2]; | |
460 | |
461 l = (item->textwidth ? item->textwidth : item->width); | |
32964 | 462 x = l - ((d - DLABEL_DELAY) / 20) % l - 1; |
32963 | 463 c[0] = *item->text; |
464 c[1] = '\0'; | |
465 | |
466 if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) { | |
467 item->starttime = GetTimerMS(); // stop again | |
468 item->last_x = x; // at current x pos | |
469 } | |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
470 } |
32963 | 471 |
472 image = fntRender(item, x, t); | |
473 } | |
474 | |
475 if (image) | |
476 PutImage(image, item->x, item->y, 1, 0); | |
477 | |
478 break; | |
479 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
480 } |
32963 | 481 |
482 wsConvert(window, db, size); | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
483 } |