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