Add backdrop functions to the multiscreen api and add a enum backdrop_type parameter...
[kugel-rb/myfork.git] / apps / menus / theme_menu.c
blobf96a6ced4b3910a6c422b04fb47734176b444e47
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 "talk.h"
36 #include "color_picker.h"
37 #include "lcd.h"
38 #include "lcd-remote.h"
39 #include "backdrop.h"
40 #include "exported_menus.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 settings_save();
52 return 0;
54 MENUITEM_FUNCTION(clear_main_bd, 0, ID2P(LANG_CLEAR_BACKDROP),
55 clear_main_backdrop, NULL, NULL, Icon_NOICON);
56 #endif
57 #ifdef HAVE_LCD_COLOR
59 enum Colors {
60 COLOR_FG = 0,
61 COLOR_BG,
62 COLOR_LSS,
63 COLOR_LSE,
64 COLOR_LST,
65 COLOR_COUNT
67 static struct colour_info
69 int *setting;
70 int lang_id;
71 } colors[COLOR_COUNT] = {
72 [COLOR_FG] = {&global_settings.fg_color, LANG_FOREGROUND_COLOR},
73 [COLOR_BG] = {&global_settings.bg_color, LANG_BACKGROUND_COLOR},
74 [COLOR_LSS] = {&global_settings.lss_color, LANG_SELECTOR_START_COLOR},
75 [COLOR_LSE] = {&global_settings.lse_color, LANG_SELECTOR_END_COLOR},
76 [COLOR_LST] = {&global_settings.lst_color, LANG_SELECTOR_TEXT_COLOR},
79 /**
80 * Menu for fore/back/selection colors
82 static int set_color_func(void* color)
84 int res, c = (intptr_t)color, banned_color=-1;
86 /* Don't let foreground be set the same as background and vice-versa */
87 if (c == COLOR_BG)
88 banned_color = *colors[COLOR_FG].setting;
89 else if (c == COLOR_FG)
90 banned_color = *colors[COLOR_BG].setting;
92 res = (int)set_color(&screens[SCREEN_MAIN],str(colors[c].lang_id),
93 colors[c].setting, banned_color);
94 settings_save();
95 settings_apply(false);
96 return res;
99 static int reset_color(void)
101 global_settings.fg_color = LCD_DEFAULT_FG;
102 global_settings.bg_color = LCD_DEFAULT_BG;
103 global_settings.lss_color = LCD_DEFAULT_LS;
104 global_settings.lse_color = LCD_DEFAULT_BG;
105 global_settings.lst_color = LCD_DEFAULT_FG;
107 settings_save();
108 settings_apply(false);
109 return 0;
111 MENUITEM_FUNCTION(set_bg_col, MENU_FUNC_USEPARAM, ID2P(LANG_BACKGROUND_COLOR),
112 set_color_func, (void*)COLOR_BG, NULL, Icon_NOICON);
113 MENUITEM_FUNCTION(set_fg_col, MENU_FUNC_USEPARAM, ID2P(LANG_FOREGROUND_COLOR),
114 set_color_func, (void*)COLOR_FG, NULL, Icon_NOICON);
115 MENUITEM_FUNCTION(set_lss_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_START_COLOR),
116 set_color_func, (void*)COLOR_LSS, NULL, Icon_NOICON);
117 MENUITEM_FUNCTION(set_lse_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_END_COLOR),
118 set_color_func, (void*)COLOR_LSE, NULL, Icon_NOICON);
119 MENUITEM_FUNCTION(set_lst_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_TEXT_COLOR),
120 set_color_func, (void*)COLOR_LST, NULL, Icon_NOICON);
121 MENUITEM_FUNCTION(reset_colors, 0, ID2P(LANG_RESET_COLORS),
122 reset_color, NULL, NULL, Icon_NOICON);
124 MAKE_MENU(lss_settings, ID2P(LANG_SELECTOR_COLOR_MENU),
125 NULL, Icon_NOICON,
126 &set_lss_col, &set_lse_col, &set_lst_col
129 /* now the actual menu */
130 MAKE_MENU(colors_settings, ID2P(LANG_COLORS_MENU),
131 NULL, Icon_Display_menu,
132 &lss_settings,
133 &set_bg_col, &set_fg_col, &reset_colors
136 #endif /* HAVE_LCD_COLOR */
137 /* LCD MENU */
138 /***********************************/
140 #ifdef HAVE_LCD_BITMAP
141 static struct browse_folder_info fonts = {FONT_DIR, SHOW_FONT};
142 #endif
143 static struct browse_folder_info wps = {WPS_DIR, SHOW_WPS};
144 #ifdef HAVE_REMOTE_LCD
145 static struct browse_folder_info rwps = {WPS_DIR, SHOW_RWPS};
146 #endif
147 static struct browse_folder_info themes = {THEME_DIR, SHOW_CFG};
149 int browse_folder(void *param)
151 const struct browse_folder_info *info =
152 (const struct browse_folder_info*)param;
153 return rockbox_browse(info->dir, info->show_options);
156 #ifdef HAVE_LCD_BITMAP
157 MENUITEM_FUNCTION(browse_fonts, MENU_FUNC_USEPARAM,
158 ID2P(LANG_CUSTOM_FONT),
159 browse_folder, (void*)&fonts, NULL, Icon_Font);
160 #endif
161 MENUITEM_FUNCTION(browse_wps, MENU_FUNC_USEPARAM,
162 ID2P(LANG_WHILE_PLAYING),
163 browse_folder, (void*)&wps, NULL, Icon_Wps);
164 #ifdef HAVE_REMOTE_LCD
165 MENUITEM_FUNCTION(browse_rwps, MENU_FUNC_USEPARAM,
166 ID2P(LANG_REMOTE_WHILE_PLAYING),
167 browse_folder, (void*)&rwps, NULL, Icon_Wps);
168 #endif
170 MENUITEM_SETTING(show_icons, &global_settings.show_icons, NULL);
171 MENUITEM_FUNCTION(browse_themes, MENU_FUNC_USEPARAM,
172 ID2P(LANG_CUSTOM_THEME),
173 browse_folder, (void*)&themes, NULL, Icon_Config);
174 #ifdef HAVE_LCD_BITMAP
175 MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, NULL);
176 #endif
178 MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
179 NULL, Icon_Wps,
180 &browse_themes,
181 #ifdef HAVE_LCD_BITMAP
182 &browse_fonts,
183 #endif
184 &browse_wps,
185 #ifdef HAVE_REMOTE_LCD
186 &browse_rwps,
187 #endif
188 &show_icons,
189 #if LCD_DEPTH > 1
190 &clear_main_bd,
191 #endif
192 #ifdef HAVE_LCD_BITMAP
193 &cursor_style,
194 #endif
195 #ifdef HAVE_LCD_COLOR
196 &colors_settings,
197 #endif