summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_display.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-05-12 10:38:00 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-05-12 10:38:00 +0000
commit1bd072c92d5f6d4a9a26d738a421f5a05048bb29 (patch)
tree11bf71c80cd995dad20b4316f201a63f78111383 /apps/gui/skin_engine/skin_display.c
parentf9736c0b63d90d3cda7e2c77d1cae20939ae328f (diff)
downloadrockbox-1bd072c92d5f6d4a9a26d738a421f5a05048bb29.tar.gz
rockbox-1bd072c92d5f6d4a9a26d738a421f5a05048bb29.zip
FS#10853 - Skin support in the radio screen! Check CustomWPS for the new tags
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25964 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/skin_display.c')
-rw-r--r--apps/gui/skin_engine/skin_display.c161
1 files changed, 136 insertions, 25 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 9b42a7c18b..8d4e5b58f4 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -31,6 +31,7 @@
31#ifdef DEBUG 31#ifdef DEBUG
32#include "debug.h" 32#include "debug.h"
33#endif 33#endif
34#include "action.h"
34#include "abrepeat.h" 35#include "abrepeat.h"
35#include "lang.h" 36#include "lang.h"
36#include "language.h" 37#include "language.h"
@@ -57,6 +58,9 @@
57#endif 58#endif
58#include "backdrop.h" 59#include "backdrop.h"
59#include "viewport.h" 60#include "viewport.h"
61#include "radio.h"
62#include "tuner.h"
63#include "root_menu.h"
60 64
61 65
62#include "wps_internals.h" 66#include "wps_internals.h"
@@ -78,7 +82,7 @@ bool skin_update(struct gui_wps *gwps, unsigned int update_type)
78 struct mp3entry *id3 = gwps->state->id3; 82 struct mp3entry *id3 = gwps->state->id3;
79 bool cuesheet_update = (id3 != NULL ? cuesheet_subtrack_changed(id3) : false); 83 bool cuesheet_update = (id3 != NULL ? cuesheet_subtrack_changed(id3) : false);
80 gwps->sync_data->do_full_update |= cuesheet_update; 84 gwps->sync_data->do_full_update |= cuesheet_update;
81 85
82 retval = skin_redraw(gwps, gwps->sync_data->do_full_update ? 86 retval = skin_redraw(gwps, gwps->sync_data->do_full_update ?
83 WPS_REFRESH_ALL : update_type); 87 WPS_REFRESH_ALL : update_type);
84 return retval; 88 return retval;
@@ -157,6 +161,14 @@ static void draw_progressbar(struct gui_wps *gwps,
157 length = id3->length; 161 length = id3->length;
158 elapsed = id3->elapsed + state->ff_rewind_count; 162 elapsed = id3->elapsed + state->ff_rewind_count;
159 } 163 }
164#if CONFIG_TUNER
165 else if (in_radio_screen())
166 {
167 int min = fm_region_data[global_settings.fm_region].freq_min;
168 elapsed = radio_current_frequency() - min;
169 length = fm_region_data[global_settings.fm_region].freq_max - min;
170 }
171#endif
160 else 172 else
161 { 173 {
162 length = 1; 174 length = 1;
@@ -191,8 +203,8 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps,
191 struct wps_state *state = gwps->state; 203 struct wps_state *state = gwps->state;
192 int lines = viewport_get_nb_lines(viewer->vp); 204 int lines = viewport_get_nb_lines(viewer->vp);
193 int line_height = font_get(viewer->vp->font)->height; 205 int line_height = font_get(viewer->vp->font)->height;
194 int cur_playlist_pos = playlist_get_display_index(); 206 int cur_pos, count;
195 int start_item = MAX(0, cur_playlist_pos + viewer->start_offset); 207 int start_item;
196 int i; 208 int i;
197 struct wps_token token; 209 struct wps_token token;
198 int x, length, alignment = WPS_TOKEN_ALIGN_LEFT; 210 int x, length, alignment = WPS_TOKEN_ALIGN_LEFT;
@@ -200,39 +212,65 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps,
200 struct mp3entry *pid3; 212 struct mp3entry *pid3;
201 char buf[MAX_PATH*2], tempbuf[MAX_PATH]; 213 char buf[MAX_PATH*2], tempbuf[MAX_PATH];
202 const char *filename; 214 const char *filename;
215 bool ismusic = true;
216#if CONFIG_TUNER
217 if (current_screen() == GO_TO_FM)
218 {
219 cur_pos = radio_current_preset();
220 count = radio_preset_count();
221 ismusic = false;
222 }
223 else
224#endif
225 {
226 cur_pos = playlist_get_display_index();
227 count = playlist_amount()+1;
228 }
229 start_item = MAX(0, cur_pos + viewer->start_offset);
203 230
204 gwps->display->set_viewport(viewer->vp); 231 gwps->display->set_viewport(viewer->vp);
205 for(i=start_item; (i-start_item)<lines && i<=playlist_amount(); i++) 232 for(i=start_item; (i-start_item)<lines && i<count; i++)
206 { 233 {
207 filename = playlist_peek(i-cur_playlist_pos); 234 int line;
208 if (i == cur_playlist_pos) 235#if CONFIG_TUNER
209 { 236 if (current_screen() == GO_TO_FM)
210 pid3 = state->id3;
211 }
212 else if (i == cur_playlist_pos+1)
213 { 237 {
214 pid3 = state->nid3; 238 pid3 = NULL;
239 line = TRACK_HAS_INFO;
240 filename = "";
215 } 241 }
216#if CONFIG_CODEC == SWCODEC 242 else
217 else if (i>cur_playlist_pos) 243#endif
218 { 244 {
219#ifdef HAVE_TC_RAMCACHE 245 filename = playlist_peek(i-cur_pos);
220 if (tagcache_fill_tags(&viewer->tempid3, filename)) 246 if (i == cur_pos)
221 { 247 {
222 pid3 = &viewer->tempid3; 248 pid3 = state->id3;
223 } 249 }
224 else 250 else if (i == cur_pos+1)
251 {
252 pid3 = state->nid3;
253 }
254#if CONFIG_CODEC == SWCODEC
255 else if (i>cur_pos)
256 {
257#ifdef HAVE_TC_RAMCACHE
258 if (tagcache_fill_tags(&viewer->tempid3, filename))
259 {
260 pid3 = &viewer->tempid3;
261 }
262 else
225#endif 263#endif
226 if (!audio_peek_track(&pid3, i-cur_playlist_pos)) 264 if (!audio_peek_track(&pid3, i-cur_pos))
227 pid3 = NULL; 265 pid3 = NULL;
228 } 266 }
229#endif 267#endif
230 else 268 else
231 { 269 {
232 pid3 = NULL; 270 pid3 = NULL;
271 }
272 line = pid3 ? TRACK_HAS_INFO : TRACK_HAS_NO_INFO;
233 } 273 }
234
235 int line = pid3 ? TRACK_HAS_INFO : TRACK_HAS_NO_INFO;
236 int j = 0, cur_string = 0; 274 int j = 0, cur_string = 0;
237 unsigned int line_len = 0; 275 unsigned int line_len = 0;
238 buf[0] = '\0'; 276 buf[0] = '\0';
@@ -243,12 +281,18 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps,
243 token.value.i = 0; 281 token.value.i = 0;
244 token.next = false; 282 token.next = false;
245 out = get_id3_token(&token, pid3, tempbuf, sizeof(tempbuf), -1, NULL); 283 out = get_id3_token(&token, pid3, tempbuf, sizeof(tempbuf), -1, NULL);
284#if CONFIG_TUNER
285 if (!out)
286 out = get_radio_token(&token, i-cur_pos,
287 tempbuf, sizeof(tempbuf), -1, NULL);
288#endif
246 if (out) 289 if (out)
247 { 290 {
248 line_len = strlcat(buf, out, sizeof(buf)); 291 line_len = strlcat(buf, out, sizeof(buf));
249 j++; 292 j++;
250 continue; 293 continue;
251 } 294 }
295
252 switch (viewer->lines[line].tokens[j]) 296 switch (viewer->lines[line].tokens[j])
253 { 297 {
254 case WPS_TOKEN_ALIGN_CENTER: 298 case WPS_TOKEN_ALIGN_CENTER:
@@ -1303,3 +1347,70 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
1303 1347
1304 return true; 1348 return true;
1305} 1349}
1350
1351bool skin_has_sbs(enum screen_type screen, struct wps_data *data)
1352{
1353 (void)screen;
1354 bool draw = false;
1355#ifdef HAVE_LCD_BITMAP
1356 if (data->wps_sb_tag)
1357 draw = data->show_sb_on_wps;
1358 else if (statusbar_position(screen) != STATUSBAR_OFF)
1359 draw = true;
1360#endif
1361 return draw;
1362}
1363
1364/* do the button loop as often as required for the peak meters to update
1365 * with a good refresh rate.
1366 * gwps is really gwps[NB_SCREENS]! don't wrap this if FOR_NB_SCREENS()
1367 */
1368int skin_wait_for_action(struct gui_wps *gwps, int context, int timeout)
1369{
1370#ifdef HAVE_LCD_BITMAP
1371 int i;
1372 int button = ACTION_NONE;
1373 /* when the peak meter is enabled we want to have a
1374 few extra updates to make it look smooth. On the
1375 other hand we don't want to waste energy if it
1376 isn't displayed */
1377 bool pm=false;
1378 FOR_NB_SCREENS(i)
1379 {
1380 if(gwps[i].data->peak_meter_enabled)
1381 pm = true;
1382 }
1383
1384 if (pm) {
1385 long next_refresh = current_tick;
1386 long next_big_refresh = current_tick + timeout;
1387 button = BUTTON_NONE;
1388 while (TIME_BEFORE(current_tick, next_big_refresh)) {
1389 button = get_action(context,TIMEOUT_NOBLOCK);
1390 if (button != ACTION_NONE) {
1391 break;
1392 }
1393 peak_meter_peek();
1394 sleep(0); /* Sleep until end of current tick. */
1395
1396 if (TIME_AFTER(current_tick, next_refresh)) {
1397 FOR_NB_SCREENS(i)
1398 {
1399 if(gwps[i].data->peak_meter_enabled)
1400 skin_update(&gwps[i], WPS_REFRESH_PEAK_METER);
1401 next_refresh += HZ / PEAK_METER_FPS;
1402 }
1403 }
1404 }
1405
1406 }
1407
1408 /* The peak meter is disabled
1409 -> no additional screen updates needed */
1410 else
1411#endif
1412 {
1413 button = get_action(context, timeout);
1414 }
1415 return button;
1416}