Move the "Status/Scrollbar" menu to Theme Settings, and add the F_THEMESETTING flag...
[kugel-rb/myfork.git] / apps / menus / theme_menu.c
blobf2e4579864fdf890a280335e92d7194fd500401c
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"
42 #if LCD_DEPTH > 1
43 /**
44 * Menu to clear the backdrop image
46 static int clear_main_backdrop(void)
48 global_settings.backdrop_file[0]=0;
49 backdrop_unload(BACKDROP_MAIN);
50 backdrop_show(BACKDROP_MAIN);
51 send_event(GUI_EVENT_REFRESH, NULL);
52 settings_save();
53 return 0;
55 MENUITEM_FUNCTION(clear_main_bd, 0, ID2P(LANG_CLEAR_BACKDROP),
56 clear_main_backdrop, NULL, NULL, Icon_NOICON);
57 #endif
58 #ifdef HAVE_LCD_COLOR
60 enum Colors {
61 COLOR_FG = 0,
62 COLOR_BG,
63 COLOR_LSS,
64 COLOR_LSE,
65 COLOR_LST,
66 COLOR_COUNT
68 static struct colour_info
70 int *setting;
71 int lang_id;
72 } colors[COLOR_COUNT] = {
73 [COLOR_FG] = {&global_settings.fg_color, LANG_FOREGROUND_COLOR},
74 [COLOR_BG] = {&global_settings.bg_color, LANG_BACKGROUND_COLOR},
75 [COLOR_LSS] = {&global_settings.lss_color, LANG_SELECTOR_START_COLOR},
76 [COLOR_LSE] = {&global_settings.lse_color, LANG_SELECTOR_END_COLOR},
77 [COLOR_LST] = {&global_settings.lst_color, LANG_SELECTOR_TEXT_COLOR},
80 /**
81 * Menu for fore/back/selection colors
83 static int set_color_func(void* color)
85 int res, c = (intptr_t)color, banned_color=-1;
87 /* Don't let foreground be set the same as background and vice-versa */
88 if (c == COLOR_BG)
89 banned_color = *colors[COLOR_FG].setting;
90 else if (c == COLOR_FG)
91 banned_color = *colors[COLOR_BG].setting;
93 res = (int)set_color(&screens[SCREEN_MAIN],str(colors[c].lang_id),
94 colors[c].setting, banned_color);
95 settings_save();
96 settings_apply(false);
97 return res;
100 static int reset_color(void)
102 global_settings.fg_color = LCD_DEFAULT_FG;
103 global_settings.bg_color = LCD_DEFAULT_BG;
104 global_settings.lss_color = LCD_DEFAULT_LS;
105 global_settings.lse_color = LCD_DEFAULT_BG;
106 global_settings.lst_color = LCD_DEFAULT_FG;
108 settings_save();
109 settings_apply(false);
110 return 0;
112 MENUITEM_FUNCTION(set_bg_col, MENU_FUNC_USEPARAM, ID2P(LANG_BACKGROUND_COLOR),
113 set_color_func, (void*)COLOR_BG, NULL, Icon_NOICON);
114 MENUITEM_FUNCTION(set_fg_col, MENU_FUNC_USEPARAM, ID2P(LANG_FOREGROUND_COLOR),
115 set_color_func, (void*)COLOR_FG, NULL, Icon_NOICON);
116 MENUITEM_FUNCTION(set_lss_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_START_COLOR),
117 set_color_func, (void*)COLOR_LSS, NULL, Icon_NOICON);
118 MENUITEM_FUNCTION(set_lse_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_END_COLOR),
119 set_color_func, (void*)COLOR_LSE, NULL, Icon_NOICON);
120 MENUITEM_FUNCTION(set_lst_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_TEXT_COLOR),
121 set_color_func, (void*)COLOR_LST, NULL, Icon_NOICON);
122 MENUITEM_FUNCTION(reset_colors, 0, ID2P(LANG_RESET_COLORS),
123 reset_color, NULL, NULL, Icon_NOICON);
125 MAKE_MENU(lss_settings, ID2P(LANG_SELECTOR_COLOR_MENU),
126 NULL, Icon_NOICON,
127 &set_lss_col, &set_lse_col, &set_lst_col
130 /* now the actual menu */
131 MAKE_MENU(colors_settings, ID2P(LANG_COLORS_MENU),
132 NULL, Icon_Display_menu,
133 &lss_settings,
134 &set_bg_col, &set_fg_col, &reset_colors
137 #endif /* HAVE_LCD_COLOR */
138 /* LCD MENU */
139 /***********************************/
142 /************************************/
143 /* BARS MENU */
144 /* */
147 #ifdef HAVE_LCD_BITMAP
148 static int statusbar_callback_ex(int action,const struct menu_item_ex *this_item,
149 enum screen_type screen)
151 (void)this_item;
152 /* we save the old statusbar value here, so the old statusbars can get
153 * removed and cleared from the display properly on exiting
154 * (in gui_statusbar_changed() ) */
155 static enum statusbar_values old_bar[NB_SCREENS];
156 switch (action)
158 case ACTION_ENTER_MENUITEM:
159 old_bar[screen] = statusbar_position(screen);
160 case ACTION_EXIT_MENUITEM:
161 gui_statusbar_changed(screen, old_bar[screen]);
162 send_event(GUI_EVENT_STATUSBAR_TOGGLE, NULL);
163 send_event(GUI_EVENT_ACTIONUPDATE, (void*)true);
164 break;
166 return action;
169 #ifdef HAVE_REMOTE_LCD
170 static int statusbar_callback_remote(int action,const struct menu_item_ex *this_item)
172 return statusbar_callback_ex(action, this_item, SCREEN_REMOTE);
174 #endif
175 static int statusbar_callback(int action,const struct menu_item_ex *this_item)
177 return statusbar_callback_ex(action, this_item, SCREEN_MAIN);
179 MENUITEM_SETTING(scrollbar_item, &global_settings.scrollbar, NULL);
180 MENUITEM_SETTING(scrollbar_width, &global_settings.scrollbar_width, NULL);
181 MENUITEM_SETTING(statusbar, &global_settings.statusbar,
182 statusbar_callback);
183 #ifdef HAVE_REMOTE_LCD
184 MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar,
185 statusbar_callback_remote);
186 #endif
187 #if CONFIG_KEYPAD == RECORDER_PAD
188 MENUITEM_SETTING(buttonbar, &global_settings.buttonbar, NULL);
189 #endif
190 MENUITEM_SETTING(volume_type, &global_settings.volume_type, NULL);
191 MENUITEM_SETTING(battery_display, &global_settings.battery_display, NULL);
192 MAKE_MENU(bars_menu, ID2P(LANG_BARS_MENU), 0, Icon_NOICON,
193 &scrollbar_item, &scrollbar_width, &statusbar,
194 #ifdef HAVE_REMOTE_LCD
195 &remote_statusbar,
196 #endif
197 #if CONFIG_KEYPAD == RECORDER_PAD
198 &buttonbar,
199 #endif
200 &volume_type, &battery_display);
201 #endif /* HAVE_LCD_BITMAP */
203 /* */
204 /* BARS MENU */
205 /************************************/
207 #ifdef HAVE_LCD_BITMAP
208 static struct browse_folder_info fonts = {FONT_DIR, SHOW_FONT};
209 #endif
210 static struct browse_folder_info wps = {WPS_DIR, SHOW_WPS};
211 #ifdef HAVE_REMOTE_LCD
212 static struct browse_folder_info rwps = {WPS_DIR, SHOW_RWPS};
213 #endif
214 static struct browse_folder_info themes = {THEME_DIR, SHOW_CFG};
216 int browse_folder(void *param)
218 const struct browse_folder_info *info =
219 (const struct browse_folder_info*)param;
220 return rockbox_browse(info->dir, info->show_options);
223 #ifdef HAVE_LCD_BITMAP
224 MENUITEM_FUNCTION(browse_fonts, MENU_FUNC_USEPARAM,
225 ID2P(LANG_CUSTOM_FONT),
226 browse_folder, (void*)&fonts, NULL, Icon_Font);
227 #endif
228 MENUITEM_FUNCTION(browse_wps, MENU_FUNC_USEPARAM,
229 ID2P(LANG_WHILE_PLAYING),
230 browse_folder, (void*)&wps, NULL, Icon_Wps);
231 #ifdef HAVE_REMOTE_LCD
232 MENUITEM_FUNCTION(browse_rwps, MENU_FUNC_USEPARAM,
233 ID2P(LANG_REMOTE_WHILE_PLAYING),
234 browse_folder, (void*)&rwps, NULL, Icon_Wps);
235 #endif
237 MENUITEM_SETTING(show_icons, &global_settings.show_icons, NULL);
238 MENUITEM_FUNCTION(browse_themes, MENU_FUNC_USEPARAM,
239 ID2P(LANG_CUSTOM_THEME),
240 browse_folder, (void*)&themes, NULL, Icon_Config);
241 #ifdef HAVE_LCD_BITMAP
242 MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, NULL);
243 #endif
245 MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
246 NULL, Icon_Wps,
247 &browse_themes,
248 #ifdef HAVE_LCD_BITMAP
249 &browse_fonts,
250 #endif
251 &browse_wps,
252 #ifdef HAVE_REMOTE_LCD
253 &browse_rwps,
254 #endif
255 &show_icons,
256 #if LCD_DEPTH > 1
257 &clear_main_bd,
258 #endif
259 #ifdef HAVE_LCD_BITMAP
260 &bars_menu,
261 &cursor_style,
262 #endif
263 #ifdef HAVE_LCD_COLOR
264 &colors_settings,
265 #endif