PacBox: Premultiply sound prom data on load rather than during emulation. Use 16...
[kugel-rb.git] / apps / radio / radio_skin.c
blobc7994b31351faa388e24b7dd2b3c7552e4853afe
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2010 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #include "config.h"
24 #include <stdio.h>
25 #include <stdbool.h>
26 #include <stdlib.h>
27 #include "skin_engine/skin_engine.h"
28 #include "settings.h"
29 #include "radio.h"
30 #include "action.h"
31 #include "appevents.h"
32 #include "statusbar-skinned.h"
35 extern struct wps_state wps_state; /* from wps.c */
36 static struct gui_wps fms_skin[NB_SCREENS] = {{ .data = NULL }};
37 static struct wps_data fms_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }};
38 static struct wps_sync_data fms_skin_sync_data = { .do_full_update = false };
40 void fms_data_load(enum screen_type screen, const char *buf, bool isfile)
42 struct wps_data *data = fms_skin[screen].data;
43 int success;
44 success = buf && skin_data_load(screen, data, buf, isfile);
46 if (!success ) /* load the default */
48 const char default_fms[] = "%s%?Ti<%Ti. |>%?Tn<%Tn|%Tf>\n"
49 "%Sx(Station:) %tf MHz\n"
50 "%?St(force fm mono)<%Sx(Force Mono)|%?ts<%Sx(Stereo)|%Sx(Mono)>>\n"
51 "%Sx(Mode:) %?tm<%Sx(Scan)|%Sx(Preset)>\n"
52 #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
53 "%?Rr<%Sx(Time:) %Rh:%Rn:%Rs|%?St(prerecording time)<%pm|%Sx(Prerecord Time) %Rs>>\n"
54 #endif
55 "%pb\n"
56 #ifdef HAVE_RDS_CAP
57 "\n%s%ty\n"
58 "%s%tz\n"
59 #endif
61 skin_data_load(screen, data, default_fms, false);
64 void fms_fix_displays(enum fms_exiting toggle_state)
66 int i;
67 FOR_NB_SCREENS(i)
69 if (toggle_state == FMS_ENTER)
71 viewportmanager_theme_enable(i, skin_has_sbs(i, fms_skin[i].data), NULL);
72 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
73 screens[i].backdrop_show(fms_skin[i].data->backdrop);
74 #endif
75 screens[i].clear_display();
76 /* force statusbar/skin update since we just cleared the whole screen */
77 send_event(GUI_EVENT_ACTIONUPDATE, (void*)1);
79 else
81 screens[i].stop_scroll();
82 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
83 screens[i].backdrop_show(sb_get_backdrop(i));
84 #endif
85 viewportmanager_theme_undo(i, skin_has_sbs(i, fms_skin[i].data));
91 void fms_skin_init(void)
93 int i;
94 FOR_NB_SCREENS(i)
96 #ifdef HAVE_ALBUMART
97 fms_skin_data[i].albumart = NULL;
98 fms_skin_data[i].playback_aa_slot = -1;
99 #endif
100 fms_skin[i].data = &fms_skin_data[i];
101 fms_skin[i].display = &screens[i];
102 /* Currently no seperate wps_state needed/possible
103 so use the only available ( "global" ) one */
104 fms_skin[i].state = &wps_state;
105 fms_skin[i].sync_data = &fms_skin_sync_data;
109 int fms_do_button_loop(bool update_screen)
111 int button = skin_wait_for_action(fms_skin, CONTEXT_FM,
112 update_screen ? TIMEOUT_NOBLOCK : HZ);
113 #ifdef HAVE_TOUCHSCREEN
114 int offset;
115 if (button == ACTION_TOUCHSCREEN)
116 button = skin_get_touchaction(&fms_skin_data[SCREEN_MAIN], &offset);
117 switch (button)
119 case ACTION_WPS_STOP:
120 return ACTION_FM_STOP;
121 case ACTION_STD_CANCEL:
122 return ACTION_FM_EXIT;
123 case ACTION_WPS_VOLUP:
124 return ACTION_SETTINGS_INC;
125 case ACTION_WPS_VOLDOWN:
126 return ACTION_SETTINGS_DEC;
127 case ACTION_WPS_PLAY:
128 return ACTION_FM_PLAY;
129 case ACTION_STD_MENU:
130 return ACTION_FM_MENU;
131 case WPS_TOUCHREGION_SCROLLBAR:
132 /* TODO */
133 break;
135 #endif
136 return button;
139 struct gui_wps *fms_get(enum screen_type screen)
141 return &fms_skin[screen];