Mercurial > mplayer.hg
annotate gui/ui/render.c @ 37120:4b62802c8ad6
configure add CONFIG_QPELDSP to avoid breaking build
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
author | michael |
---|---|
date | Fri, 30 May 2014 00:59:49 +0000 |
parents | b28b632efeef |
children |
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 |
37017 | 19 /** |
20 * @file | |
21 * @brief GUI rendering | |
22 */ | |
23 | |
37053 | 24 #include <math.h> |
33123
9566100d88a1
Replace inttypes.h by stdint.h and remove inttypes.h where unneeded.
ib
parents:
32982
diff
changeset
|
25 #include <stdint.h> |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
26 #include <stdio.h> |
32963 | 27 #include <stdlib.h> |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
28 #include <string.h> |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
29 |
33556 | 30 #include "render.h" |
32952 | 31 #include "gui/interface.h" |
37007 | 32 #include "gui/app/gui.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
25603
diff
changeset
|
33 #include "gui/skin/font.h" |
34175 | 34 #include "gui/util/string.h" |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
35 |
36984
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
36 #include "access_mpcontext.h" |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
37 #include "help_mp.h" |
32963 | 38 #include "libavutil/avstring.h" |
37053 | 39 #include "libavutil/common.h" |
32954 | 40 #include "osdep/timer.h" |
32963 | 41 #include "stream/stream.h" |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
42 |
37016 | 43 /** |
44 * @brief Time in milliseconds a scrolling dlabel stops | |
45 * when reaching the left margin until scrolling starts over | |
46 */ | |
47 #define DLABEL_DELAY 2500 | |
33269 | 48 |
36980 | 49 /** |
36984
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
50 * @brief Convert #guiInfo member Filename. |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
51 * |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
52 * @param how 0 (cut file path and extension), |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
53 * 1 (additionally, convert lower case) or |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
54 * 2 (additionally, convert upper case) |
37065 | 55 * @param fname memory location of a buffer to receive the converted Filename |
56 * @param maxlen size of the @a fname buffer | |
36984
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
57 * |
37065 | 58 * @return pointer to the @a fname buffer |
36984
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 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
|
61 { |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
62 char *p; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
63 size_t len; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
64 stream_t *stream; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
65 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
66 switch (guiInfo.StreamType) { |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
67 case STREAMTYPE_FILE: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
68 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
69 if (guiInfo.Filename && *guiInfo.Filename) { |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
70 p = strrchr(guiInfo.Filename, '/'); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
71 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
72 if (p) |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
73 av_strlcpy(fname, p + 1, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
74 else |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
75 av_strlcpy(fname, guiInfo.Filename, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
76 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
77 len = strlen(fname); |
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 if (len > 3 && fname[len - 3] == '.') |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
80 fname[len - 3] = 0; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
81 else if (len > 4 && fname[len - 4] == '.') |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
82 fname[len - 4] = 0; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
83 else if (len > 5 && fname[len - 5] == '.') |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
84 fname[len - 5] = 0; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
85 } else |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
86 av_strlcpy(fname, MSGTR_GUI_MSG_NoFileLoaded, maxlen); |
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 break; |
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 case STREAMTYPE_STREAM: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
91 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
92 av_strlcpy(fname, guiInfo.Filename, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
93 break; |
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 case STREAMTYPE_CDDA: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
96 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
97 snprintf(fname, maxlen, MSGTR_GUI_TitleN, guiInfo.Track); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
98 break; |
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 case STREAMTYPE_VCD: |
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 snprintf(fname, maxlen, MSGTR_GUI_TitleN, guiInfo.Track - 1); |
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_DVD: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
106 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
107 if (guiInfo.Chapter) |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
108 snprintf(fname, maxlen, MSGTR_GUI_ChapterN, guiInfo.Chapter); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
109 else |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
110 av_strlcpy(fname, MSGTR_GUI_NoChapter, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
111 |
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 case STREAMTYPE_TV: |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
115 case STREAMTYPE_DVB: |
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 p = MSGTR_GUI_NoChannelName; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
118 stream = mpctx_get_stream(guiInfo.mpcontext); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
119 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
120 if (stream) |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
121 stream_control(stream, STREAM_CTRL_GET_CURRENT_CHANNEL, &p); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
122 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
123 av_strlcpy(fname, p, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
124 break; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
125 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
126 default: |
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 av_strlcpy(fname, MSGTR_GUI_MSG_NoMediaOpened, maxlen); |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
129 break; |
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 |
36988 | 132 if (how == 1) |
133 strlower(fname); | |
134 if (how == 2) | |
135 strupper(fname); | |
36984
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
136 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
137 return fname; |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
138 } |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
139 |
3f3a415d605b
Move most of TranslateFilename() back to the renderer files.
ib
parents:
36980
diff
changeset
|
140 /** |
36980 | 141 * @brief Translate all variables in the @a text. |
142 * | |
143 * @param text text containing variables | |
144 * | |
145 * @return new text with all variables translated | |
146 */ | |
36974 | 147 static char *TranslateVariables(const char *text) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
148 { |
36974 | 149 static char translation[512]; |
150 char trans[512]; | |
32972 | 151 unsigned int i, c; |
32963 | 152 int t; |
153 | |
36974 | 154 *translation = 0; |
32963 | 155 |
36974 | 156 for (c = 0, i = 0; i < strlen(text); i++) { |
157 if (text[i] != '$') { | |
158 if (c + 1 < sizeof(translation)) { | |
159 translation[c++] = text[i]; | |
160 translation[c] = 0; | |
32972 | 161 } |
32963 | 162 } else { |
36974 | 163 switch (text[++i]) { |
32963 | 164 case '1': |
33897 | 165 t = guiInfo.ElapsedTime; |
36979 | 166 HH_MM_SS: snprintf(trans, sizeof(trans), "%02d:%02d:%02d", t / 3600, t / 60 % 60, t % 60); |
36974 | 167 av_strlcat(translation, trans, sizeof(translation)); |
32963 | 168 break; |
169 | |
170 case '2': | |
33897 | 171 t = guiInfo.ElapsedTime; |
36979 | 172 MMMM_SS: snprintf(trans, sizeof(trans), "%04d:%02d", t / 60, t % 60); |
36974 | 173 av_strlcat(translation, trans, sizeof(translation)); |
32963 | 174 break; |
175 | |
176 case '3': | |
36974 | 177 snprintf(trans, sizeof(trans), "%02d", guiInfo.ElapsedTime / 3600); |
178 av_strlcat(translation, trans, sizeof(translation)); | |
32963 | 179 break; |
180 | |
181 case '4': | |
36978 | 182 snprintf(trans, sizeof(trans), "%02d", guiInfo.ElapsedTime / 60 % 60); |
36974 | 183 av_strlcat(translation, trans, sizeof(translation)); |
32963 | 184 break; |
185 | |
186 case '5': | |
36974 | 187 snprintf(trans, sizeof(trans), "%02d", guiInfo.ElapsedTime % 60); |
188 av_strlcat(translation, trans, sizeof(translation)); | |
32963 | 189 break; |
190 | |
36977 | 191 case '6': |
192 t = guiInfo.RunningTime; | |
36979 | 193 goto HH_MM_SS; |
36977 | 194 |
195 case '7': | |
196 t = guiInfo.RunningTime; | |
36979 | 197 goto MMMM_SS; |
36977 | 198 |
32963 | 199 case '8': |
36974 | 200 snprintf(trans, sizeof(trans), "%01d:%02d:%02d", guiInfo.ElapsedTime / 3600, (guiInfo.ElapsedTime / 60) % 60, guiInfo.ElapsedTime % 60); |
201 av_strlcat(translation, trans, sizeof(translation)); | |
32963 | 202 break; |
203 | |
204 case 'a': | |
33646 | 205 switch (guiInfo.AudioChannels) { |
32963 | 206 case 0: |
36974 | 207 av_strlcat(translation, "n", sizeof(translation)); |
32963 | 208 break; |
209 | |
210 case 1: | |
36974 | 211 av_strlcat(translation, "m", sizeof(translation)); |
32963 | 212 break; |
213 | |
214 case 2: | |
36978 | 215 av_strlcat(translation, guiInfo.AudioPassthrough ? "r" : "t", sizeof(translation)); |
32963 | 216 break; |
36910
11932adad7a2
Add symbol character 'r' for dynamic label variable $a.
ib
parents:
36909
diff
changeset
|
217 |
11932adad7a2
Add symbol character 'r' for dynamic label variable $a.
ib
parents:
36909
diff
changeset
|
218 default: |
36974 | 219 av_strlcat(translation, "r", sizeof(translation)); |
36910
11932adad7a2
Add symbol character 'r' for dynamic label variable $a.
ib
parents:
36909
diff
changeset
|
220 break; |
32963 | 221 } |
222 break; | |
223 | |
36977 | 224 case 'b': |
225 snprintf(trans, sizeof(trans), "%3.2f%%", guiInfo.Balance); | |
226 av_strlcat(translation, trans, sizeof(translation)); | |
227 break; | |
228 | |
229 case 'B': | |
230 snprintf(trans, sizeof(trans), "%3.1f", guiInfo.Balance); | |
231 av_strlcat(translation, trans, sizeof(translation)); | |
232 break; | |
233 | |
234 case 'C': | |
235 snprintf(trans, sizeof(trans), "%s", guiInfo.CodecName ? guiInfo.CodecName : ""); | |
236 av_strlcat(translation, trans, sizeof(translation)); | |
237 break; | |
238 | |
239 case 'D': | |
240 snprintf(trans, sizeof(trans), "%3.0f", guiInfo.Balance); | |
241 av_strlcat(translation, trans, sizeof(translation)); | |
242 break; | |
243 | |
244 case 'e': | |
245 if (guiInfo.Playing == GUI_PAUSE) | |
246 av_strlcat(translation, "e", sizeof(translation)); | |
247 break; | |
248 | |
249 case 'f': | |
250 TranslateFilename(1, trans, sizeof(trans)); | |
251 av_strlcat(translation, trans, sizeof(translation)); | |
252 break; | |
253 | |
254 case 'F': | |
255 TranslateFilename(2, trans, sizeof(trans)); | |
256 av_strlcat(translation, trans, sizeof(translation)); | |
257 break; | |
258 | |
259 case 'o': | |
260 TranslateFilename(0, trans, sizeof(trans)); | |
261 av_strlcat(translation, trans, sizeof(translation)); | |
262 break; | |
263 | |
264 case 'l': // legacy | |
265 case 'p': | |
266 if (guiInfo.Playing == GUI_PLAY) | |
267 av_strlcat(translation, "p", sizeof(translation)); | |
268 break; | |
269 | |
270 case 'P': | |
271 switch (guiInfo.Playing) { | |
272 case GUI_STOP: | |
273 av_strlcat(translation, "s", sizeof(translation)); | |
274 break; | |
275 | |
276 case GUI_PLAY: | |
277 av_strlcat(translation, "p", sizeof(translation)); | |
278 break; | |
279 | |
280 case GUI_PAUSE: | |
281 av_strlcat(translation, "e", sizeof(translation)); | |
282 break; | |
283 } | |
284 break; | |
285 | |
286 case 's': | |
287 if (guiInfo.Playing == GUI_STOP) | |
288 av_strlcat(translation, "s", sizeof(translation)); | |
289 break; | |
290 | |
291 case 't': | |
292 snprintf(trans, sizeof(trans), "%02d", guiInfo.Track); | |
293 av_strlcat(translation, trans, sizeof(translation)); | |
294 break; | |
295 | |
32963 | 296 case 'T': |
33555 | 297 switch (guiInfo.StreamType) { |
32963 | 298 case STREAMTYPE_FILE: |
36974 | 299 av_strlcat(translation, "f", sizeof(translation)); |
32963 | 300 break; |
301 | |
34077 | 302 case STREAMTYPE_STREAM: |
36974 | 303 av_strlcat(translation, "u", sizeof(translation)); |
34077 | 304 break; |
305 | |
34387 | 306 case STREAMTYPE_CDDA: |
36974 | 307 av_strlcat(translation, "a", sizeof(translation)); |
34387 | 308 break; |
309 | |
32963 | 310 case STREAMTYPE_VCD: |
36974 | 311 av_strlcat(translation, "v", sizeof(translation)); |
32963 | 312 break; |
313 | |
314 case STREAMTYPE_DVD: | |
36974 | 315 av_strlcat(translation, "d", sizeof(translation)); |
32963 | 316 break; |
317 | |
36429 | 318 case STREAMTYPE_TV: |
319 case STREAMTYPE_DVB: | |
36974 | 320 av_strlcat(translation, "b", sizeof(translation)); |
36429 | 321 break; |
322 | |
32963 | 323 default: |
36974 | 324 av_strlcat(translation, " ", sizeof(translation)); |
32963 | 325 break; |
326 } | |
327 break; | |
328 | |
36977 | 329 case 'U': |
330 snprintf(trans, sizeof(trans), "%3.0f", guiInfo.Volume); | |
331 av_strlcat(translation, trans, sizeof(translation)); | |
332 break; | |
333 | |
334 case 'v': | |
335 snprintf(trans, sizeof(trans), "%3.2f%%", guiInfo.Volume); | |
336 av_strlcat(translation, trans, sizeof(translation)); | |
337 break; | |
338 | |
339 case 'V': | |
340 snprintf(trans, sizeof(trans), "%3.1f", guiInfo.Volume); | |
341 av_strlcat(translation, trans, sizeof(translation)); | |
342 break; | |
343 | |
344 case 'x': | |
345 snprintf(trans, sizeof(trans), "%d", guiInfo.VideoWidth); | |
346 av_strlcat(translation, trans, sizeof(translation)); | |
347 break; | |
348 | |
349 case 'y': | |
350 snprintf(trans, sizeof(trans), "%d", guiInfo.VideoHeight); | |
351 av_strlcat(translation, trans, sizeof(translation)); | |
352 break; | |
353 | |
32963 | 354 case '$': |
36974 | 355 av_strlcat(translation, "$", sizeof(translation)); |
32963 | 356 break; |
357 | |
358 default: | |
359 continue; | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
360 } |
32963 | 361 |
36974 | 362 c = strlen(translation); |
32963 | 363 } |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
364 } |
32963 | 365 |
36974 | 366 return translation; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
367 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
368 |
37017 | 369 /** |
370 * @brief Put a part of a #guiImage image into a (window's) draw buffer. | |
371 * | |
372 * @param x x position where to start in the draw buffer | |
373 * @param y y position where to start in the draw buffer | |
374 * @param drawbuf draw buffer where the image should be put in | |
375 * @param drawbuf_width width of the draw buffer | |
376 * @param img image (containing several phases, i.e. image parts) | |
377 * @param parts number of parts in the image | |
378 * @param index index of the part of the image to be drawn | |
379 * @param below flag indicating whether the image parts are arranged | |
380 * below each other or side by side | |
381 */ | |
37007 | 382 static void PutImage(int x, int y, uint32_t *drawbuf, int drawbuf_width, guiImage *img, int parts, int index, int below) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
383 { |
37009 | 384 register int i, ic, yc; |
37007 | 385 register uint32_t pixel; |
386 int xlimit, ylimit, ix, iy; | |
37005 | 387 uint32_t *pixels; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
388 |
37010 | 389 if (!img || !img->Image) |
32963 | 390 return; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
391 |
37007 | 392 if (below) { |
393 i = img->Width * (img->Height / parts) * index; | |
394 xlimit = x + img->Width; | |
395 ylimit = y + img->Height / parts; | |
396 } else { | |
397 i = (img->Width / parts) * index; | |
398 xlimit = x + img->Width / parts; | |
399 ylimit = y + img->Height; | |
400 } | |
401 | |
37006 | 402 pixels = (uint32_t *)img->Image; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
403 |
36993 | 404 yc = y * drawbuf_width; |
32963 | 405 |
37007 | 406 for (iy = y; iy < ylimit; iy++) { |
407 ic = i; | |
408 | |
409 for (ix = x; ix < xlimit; ix++) { | |
36993 | 410 pixel = pixels[i++]; |
32963 | 411 |
36993 | 412 if (!IS_TRANSPARENT(pixel)) |
413 drawbuf[yc + ix] = pixel; | |
32963 | 414 } |
415 | |
37007 | 416 if (!below) |
37009 | 417 i = ic + img->Width; |
37007 | 418 |
36993 | 419 yc += drawbuf_width; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
420 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
421 } |
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
422 |
37017 | 423 /** |
424 * @brief Render all GUI items in a window, i.e. copy the respective images | |
425 * into the draw buffer. | |
426 * | |
427 * @param window pointer to a ws window structure of the window to be rendered | |
428 * @param items pointer to the array of items | |
429 * @param till maximum index in use for the @a items, i.e. number of last item in array | |
37065 | 430 * @param drawbuf memory location of the @a window's draw buffer |
37017 | 431 */ |
37011 | 432 void RenderAll(wsWindow *window, guiItem *items, int till, char *drawbuf) |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
433 { |
37005 | 434 uint32_t *db; |
35688 | 435 guiItem *item; |
33555 | 436 guiImage *image = NULL; |
37012 | 437 int dw, i, index, x; |
37015 | 438 char *trans; |
37012 | 439 unsigned int d; |
32963 | 440 |
37005 | 441 db = (uint32_t *)drawbuf; |
442 dw = window->Width; | |
32963 | 443 |
37011 | 444 for (i = 0; i <= till; i++) { |
36994 | 445 item = &items[i]; |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
446 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
447 switch (item->pressed) { |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
448 case btnPressed: |
36994 | 449 index = 0; |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
450 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
451 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
452 case btnReleased: |
36994 | 453 index = 1; |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
454 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
455 |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
456 default: |
36994 | 457 index = 2; |
32966
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
458 break; |
1f51f39916e1
Replace ternary operator by more intelligible switch statement.
ib
parents:
32965
diff
changeset
|
459 } |
32963 | 460 |
461 switch (item->type) { | |
462 case itButton: | |
35541 | 463 |
37007 | 464 PutImage(item->x, item->y, db, dw, &item->Bitmap, 3, index, True); |
32963 | 465 break; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
466 |
36920 | 467 case itPimage: |
35541 | 468 |
37008 | 469 PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True); |
32963 | 470 break; |
471 | |
472 case itHPotmeter: | |
35541 | 473 |
37008 | 474 PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True); |
37020 | 475 PutImage(item->x + (item->width - item->pbwidth) * item->value / 100.0, item->y, db, dw, &item->Mask, 3, index, True); |
32963 | 476 break; |
477 | |
478 case itVPotmeter: | |
35541 | 479 |
37008 | 480 PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, False); |
37020 | 481 PutImage(item->x, item->y + (item->height - item->pbheight) * (1.0 - item->value / 100.0), db, dw, &item->Mask, 3, index, True); |
32963 | 482 break; |
483 | |
37053 | 484 case itRPotmeter: |
485 | |
486 PutImage(item->x, item->y, db, dw, &item->Bitmap, item->numphases, (item->numphases - 1) * item->value / 100.0, True); | |
487 | |
488 if (item->Mask.Image) { | |
489 double radius, radian; | |
490 int y; | |
491 | |
492 // keep the button inside the potmeter outline | |
493 radius = (FFMIN(item->width, item->height) - FFMAX(item->pbwidth, item->pbheight)) / 2.0; | |
494 | |
495 radian = item->value / 100.0 * item->arclength + item->zeropoint; | |
496 | |
497 // coordinates plus a correction for a non-square item | |
498 // (remember: both axes are mirrored, we have a clockwise radian) | |
499 x = radius * (1 + cos(radian)) + FFMAX(0, (item->width - item->height) / 2.0) + 0.5; | |
500 y = radius * (1 + sin(radian)) + FFMAX(0, (item->height - item->width) / 2.0) + 0.5; | |
501 | |
502 PutImage(item->x + x, item->y + y, db, dw, &item->Mask, 3, index, True); | |
503 } | |
504 | |
505 break; | |
506 | |
32963 | 507 case itSLabel: |
35541 | 508 |
32969 | 509 if (item->width == -1) |
510 item->width = fntTextWidth(item->fontid, item->label); | |
35541 | 511 |
33971 | 512 image = fntTextRender(item, 0, item->label); |
35541 | 513 |
32963 | 514 if (image) |
37007 | 515 PutImage(item->x, item->y, db, dw, image, 1, 0, True); |
35541 | 516 |
32969 | 517 break; |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
518 |
32963 | 519 case itDLabel: |
37013 | 520 |
37015 | 521 trans = TranslateVariables(item->label); |
32963 | 522 |
37015 | 523 if (!item->text || (strcmp(item->text, trans) != 0)) { |
32963 | 524 free(item->text); |
37015 | 525 item->text = strdup(trans); |
526 item->textwidth = fntTextWidth(item->fontid, trans); | |
32963 | 527 item->starttime = GetTimerMS(); |
528 item->last_x = 0; | |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
529 } |
32963 | 530 |
531 d = GetTimerMS() - item->starttime; | |
532 | |
32964 | 533 if (d < DLABEL_DELAY) |
37013 | 534 x = item->last_x; // don't scroll yet |
32963 | 535 else { |
536 int l; | |
537 char c[2]; | |
538 | |
539 l = (item->textwidth ? item->textwidth : item->width); | |
35362 | 540 x = (l ? l - ((d - DLABEL_DELAY) / 20) % l - 1 : 0); |
32963 | 541 c[0] = *item->text; |
37014 | 542 c[1] = 0; |
32963 | 543 |
544 if (x < (fntTextWidth(item->fontid, c) + 1) >> 1) { | |
37013 | 545 item->starttime = GetTimerMS(); // stop again |
546 item->last_x = x; // at current x pos | |
32963 | 547 } |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32759
diff
changeset
|
548 } |
32963 | 549 |
37015 | 550 image = fntTextRender(item, x, trans); |
32963 | 551 |
552 if (image) | |
37007 | 553 PutImage(item->x, item->y, db, dw, image, 1, 0, True); |
32963 | 554 |
555 break; | |
556 } | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
557 } |
32963 | 558 |
36994 | 559 wsImageRender(window, drawbuf); |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
diff
changeset
|
560 } |