summaryrefslogtreecommitdiff
path: root/apps/menus/display_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/menus/display_menu.c')
-rw-r--r--apps/menus/display_menu.c537
1 files changed, 533 insertions, 4 deletions
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c
index adb24395fa..a1067fc333 100644
--- a/apps/menus/display_menu.c
+++ b/apps/menus/display_menu.c
@@ -1,4 +1,3 @@
1
2/*************************************************************************** 1/***************************************************************************
3 * __________ __ ___. 2 * __________ __ ___.
4 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
@@ -27,7 +26,537 @@
27#include "settings.h" 26#include "settings.h"
28#include "menu.h" 27#include "menu.h"
29#include "settings_menu.h" 28#include "settings_menu.h"
29#include "tree.h"
30#include "list.h"
31#ifdef HAVE_LCD_BITMAP
32#include "backdrop.h"
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
40
41#ifdef CONFIG_BACKLIGHT
42int filterfirstkeypress_callback(int action,const struct menu_item_ex *this_item)
43{
44 (void)this_item;
45 switch (action)
46 {
47 case ACTION_EXIT_MENUITEM:
48 set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
49#ifdef HAVE_REMOTE_LCD
50 set_remote_backlight_filter_keypress(
51 global_settings.remote_bl_filter_first_keypress);
52#endif
53
54 break;
55 }
56 return action;
57}
58#endif
59#ifdef HAVE_LCD_BITMAP
60int flipdisplay_callback(int action,const struct menu_item_ex *this_item)
61{
62 (void)this_item;
63 switch (action)
64 {
65 case ACTION_EXIT_MENUITEM:
66 button_set_flip(global_settings.flip_display);
67 lcd_set_flip(global_settings.flip_display);
68#ifdef HAVE_REMOTE_LCD
69 lcd_remote_set_flip(global_settings.remote_flip_display);
70 lcd_remote_update();
71#endif
72 break;
73 }
74 return action;
75}
76#endif
77
78/***********************************/
79/* LCD MENU */
80#ifdef CONFIG_BACKLIGHT
81MENUITEM_SETTING(backlight_timeout, &global_settings.backlight_timeout, NULL);
82#ifdef CONFIG_CHARGING
83MENUITEM_SETTING(backlight_timeout_plugged,
84 &global_settings.backlight_timeout_plugged, NULL);
85#endif
86#ifdef HAS_BUTTON_HOLD
87MENUITEM_SETTING(backlight_on_button_hold,
88 &global_settings.backlight_on_button_hold, NULL);
89#endif
90MENUITEM_SETTING(caption_backlight, &global_settings.caption_backlight, NULL);
91#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
92MENUITEM_SETTING(backlight_fade_in, &global_settings.backlight_fade_in, NULL);
93MENUITEM_SETTING(backlight_fade_out, &global_settings.backlight_fade_out, NULL);
94#endif
95MENUITEM_SETTING(bl_filter_first_keypress,
96 &global_settings.bl_filter_first_keypress,
97 filterfirstkeypress_callback);
98#ifdef HAVE_LCD_SLEEP
99MENUITEM_SETTING(lcd_sleep_after_backlight_off,
100 &global_settings.lcd_sleep_after_backlight_off, NULL);
101#endif
102#ifdef HAVE_BACKLIGHT_BRIGHTNESS
103MENUITEM_SETTING(brightness_item, &global_settings.brightness, NULL);
104#endif
105#endif /* CONFIG_BACKLIGHT */
106#ifdef HAVE_LCD_CONTRAST
107MENUITEM_SETTING(contrast, &global_settings.contrast, NULL);
108#endif
109#ifdef HAVE_LCD_BITMAP
110#ifdef HAVE_LCD_INVERT
111MENUITEM_SETTING(invert, &global_settings.invert, NULL);
112#endif
113#ifdef HAVE_LCD_FLIP
114MENUITEM_SETTING(flip_display, &global_settings.flip_display, flipdisplay_callback);
115#endif
116MENUITEM_SETTING(invert_cursor, &global_settings.invert_cursor, NULL);
117#endif /* HAVE_LCD_BITMAP */
118#ifdef HAVE_LCD_COLOR
119/**
120* Menu to clear the backdrop image
121 */
122static int clear_main_backdrop(void)
123{
124 global_settings.backdrop_file[0]=0;
125 unload_main_backdrop();
126 show_main_backdrop();
127 return 0;
128}
129
130/**
131 * Menu for fore/back colors
132 */
133static int set_fg_color(void)
134{
135 int res;
136 res = (int)set_color(&screens[SCREEN_MAIN],str(LANG_FOREGROUND_COLOR),
137 &global_settings.fg_color,global_settings.bg_color);
138
139 screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
140 return res;
141}
142
143static int set_bg_color(void)
144{
145 int res;
146 res = (int)set_color(&screens[SCREEN_MAIN],str(LANG_BACKGROUND_COLOR),
147 &global_settings.bg_color,global_settings.fg_color);
148
149 screens[SCREEN_MAIN].set_background(global_settings.bg_color);
150 return res;
151}
152
153static int reset_color(void)
154{
155 global_settings.fg_color = LCD_DEFAULT_FG;
156 global_settings.bg_color = LCD_DEFAULT_BG;
157
158 screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
159 screens[SCREEN_MAIN].set_background(global_settings.bg_color);
160 return 0;
161}
162MENUITEM_FUNCTION(clear_main_bd, ID2P(LANG_CLEAR_BACKDROP),
163 clear_main_backdrop, NULL, NOICON);
164MENUITEM_FUNCTION(set_bg_col, ID2P(LANG_BACKGROUND_COLOR),
165 set_bg_color, NULL, NOICON);
166MENUITEM_FUNCTION(set_fg_col, ID2P(LANG_FOREGROUND_COLOR),
167 set_fg_color, NULL, NOICON);
168MENUITEM_FUNCTION(reset_colors, ID2P(LANG_RESET_COLORS),
169 reset_color, NULL, NOICON);
170#endif
171
172/* now the actual menu */
173MAKE_MENU(lcd_settings,ID2P(LANG_LCD_MENU),
174 NULL, bitmap_icons_6x8[Icon_Display_menu]
175#ifdef CONFIG_BACKLIGHT
176 ,&backlight_timeout
177# ifdef CONFIG_CHARGING
178 ,&backlight_timeout_plugged
179# endif
180# ifdef HAS_BUTTON_HOLD
181 ,&backlight_on_button_hold
182# endif
183 ,&caption_backlight
184# if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
185 ,&backlight_fade_in, &backlight_fade_out
186# endif
187 ,&bl_filter_first_keypress
188# ifdef HAVE_LCD_SLEEP
189 ,&lcd_sleep_after_backlight_off
190# endif
191# ifdef HAVE_BACKLIGHT_BRIGHTNESS
192 ,&brightness_item
193# endif
194#endif /* CONFIG_BACKLIGHT */
195#ifdef HAVE_LCD_CONTRAST
196 ,&contrast
197#endif
198#ifdef HAVE_LCD_BITMAP
199# ifdef HAVE_LCD_INVERT
200 ,&invert
201# endif
202# ifdef HAVE_LCD_FLIP
203 ,&flip_display
204# endif
205 ,&invert_cursor
206#endif /* HAVE_LCD_BITMAP */
207#ifdef HAVE_LCD_COLOR
208 ,&clear_main_bd, &set_bg_col, &set_fg_col, &reset_colors
209#endif
210 );
211/* LCD MENU */
212/***********************************/
213
214
215/********************************/
216/* Remote LCD settings menu */
217#ifdef HAVE_REMOTE_LCD
218MENUITEM_SETTING(remote_backlight_timeout,
219 &global_settings.remote_backlight_timeout, NULL);
220
221#ifdef CONFIG_CHARGING
222MENUITEM_SETTING(remote_backlight_timeout_plugged,
223 &global_settings.remote_backlight_timeout_plugged, NULL);
224#endif
225
226#ifdef HAS_REMOTE_BUTTON_HOLD
227MENUITEM_SETTING(remote_backlight_on_button_hold,
228 &global_settings.remote_backlight_on_button_hold, NULL);
229#endif
230
231MENUITEM_SETTING(remote_caption_backlight,
232 &global_settings.remote_caption_backlight, NULL);
233MENUITEM_SETTING(remote_bl_filter_first_keypress,
234 &global_settings.remote_bl_filter_first_keypress,
235 filterfirstkeypress_callback);
236MENUITEM_SETTING(remote_contrast,
237 &global_settings.remote_contrast, NULL);
238MENUITEM_SETTING(remote_invert,
239 &global_settings.remote_invert, NULL);
240
241MENUITEM_SETTING(remote_flip_display,
242 &global_settings.remote_flip_display, flipdisplay_callback);
243
244#ifdef HAVE_REMOTE_LCD_TICKING
245int ticking_callback(int action,const struct menu_item_ex *this_item)
246{
247 (void)this_item;
248 switch (action)
249 {
250 case ACTION_EXIT_MENUITEM:
251 lcd_remote_emireduce(global_settings.remote_reduce_ticking);
252 break;
253 }
254 return action;
255}
256MENUITEM_SETTING(remote_reduce_ticking,
257 &global_settings.remote_reduce_ticking, ticking_callback);
258#endif
259
260MAKE_MENU(lcd_remote_settings, ID2P(LANG_LCD_REMOTE_MENU),
261 NULL, bitmap_icons_6x8[Icon_Remote_Display_menu],
262 &remote_backlight_timeout,
263#ifdef CONFIG_CHARGING
264 &remote_backlight_timeout_plugged,
265#endif
266#ifdef HAS_REMOTE_BUTTON_HOLD
267 &remote_backlight_on_button_hold,
268#endif
269 &remote_caption_backlight, &remote_bl_filter_first_keypress,
270 &remote_contrast, &remote_invert, &remote_flip_display
271#ifdef HAVE_REMOTE_LCD_TICKING
272 ,&remote_reduce_ticking
273#endif
274 );
275
276#endif /* HAVE_REMOTE_LCD */
277/* Remote LCD settings menu */
278/********************************/
279
280/***********************************/
281/* SCROLL MENU */
282MENUITEM_SETTING(scroll_speed, &global_settings.scroll_speed, NULL);
283MENUITEM_SETTING(scroll_delay, &global_settings.scroll_delay, NULL);
284#ifdef HAVE_LCD_BITMAP
285MENUITEM_SETTING(scroll_step, &global_settings.scroll_step, NULL);
286#endif
287MENUITEM_SETTING(bidir_limit, &global_settings.bidir_limit, NULL);
288#ifdef HAVE_REMOTE_LCD
289MENUITEM_SETTING(remote_scroll_speed, &global_settings.remote_scroll_speed, NULL);
290MENUITEM_SETTING(remote_scroll_delay, &global_settings.remote_scroll_delay, NULL);
291MENUITEM_SETTING(remote_scroll_step, &global_settings.remote_scroll_step, NULL);
292MENUITEM_SETTING(remote_bidir_limit, &global_settings.remote_bidir_limit, NULL);
293MAKE_MENU(remote_scroll_sets, ID2P(LANG_REMOTE_SCROLL_SETS), 0, NOICON,
294 &remote_scroll_speed, &remote_scroll_delay,
295 &remote_scroll_step, &remote_bidir_limit);
296#endif /* HAVE_REMOTE_LCD */
297#ifdef HAVE_LCD_CHARCELLS
298MENUITEM_SETTING(jump_scroll, &global_settings.jump_scroll, NULL);
299MENUITEM_SETTING(jump_scroll_delay, &global_settings.jump_scroll_delay, NULL);
300#endif
301#ifdef HAVE_LCD_BITMAP
302int screenscroll_callback(int action,const struct menu_item_ex *this_item)
303{
304 (void)this_item;
305 switch (action)
306 {
307 case ACTION_EXIT_MENUITEM:
308 gui_list_screen_scroll_out_of_view(global_settings.offset_out_of_view);
309 break;
310 }
311 return action;
312}
313MENUITEM_SETTING(offset_out_of_view, &global_settings.offset_out_of_view,
314 screenscroll_callback);
315MENUITEM_SETTING(screen_scroll_step, &global_settings.screen_scroll_step, NULL);
316#endif
317MENUITEM_SETTING(scroll_paginated, &global_settings.scroll_paginated, NULL);
318
319MAKE_MENU(scroll_settings_menu, ID2P(LANG_SCROLL_MENU), 0, NOICON,
320 &scroll_speed, &scroll_delay,
321#ifdef HAVE_LCD_BITMAP
322 &scroll_step,
323#endif
324 &bidir_limit,
325#ifdef HAVE_REMOTE_LCD
326 &remote_scroll_sets,
327#endif
328#ifdef HAVE_LCD_CHARCELLS
329 &jump_scroll, &jump_scroll_delay,
330#endif
331#ifdef HAVE_LCD_BITMAP
332 &offset_out_of_view, &screen_scroll_step,
333#endif
334 &scroll_paginated
335 );
336/* SCROLL MENU */
337/***********************************/
338
339/***********************************/
340/* BARS MENU */
341#ifdef HAVE_LCD_BITMAP
342MENUITEM_SETTING(scrollbar_item, &global_settings.scrollbar, NULL);
343MENUITEM_SETTING(statusbar, &global_settings.statusbar, NULL);
344#if CONFIG_KEYPAD == RECORDER_PAD
345MENUITEM_SETTING(buttonbar, &global_settings.buttonbar, NULL);
346#endif
347MENUITEM_SETTING(volume_type, &global_settings.volume_type, NULL);
348MENUITEM_SETTING(battery_display, &global_settings.battery_display, NULL);
349MAKE_MENU(bars_menu, ID2P(LANG_BARS_MENU), 0, NOICON,
350 &scrollbar_item, &statusbar,
351#if CONFIG_KEYPAD == RECORDER_PAD
352 &buttonbar,
353#endif
354 &volume_type, &battery_display);
355#endif /* HAVE_LCD_BITMAP */
356/* BARS MENU */
357/***********************************/
358
359
360/***********************************/
361/* PEAK METER MENU */
362
363#ifdef HAVE_LCD_BITMAP
364int peakmeter_callback(int action,const struct menu_item_ex *this_item)
365{
366 (void)this_item;
367 switch (action)
368 {
369 case ACTION_EXIT_MENUITEM:
370 peak_meter_init_times(global_settings.peak_meter_release,
371 global_settings.peak_meter_hold,
372 global_settings.peak_meter_clip_hold);
373 break;
374 }
375 return action;
376}
377MENUITEM_SETTING(peak_meter_clip_hold,
378 &global_settings.peak_meter_clip_hold, peakmeter_callback);
379
380MENUITEM_SETTING(peak_meter_release,
381 &global_settings.peak_meter_release, peakmeter_callback);
382/**
383 * Menu to select wether the scale of the meter
384 * displays dBfs of linear values.
385 */
386static int peak_meter_scale(void) {
387 bool retval = false;
388 bool use_dbfs = global_settings.peak_meter_dbfs;
389 retval = set_bool_options(str(LANG_PM_SCALE),
390 &use_dbfs,
391 STR(LANG_PM_DBFS), STR(LANG_PM_LINEAR),
392 NULL);
393
394 /* has the user really changed the scale? */
395 if (use_dbfs != global_settings.peak_meter_dbfs) {
396
397 /* store the change */
398 global_settings.peak_meter_dbfs = use_dbfs;
399 peak_meter_set_use_dbfs(use_dbfs);
400
401 /* If the user changed the scale mode the meaning of
402 peak_meter_min (peak_meter_max) has changed. Thus we have
403 to convert the values stored in global_settings. */
404 if (use_dbfs) {
405
406 /* we only store -dBfs */
407 global_settings.peak_meter_min = -peak_meter_get_min() / 100;
408 global_settings.peak_meter_max = -peak_meter_get_max() / 100;
409 } else {
410 int max;
411
412 /* linear percent */
413 global_settings.peak_meter_min = peak_meter_get_min();
414
415 /* converting dBfs -> percent results in a precision loss.
416 I assume that the user doesn't bother that conversion
417 dBfs <-> percent isn't symmetrical for odd values but that
418 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
419 resulting from dBfs -> percent manually here */
420 max = peak_meter_get_max();
421 global_settings.peak_meter_max = max < 99 ? max : 100;
422 }
423 settings_apply_pm_range();
424 }
425 return retval;
426}
427
428/**
429 * Adjust the min value of the value range that
430 * the peak meter shall visualize.
431 */
432static int peak_meter_min(void) {
433 bool retval = false;
434 if (global_settings.peak_meter_dbfs) {
435
436 /* for dBfs scale */
437 int range_max = -global_settings.peak_meter_max;
438 int min = -global_settings.peak_meter_min;
439
440 retval = set_int(str(LANG_PM_MIN), str(LANG_PM_DBFS), UNIT_DB,
441 &min, NULL, 1, -89, range_max, NULL);
442
443 global_settings.peak_meter_min = - min;
444 }
445
446 /* for linear scale */
447 else {
448 int min = global_settings.peak_meter_min;
449
450 retval = set_int(str(LANG_PM_MIN), "%", UNIT_PERCENT,
451 &min, NULL,
452 1, 0, global_settings.peak_meter_max - 1, NULL);
453
454 global_settings.peak_meter_min = (unsigned char)min;
455 }
456
457 settings_apply_pm_range();
458 return retval;
459}
460
461
462/**
463 * Adjust the max value of the value range that
464 * the peak meter shall visualize.
465 */
466static int peak_meter_max(void) {
467 bool retval = false;
468 if (global_settings.peak_meter_dbfs) {
469
470 /* for dBfs scale */
471 int range_min = -global_settings.peak_meter_min;
472 int max = -global_settings.peak_meter_max;;
473
474 retval = set_int(str(LANG_PM_MAX), str(LANG_PM_DBFS), UNIT_DB,
475 &max, NULL, 1, range_min, 0, NULL);
476
477 global_settings.peak_meter_max = - max;
478
479 }
480
481 /* for linear scale */
482 else {
483 int max = global_settings.peak_meter_max;
484
485 retval = set_int(str(LANG_PM_MAX), "%", UNIT_PERCENT,
486 &max, NULL,
487 1, global_settings.peak_meter_min + 1, 100, NULL);
488
489 global_settings.peak_meter_max = (unsigned char)max;
490 }
491
492 settings_apply_pm_range();
493 return retval;
494}
495MENUITEM_FUNCTION(peak_meter_scale_item, ID2P(LANG_PM_SCALE),
496 peak_meter_scale, NULL, NOICON);
497MENUITEM_FUNCTION(peak_meter_min_item, ID2P(LANG_PM_MIN),
498 peak_meter_min, NULL, NOICON);
499MENUITEM_FUNCTION(peak_meter_max_item, ID2P(LANG_PM_MAX),
500 peak_meter_max, NULL, NOICON);
501MAKE_MENU(peak_meter_menu, ID2P(LANG_PM_MENU), NULL, NOICON,
502 &peak_meter_clip_hold, &peak_meter_release,
503 &peak_meter_scale_item, &peak_meter_min_item, &peak_meter_max_item);
504#endif /* HAVE_LCD_BITMAP */
505/* PEAK METER MENU */
506/***********************************/
507
508
509
510struct browse_folder_info {
511 const char* dir;
512 int show_options;
513};
514#ifdef HAVE_LCD_BITMAP
515static struct browse_folder_info fonts = {FONT_DIR, SHOW_FONT};
516#endif
517static struct browse_folder_info wps = {WPS_DIR, SHOW_WPS};
518#ifdef HAVE_REMOTE_LCD
519static struct browse_folder_info rwps = {WPS_DIR, SHOW_RWPS};
520#endif
521
522static int browse_folder(void *param)
523{
524 const struct browse_folder_info *info =
525 (const struct browse_folder_info*)param;
526 return rockbox_browse(info->dir, info->show_options);
527}
528
529#ifdef HAVE_LCD_BITMAP
530MENUITEM_FUNCTION_WPARAM(browse_fonts, ID2P(LANG_CUSTOM_FONT),
531 browse_folder, (void*)&fonts, NULL, NOICON);
532#endif
533MENUITEM_FUNCTION_WPARAM(browse_wps, ID2P(LANG_WHILE_PLAYING),
534 browse_folder, (void*)&wps, NULL, NOICON);
535#ifdef HAVE_REMOTE_LCD
536MENUITEM_FUNCTION_WPARAM(browse_rwps, ID2P(LANG_REMOTE_WHILE_PLAYING),
537 browse_folder, (void*)&rwps, NULL, NOICON);
538#endif
539
540MENUITEM_SETTING(show_icons, &global_settings.show_icons, NULL);
541MENUITEM_SETTING(codepage_setting, &global_settings.default_codepage, NULL);
542
30 543
31bool display_settings_menu(void); /* from ../settings_menu.c */ 544MAKE_MENU(display_menu, ID2P(LANG_DISPLAY),
32MENUITEM_FUNCTION(display_menu,ID2P(LANG_DISPLAY), 545 NULL, bitmap_icons_6x8[Icon_Display_menu],
33 (menu_function)display_settings_menu,NULL, bitmap_icons_6x8[Icon_Display_menu]); 546#ifdef HAVE_LCD_BITMAP
547 &browse_fonts,
548#endif
549 &browse_wps,
550#ifdef HAVE_REMOTE_LCD
551 &browse_rwps,
552#endif
553 &lcd_settings,
554#ifdef HAVE_REMOTE_LCD
555 &lcd_remote_settings,
556#endif
557 &show_icons, &scroll_settings_menu,
558#ifdef HAVE_LCD_BITMAP
559 &bars_menu, &peak_meter_menu,
560#endif
561 &codepage_setting,
562 );