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