Mercurial > mplayer.hg
annotate gui/ui/render.c @ 33949:ee2bcd643829
Resize video window after switching from fullscreen to normal size.
The _NETWM_STATE_FULLSCREEN EWMH restores the original geometry
which differs from the original size of the video if fullscreen
has already been active at playback time.
author | ib |
---|---|
date | Thu, 01 Sep 2011 17:53:33 +0000 |
parents | d4f80f889106 |
children | 922771be85f6 |
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 |
33556 | 24 #include "render.h" |
32952 | 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 |
33555 | 49 switch (guiInfo.StreamType) { |
32963 | 50 case STREAMTYPE_STREAM: |
33555 | 51 av_strlcpy(tmp, guiInfo.Filename, tmplen); |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
52 break; |
32963 | 53 |
54 case STREAMTYPE_FILE: | |
33555 | 55 if (guiInfo.Filename && guiInfo.Filename[0]) { |
56 p = strrchr(guiInfo.Filename, '/'); | |
32963 | 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 |
33555 | 61 av_strlcpy(tmp, guiInfo.Filename, tmplen); |
32963 | 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: |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
77 if (guiInfo.Chapter) |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
78 snprintf(tmp, tmplen, MSGTR_Chapter, guiInfo.Chapter); |
32963 | 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: |
33874 | 86 snprintf(tmp, tmplen, MSGTR_Title, guiInfo.Track - 1); |
32963 | 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': | |
33555 | 131 snprintf(tmp, sizeof(tmp), "%02d", guiInfo.Track); |
32963 | 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': | |
33897 | 151 t = guiInfo.RunningTime; |
32963 | 152 goto calclengthhhmmss; |
153 | |
154 case '1': | |
33897 | 155 t = guiInfo.ElapsedTime; |
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': | |
33897 | 162 t = guiInfo.RunningTime; |
32963 | 163 goto calclengthmmmmss; |
164 | |
165 case '2': | |
33897 | 166 t = guiInfo.ElapsedTime; |
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': | |
33897 | 173 snprintf(tmp, sizeof(tmp), "%02d", guiInfo.ElapsedTime / 3600); |
32963 | 174 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
175 break; | |
176 | |
177 case '4': | |
33897 | 178 snprintf(tmp, sizeof(tmp), "%02d", (guiInfo.ElapsedTime / 60) % 60); |
32963 | 179 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
180 break; | |
181 | |
182 case '5': | |
33897 | 183 snprintf(tmp, sizeof(tmp), "%02d", guiInfo.ElapsedTime % 60); |
32963 | 184 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
185 break; | |
186 | |
187 case '8': | |
33897 | 188 snprintf(tmp, sizeof(tmp), "%01d:%02d:%02d", guiInfo.ElapsedTime / 3600, (guiInfo.ElapsedTime / 60) % 60, guiInfo.ElapsedTime % 60); |
32963 | 189 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
190 break; | |
191 | |
192 case 'v': | |
33555 | 193 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiInfo.Volume); |
32963 | 194 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
195 break; | |
196 | |
197 case 'V': | |
33555 | 198 snprintf(tmp, sizeof(tmp), "%3.1f", guiInfo.Volume); |
32963 | 199 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
200 break; | |
201 | |
202 case 'b': | |
33555 | 203 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiInfo.Balance); |
32963 | 204 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
205 break; | |
206 | |
207 case 'B': | |
33555 | 208 snprintf(tmp, sizeof(tmp), "%3.1f", guiInfo.Balance); |
32963 | 209 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
210 break; | |
211 | |
212 case 'x': | |
33901 | 213 snprintf(tmp, sizeof(tmp), "%d", guiInfo.VideoWidth); |
32963 | 214 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
215 break; | |
216 | |
217 case 'y': | |
33901 | 218 snprintf(tmp, sizeof(tmp), "%d", guiInfo.VideoHeight); |
32963 | 219 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
220 break; | |
221 | |
222 case 'C': | |
33774
474ffcdcc6e7
Change guiInterface_t void pointer member declarations.
ib
parents:
33773
diff
changeset
|
223 snprintf(tmp, sizeof(tmp), "%s", guiInfo.sh_video ? guiInfo.sh_video->codec->name : ""); |
32963 | 224 av_strlcat(trbuf, tmp, sizeof(trbuf)); |
225 break; | |
226 | |
227 case 's': | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33556
diff
changeset
|
228 if (guiInfo.Playing == GUI_STOP) |
32963 | 229 av_strlcat(trbuf, "s", sizeof(trbuf)); |
230 break; | |
231 | |
33616 | 232 case 'l': // legacy |
233 case 'p': | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33556
diff
changeset
|
234 if (guiInfo.Playing == GUI_PLAY) |
32963 | 235 av_strlcat(trbuf, "p", sizeof(trbuf)); |
236 break; | |
237 | |
238 case 'e': | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33556
diff
changeset
|
239 if (guiInfo.Playing == GUI_PAUSE) |
32963 | 240 av_strlcat(trbuf, "e", sizeof(trbuf)); |
241 break; | |
242 | |
243 case 'a': | |
244 | |
33555 | 245 mixer = mpctx_get_mixer(guiInfo.mpcontext); |
32967 | 246 |
32963 | 247 if (mixer->muted) { |
248 av_strlcat(trbuf, "n", sizeof(trbuf)); | |
249 break; | |
250 } | |
251 | |
33646 | 252 switch (guiInfo.AudioChannels) { |
32963 | 253 case 0: |
254 av_strlcat(trbuf, "n", sizeof(trbuf)); | |
255 break; | |
256 | |
257 case 1: | |
258 av_strlcat(trbuf, "m", sizeof(trbuf)); | |
259 break; | |
260 | |
261 case 2: | |
262 av_strlcat(trbuf, "t", sizeof(trbuf)); | |
263 break; | |
264 } | |
265 | |
266 break; | |
267 | |
268 case 'T': | |
33555 | 269 switch (guiInfo.StreamType) { |
32963 | 270 case STREAMTYPE_FILE: |
271 av_strlcat(trbuf, "f", sizeof(trbuf)); | |
272 break; | |
273 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
274 #ifdef CONFIG_VCD |
32963 | 275 case STREAMTYPE_VCD: |
276 av_strlcat(trbuf, "v", sizeof(trbuf)); | |
277 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
278 #endif |
32963 | 279 |
280 case STREAMTYPE_STREAM: | |
281 av_strlcat(trbuf, "u", sizeof(trbuf)); | |
282 break; | |
283 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27207
diff
changeset
|
284 #ifdef CONFIG_DVDREAD |
32963 | 285 case STREAMTYPE_DVD: |
286 av_strlcat(trbuf, "d", sizeof(trbuf)); | |
287 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
288 #endif |
32963 | 289 |
290 default: | |
291 av_strlcat(trbuf, " ", sizeof(trbuf)); | |
292 break; | |
293 } | |
294 break; | |
295 | |
296 case '$': | |
297 av_strlcat(trbuf, "$", sizeof(trbuf)); | |
298 break; | |
299 | |
300 default: | |
301 continue; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
302 } |
32963 | 303 |
304 c = strlen(trbuf); | |
305 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
306 } |
32963 | 307 |
308 return trbuf; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
309 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
310 |
33555 | 311 static void PutImage(guiImage *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
|
312 { |
32963 | 313 int i = 0, ix, iy; |
314 uint32_t *buf = NULL; | |
315 uint32_t *drw = NULL; | |
316 register uint32_t tmp; | |
317 | |
318 /* register uint32_t yc; */ | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
319 |
32963 | 320 if (!bf || (bf->Image == NULL)) |
321 return; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
322 |
32963 | 323 i = bf->Width * (bf->Height / max) * ofs; |
324 buf = (uint32_t *)image_buffer; | |
325 drw = (uint32_t *)bf->Image; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
326 |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
327 #if 1 |
32963 | 328 for (iy = y; iy < (int)(y + bf->Height / max); iy++) |
329 for (ix = x; ix < (int)(x + bf->Width); ix++) { | |
330 tmp = drw[i++]; | |
331 | |
33534 | 332 if (!IS_TRANSPARENT(tmp)) |
32963 | 333 buf[iy * image_width + ix] = tmp; |
334 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
335 #else |
32963 | 336 yc = y * image_width; |
337 | |
338 for (iy = y; iy < (int)(y + bf->Height / max); iy++) { | |
339 for (ix = x; ix < (int)(x + bf->Width); ix++) { | |
340 tmp = drw[i++]; | |
341 | |
33534 | 342 if (!IS_TRANSPARENT(tmp)) |
32963 | 343 buf[yc + ix] = tmp; |
344 } | |
345 | |
346 yc += image_width; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
347 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
348 #endif |
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 |
33555 | 351 static void SimplePotmeterPutImage(guiImage *bf, int x, int y, float frac) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
352 { |
32963 | 353 int i = 0, w, r, ix, iy; |
354 uint32_t *buf = NULL; | |
355 uint32_t *drw = NULL; | |
356 register uint32_t tmp; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
357 |
32963 | 358 if (!bf || (bf->Image == NULL)) |
359 return; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
360 |
32963 | 361 buf = (uint32_t *)image_buffer; |
362 drw = (uint32_t *)bf->Image; | |
363 w = bf->Width * frac; | |
364 r = bf->Width - w; | |
365 | |
366 for (iy = y; iy < (int)(y + bf->Height); iy++) { | |
367 for (ix = x; ix < (int)(x + w); ix++) { | |
368 tmp = drw[i++]; | |
369 | |
33534 | 370 if (!IS_TRANSPARENT(tmp)) |
32963 | 371 buf[iy * image_width + ix] = tmp; |
372 } | |
373 | |
374 i += r; | |
375 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
376 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
377 |
33548 | 378 void RenderAll(wsTWindow *window, wItem *Items, int nrItems, char *db) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
379 { |
32963 | 380 wItem *item; |
33555 | 381 guiImage *image = NULL; |
32963 | 382 int i, ofs; |
383 | |
384 image_buffer = db; | |
385 image_width = window->Width; | |
386 | |
387 for (i = 0; i < nrItems + 1; i++) { | |
388 item = &Items[i]; | |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
389 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
390 switch (item->pressed) { |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
391 case btnPressed: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
392 ofs = 0; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
393 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
394 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
395 case btnReleased: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
396 ofs = 1; |
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 default: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
400 ofs = 2; |
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 } |
32963 | 403 |
404 switch (item->type) { | |
405 case itButton: | |
406 PutImage(&item->Bitmap, item->x, item->y, 3, ofs); | |
407 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
408 |
32963 | 409 case itPotmeter: |
410 if (item->numphases == 1) | |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
411 SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0); |
32963 | 412 else |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
413 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0)); |
32963 | 414 break; |
415 | |
416 case itHPotmeter: | |
417 if (item->numphases == 1) | |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
418 SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0); |
32963 | 419 else |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
420 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
|
421 PutImage(&item->Mask, item->x + (item->width - item->pwidth) * (item->value / 100.0), item->y, 3, ofs); |
32963 | 422 break; |
423 | |
424 case itVPotmeter: | |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
425 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
|
426 PutImage(&item->Mask, item->x, item->y + (item->height - item->pheight) * (1.0 - item->value / 100.0), 3, ofs); |
32963 | 427 break; |
428 | |
429 case itSLabel: | |
32969 | 430 if (item->width == -1) |
431 item->width = fntTextWidth(item->fontid, item->label); | |
32963 | 432 image = fntRender(item, 0, item->label); |
433 if (image) | |
434 PutImage(image, item->x, item->y, 1, 0); | |
32969 | 435 break; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
436 |
32963 | 437 case itDLabel: |
438 { | |
439 int x; | |
440 unsigned int d; | |
441 char *t = Translate(item->label); | |
442 | |
443 if (!item->text || (strcmp(item->text, t) != 0)) { | |
444 free(item->text); | |
445 item->text = strdup(t); | |
446 item->textwidth = fntTextWidth(item->fontid, t); | |
447 item->starttime = GetTimerMS(); | |
448 item->last_x = 0; | |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
449 } |
32963 | 450 |
451 d = GetTimerMS() - item->starttime; | |
452 | |
32964 | 453 if (d < DLABEL_DELAY) |
32963 | 454 x = item->last_x; // don't scroll yet |
455 else { | |
456 int l; | |
457 char c[2]; | |
458 | |
459 l = (item->textwidth ? item->textwidth : item->width); | |
32964 | 460 x = l - ((d - DLABEL_DELAY) / 20) % l - 1; |
32963 | 461 c[0] = *item->text; |
462 c[1] = '\0'; | |
463 | |
464 if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) { | |
465 item->starttime = GetTimerMS(); // stop again | |
466 item->last_x = x; // at current x pos | |
467 } | |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
468 } |
32963 | 469 |
470 image = fntRender(item, x, t); | |
471 } | |
472 | |
473 if (image) | |
474 PutImage(image, item->x, item->y, 1, 0); | |
475 | |
476 break; | |
477 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
478 } |
32963 | 479 |
33548 | 480 wsConvert(window, db); |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
481 } |