Mercurial > mplayer.hg
annotate gui/ui/render.c @ 36995:efec4d517450
Activate the #else part of the conditional directive.
This code should be faster.
author | ib |
---|---|
date | Thu, 27 Mar 2014 13:43:19 +0000 |
parents | 167442bc79d0 |
children | 9402cbe067c8 |
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" |
34175 | 27 #include "gui/util/string.h" |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
28 |
36984
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
29 #include "access_mpcontext.h" |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
30 #include "help_mp.h" |
32963 | 31 #include "libavutil/avstring.h" |
32954 | 32 #include "osdep/timer.h" |
32963 | 33 #include "stream/stream.h" |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
34 |
33269 | 35 #define DLABEL_DELAY 2500 // in milliseconds |
36 | |
32963 | 37 static char *image_buffer; |
36993 | 38 static int drawbuf_width; |
32956 | 39 |
36980 | 40 /** |
36984
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
41 * @brief Convert #guiInfo member Filename. |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
42 * |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
43 * @param how 0 (cut file path and extension), |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
44 * 1 (additionally, convert lower case) or |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
45 * 2 (additionally, convert upper case) |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
46 * @param fname pointer to a buffer to receive the converted Filename |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
47 * @param maxlen size of @a fname buffer |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
48 * |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
49 * @return pointer to @a fname buffer |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
50 */ |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
51 static char *TranslateFilename(int how, char *fname, size_t maxlen) |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
52 { |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
53 char *p; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
54 size_t len; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
55 stream_t *stream; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
56 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
57 switch (guiInfo.StreamType) { |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
58 case STREAMTYPE_FILE: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
59 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
60 if (guiInfo.Filename && *guiInfo.Filename) { |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
61 p = strrchr(guiInfo.Filename, '/'); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
62 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
63 if (p) |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
64 av_strlcpy(fname, p + 1, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
65 else |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
66 av_strlcpy(fname, guiInfo.Filename, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
67 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
68 len = strlen(fname); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
69 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
70 if (len > 3 && fname[len - 3] == '.') |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
71 fname[len - 3] = 0; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
72 else if (len > 4 && fname[len - 4] == '.') |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
73 fname[len - 4] = 0; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
74 else if (len > 5 && fname[len - 5] == '.') |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
75 fname[len - 5] = 0; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
76 } else |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
77 av_strlcpy(fname, MSGTR_GUI_MSG_NoFileLoaded, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
78 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
79 break; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
80 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
81 case STREAMTYPE_STREAM: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
82 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
83 av_strlcpy(fname, guiInfo.Filename, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
84 break; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
85 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
86 case STREAMTYPE_CDDA: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
87 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
88 snprintf(fname, maxlen, MSGTR_GUI_TitleN, guiInfo.Track); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
89 break; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
90 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
91 case STREAMTYPE_VCD: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
92 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
93 snprintf(fname, maxlen, MSGTR_GUI_TitleN, guiInfo.Track - 1); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
94 break; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
95 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
96 case STREAMTYPE_DVD: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
97 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
98 if (guiInfo.Chapter) |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
99 snprintf(fname, maxlen, MSGTR_GUI_ChapterN, guiInfo.Chapter); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
100 else |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
101 av_strlcpy(fname, MSGTR_GUI_NoChapter, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
102 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
103 break; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
104 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
105 case STREAMTYPE_TV: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
106 case STREAMTYPE_DVB: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
107 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
108 p = MSGTR_GUI_NoChannelName; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
109 stream = mpctx_get_stream(guiInfo.mpcontext); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
110 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
111 if (stream) |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
112 stream_control(stream, STREAM_CTRL_GET_CURRENT_CHANNEL, &p); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
113 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
114 av_strlcpy(fname, p, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
115 break; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
116 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
117 default: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
118 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
119 av_strlcpy(fname, MSGTR_GUI_MSG_NoMediaOpened, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
120 break; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
121 } |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
122 |
36988 | 123 if (how == 1) |
124 strlower(fname); | |
125 if (how == 2) | |
126 strupper(fname); | |
36984
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
127 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
128 return fname; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
129 } |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
130 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
131 /** |
36980 | 132 * @brief Translate all variables in the @a text. |
133 * | |
134 * @param text text containing variables | |
135 * | |
136 * @return new text with all variables translated | |
137 */ | |
36974 | 138 static char *TranslateVariables(const char *text) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
139 { |
36974 | 140 static char translation[512]; |
141 char trans[512]; | |
32972 | 142 unsigned int i, c; |
32963 | 143 int t; |
144 | |
36974 | 145 *translation = 0; |
32963 | 146 |
36974 | 147 for (c = 0, i = 0; i < strlen(text); i++) { |
148 if (text[i] != '$') { | |
149 if (c + 1 < sizeof(translation)) { | |
150 translation[c++] = text[i]; | |
151 translation[c] = 0; | |
32972 | 152 } |
32963 | 153 } else { |
36974 | 154 switch (text[++i]) { |
32963 | 155 case '1': |
33897 | 156 t = guiInfo.ElapsedTime; |
36979 | 157 HH_MM_SS: snprintf(trans, sizeof(trans), "%02d:%02d:%02d", t / 3600, t / 60 % 60, t % 60); |
36974 | 158 av_strlcat(translation, trans, sizeof(translation)); |
32963 | 159 break; |
160 | |
161 case '2': | |
33897 | 162 t = guiInfo.ElapsedTime; |
36979 | 163 MMMM_SS: snprintf(trans, sizeof(trans), "%04d:%02d", t / 60, t % 60); |
36974 | 164 av_strlcat(translation, trans, sizeof(translation)); |
32963 | 165 break; |
166 | |
167 case '3': | |
36974 | 168 snprintf(trans, sizeof(trans), "%02d", guiInfo.ElapsedTime / 3600); |
169 av_strlcat(translation, trans, sizeof(translation)); | |
32963 | 170 break; |
171 | |
172 case '4': | |
36978 | 173 snprintf(trans, sizeof(trans), "%02d", guiInfo.ElapsedTime / 60 % 60); |
36974 | 174 av_strlcat(translation, trans, sizeof(translation)); |
32963 | 175 break; |
176 | |
177 case '5': | |
36974 | 178 snprintf(trans, sizeof(trans), "%02d", guiInfo.ElapsedTime % 60); |
179 av_strlcat(translation, trans, sizeof(translation)); | |
32963 | 180 break; |
181 | |
36977 | 182 case '6': |
183 t = guiInfo.RunningTime; | |
36979 | 184 goto HH_MM_SS; |
36977 | 185 |
186 case '7': | |
187 t = guiInfo.RunningTime; | |
36979 | 188 goto MMMM_SS; |
36977 | 189 |
32963 | 190 case '8': |
36974 | 191 snprintf(trans, sizeof(trans), "%01d:%02d:%02d", guiInfo.ElapsedTime / 3600, (guiInfo.ElapsedTime / 60) % 60, guiInfo.ElapsedTime % 60); |
192 av_strlcat(translation, trans, sizeof(translation)); | |
32963 | 193 break; |
194 | |
195 case 'a': | |
33646 | 196 switch (guiInfo.AudioChannels) { |
32963 | 197 case 0: |
36974 | 198 av_strlcat(translation, "n", sizeof(translation)); |
32963 | 199 break; |
200 | |
201 case 1: | |
36974 | 202 av_strlcat(translation, "m", sizeof(translation)); |
32963 | 203 break; |
204 | |
205 case 2: | |
36978 | 206 av_strlcat(translation, guiInfo.AudioPassthrough ? "r" : "t", sizeof(translation)); |
32963 | 207 break; |
36910
11932adad7a2
Add symbol character 'r' for dynamic label variable $a.
ib
parents:
36909
diff
changeset
|
208 |
11932adad7a2
Add symbol character 'r' for dynamic label variable $a.
ib
parents:
36909
diff
changeset
|
209 default: |
36974 | 210 av_strlcat(translation, "r", sizeof(translation)); |
36910
11932adad7a2
Add symbol character 'r' for dynamic label variable $a.
ib
parents:
36909
diff
changeset
|
211 break; |
32963 | 212 } |
213 break; | |
214 | |
36977 | 215 case 'b': |
216 snprintf(trans, sizeof(trans), "%3.2f%%", guiInfo.Balance); | |
217 av_strlcat(translation, trans, sizeof(translation)); | |
218 break; | |
219 | |
220 case 'B': | |
221 snprintf(trans, sizeof(trans), "%3.1f", guiInfo.Balance); | |
222 av_strlcat(translation, trans, sizeof(translation)); | |
223 break; | |
224 | |
225 case 'C': | |
226 snprintf(trans, sizeof(trans), "%s", guiInfo.CodecName ? guiInfo.CodecName : ""); | |
227 av_strlcat(translation, trans, sizeof(translation)); | |
228 break; | |
229 | |
230 case 'D': | |
231 snprintf(trans, sizeof(trans), "%3.0f", guiInfo.Balance); | |
232 av_strlcat(translation, trans, sizeof(translation)); | |
233 break; | |
234 | |
235 case 'e': | |
236 if (guiInfo.Playing == GUI_PAUSE) | |
237 av_strlcat(translation, "e", sizeof(translation)); | |
238 break; | |
239 | |
240 case 'f': | |
241 TranslateFilename(1, trans, sizeof(trans)); | |
242 av_strlcat(translation, trans, sizeof(translation)); | |
243 break; | |
244 | |
245 case 'F': | |
246 TranslateFilename(2, trans, sizeof(trans)); | |
247 av_strlcat(translation, trans, sizeof(translation)); | |
248 break; | |
249 | |
250 case 'o': | |
251 TranslateFilename(0, trans, sizeof(trans)); | |
252 av_strlcat(translation, trans, sizeof(translation)); | |
253 break; | |
254 | |
255 case 'l': // legacy | |
256 case 'p': | |
257 if (guiInfo.Playing == GUI_PLAY) | |
258 av_strlcat(translation, "p", sizeof(translation)); | |
259 break; | |
260 | |
261 case 'P': | |
262 switch (guiInfo.Playing) { | |
263 case GUI_STOP: | |
264 av_strlcat(translation, "s", sizeof(translation)); | |
265 break; | |
266 | |
267 case GUI_PLAY: | |
268 av_strlcat(translation, "p", sizeof(translation)); | |
269 break; | |
270 | |
271 case GUI_PAUSE: | |
272 av_strlcat(translation, "e", sizeof(translation)); | |
273 break; | |
274 } | |
275 break; | |
276 | |
277 case 's': | |
278 if (guiInfo.Playing == GUI_STOP) | |
279 av_strlcat(translation, "s", sizeof(translation)); | |
280 break; | |
281 | |
282 case 't': | |
283 snprintf(trans, sizeof(trans), "%02d", guiInfo.Track); | |
284 av_strlcat(translation, trans, sizeof(translation)); | |
285 break; | |
286 | |
32963 | 287 case 'T': |
33555 | 288 switch (guiInfo.StreamType) { |
32963 | 289 case STREAMTYPE_FILE: |
36974 | 290 av_strlcat(translation, "f", sizeof(translation)); |
32963 | 291 break; |
292 | |
34077 | 293 case STREAMTYPE_STREAM: |
36974 | 294 av_strlcat(translation, "u", sizeof(translation)); |
34077 | 295 break; |
296 | |
34387 | 297 case STREAMTYPE_CDDA: |
36974 | 298 av_strlcat(translation, "a", sizeof(translation)); |
34387 | 299 break; |
300 | |
32963 | 301 case STREAMTYPE_VCD: |
36974 | 302 av_strlcat(translation, "v", sizeof(translation)); |
32963 | 303 break; |
304 | |
305 case STREAMTYPE_DVD: | |
36974 | 306 av_strlcat(translation, "d", sizeof(translation)); |
32963 | 307 break; |
308 | |
36429 | 309 case STREAMTYPE_TV: |
310 case STREAMTYPE_DVB: | |
36974 | 311 av_strlcat(translation, "b", sizeof(translation)); |
36429 | 312 break; |
313 | |
32963 | 314 default: |
36974 | 315 av_strlcat(translation, " ", sizeof(translation)); |
32963 | 316 break; |
317 } | |
318 break; | |
319 | |
36977 | 320 case 'U': |
321 snprintf(trans, sizeof(trans), "%3.0f", guiInfo.Volume); | |
322 av_strlcat(translation, trans, sizeof(translation)); | |
323 break; | |
324 | |
325 case 'v': | |
326 snprintf(trans, sizeof(trans), "%3.2f%%", guiInfo.Volume); | |
327 av_strlcat(translation, trans, sizeof(translation)); | |
328 break; | |
329 | |
330 case 'V': | |
331 snprintf(trans, sizeof(trans), "%3.1f", guiInfo.Volume); | |
332 av_strlcat(translation, trans, sizeof(translation)); | |
333 break; | |
334 | |
335 case 'x': | |
336 snprintf(trans, sizeof(trans), "%d", guiInfo.VideoWidth); | |
337 av_strlcat(translation, trans, sizeof(translation)); | |
338 break; | |
339 | |
340 case 'y': | |
341 snprintf(trans, sizeof(trans), "%d", guiInfo.VideoHeight); | |
342 av_strlcat(translation, trans, sizeof(translation)); | |
343 break; | |
344 | |
32963 | 345 case '$': |
36974 | 346 av_strlcat(translation, "$", sizeof(translation)); |
32963 | 347 break; |
348 | |
349 default: | |
350 continue; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
351 } |
32963 | 352 |
36974 | 353 c = strlen(translation); |
32963 | 354 } |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
355 } |
32963 | 356 |
36974 | 357 return translation; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
358 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
359 |
36993 | 360 static void PutImage(guiImage *img, int x, int y, int parts, int index) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
361 { |
36992 | 362 int i, ix, iy; |
36993 | 363 uint32_t *pixels, *drawbuf; |
36995 | 364 register uint32_t yc, pixel; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
365 |
36993 | 366 if (!img || (img->Image == NULL)) |
32963 | 367 return; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
368 |
36993 | 369 i = img->Width * (img->Height / parts) * index; |
370 drawbuf = (uint32_t *)image_buffer; | |
371 pixels = (uint32_t *)img->Image; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
372 |
36993 | 373 yc = y * drawbuf_width; |
32963 | 374 |
36993 | 375 for (iy = y; iy < (int)(y + img->Height / parts); iy++) { |
376 for (ix = x; ix < (int)(x + img->Width); ix++) { | |
377 pixel = pixels[i++]; | |
32963 | 378 |
36993 | 379 if (!IS_TRANSPARENT(pixel)) |
380 drawbuf[yc + ix] = pixel; | |
32963 | 381 } |
382 | |
36993 | 383 yc += drawbuf_width; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
384 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
385 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
386 |
36921
974ee5f5bf44
Rename SimplePotmeterPutImage() SinglePhasePutImage().
ib
parents:
36920
diff
changeset
|
387 static void SinglePhasePutImage(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
|
388 { |
32963 | 389 int i = 0, w, r, ix, iy; |
36992 | 390 uint32_t *drw, *buf; |
32963 | 391 register uint32_t tmp; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
392 |
32963 | 393 if (!bf || (bf->Image == NULL)) |
394 return; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
395 |
32963 | 396 buf = (uint32_t *)image_buffer; |
397 drw = (uint32_t *)bf->Image; | |
398 w = bf->Width * frac; | |
399 r = bf->Width - w; | |
400 | |
401 for (iy = y; iy < (int)(y + bf->Height); iy++) { | |
402 for (ix = x; ix < (int)(x + w); ix++) { | |
403 tmp = drw[i++]; | |
404 | |
33534 | 405 if (!IS_TRANSPARENT(tmp)) |
36993 | 406 buf[iy * drawbuf_width + ix] = tmp; |
32963 | 407 } |
408 | |
409 i += r; | |
410 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
411 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
412 |
36994 | 413 void RenderAll(wsWindow *window, guiItem *items, int nrItems, char *drawbuf) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
414 { |
35688 | 415 guiItem *item; |
33555 | 416 guiImage *image = NULL; |
36994 | 417 int i, index; |
32963 | 418 |
36994 | 419 image_buffer = drawbuf; |
36993 | 420 drawbuf_width = window->Width; |
32963 | 421 |
422 for (i = 0; i < nrItems + 1; i++) { | |
36994 | 423 item = &items[i]; |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
424 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
425 switch (item->pressed) { |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
426 case btnPressed: |
36994 | 427 index = 0; |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
428 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
429 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
430 case btnReleased: |
36994 | 431 index = 1; |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
432 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
433 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
434 default: |
36994 | 435 index = 2; |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
436 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
437 } |
32963 | 438 |
439 switch (item->type) { | |
440 case itButton: | |
35541 | 441 |
36994 | 442 PutImage(&item->Bitmap, item->x, item->y, 3, index); |
32963 | 443 break; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
444 |
36920 | 445 case itPimage: |
35541 | 446 |
32963 | 447 if (item->numphases == 1) |
36921
974ee5f5bf44
Rename SimplePotmeterPutImage() SinglePhasePutImage().
ib
parents:
36920
diff
changeset
|
448 SinglePhasePutImage(&item->Bitmap, item->x, item->y, item->value / 100.0); |
32963 | 449 else |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
450 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0)); |
35541 | 451 |
32963 | 452 break; |
453 | |
454 case itHPotmeter: | |
35541 | 455 |
32963 | 456 if (item->numphases == 1) |
36921
974ee5f5bf44
Rename SimplePotmeterPutImage() SinglePhasePutImage().
ib
parents:
36920
diff
changeset
|
457 SinglePhasePutImage(&item->Bitmap, item->x, item->y, item->value / 100.0); |
32963 | 458 else |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
459 PutImage(&item->Bitmap, item->x, item->y, item->numphases, (item->numphases - 1) * (item->value / 100.0)); |
35541 | 460 |
36994 | 461 PutImage(&item->Mask, item->x + (item->width - item->pwidth) * (item->value / 100.0), item->y, 3, index); |
32963 | 462 break; |
463 | |
464 case itVPotmeter: | |
35541 | 465 |
32970
3673c28ce811
Use double constants for higher precision calculations.
ib
parents:
32969
diff
changeset
|
466 PutImage(&item->Bitmap, item->x, item->y, item->numphases, item->numphases * (1.0 - item->value / 100.0)); |
36994 | 467 PutImage(&item->Mask, item->x, item->y + (item->height - item->pheight) * (1.0 - item->value / 100.0), 3, index); |
32963 | 468 break; |
469 | |
470 case itSLabel: | |
35541 | 471 |
32969 | 472 if (item->width == -1) |
473 item->width = fntTextWidth(item->fontid, item->label); | |
35541 | 474 |
33971 | 475 image = fntTextRender(item, 0, item->label); |
35541 | 476 |
32963 | 477 if (image) |
478 PutImage(image, item->x, item->y, 1, 0); | |
35541 | 479 |
32969 | 480 break; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
481 |
32963 | 482 case itDLabel: |
483 { | |
484 int x; | |
485 unsigned int d; | |
36974 | 486 char *t = TranslateVariables(item->label); |
32963 | 487 |
488 if (!item->text || (strcmp(item->text, t) != 0)) { | |
489 free(item->text); | |
490 item->text = strdup(t); | |
491 item->textwidth = fntTextWidth(item->fontid, t); | |
492 item->starttime = GetTimerMS(); | |
493 item->last_x = 0; | |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
494 } |
32963 | 495 |
496 d = GetTimerMS() - item->starttime; | |
497 | |
32964 | 498 if (d < DLABEL_DELAY) |
32963 | 499 x = item->last_x; // don't scroll yet |
500 else { | |
501 int l; | |
502 char c[2]; | |
503 | |
504 l = (item->textwidth ? item->textwidth : item->width); | |
35362 | 505 x = (l ? l - ((d - DLABEL_DELAY) / 20) % l - 1 : 0); |
32963 | 506 c[0] = *item->text; |
507 c[1] = '\0'; | |
508 | |
509 if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) { | |
510 item->starttime = GetTimerMS(); // stop again | |
511 item->last_x = x; // at current x pos | |
512 } | |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
513 } |
32963 | 514 |
33971 | 515 image = fntTextRender(item, x, t); |
32963 | 516 } |
517 | |
518 if (image) | |
519 PutImage(image, item->x, item->y, 1, 0); | |
520 | |
521 break; | |
522 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
523 } |
32963 | 524 |
36994 | 525 wsImageRender(window, drawbuf); |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
526 } |