annotate gui/mplayer/gui_common.c @ 32969:ad1a232df994

Make slabel work. It is amazing that so far no skin is using a slabel (static label), but the reason is quite simple. Former versions of the GUI crashed when rendering a slabel. The current GUI recognizes the malloc error but can't render the slabel due to (probable) lack of memory. An item that shall be fnt-rendered must have a valid item width. Additionally, a break was missing which caused a slabel that would have been already handled to erroneously run through the dlabel handling as well.
author ib
date Tue, 08 Mar 2011 15:29:19 +0000
parents 1fa7a299b1b4
children 3673c28ce811
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
1 /*
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
2 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
5 * it under the terms of the GNU General Public License as published by
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
7 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
8 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
12 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
13 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
14 * You should have received a copy of the GNU General Public License along
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
17 */
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
18
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
1aeeba137de9 Remove needless includes.
ib
parents: 32920
diff changeset
24 #include "gui_common.h"
1aeeba137de9 Remove needless includes.
ib
parents: 32920
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
28 #include "access_mpcontext.h"
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
32 #include "libavutil/avstring.h"
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
682b370ac832 Get prototype for GetTimerMS() from header file.
ib
parents: 32952
diff changeset
35 #include "osdep/timer.h"
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
36 #include "stream/stream.h"
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
37
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
38 static char *image_buffer;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
39 static int image_width;
32956
cde5d1cbb4bc Move global variables to top of file.
ib
parents: 32955
diff changeset
40
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
43 int i;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
44 char *p;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
45 size_t len;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
46
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
47 switch (guiIntfStruct.StreamType) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
51
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
52 case STREAMTYPE_FILE:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
53 if (guiIntfStruct.Filename && guiIntfStruct.Filename[0]) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
54 p = strrchr(guiIntfStruct.Filename, '/');
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
55
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
56 if (p)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
59 av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
60
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
61 len = strlen(tmp);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
62
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
63 if (len > 3 && tmp[len - 3] == '.')
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
64 tmp[len - 3] = 0;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
65 else if (len > 4 && tmp[len - 4] == '.')
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
66 tmp[len - 4] = 0;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
67 else if (len > 5 && tmp[len - 5] == '.')
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
68 tmp[len - 5] = 0;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
69 } else
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
70 av_strlcpy(tmp, MSGTR_NoFileLoaded, tmplen);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
71 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
72
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 27207
diff changeset
73 #ifdef CONFIG_DVDREAD
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
74 case STREAMTYPE_DVD:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
75 if (guiIntfStruct.DVD.current_chapter)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
76 snprintf(tmp, tmplen, MSGTR_Chapter, guiIntfStruct.DVD.current_chapter);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
77 else
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
78 av_strlcat(tmp, MSGTR_NoChapter, tmplen);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
79 break;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
80 #endif
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
81
27370
14c5017f40d2 Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents: 27341
diff changeset
82 #ifdef CONFIG_VCD
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
83 case STREAMTYPE_VCD:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
84 snprintf(tmp, tmplen, MSGTR_VCDTrack, guiIntfStruct.Track);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
85 break;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
86 #endif
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
87
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
88 default:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
89 av_strlcpy(tmp, MSGTR_NoMediaOpened, tmplen);
32968
1fa7a299b1b4 Cosmetic: Add missing break.
ib
parents: 32967
diff changeset
90 break;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
91 }
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
92
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
93 if (c) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
94 for (i = 0; i < (int)strlen(tmp); i++) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
95 int t = 0;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
96
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
97 if (c == 1)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
98 if (tmp[i] >= 'A' && tmp[i] <= 'Z')
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
99 t = 32;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
100
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
101 if (c == 2)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
102 if (tmp[i] >= 'a' && tmp[i] <= 'z')
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
103 t = -32;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
104
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
105 tmp[i] = (char)(tmp[i] + t);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
106 }
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
107 }
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
108 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
109
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
110 /* Unsafe! Pass only null-terminated strings as (char *)str. */
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
111 char *Translate(char *str)
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
112 {
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
113 static char trbuf[512];
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
114 char tmp[512];
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
115 int i, c;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
116 int t;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
117 int strsize = 0;
32967
d9363dbd3f83 Avoid mixing declaration and code.
ib
parents: 32966
diff changeset
118 mixer_t *mixer;
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
119
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
120 memset(trbuf, 0, 512);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
121 memset(tmp, 0, 128);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
122 strsize = strlen(str);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
123
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
124 for (c = 0, i = 0; i < strsize; i++) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
125 if (str[i] != '$') {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
126 trbuf[c++] = str[i];
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
127 trbuf[c] = 0;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
128 } else {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
129 switch (str[++i]) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
130 case 't':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
131 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.Track);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
132 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
133 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
134
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
135 case 'o':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
136 TranslateFilename(0, tmp, sizeof(tmp));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
137 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
138 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
139
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
140 case 'f':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
141 TranslateFilename(1, tmp, sizeof(tmp));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
142 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
143 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
144
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
145 case 'F':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
146 TranslateFilename(2, tmp, sizeof(tmp));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
147 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
148 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
149
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
150 case '6':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
151 t = guiIntfStruct.LengthInSec;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
152 goto calclengthhhmmss;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
153
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
154 case '1':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
155 t = guiIntfStruct.TimeSec;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
156 calclengthhhmmss:
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
157 snprintf(tmp, sizeof(tmp), "%02d:%02d:%02d", t / 3600, t / 60 % 60, t % 60);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
158 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
159 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
160
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
161 case '7':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
162 t = guiIntfStruct.LengthInSec;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
163 goto calclengthmmmmss;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
164
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
165 case '2':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
166 t = guiIntfStruct.TimeSec;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
167 calclengthmmmmss:
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
168 snprintf(tmp, sizeof(tmp), "%04d:%02d", t / 60, t % 60);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
169 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
170 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
171
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
172 case '3':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
173 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec / 3600);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
174 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
175 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
176
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
177 case '4':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
178 snprintf(tmp, sizeof(tmp), "%02d", (guiIntfStruct.TimeSec / 60) % 60);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
179 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
180 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
181
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
182 case '5':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
183 snprintf(tmp, sizeof(tmp), "%02d", guiIntfStruct.TimeSec % 60);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
184 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
185 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
186
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
187 case '8':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
188 snprintf(tmp, sizeof(tmp), "%01d:%02d:%02d", guiIntfStruct.TimeSec / 3600, (guiIntfStruct.TimeSec / 60) % 60, guiIntfStruct.TimeSec % 60);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
189 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
190 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
191
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
192 case 'v':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
193 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Volume);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
194 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
195 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
196
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
197 case 'V':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
198 snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Volume);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
199 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
200 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
201
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
202 case 'b':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
203 snprintf(tmp, sizeof(tmp), "%3.2f%%", guiIntfStruct.Balance);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
204 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
205 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
206
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
207 case 'B':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
208 snprintf(tmp, sizeof(tmp), "%3.1f", guiIntfStruct.Balance);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
209 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
210 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
211
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
212 case 'd':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
213 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.FrameDrop);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
214 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
215 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
216
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
217 case 'x':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
218 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieWidth);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
219 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
220 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
221
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
222 case 'y':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
223 snprintf(tmp, sizeof(tmp), "%d", guiIntfStruct.MovieHeight);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
224 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
225 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
226
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
227 case 'C':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
228 snprintf(tmp, sizeof(tmp), "%s", guiIntfStruct.sh_video ? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : "");
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
229 av_strlcat(trbuf, tmp, sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
230 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
231
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
232 case 's':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
233 if (guiIntfStruct.Playing == 0)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
234 av_strlcat(trbuf, "s", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
235 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
236
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
237 case 'l':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
238 if (guiIntfStruct.Playing == 1)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
239 av_strlcat(trbuf, "p", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
240 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
241
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
242 case 'e':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
243 if (guiIntfStruct.Playing == 2)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
244 av_strlcat(trbuf, "e", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
245 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
246
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
247 case 'a':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
248
32967
d9363dbd3f83 Avoid mixing declaration and code.
ib
parents: 32966
diff changeset
249 mixer = mpctx_get_mixer(guiIntfStruct.mpcontext);
d9363dbd3f83 Avoid mixing declaration and code.
ib
parents: 32966
diff changeset
250
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
251 if (mixer->muted) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
252 av_strlcat(trbuf, "n", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
253 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
254 }
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
255
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
256 switch (guiIntfStruct.AudioType) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
257 case 0:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
258 av_strlcat(trbuf, "n", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
259 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
260
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
261 case 1:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
262 av_strlcat(trbuf, "m", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
263 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
264
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
265 case 2:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
266 av_strlcat(trbuf, "t", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
267 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
268 }
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
269
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
270 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
271
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
272 case 'T':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
273 switch (guiIntfStruct.StreamType) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
274 case STREAMTYPE_FILE:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
275 av_strlcat(trbuf, "f", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
276 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
277
27370
14c5017f40d2 Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents: 27341
diff changeset
278 #ifdef CONFIG_VCD
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
279 case STREAMTYPE_VCD:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
280 av_strlcat(trbuf, "v", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
281 break;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
282 #endif
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
283
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
284 case STREAMTYPE_STREAM:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
285 av_strlcat(trbuf, "u", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
286 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
287
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 27207
diff changeset
288 #ifdef CONFIG_DVDREAD
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
289 case STREAMTYPE_DVD:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
290 av_strlcat(trbuf, "d", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
291 break;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
292 #endif
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
293
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
294 default:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
295 av_strlcat(trbuf, " ", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
296 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
297 }
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
298 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
299
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
300 case '$':
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
301 av_strlcat(trbuf, "$", sizeof(trbuf));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
302 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
303
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
304 default:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
305 continue;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
306 }
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
307
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
308 c = strlen(trbuf);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
309 }
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
310 }
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
311
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
315 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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
317 int i = 0, ix, iy;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
318 uint32_t *buf = NULL;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
319 uint32_t *drw = NULL;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
320 register uint32_t tmp;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
321
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
322 /* register uint32_t yc; */
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
323
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
324 if (!bf || (bf->Image == NULL))
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
325 return;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
326
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
327 i = bf->Width * (bf->Height / max) * ofs;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
328 buf = (uint32_t *)image_buffer;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
332 for (iy = y; iy < (int)(y + bf->Height / max); iy++)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
333 for (ix = x; ix < (int)(x + bf->Width); ix++) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
334 tmp = drw[i++];
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
335
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
336 if (tmp != 0x00ff00ff)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
337 buf[iy * image_width + ix] = tmp;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
338 }
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
339 #else
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
340 yc = y * image_width;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
341
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
342 for (iy = y; iy < (int)(y + bf->Height / max); iy++) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
343 for (ix = x; ix < (int)(x + bf->Width); ix++) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
344 tmp = drw[i++];
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
345
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
346 if (tmp != 0x00ff00ff)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
347 buf[yc + ix] = tmp;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
348 }
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
349
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
355 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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
357 int i = 0, w, r, ix, iy;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
358 uint32_t *buf = NULL;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
359 uint32_t *drw = NULL;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
360 register uint32_t tmp;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
361
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
362 if (!bf || (bf->Image == NULL))
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
363 return;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
364
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
365 buf = (uint32_t *)image_buffer;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
366 drw = (uint32_t *)bf->Image;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
367 w = bf->Width * frac;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
368 r = bf->Width - w;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
369
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
370 for (iy = y; iy < (int)(y + bf->Height); iy++) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
371 for (ix = x; ix < (int)(x + w); ix++) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
372 tmp = drw[i++];
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
373
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
374 if (tmp != 0x00ff00ff)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
375 buf[iy * image_width + ix] = tmp;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
376 }
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
377
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
378 i += r;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
384 wItem *item;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
385 txSample *image = NULL;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
386 int i, ofs;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
387
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
388 image_buffer = db;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
389 image_width = window->Width;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
390
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
391 for (i = 0; i < nrItems + 1; i++) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
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
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
407
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
408 switch (item->type) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
409 case itButton:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
410 PutImage(&item->Bitmap, item->x, item->y, 3, ofs);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
411 break;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
412
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
413 case itPotmeter:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
414 if (item->numphases == 1)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
415 SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0f);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
416 else
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
417 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0f));
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
418 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
419
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
420 case itHPotmeter:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
421 if (item->numphases == 1)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
422 SimplePotmeterPutImage(&item->Bitmap, item->x, item->y, item->value / 100.0f);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
423 else
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
424 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0f));
32965
3242637f94b6 Remove needless casts.
ib
parents: 32964
diff changeset
425 PutImage(&item->Mask, item->x + (item->width - item->pwidth) * (item->value / 100.0f), item->y, 3, ofs);
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
426 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
427
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
428 case itVPotmeter:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
429 PutImage(&item->Bitmap, item->x, item->y, item->numphases, item->numphases * (1.0f - item->value / 100.0f));
32965
3242637f94b6 Remove needless casts.
ib
parents: 32964
diff changeset
430 PutImage(&item->Mask, item->x, item->y + (item->height - item->pheight) * (1.0f - item->value / 100.0f), 3, ofs);
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
431 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
432
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
433 case itSLabel:
32969
ad1a232df994 Make slabel work.
ib
parents: 32968
diff changeset
434 if (item->width == -1)
ad1a232df994 Make slabel work.
ib
parents: 32968
diff changeset
435 item->width = fntTextWidth(item->fontid, item->label);
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
436 image = fntRender(item, 0, item->label);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
437 if (image)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
438 PutImage(image, item->x, item->y, 1, 0);
32969
ad1a232df994 Make slabel work.
ib
parents: 32968
diff changeset
439 break;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
440
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
441 case itDLabel:
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
442 {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
443 int x;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
444 unsigned int d;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
445 char *t = Translate(item->label);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
446
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
447 if (!item->text || (strcmp(item->text, t) != 0)) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
448 free(item->text);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
449 item->text = strdup(t);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
450 item->textwidth = fntTextWidth(item->fontid, t);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
451 item->starttime = GetTimerMS();
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
452 item->last_x = 0;
32761
3ceeb62a1125 Improve the readability of dynamic labels which scroll.
ib
parents: 32759
diff changeset
453 }
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
454
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
455 d = GetTimerMS() - item->starttime;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
456
32964
cddc94d28830 Cosmetic: Rename macro controlling the dlabel delay.
ib
parents: 32963
diff changeset
457 if (d < DLABEL_DELAY)
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
458 x = item->last_x; // don't scroll yet
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
459 else {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
460 int l;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
461 char c[2];
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
462
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
463 l = (item->textwidth ? item->textwidth : item->width);
32964
cddc94d28830 Cosmetic: Rename macro controlling the dlabel delay.
ib
parents: 32963
diff changeset
464 x = l - ((d - DLABEL_DELAY) / 20) % l - 1;
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
465 c[0] = *item->text;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
466 c[1] = '\0';
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
467
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
468 if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) {
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
469 item->starttime = GetTimerMS(); // stop again
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
470 item->last_x = x; // at current x pos
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
471 }
32761
3ceeb62a1125 Improve the readability of dynamic labels which scroll.
ib
parents: 32759
diff changeset
472 }
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
473
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
474 image = fntRender(item, x, t);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
475 }
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
476
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
477 if (image)
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
478 PutImage(image, item->x, item->y, 1, 0);
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
479
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
480 break;
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
481 }
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
482 }
32963
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
483
ce00479b68ce Cosmetic: Format to MPlayer coding style.
ib
parents: 32962
diff changeset
484 wsConvert(window, db, size);
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
485 }