Move language resources to a separate file. Only build and include langs when buildin...
[Rockbox.git] / apps / menus / theme_menu.c
blob0c01b548b6b1222ac3d6f620a58466398ae0dbd3
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 Jonathan Gordon
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include <limits.h>
23 #include "config.h"
24 #include "lang.h"
25 #include "action.h"
26 #include "settings.h"
27 #include "menu.h"
28 #include "tree.h"
29 #include "list.h"
30 #ifdef HAVE_LCD_BITMAP
31 #include "peakmeter.h"
32 #endif
33 #include "talk.h"
34 #include "color_picker.h"
35 #include "lcd.h"
36 #include "lcd-remote.h"
37 #include "backdrop.h"
38 #include "exported_menus.h"
40 #if LCD_DEPTH > 1
41 /**
42 * Menu to clear the backdrop image
44 static int clear_main_backdrop(void)
46 global_settings.backdrop_file[0]=0;
47 unload_main_backdrop();
48 show_main_backdrop();
49 settings_save();
50 return 0;
52 MENUITEM_FUNCTION(clear_main_bd, 0, ID2P(LANG_CLEAR_BACKDROP),
53 clear_main_backdrop, NULL, NULL, Icon_NOICON);
54 #endif
55 #ifdef HAVE_LCD_COLOR
57 enum Colors {
58 COLOR_FG = 0,
59 COLOR_BG,
60 COLOR_LSS,
61 COLOR_LSE,
62 COLOR_LST,
63 COLOR_COUNT
65 static struct colour_info
67 int *setting;
68 int lang_id;
69 } colors[COLOR_COUNT] = {
70 [COLOR_FG] = {&global_settings.fg_color, LANG_FOREGROUND_COLOR},
71 [COLOR_BG] = {&global_settings.bg_color, LANG_BACKGROUND_COLOR},
72 [COLOR_LSS] = {&global_settings.lss_color, LANG_SELECTOR_START_COLOR},
73 [COLOR_LSE] = {&global_settings.lse_color, LANG_SELECTOR_END_COLOR},
74 [COLOR_LST] = {&global_settings.lst_color, LANG_SELECTOR_TEXT_COLOR},
77 /**
78 * Menu for fore/back/selection colors
80 static int set_color_func(void* color)
82 int res, c = (intptr_t)color, banned_color=-1;
84 /* Don't let foreground be set the same as background and vice-versa */
85 if (c == COLOR_BG)
86 banned_color = *colors[COLOR_FG].setting;
87 else if (c == COLOR_FG)
88 banned_color = *colors[COLOR_BG].setting;
90 res = (int)set_color(&screens[SCREEN_MAIN],str(colors[c].lang_id),
91 colors[c].setting, banned_color);
92 settings_save();
93 settings_apply(false);
94 return res;
97 static int reset_color(void)
99 global_settings.fg_color = LCD_DEFAULT_FG;
100 global_settings.bg_color = LCD_DEFAULT_BG;
101 global_settings.lss_color = LCD_DEFAULT_LS;
102 global_settings.lse_color = LCD_DEFAULT_BG;
103 global_settings.lst_color = LCD_DEFAULT_FG;
105 settings_save();
106 settings_apply(false);
107 return 0;
109 MENUITEM_FUNCTION(set_bg_col, MENU_FUNC_USEPARAM, ID2P(LANG_BACKGROUND_COLOR),
110 set_color_func, (void*)COLOR_BG, NULL, Icon_NOICON);
111 MENUITEM_FUNCTION(set_fg_col, MENU_FUNC_USEPARAM, ID2P(LANG_FOREGROUND_COLOR),
112 set_color_func, (void*)COLOR_FG, NULL, Icon_NOICON);
113 MENUITEM_FUNCTION(set_lss_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_START_COLOR),
114 set_color_func, (void*)COLOR_LSS, NULL, Icon_NOICON);
115 MENUITEM_FUNCTION(set_lse_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_END_COLOR),
116 set_color_func, (void*)COLOR_LSE, NULL, Icon_NOICON);
117 MENUITEM_FUNCTION(set_lst_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_TEXT_COLOR),
118 set_color_func, (void*)COLOR_LST, NULL, Icon_NOICON);
119 MENUITEM_FUNCTION(reset_colors, 0, ID2P(LANG_RESET_COLORS),
120 reset_color, NULL, NULL, Icon_NOICON);
122 MAKE_MENU(lss_settings, ID2P(LANG_SELECTOR_COLOR_MENU),
123 NULL, Icon_NOICON,
124 &set_lss_col, &set_lse_col, &set_lst_col
127 /* now the actual menu */
128 MAKE_MENU(colors_settings, ID2P(LANG_COLORS_MENU),
129 NULL, Icon_Display_menu,
130 &lss_settings,
131 &set_bg_col, &set_fg_col, &reset_colors
134 #endif /* HAVE_LCD_COLOR */
135 /* LCD MENU */
136 /***********************************/
138 #ifdef HAVE_LCD_BITMAP
139 static struct browse_folder_info fonts = {FONT_DIR, SHOW_FONT};
140 #endif
141 static struct browse_folder_info wps = {WPS_DIR, SHOW_WPS};
142 #ifdef HAVE_REMOTE_LCD
143 static struct browse_folder_info rwps = {WPS_DIR, SHOW_RWPS};
144 #endif
145 static struct browse_folder_info themes = {THEME_DIR, SHOW_CFG};
147 int browse_folder(void *param)
149 const struct browse_folder_info *info =
150 (const struct browse_folder_info*)param;
151 return rockbox_browse(info->dir, info->show_options);
154 #ifdef HAVE_LCD_BITMAP
155 MENUITEM_FUNCTION(browse_fonts, MENU_FUNC_USEPARAM,
156 ID2P(LANG_CUSTOM_FONT),
157 browse_folder, (void*)&fonts, NULL, Icon_Font);
158 #endif
159 MENUITEM_FUNCTION(browse_wps, MENU_FUNC_USEPARAM,
160 ID2P(LANG_WHILE_PLAYING),
161 browse_folder, (void*)&wps, NULL, Icon_Wps);
162 #ifdef HAVE_REMOTE_LCD
163 MENUITEM_FUNCTION(browse_rwps, MENU_FUNC_USEPARAM,
164 ID2P(LANG_REMOTE_WHILE_PLAYING),
165 browse_folder, (void*)&rwps, NULL, Icon_Wps);
166 #endif
168 MENUITEM_SETTING(show_icons, &global_settings.show_icons, NULL);
169 MENUITEM_FUNCTION(browse_themes, MENU_FUNC_USEPARAM,
170 ID2P(LANG_CUSTOM_THEME),
171 browse_folder, (void*)&themes, NULL, Icon_Config);
172 #ifdef HAVE_LCD_BITMAP
173 MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, NULL);
174 #endif
176 MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
177 NULL, Icon_Wps,
178 &browse_themes,
179 #ifdef HAVE_LCD_BITMAP
180 &browse_fonts,
181 #endif
182 &browse_wps,
183 #ifdef HAVE_REMOTE_LCD
184 &browse_rwps,
185 #endif
186 &show_icons,
187 #if LCD_DEPTH > 1
188 &clear_main_bd,
189 #endif
190 #ifdef HAVE_LCD_BITMAP
191 &cursor_style,
192 #endif
193 #ifdef HAVE_LCD_COLOR
194 &colors_settings,
195 #endif