Mercurial > mplayer.hg
annotate gui/mplayer/gui_common.c @ 32967:d9363dbd3f83
Avoid mixing declaration and code.
Additionally, move assignment where variable is used.
author | ib |
---|---|
date | Tue, 08 Mar 2011 13:12:30 +0000 |
parents | 1f51f39916e1 |
children | 1fa7a299b1b4 |
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 |
32963 | 19 #include <inttypes.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" |
29 #include "codec-cfg.h" // this should be in libmpdemux/stheader.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); | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
90 } |
32963 | 91 |
92 if (c) { | |
93 for (i = 0; i < (int)strlen(tmp); i++) { | |
94 int t = 0; | |
95 | |
96 if (c == 1) | |
97 if (tmp[i] >= 'A' && tmp[i] <= 'Z') | |
98 t = 32; | |
99 | |
100 if (c == 2) | |
101 if (tmp[i] >= 'a' && tmp[i] <= 'z') | |
102 t = -32; | |
103 | |
104 tmp[i] = (char)(tmp[i] + t); | |
105 } | |
106 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
107 } |
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 /* Unsafe! Pass only null-terminated strings as (char *)str. */ |
32963 | 110 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]; | |
114 int i, c; | |
115 int t; | |
116 int strsize = 0; | |
32967 | 117 mixer_t *mixer; |
32963 | 118 |
119 memset(trbuf, 0, 512); | |
120 memset(tmp, 0, 128); | |
121 strsize = strlen(str); | |
122 | |
123 for (c = 0, i = 0; i < strsize; i++) { | |
124 if (str[i] != '$') { | |
125 trbuf[c++] = str[i]; | |
126 trbuf[c] = 0; | |
127 } else { | |
128 switch (str[++i]) { | |
129 case 't': | |
130 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.Track); | |
131 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
132 break; | |
133 | |
134 case 'o': | |
135 TranslateFilename(0, tmp, sizeof(tmp)); | |
136 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
137 break; | |
138 | |
139 case 'f': | |
140 TranslateFilename(1, tmp, sizeof(tmp)); | |
141 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
142 break; | |
143 | |
144 case 'F': | |
145 TranslateFilename(2, tmp, sizeof(tmp)); | |
146 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
147 break; | |
148 | |
149 case '6': | |
150 t = guiIntfStruct.LengthInSec; | |
151 goto calclengthhhmmss; | |
152 | |
153 case '1': | |
154 t = guiIntfStruct.TimeSec; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
155 calclengthhhmmss: |
32963 | 156 snprintf(tmp, sizeof(tmp), "%02d:%02d:%02d", t / 3600, t / 60 % 60, t % 60); |
157 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
158 break; | |
159 | |
160 case '7': | |
161 t = guiIntfStruct.LengthInSec; | |
162 goto calclengthmmmmss; | |
163 | |
164 case '2': | |
165 t = guiIntfStruct.TimeSec; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
166 calclengthmmmmss: |
32963 | 167 snprintf(tmp, sizeof(tmp), "%04d:%02d", t / 60, t % 60); |
168 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
169 break; | |
170 | |
171 case '3': | |
172 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec / 3600); | |
173 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
174 break; | |
175 | |
176 case '4': | |
177 snprintf(tmp, sizeof(tmp), "%02d", (guiIntfStruct.TimeSec / 60) % 60); | |
178 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
179 break; | |
180 | |
181 case '5': | |
182 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec % 60); | |
183 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
184 break; | |
185 | |
186 case '8': | |
187 snprintf(tmp, sizeof(tmp), "%01d:%02d:%02d", guiIntfStruct.TimeSec / 3600, (guiIntfStruct.TimeSec / 60) % 60, guiIntfStruct.TimeSec % 60); | |
188 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
189 break; | |
190 | |
191 case 'v': | |
192 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Volume); | |
193 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
194 break; | |
195 | |
196 case 'V': | |
197 snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Volume); | |
198 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
199 break; | |
200 | |
201 case 'b': | |
202 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Balance); | |
203 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
204 break; | |
205 | |
206 case 'B': | |
207 snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Balance); | |
208 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
209 break; | |
210 | |
211 case 'd': | |
212 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.FrameDrop); | |
213 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
214 break; | |
215 | |
216 case 'x': | |
217 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieWidth); | |
218 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
219 break; | |
220 | |
221 case 'y': | |
222 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieHeight); | |
223 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
224 break; | |
225 | |
226 case 'C': | |
227 snprintf(tmp, sizeof(tmp), "%s", guiIntfStruct.sh_video ? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : ""); | |
228 av_strlcat(trbuf, tmp, sizeof(trbuf)); | |
229 break; | |
230 | |
231 case 's': | |
232 if (guiIntfStruct.Playing == 0) | |
233 av_strlcat(trbuf, "s", sizeof(trbuf)); | |
234 break; | |
235 | |
236 case 'l': | |
237 if (guiIntfStruct.Playing == 1) | |
238 av_strlcat(trbuf, "p", sizeof(trbuf)); | |
239 break; | |
240 | |
241 case 'e': | |
242 if (guiIntfStruct.Playing == 2) | |
243 av_strlcat(trbuf, "e", sizeof(trbuf)); | |
244 break; | |
245 | |
246 case 'a': | |
247 | |
32967 | 248 mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); |
249 | |
32963 | 250 if (mixer->muted) { |
251 av_strlcat(trbuf, "n", sizeof(trbuf)); | |
252 break; | |
253 } | |
254 | |
255 switch (guiIntfStruct.AudioType) { | |
256 case 0: | |
257 av_strlcat(trbuf, "n", sizeof(trbuf)); | |
258 break; | |
259 | |
260 case 1: | |
261 av_strlcat(trbuf, "m", sizeof(trbuf)); | |
262 break; | |
263 | |
264 case 2: | |
265 av_strlcat(trbuf, "t", sizeof(trbuf)); | |
266 break; | |
267 } | |
268 | |
269 break; | |
270 | |
271 case 'T': | |
272 switch (guiIntfStruct.StreamType) { | |
273 case STREAMTYPE_FILE: | |
274 av_strlcat(trbuf, "f", sizeof(trbuf)); | |
275 break; | |
276 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
277 #ifdef CONFIG_VCD |
32963 | 278 case STREAMTYPE_VCD: |
279 av_strlcat(trbuf, "v", sizeof(trbuf)); | |
280 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
281 #endif |
32963 | 282 |
283 case STREAMTYPE_STREAM: | |
284 av_strlcat(trbuf, "u", sizeof(trbuf)); | |
285 break; | |
286 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27207
diff
changeset
|
287 #ifdef CONFIG_DVDREAD |
32963 | 288 case STREAMTYPE_DVD: |
289 av_strlcat(trbuf, "d", sizeof(trbuf)); | |
290 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
291 #endif |
32963 | 292 |
293 default: | |
294 av_strlcat(trbuf, " ", sizeof(trbuf)); | |
295 break; | |
296 } | |
297 break; | |
298 | |
299 case '$': | |
300 av_strlcat(trbuf, "$", sizeof(trbuf)); | |
301 break; | |
302 | |
303 default: | |
304 continue; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
305 } |
32963 | 306 |
307 c = strlen(trbuf); | |
308 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
309 } |
32963 | 310 |
311 return trbuf; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
312 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
313 |
32963 | 314 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
|
315 { |
32963 | 316 int i = 0, ix, iy; |
317 uint32_t *buf = NULL; | |
318 uint32_t *drw = NULL; | |
319 register uint32_t tmp; | |
320 | |
321 /* register uint32_t yc; */ | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
322 |
32963 | 323 if (!bf || (bf->Image == NULL)) |
324 return; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
325 |
32963 | 326 i = bf->Width * (bf->Height / max) * ofs; |
327 buf = (uint32_t *)image_buffer; | |
328 drw = (uint32_t *)bf->Image; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
329 |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
330 #if 1 |
32963 | 331 for (iy = y; iy < (int)(y + bf->Height / max); iy++) |
332 for (ix = x; ix < (int)(x + bf->Width); ix++) { | |
333 tmp = drw[i++]; | |
334 | |
335 if (tmp != 0x00ff00ff) | |
336 buf[iy * image_width + ix] = tmp; | |
337 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
338 #else |
32963 | 339 yc = y * image_width; |
340 | |
341 for (iy = y; iy < (int)(y + bf->Height / max); iy++) { | |
342 for (ix = x; ix < (int)(x + bf->Width); ix++) { | |
343 tmp = drw[i++]; | |
344 | |
345 if (tmp != 0x00ff00ff) | |
346 buf[yc + ix] = tmp; | |
347 } | |
348 | |
349 yc += image_width; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
350 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
351 #endif |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
352 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
353 |
32963 | 354 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
|
355 { |
32963 | 356 int i = 0, w, r, ix, iy; |
357 uint32_t *buf = NULL; | |
358 uint32_t *drw = NULL; | |
359 register uint32_t tmp; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
360 |
32963 | 361 if (!bf || (bf->Image == NULL)) |
362 return; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
363 |
32963 | 364 buf = (uint32_t *)image_buffer; |
365 drw = (uint32_t *)bf->Image; | |
366 w = bf->Width * frac; | |
367 r = bf->Width - w; | |
368 | |
369 for (iy = y; iy < (int)(y + bf->Height); iy++) { | |
370 for (ix = x; ix < (int)(x + w); ix++) { | |
371 tmp = drw[i++]; | |
372 | |
373 if (tmp != 0x00ff00ff) | |
374 buf[iy * image_width + ix] = tmp; | |
375 } | |
376 | |
377 i += r; | |
378 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
379 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
380 |
32963 | 381 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
|
382 { |
32963 | 383 wItem *item; |
384 txSample *image = NULL; | |
385 int i, ofs; | |
386 | |
387 image_buffer = db; | |
388 image_width = window->Width; | |
389 | |
390 for (i = 0; i < nrItems + 1; i++) { | |
391 item = &Items[i]; | |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
392 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
393 switch (item->pressed) { |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
394 case btnPressed: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
395 ofs = 0; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
396 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
397 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
398 case btnReleased: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
399 ofs = 1; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
400 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
401 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
402 default: |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
403 ofs = 2; |
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 } |
32963 | 406 |
407 switch (item->type) { | |
408 case itButton: | |
409 PutImage(&item->Bitmap, item->x, item->y, 3, ofs); | |
410 break; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
411 |
32963 | 412 case itPotmeter: |
413 if (item->numphases == 1) | |
414 SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0f); | |
415 else | |
416 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0f)); | |
417 break; | |
418 | |
419 case itHPotmeter: | |
420 if (item->numphases == 1) | |
421 SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0f); | |
422 else | |
423 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0f)); | |
32965 | 424 PutImage(&item->Mask, item->x + (item->width - item->pwidth) * (item->value / 100.0f), item->y, 3, ofs); |
32963 | 425 break; |
426 | |
427 case itVPotmeter: | |
428 PutImage(&item->Bitmap, item->x, item->y, item->numphases, item->numphases * (1.0f - item->value / 100.0f)); | |
32965 | 429 PutImage(&item->Mask, item->x, item->y + (item->height - item->pheight) * (1.0f - item->value / 100.0f), 3, ofs); |
32963 | 430 break; |
431 | |
432 case itSLabel: | |
433 image = fntRender(item, 0, item->label); | |
434 if (image) | |
435 PutImage(image, item->x, item->y, 1, 0); | |
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 |
480 wsConvert(window, db, size); | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
481 } |