pdbox: Syntax cleanup for the cosine table.
[maemo-rb.git] / apps / menus / theme_menu.c
blobf2a1cd2f174b589deb95475d87f9781776e76add
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 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 ****************************************************************************/
22 #include <stdbool.h>
23 #include <stddef.h>
24 #include <limits.h>
25 #include "config.h"
26 #include "lang.h"
27 #include "action.h"
28 #include "settings.h"
29 #include "menu.h"
30 #include "tree.h"
31 #include "list.h"
32 #ifdef HAVE_LCD_BITMAP
33 #include "peakmeter.h"
34 #endif
35 #include "color_picker.h"
36 #include "lcd.h"
37 #include "lcd-remote.h"
38 #include "backdrop.h"
39 #include "exported_menus.h"
40 #include "appevents.h"
41 #include "viewport.h"
42 #include "statusbar-skinned.h"
44 #if LCD_DEPTH > 1
45 /**
46 * Menu to clear the backdrop image
48 static int clear_main_backdrop(void)
50 global_settings.backdrop_file[0] = '-';
51 global_settings.backdrop_file[1] = '\0';
52 sb_set_backdrop(SCREEN_MAIN, NULL);
53 viewportmanager_theme_enable(SCREEN_MAIN, false, NULL);
54 viewportmanager_theme_undo(SCREEN_MAIN, true);
55 settings_save();
56 return 0;
58 MENUITEM_FUNCTION(clear_main_bd, 0, ID2P(LANG_CLEAR_BACKDROP),
59 clear_main_backdrop, NULL, NULL, Icon_NOICON);
60 #endif
61 #ifdef HAVE_LCD_COLOR
63 enum Colors {
64 COLOR_FG = 0,
65 COLOR_BG,
66 COLOR_LSS,
67 COLOR_LSE,
68 COLOR_LST,
69 COLOR_COUNT
71 static struct colour_info
73 int *setting;
74 int lang_id;
75 } colors[COLOR_COUNT] = {
76 [COLOR_FG] = {&global_settings.fg_color, LANG_FOREGROUND_COLOR},
77 [COLOR_BG] = {&global_settings.bg_color, LANG_BACKGROUND_COLOR},
78 [COLOR_LSS] = {&global_settings.lss_color, LANG_SELECTOR_START_COLOR},
79 [COLOR_LSE] = {&global_settings.lse_color, LANG_SELECTOR_END_COLOR},
80 [COLOR_LST] = {&global_settings.lst_color, LANG_SELECTOR_TEXT_COLOR},
83 /**
84 * Menu for fore/back/selection colors
86 static int set_color_func(void* color)
88 int res, c = (intptr_t)color, banned_color=-1;
90 /* Don't let foreground be set the same as background and vice-versa */
91 if (c == COLOR_BG)
92 banned_color = *colors[COLOR_FG].setting;
93 else if (c == COLOR_FG)
94 banned_color = *colors[COLOR_BG].setting;
96 res = (int)set_color(&screens[SCREEN_MAIN],str(colors[c].lang_id),
97 colors[c].setting, banned_color);
98 settings_save();
99 settings_apply(false);
100 return res;
103 static int reset_color(void)
105 global_settings.fg_color = LCD_DEFAULT_FG;
106 global_settings.bg_color = LCD_DEFAULT_BG;
107 global_settings.lss_color = LCD_DEFAULT_LS;
108 global_settings.lse_color = LCD_DEFAULT_BG;
109 global_settings.lst_color = LCD_DEFAULT_FG;
111 settings_save();
112 settings_apply(false);
113 return 0;
115 MENUITEM_FUNCTION(set_bg_col, MENU_FUNC_USEPARAM, ID2P(LANG_BACKGROUND_COLOR),
116 set_color_func, (void*)COLOR_BG, NULL, Icon_NOICON);
117 MENUITEM_FUNCTION(set_fg_col, MENU_FUNC_USEPARAM, ID2P(LANG_FOREGROUND_COLOR),
118 set_color_func, (void*)COLOR_FG, NULL, Icon_NOICON);
119 MENUITEM_FUNCTION(set_lss_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_START_COLOR),
120 set_color_func, (void*)COLOR_LSS, NULL, Icon_NOICON);
121 MENUITEM_FUNCTION(set_lse_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_END_COLOR),
122 set_color_func, (void*)COLOR_LSE, NULL, Icon_NOICON);
123 MENUITEM_FUNCTION(set_lst_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_TEXT_COLOR),
124 set_color_func, (void*)COLOR_LST, NULL, Icon_NOICON);
125 MENUITEM_FUNCTION(reset_colors, 0, ID2P(LANG_RESET_COLORS),
126 reset_color, NULL, NULL, Icon_NOICON);
128 MAKE_MENU(lss_settings, ID2P(LANG_SELECTOR_COLOR_MENU),
129 NULL, Icon_NOICON,
130 &set_lss_col, &set_lse_col, &set_lst_col
133 /* now the actual menu */
134 MAKE_MENU(colors_settings, ID2P(LANG_COLORS_MENU),
135 NULL, Icon_Display_menu,
136 &lss_settings,
137 &set_bg_col, &set_fg_col, &reset_colors
140 #endif /* HAVE_LCD_COLOR */
141 /* LCD MENU */
142 /***********************************/
145 /************************************/
146 /* BARS MENU */
147 /* */
150 #ifdef HAVE_LCD_BITMAP
151 static int statusbar_callback_ex(int action,const struct menu_item_ex *this_item,
152 enum screen_type screen)
154 (void)this_item;
155 /* we save the old statusbar value here, so the old statusbars can get
156 * removed and cleared from the display properly on exiting
157 * (in gui_statusbar_changed() ) */
158 static enum statusbar_values old_bar[NB_SCREENS];
159 switch (action)
161 case ACTION_ENTER_MENUITEM:
162 old_bar[screen] = statusbar_position(screen);
163 break;
164 case ACTION_EXIT_MENUITEM:
165 if (old_bar[screen] != statusbar_position(screen))
166 settings_apply_skins();
167 break;
169 return ACTION_REDRAW;
172 #ifdef HAVE_REMOTE_LCD
173 static int statusbar_callback_remote(int action,const struct menu_item_ex *this_item)
175 return statusbar_callback_ex(action, this_item, SCREEN_REMOTE);
177 #endif
178 static int statusbar_callback(int action,const struct menu_item_ex *this_item)
180 return statusbar_callback_ex(action, this_item, SCREEN_MAIN);
183 #ifdef HAVE_BUTTONBAR
184 static int buttonbar_callback(int action, const struct menu_item_ex *this_item)
186 (void)this_item;
187 switch (action)
189 case ACTION_EXIT_MENUITEM:
190 viewportmanager_theme_changed(THEME_BUTTONBAR);
191 break;
193 return ACTION_REDRAW;
195 #endif
196 MENUITEM_SETTING(scrollbar_item, &global_settings.scrollbar, NULL);
197 MENUITEM_SETTING(scrollbar_width, &global_settings.scrollbar_width, NULL);
198 MENUITEM_SETTING(statusbar, &global_settings.statusbar,
199 statusbar_callback);
200 #ifdef HAVE_REMOTE_LCD
201 MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar,
202 statusbar_callback_remote);
203 #endif
204 #ifdef HAVE_BUTTONBAR
205 MENUITEM_SETTING(buttonbar, &global_settings.buttonbar, buttonbar_callback);
206 #endif
207 MENUITEM_SETTING(volume_type, &global_settings.volume_type, NULL);
208 MENUITEM_SETTING(battery_display, &global_settings.battery_display, NULL);
209 MAKE_MENU(bars_menu, ID2P(LANG_BARS_MENU), 0, Icon_NOICON,
210 &scrollbar_item, &scrollbar_width, &statusbar,
211 #ifdef HAVE_REMOTE_LCD
212 &remote_statusbar,
213 #endif
214 #if CONFIG_KEYPAD == RECORDER_PAD
215 &buttonbar,
216 #endif
217 &volume_type, &battery_display);
218 #endif /* HAVE_LCD_BITMAP */
220 /* */
221 /* BARS MENU */
222 /************************************/
224 #ifdef HAVE_LCD_BITMAP
225 static struct browse_folder_info fonts = {FONT_DIR, SHOW_FONT};
226 static struct browse_folder_info sbs = {SBS_DIR, SHOW_SBS};
227 #if CONFIG_TUNER
228 static struct browse_folder_info fms = {WPS_DIR, SHOW_FMS};
229 #endif
230 #endif
231 static struct browse_folder_info wps = {WPS_DIR, SHOW_WPS};
232 #ifdef HAVE_REMOTE_LCD
233 static struct browse_folder_info rwps = {WPS_DIR, SHOW_RWPS};
234 static struct browse_folder_info rsbs = {SBS_DIR, SHOW_RSBS};
235 #if CONFIG_TUNER
236 static struct browse_folder_info rfms = {WPS_DIR, SHOW_RFMS};
237 #endif
238 #endif
239 static struct browse_folder_info themes = {THEME_DIR, SHOW_CFG};
241 int browse_folder(void *param)
243 const struct browse_folder_info *info =
244 (const struct browse_folder_info*)param;
245 return rockbox_browse(info->dir, info->show_options);
248 #ifdef HAVE_LCD_BITMAP
249 MENUITEM_FUNCTION(browse_fonts, MENU_FUNC_USEPARAM,
250 ID2P(LANG_CUSTOM_FONT),
251 browse_folder, (void*)&fonts, NULL, Icon_Font);
253 MENUITEM_FUNCTION(browse_sbs, MENU_FUNC_USEPARAM,
254 ID2P(LANG_BASE_SKIN),
255 browse_folder, (void*)&sbs, NULL, Icon_Wps);
256 #if CONFIG_TUNER
257 MENUITEM_FUNCTION(browse_fms, MENU_FUNC_USEPARAM,
258 ID2P(LANG_RADIOSCREEN),
259 browse_folder, (void*)&fms, NULL, Icon_Wps);
260 #endif
261 #endif
262 MENUITEM_FUNCTION(browse_wps, MENU_FUNC_USEPARAM,
263 ID2P(LANG_WHILE_PLAYING),
264 browse_folder, (void*)&wps, NULL, Icon_Wps);
265 #ifdef HAVE_REMOTE_LCD
266 MENUITEM_FUNCTION(browse_rwps, MENU_FUNC_USEPARAM,
267 ID2P(LANG_REMOTE_WHILE_PLAYING),
268 browse_folder, (void*)&rwps, NULL, Icon_Wps);
269 MENUITEM_FUNCTION(browse_rsbs, MENU_FUNC_USEPARAM,
270 ID2P(LANG_REMOTE_BASE_SKIN),
271 browse_folder, (void*)&rsbs, NULL, Icon_Wps);
272 #if CONFIG_TUNER
273 MENUITEM_FUNCTION(browse_rfms, MENU_FUNC_USEPARAM,
274 ID2P(LANG_REMOTE_RADIOSCREEN),
275 browse_folder, (void*)&rfms, NULL, Icon_Wps);
276 #endif
277 #endif
279 MENUITEM_SETTING(show_icons, &global_settings.show_icons, NULL);
280 MENUITEM_FUNCTION(browse_themes, MENU_FUNC_USEPARAM,
281 ID2P(LANG_CUSTOM_THEME),
282 browse_folder, (void*)&themes, NULL, Icon_Config);
283 #ifdef HAVE_LCD_BITMAP
284 MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, NULL);
285 #endif
287 MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
288 NULL, Icon_Wps,
289 &browse_themes,
290 #ifdef HAVE_LCD_BITMAP
291 &browse_fonts,
292 #endif
293 &browse_wps,
294 #ifdef HAVE_REMOTE_LCD
295 &browse_rwps,
296 #endif
297 #if CONFIG_TUNER
298 &browse_fms,
299 #ifdef HAVE_REMOTE_LCD
300 &browse_rfms,
301 #endif
302 #endif
303 #ifdef HAVE_LCD_BITMAP
304 &browse_sbs,
305 #endif
306 #ifdef HAVE_REMOTE_LCD
307 &browse_rsbs,
308 #endif
309 &show_icons,
310 #if LCD_DEPTH > 1
311 &clear_main_bd,
312 #endif
313 #ifdef HAVE_LCD_BITMAP
314 &bars_menu,
315 &cursor_style,
316 #endif
317 #ifdef HAVE_LCD_COLOR
318 &colors_settings,
319 #endif