Mercurial > mplayer.hg
annotate gui/mplayer/gui_common.c @ 33534:22c3241467b3
Remove function Normalize().
This function changed ARGB data as if it had been RGB24 data (not quite
correctly) converted to ARGB with all colors transparent.
Instead now, set the alpha channel for RGB24 data and leave ARGB data
untouched.
For X11, the alpha channel is disregarded, so both approaches are equal,
but the new one is more intelligible as we get correct ARGB PNG data.
For legacy reasons, all kind of fuchsia/magenta must be treated as
transparent, because some skins are using at least both full opaque and
full transparent fuchsia/magenta for transparency.
author | ib |
---|---|
date | Thu, 16 Jun 2011 11:19:15 +0000 |
parents | d2e61ef877d2 |
children | ba473335e68b |
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: |
32963 | 157 snprintf(tmp, sizeof(tmp), "%02d:%02d:%02d", t / 3600, t / 60 % 60, t % 60); |
158 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
159 break; | |
160 | |
161 case '7': | |
162 t = guiIntfStruct.LengthInSec; | |
163 goto calclengthmmmmss; | |
164 | |
165 case '2': | |
166 t = guiIntfStruct.TimeSec; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
167 calclengthmmmmss: |
32963 | 168 snprintf(tmp, sizeof(tmp), "%04d:%02d", t / 60, t % 60); |
169 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
170 break; | |
171 | |
172 case '3': | |
173 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec / 3600); | |
174 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
175 break; | |
176 | |
177 case '4': | |
178 snprintf(tmp, sizeof(tmp), "%02d", (guiIntfStruct.TimeSec / 60) % 60); | |
179 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
180 break; | |
181 | |
182 case '5': | |
183 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec % 60); | |
184 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
185 break; | |
186 | |
187 case '8': | |
33405 | 188 snprintf(tmp, sizeof(tmp), "%01d:%02d:%02d", guiIntfStruct.TimeSec / 3600, (guiIntfStruct.TimeSec / 60) % 60, guiIntfStruct.TimeSec % 60); |
32963 | 189 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
190 break; | |
191 | |
192 case 'v': | |
193 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Volume); | |
194 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
195 break; | |
196 | |
197 case 'V': | |
198 snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Volume); | |
199 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
200 break; | |
201 | |
202 case 'b': | |
203 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Balance); | |
204 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
205 break; | |
206 | |
207 case 'B': | |
208 snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Balance); | |
209 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
210 break; | |
211 | |
212 case 'd': | |
213 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.FrameDrop); | |
214 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
215 break; | |
216 | |
217 case 'x': | |
218 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieWidth); | |
219 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
220 break; | |
221 | |
222 case 'y': | |
223 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieHeight); | |
224 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
225 break; | |
226 | |
227 case 'C': | |
228 snprintf(tmp, sizeof(tmp), "%s", guiIntfStruct.sh_video ? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : ""); | |
229 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
230 break; | |
231 | |
232 case 's': | |
233 if (guiIntfStruct.Playing == 0) | |
234 av_strlcat(trbuf, "s", sizeof(trbuf)); | |
235 break; | |
236 | |
237 case 'l': | |
238 if (guiIntfStruct.Playing == 1) | |
239 av_strlcat(trbuf, "p", sizeof(trbuf)); | |
240 break; | |
241 | |
242 case 'e': | |
243 if (guiIntfStruct.Playing == 2) | |
244 av_strlcat(trbuf, "e", sizeof(trbuf)); | |
245 break; | |
246 | |
247 case 'a': | |
248 | |
32967 | 249 mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); |
250 | |
32963 | 251 if (mixer->muted) { |
252 av_strlcat(trbuf, "n", sizeof(trbuf)); | |
253 break; | |
254 } | |
255 | |
256 switch (guiIntfStruct.AudioType) { | |
257 case 0: | |
258 av_strlcat(trbuf, "n", sizeof(trbuf)); | |
259 break; | |
260 | |
261 case 1: | |
262 av_strlcat(trbuf, "m", sizeof(trbuf)); | |
263 break; | |
264 | |
265 case 2: | |
266 av_strlcat(trbuf, "t", sizeof(trbuf)); | |
267 break; | |
268 } | |
269 | |
270 break; | |
271 | |
272 case 'T': | |
273 switch (guiIntfStruct.StreamType) { | |
274 case STREAMTYPE_FILE: | |
275 av_strlcat(trbuf, "f", sizeof(trbuf)); | |
276 break; | |
277 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
278 #ifdef CONFIG_VCD |
32963 | 279 case STREAMTYPE_VCD: |
280 av_strlcat(trbuf, "v", sizeof(trbuf)); | |
281 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
282 #endif |
32963 | 283 |
284 case STREAMTYPE_STREAM: | |
285 av_strlcat(trbuf, "u", sizeof(trbuf)); | |
286 break; | |
287 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27207
diff
changeset
|
288 #ifdef CONFIG_DVDREAD |
32963 | 289 case STREAMTYPE_DVD: |
290 av_strlcat(trbuf, "d", sizeof(trbuf)); | |
291 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
292 #endif |
32963 | 293 |
294 default: | |
295 av_strlcat(trbuf, " ", sizeof(trbuf)); | |
296 break; | |
297 } | |
298 break; | |
299 | |
300 case '$': | |
301 av_strlcat(trbuf, "$", sizeof(trbuf)); | |
302 break; | |
303 | |
304 default: | |
305 continue; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
306 } |
32963 | 307 |
308 c = strlen(trbuf); | |
309 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
310 } |
32963 | 311 |
312 return trbuf; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
313 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
314 |
32975
0dc9d64cd64e
Make functions static that are only used inside the file.
ib
parents:
32973
diff
changeset
|
315 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
|
316 { |
32963 | 317 int i = 0, ix, iy; |
318 uint32_t *buf = NULL; | |
319 uint32_t *drw = NULL; | |
320 register uint32_t tmp; | |
321 | |
322 /* register uint32_t yc; */ | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
323 |
32963 | 324 if (!bf || (bf->Image == NULL)) |
325 return; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
326 |
32963 | 327 i = bf->Width * (bf->Height / max) * ofs; |
328 buf = (uint32_t *)image_buffer; | |
329 drw = (uint32_t *)bf->Image; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
330 |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
331 #if 1 |
32963 | 332 for (iy = y; iy < (int)(y + bf->Height / max); iy++) |
333 for (ix = x; ix < (int)(x + bf->Width); ix++) { | |
334 tmp = drw[i++]; | |
335 | |
33534 | 336 if (!IS_TRANSPARENT(tmp)) |
32963 | 337 buf[iy * image_width + ix] = tmp; |
338 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
339 #else |
32963 | 340 yc = y * image_width; |
341 | |
342 for (iy = y; iy < (int)(y + bf->Height / max); iy++) { | |
343 for (ix = x; ix < (int)(x + bf->Width); ix++) { | |
344 tmp = drw[i++]; | |
345 | |
33534 | 346 if (!IS_TRANSPARENT(tmp)) |
32963 | 347 buf[yc + ix] = tmp; |
348 } | |
349 | |
350 yc += image_width; | |
25603
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 #endif |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
353 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
354 |
32975
0dc9d64cd64e
Make functions static that are only used inside the file.
ib
parents:
32973
diff
changeset
|
355 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
|
356 { |
32963 | 357 int i = 0, w, r, ix, iy; |
358 uint32_t *buf = NULL; | |
359 uint32_t *drw = NULL; | |
360 register uint32_t tmp; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
361 |
32963 | 362 if (!bf || (bf->Image == NULL)) |
363 return; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
364 |
32963 | 365 buf = (uint32_t *)image_buffer; |
366 drw = (uint32_t *)bf->Image; | |
367 w = bf->Width * frac; | |
368 r = bf->Width - w; | |
369 | |
370 for (iy = y; iy < (int)(y + bf->Height); iy++) { | |
371 for (ix = x; ix < (int)(x + w); ix++) { | |
372 tmp = drw[i++]; | |
373 | |
33534 | 374 if (!IS_TRANSPARENT(tmp)) |
32963 | 375 buf[iy * image_width + ix] = tmp; |
376 } | |
377 | |
378 i += r; | |
379 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
380 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
381 |
32963 | 382 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
|
383 { |
32963 | 384 wItem *item; |
385 txSample *image = NULL; | |
386 int i, ofs; | |
387 | |
388 image_buffer = db; | |
389 image_width = window->Width; | |
390 | |
391 for (i = 0; i < nrItems + 1; i++) { | |
392 item = &Items[i]; | |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
393 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
394 switch (item->pressed) { |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
395 case btnPressed: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
396 ofs = 0; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
397 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
398 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
399 case btnReleased: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
400 ofs = 1; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
401 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
402 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
403 default: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
404 ofs = 2; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
405 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
406 } |
32963 | 407 |
408 switch (item->type) { | |
409 case itButton: | |
410 PutImage(&item->Bitmap, item->x, item->y, 3, ofs); | |
411 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
412 |
32963 | 413 case itPotmeter: |
414 if (item->numphases == 1) | |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
415 SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0); |
32963 | 416 else |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
417 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0)); |
32963 | 418 break; |
419 | |
420 case itHPotmeter: | |
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)); |
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
425 PutImage(&item->Mask, item->x + (item->width - item->pwidth) * (item->value / 100.0), item->y, 3, ofs); |
32963 | 426 break; |
427 | |
428 case itVPotmeter: | |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
429 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
|
430 PutImage(&item->Mask, item->x, item->y + (item->height - item->pheight) * (1.0 - item->value / 100.0), 3, ofs); |
32963 | 431 break; |
432 | |
433 case itSLabel: | |
32969 | 434 if (item->width == -1) |
435 item->width = fntTextWidth(item->fontid, item->label); | |
32963 | 436 image = fntRender(item, 0, item->label); |
437 if (image) | |
438 PutImage(image, item->x, item->y, 1, 0); | |
32969 | 439 break; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
440 |
32963 | 441 case itDLabel: |
442 { | |
443 int x; | |
444 unsigned int d; | |
445 char *t = Translate(item->label); | |
446 | |
447 if (!item->text || (strcmp(item->text, t) != 0)) { | |
448 free(item->text); | |
449 item->text = strdup(t); | |
450 item->textwidth = fntTextWidth(item->fontid, t); | |
451 item->starttime = GetTimerMS(); | |
452 item->last_x = 0; | |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
453 } |
32963 | 454 |
455 d = GetTimerMS() - item->starttime; | |
456 | |
32964 | 457 if (d < DLABEL_DELAY) |
32963 | 458 x = item->last_x; // don't scroll yet |
459 else { | |
460 int l; | |
461 char c[2]; | |
462 | |
463 l = (item->textwidth ? item->textwidth : item->width); | |
32964 | 464 x = l - ((d - DLABEL_DELAY) / 20) % l - 1; |
32963 | 465 c[0] = *item->text; |
466 c[1] = '\0'; | |
467 | |
468 if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) { | |
469 item->starttime = GetTimerMS(); // stop again | |
470 item->last_x = x; // at current x pos | |
471 } | |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
472 } |
32963 | 473 |
474 image = fntRender(item, x, t); | |
475 } | |
476 | |
477 if (image) | |
478 PutImage(image, item->x, item->y, 1, 0); | |
479 | |
480 break; | |
481 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
482 } |
32963 | 483 |
484 wsConvert(window, db, size); | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
485 } |