diff --git a/apps/bookmark.c b/apps/bookmark.c index e832165b3c..646be3b1cd 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -92,13 +92,14 @@ bool bookmark_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_BOOKMARK_MENU_CREATE), bookmark_create_menu}, { STR(LANG_BOOKMARK_MENU_LIST), bookmark_load_menu}, { STR(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), bookmark_mrb_load}, }; - m=menu_init( items, sizeof items / sizeof(struct menu_items), NULL ); + m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL, + NULL, NULL, NULL); #ifdef HAVE_LCD_CHARCELLS status_set_param(true); diff --git a/apps/debug_menu.c b/apps/debug_menu.c index d0c575ba12..7872323347 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -1475,7 +1475,7 @@ bool debug_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { "Dump ROM contents", -1, dbg_save_roms }, { "View I/O ports", -1, dbg_ports }, #ifdef HAVE_LCD_BITMAP @@ -1509,7 +1509,8 @@ bool debug_menu(void) #endif }; - m=menu_init( items, sizeof items / sizeof(struct menu_items), NULL ); + m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); diff --git a/apps/lang/english.lang b/apps/lang/english.lang index f88e211192..2c98f9f641 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -1701,3 +1701,23 @@ id: LANG_FILE_OPTIONS desc: in playlist viewer on+play menu eng: "File Options" new: + +id: LANG_BUTTON_BAR +desc: in settings menu +eng: "Button bar" +new: + +id: LANG_DIRBROWSE_F1 +desc: in dir browser, F1 button bar text +eng: "Menu" +new: + +id: LANG_DIRBROWSE_F2 +desc: in dir browser, F2 button bar text +eng: "Option" +new: + +id: LANG_DIRBROWSE_F3 +desc: in dir browser, F3 button bar text +eng: "LCD" +new: diff --git a/apps/main_menu.c b/apps/main_menu.c index ade6e7bd99..6fec696240 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c @@ -261,12 +261,13 @@ bool rec_menu(void) bool result; /* recording menu */ - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_RECORDING_MENU), recording_screen }, { STR(LANG_RECORDING_SETTINGS), recording_settings}, }; - m=menu_init( items, sizeof items / sizeof(struct menu_items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); @@ -280,7 +281,7 @@ bool info_menu(void) bool result; /* info menu */ - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_MENU_SHOW_ID3_INFO), browse_id3 }, { STR(LANG_INFO_MENU), show_info }, { STR(LANG_VERSION), show_credits }, @@ -291,7 +292,8 @@ bool info_menu(void) #endif }; - m=menu_init( items, sizeof items / sizeof(struct menu_items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); @@ -305,7 +307,7 @@ bool main_menu(void) int i = 0; /* main menu */ - struct menu_items items[8]; + struct menu_item items[8]; items[i].desc = str(LANG_BOOKMARK_MENU); items[i].voice_id = LANG_BOOKMARK_MENU; @@ -345,7 +347,7 @@ bool main_menu(void) items[i].voice_id = LANG_INFO; items[i++].function = info_menu; - m=menu_init( items, i, NULL ); + m=menu_init( items, i, NULL, NULL, NULL, NULL ); #ifdef HAVE_LCD_CHARCELLS status_set_param(true); #endif diff --git a/apps/menu.c b/apps/menu.c index f9443548f6..d1f073645b 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -42,9 +42,13 @@ struct menu { int top; int cursor; - struct menu_items* items; + struct menu_item* items; int itemcount; int (*callback)(int, int); +#ifdef HAVE_LCD_BITMAP + bool use_buttonbar; /* true if a buttonbar is defined */ + char *buttonbar[3]; +#endif }; #define MAX_MENUS 5 @@ -132,12 +136,22 @@ void menu_draw(int m) #ifdef HAVE_LCD_BITMAP int fw, fh; int menu_lines; + int height = LCD_HEIGHT; + lcd_setfont(FONT_UI); lcd_getstringsize("A", &fw, &fh); if (global_settings.statusbar) - menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh; - else - menu_lines = LCD_HEIGHT/fh; + height -= STATUSBAR_HEIGHT; + + if(global_settings.buttonbar && menus[m].use_buttonbar) { + buttonbar_set(menus[m].buttonbar[0], + menus[m].buttonbar[1], + menus[m].buttonbar[2]); + height -= BUTTONBAR_HEIGHT; + } + + menu_lines = height / fh; + #else int menu_lines = MENU_LINES; #endif @@ -170,10 +184,14 @@ void menu_draw(int m) #ifdef HAVE_LCD_BITMAP if (global_settings.scrollbar && menus[m].itemcount > menu_lines) scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1, - LCD_HEIGHT - SCROLLBAR_Y, menus[m].itemcount, menus[m].top, + height, menus[m].itemcount, menus[m].top, menus[m].top + menu_lines, VERTICAL); + + if(global_settings.buttonbar && menus[m].use_buttonbar) + buttonbar_draw(); #endif status_draw(true); + lcd_update(); } @@ -187,12 +205,17 @@ static void put_cursor(int m, int target) #ifdef HAVE_LCD_BITMAP int fw, fh; int menu_lines; + int height = LCD_HEIGHT; + lcd_setfont(FONT_UI); lcd_getstringsize("A", &fw, &fh); - if (global_settings.statusbar) - menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh; - else - menu_lines = LCD_HEIGHT/fh; + if(global_settings.statusbar) + height -= STATUSBAR_HEIGHT; + + if(global_settings.buttonbar && menus[m].use_buttonbar) + height -= BUTTONBAR_HEIGHT; + + menu_lines = height / fh; #else int menu_lines = MENU_LINES; #endif @@ -226,7 +249,8 @@ static void put_cursor(int m, int target) } -int menu_init(struct menu_items* mitems, int count, int (*callback)(int, int)) +int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int), + char *button1, char *button2, char *button3) { int i; @@ -245,7 +269,20 @@ int menu_init(struct menu_items* mitems, int count, int (*callback)(int, int)) menus[i].top = 0; menus[i].cursor = 0; menus[i].callback = callback; +#ifdef HAVE_LCD_BITMAP + menus[i].buttonbar[0] = button1; + menus[i].buttonbar[1] = button2; + menus[i].buttonbar[2] = button3; + if(button1 || button2 || button3) + menus[i].use_buttonbar = true; + else + menus[i].use_buttonbar = false; +#else + (void)button1; + (void)button2; + (void)button3; +#endif return i; } @@ -262,12 +299,21 @@ int menu_show(int m) #ifdef HAVE_LCD_BITMAP int fw, fh; int menu_lines; + int height = LCD_HEIGHT; + lcd_setfont(FONT_UI); lcd_getstringsize("A", &fw, &fh); if (global_settings.statusbar) - menu_lines = (LCD_HEIGHT - STATUSBAR_HEIGHT) / fh; - else - menu_lines = LCD_HEIGHT/fh; + height -= STATUSBAR_HEIGHT; + + if(global_settings.buttonbar && menus[m].use_buttonbar) { + buttonbar_set(menus[m].buttonbar[0], + menus[m].buttonbar[1], + menus[m].buttonbar[2]); + height -= BUTTONBAR_HEIGHT; + } + + menu_lines = height / fh; #endif menu_draw(m); @@ -439,7 +485,7 @@ int menu_count(int menu) bool menu_moveup(int menu) { - struct menu_items swap; + struct menu_item swap; /* can't be the first item ! */ if( menus[menu].cursor == 0) @@ -460,7 +506,7 @@ bool menu_moveup(int menu) bool menu_movedown(int menu) { - struct menu_items swap; + struct menu_item swap; /* can't be the last item ! */ if( menus[menu].cursor == menus[menu].itemcount - 1) diff --git a/apps/menu.h b/apps/menu.h index 88a0372299..166a9336b9 100644 --- a/apps/menu.h +++ b/apps/menu.h @@ -22,13 +22,14 @@ #include -struct menu_items { +struct menu_item { unsigned char *desc; /* string */ int voice_id; /* the associated voice clip, -1 if none */ bool (*function) (void); /* return true if USB was connected */ }; -int menu_init(struct menu_items* items, int count, int (*callback) (int keycode, int menu)); +int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int), + char *button1, char *button2, char *button3); void menu_exit(int menu); void put_cursorxy(int x, int y, bool on); @@ -48,6 +49,3 @@ bool menu_movedown(int menu); void menu_draw(int menu); #endif /* End __MENU_H__ */ - - - diff --git a/apps/onplay.c b/apps/onplay.c index 9dab34c283..04bb6b9a3a 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -140,54 +140,54 @@ static bool view_playlist(void) /* Sub-menu for playlist options */ static bool playlist_options(void) { - struct menu_items menu[7]; + struct menu_item items[7]; struct playlist_args args[7]; /* increase these 2 if you add entries! */ int m, i=0, pstart=0, result; bool ret = false; if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U) { - menu[i].desc = str(LANG_VIEW); - menu[i].voice_id = LANG_VIEW; - menu[i].function = view_playlist; + items[i].desc = str(LANG_VIEW); + items[i].voice_id = LANG_VIEW; + items[i].function = view_playlist; i++; pstart++; } if (mpeg_status() & MPEG_STATUS_PLAY) { - menu[i].desc = str(LANG_INSERT); - menu[i].voice_id = LANG_INSERT; + items[i].desc = str(LANG_INSERT); + items[i].voice_id = LANG_INSERT; args[i].position = PLAYLIST_INSERT; args[i].queue = false; i++; - menu[i].desc = str(LANG_INSERT_FIRST); - menu[i].voice_id = LANG_INSERT_FIRST; + items[i].desc = str(LANG_INSERT_FIRST); + items[i].voice_id = LANG_INSERT_FIRST; args[i].position = PLAYLIST_INSERT_FIRST; args[i].queue = false; i++; - menu[i].desc = str(LANG_INSERT_LAST); - menu[i].voice_id = LANG_INSERT_LAST; + items[i].desc = str(LANG_INSERT_LAST); + items[i].voice_id = LANG_INSERT_LAST; args[i].position = PLAYLIST_INSERT_LAST; args[i].queue = false; i++; - menu[i].desc = str(LANG_QUEUE); - menu[i].voice_id = LANG_QUEUE; + items[i].desc = str(LANG_QUEUE); + items[i].voice_id = LANG_QUEUE; args[i].position = PLAYLIST_INSERT; args[i].queue = true; i++; - menu[i].desc = str(LANG_QUEUE_FIRST); - menu[i].voice_id = LANG_QUEUE_FIRST; + items[i].desc = str(LANG_QUEUE_FIRST); + items[i].voice_id = LANG_QUEUE_FIRST; args[i].position = PLAYLIST_INSERT_FIRST; args[i].queue = true; i++; - menu[i].desc = str(LANG_QUEUE_LAST); - menu[i].voice_id = LANG_QUEUE_LAST; + items[i].desc = str(LANG_QUEUE_LAST); + items[i].voice_id = LANG_QUEUE_LAST; args[i].position = PLAYLIST_INSERT_LAST; args[i].queue = true; i++; @@ -195,17 +195,17 @@ static bool playlist_options(void) else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || (selected_file_attr & ATTR_DIRECTORY)) { - menu[i].desc = str(LANG_INSERT); - menu[i].voice_id = LANG_INSERT; + items[i].desc = str(LANG_INSERT); + items[i].voice_id = LANG_INSERT; args[i].position = PLAYLIST_INSERT; args[i].queue = false; i++; } - m = menu_init( menu, i, NULL ); + m = menu_init( items, i, NULL, NULL, NULL, NULL ); result = menu_show(m); if (result >= 0 && result < pstart) - ret = menu[result].function(); + ret = items[result].function(); else if (result >= pstart) ret = add_to_playlist(args[result].position, args[result].queue); menu_exit(m); @@ -550,7 +550,7 @@ bool create_dir(void) int onplay(char* file, int attr) { - struct menu_items menu[5]; /* increase this if you add entries! */ + struct menu_item items[5]; /* increase this if you add entries! */ int m, i=0, result; onplay_result = ONPLAY_OK; @@ -564,44 +564,44 @@ int onplay(char* file, int attr) (attr & ATTR_DIRECTORY) || ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)) { - menu[i].desc = str(LANG_PLAYINDICES_PLAYLIST); - menu[i].voice_id = LANG_PLAYINDICES_PLAYLIST; - menu[i].function = playlist_options; + items[i].desc = str(LANG_PLAYINDICES_PLAYLIST); + items[i].voice_id = LANG_PLAYINDICES_PLAYLIST; + items[i].function = playlist_options; i++; } - menu[i].desc = str(LANG_RENAME); - menu[i].voice_id = LANG_RENAME; - menu[i].function = rename_file; + items[i].desc = str(LANG_RENAME); + items[i].voice_id = LANG_RENAME; + items[i].function = rename_file; i++; if (!(attr & ATTR_DIRECTORY)) { - menu[i].desc = str(LANG_DELETE); - menu[i].voice_id = LANG_DELETE; - menu[i].function = delete_file; + items[i].desc = str(LANG_DELETE); + items[i].voice_id = LANG_DELETE; + items[i].function = delete_file; i++; } if ((attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) { - menu[i].desc = str(LANG_VBRFIX); - menu[i].voice_id = LANG_VBRFIX; - menu[i].function = vbr_fix; + items[i].desc = str(LANG_VBRFIX); + items[i].voice_id = LANG_VBRFIX; + items[i].function = vbr_fix; i++; } } - menu[i].desc = str(LANG_CREATE_DIR); - menu[i].voice_id = LANG_CREATE_DIR; - menu[i].function = create_dir; + items[i].desc = str(LANG_CREATE_DIR); + items[i].voice_id = LANG_CREATE_DIR; + items[i].function = create_dir; i++; /* DIY menu handling, since we want to exit after selection */ - m = menu_init( menu, i, NULL ); + m = menu_init( items, i, NULL, NULL, NULL, NULL ); result = menu_show(m); if (result >= 0) - menu[result].function(); + items[result].function(); menu_exit(m); return onplay_result; diff --git a/apps/playlist_menu.c b/apps/playlist_menu.c index 9da13c335b..da1f9f3734 100644 --- a/apps/playlist_menu.c +++ b/apps/playlist_menu.c @@ -66,14 +66,15 @@ bool playlist_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_CREATE_PLAYLIST), create_playlist }, { STR(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer }, { STR(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist }, { STR(LANG_RECURSE_DIRECTORY), recurse_directory }, }; - - m = menu_init( items, sizeof items / sizeof(struct menu_items), NULL ); + + m = menu_init( items, sizeof items / sizeof(struct menu_item), NULL, + NULL, NULL, NULL ); result = menu_run(m); menu_exit(m); return result; diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 8d6429f767..e41b942538 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -680,23 +680,23 @@ static bool update_playlist(bool force) changed. */ static int onplay_menu(int index) { - struct menu_items menu[3]; /* increase this if you add entries! */ + struct menu_item items[3]; /* increase this if you add entries! */ int m, i=0, result, ret = 0; bool current = (tracks[index].index == viewer.current_playing_track); - menu[i].desc = str(LANG_REMOVE); - menu[i].voice_id = LANG_REMOVE; + items[i].desc = str(LANG_REMOVE); + items[i].voice_id = LANG_REMOVE; i++; - menu[i].desc = str(LANG_MOVE); - menu[i].voice_id = LANG_MOVE; + items[i].desc = str(LANG_MOVE); + items[i].voice_id = LANG_MOVE; i++; - menu[i].desc = str(LANG_FILE_OPTIONS); - menu[i].voice_id = LANG_FILE_OPTIONS; + items[i].desc = str(LANG_FILE_OPTIONS); + items[i].voice_id = LANG_FILE_OPTIONS; i++; - m = menu_init(menu, i, NULL); + m = menu_init(items, i, NULL, NULL, NULL, NULL); result = menu_show(m); if (result == MENU_ATTACHED_USB) ret = -1; @@ -759,14 +759,15 @@ static bool viewer_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_SHOW_ICONS), show_icons }, { STR(LANG_SHOW_INDICES), show_indices }, { STR(LANG_TRACK_DISPLAY), track_display }, { STR(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist }, }; - - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL ); result = menu_run(m); menu_exit(m); diff --git a/apps/settings.c b/apps/settings.c index 7ce4beacaf..e68e74b2c2 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -117,7 +117,7 @@ offset abs 0x23 0x37 0x24 0x38 0x25 0x39 + Trickle charge flag (bit 4), buttonbar (bit 5)> 0x26 0x40 0x27 0x41 0x28 0x42 @@ -396,7 +396,8 @@ int settings_save( void ) config_block[0x25] = (unsigned char) ((global_settings.disk_poweroff & 1) | ((global_settings.buffer_margin & 7) << 1) | - ((global_settings.trickle_charge & 1) << 4)); + ((global_settings.trickle_charge & 1) << 4) | + ((global_settings.buttonbar & 1) << 5)); { int elapsed_secs; @@ -723,6 +724,7 @@ void settings_load(void) global_settings.disk_poweroff = config_block[0x25] & 1; global_settings.buffer_margin = (config_block[0x25] >> 1) & 7; global_settings.trickle_charge = (config_block[0x25] >> 4) & 1; + global_settings.buttonbar = (config_block[0x25] >> 5) & 1; } if (config_block[0x27] != 0xff) @@ -977,6 +979,8 @@ bool settings_load_config(char* file) set_cfg_int(&global_settings.scroll_step, value, 1, LCD_WIDTH); else if (!strcasecmp(name, "statusbar")) set_cfg_bool(&global_settings.statusbar, value); + else if (!strcasecmp(name, "buttonbar")) + set_cfg_bool(&global_settings.buttonbar, value); else if (!strcasecmp(name, "peak meter release")) set_cfg_int(&global_settings.peak_meter_release, value, 1, 0x7e); else if (!strcasecmp(name, "peak meter hold")) { @@ -1336,8 +1340,9 @@ bool settings_save_config(void) fprintf(fd, "#\r\n# Display\r\n#\r\n"); #ifdef HAVE_LCD_BITMAP - fprintf(fd, "statusbar: %s\r\nscrollbar: %s\r\n", + fprintf(fd, "statusbar: %s\r\nbuttonbar: %s\r\nscrollbar: %s\r\n", boolopt[global_settings.statusbar], + boolopt[global_settings.buttonbar], boolopt[global_settings.scrollbar]); { @@ -1588,6 +1593,7 @@ void settings_reset(void) { global_settings.dirfilter = SHOW_MUSIC; global_settings.sort_case = false; global_settings.statusbar = true; + global_settings.buttonbar = true; global_settings.scrollbar = true; global_settings.repeat_mode = REPEAT_ALL; global_settings.playlist_shuffle = false; diff --git a/apps/settings.h b/apps/settings.h index ab3cd6fca8..d5992ccd79 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -159,6 +159,9 @@ struct user_settings /* show status bar */ bool statusbar; /* 0=hide, 1=show */ + /* show button bar */ + bool buttonbar; /* 0=hide, 1=show */ + /* show scroll bar */ bool scrollbar; /* 0=hide, 1=show */ diff --git a/apps/settings_menu.c b/apps/settings_menu.c index ea2738f176..64df007afe 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c @@ -402,7 +402,7 @@ static bool peak_meter_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_PM_RELEASE) , peak_meter_release }, { STR(LANG_PM_PEAK_HOLD), peak_meter_hold }, { STR(LANG_PM_CLIP_HOLD), peak_meter_clip_hold }, @@ -414,8 +414,9 @@ static bool peak_meter_menu(void) { STR(LANG_PM_MIN) , peak_meter_min }, { STR(LANG_PM_MAX) , peak_meter_max }, }; - - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL ); result = menu_run(m); menu_exit(m); return result; @@ -882,6 +883,11 @@ static bool status_bar(void) { return set_bool( str(LANG_STATUS_BAR), &global_settings.statusbar ); } + +static bool button_bar(void) +{ + return set_bool( str(LANG_BUTTON_BAR), &global_settings.buttonbar ); +} #endif static bool ff_rewind_settings_menu(void) @@ -889,12 +895,13 @@ static bool ff_rewind_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_FFRW_STEP), ff_rewind_min_step }, { STR(LANG_FFRW_ACCEL), ff_rewind_accel }, }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); @@ -906,7 +913,7 @@ static bool playback_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_SHUFFLE), shuffle }, { STR(LANG_REPEAT), repeat_mode }, { STR(LANG_PLAY_SELECTED), play_selected }, @@ -918,7 +925,8 @@ static bool playback_settings_menu(void) bool old_shuffle = global_settings.playlist_shuffle; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); @@ -941,13 +949,14 @@ static bool bookmark_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark}, { STR(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark}, { STR(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB}, }; - m=menu_init( items, sizeof items / sizeof(struct menu_items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); @@ -1008,14 +1017,15 @@ static bool fileview_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_CASE_MENU), sort_case }, { STR(LANG_FILTER), dir_filter }, { STR(LANG_FOLLOW), browse_current }, { STR(LANG_SHOW_ICONS), show_icons }, }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1027,7 +1037,7 @@ static bool scroll_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_SCROLL_SPEED), scroll_speed }, { STR(LANG_SCROLL_DELAY), scroll_delay }, #ifdef HAVE_LCD_BITMAP @@ -1040,7 +1050,8 @@ static bool scroll_settings_menu(void) #endif }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1051,7 +1062,7 @@ static bool lcd_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_BACKLIGHT), backlight_timer }, { STR(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging }, { STR(LANG_CAPTION_BACKLIGHT), caption_backlight }, @@ -1063,7 +1074,8 @@ static bool lcd_settings_menu(void) #endif }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1075,14 +1087,16 @@ static bool bars_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_SCROLL_BAR), scroll_bar }, { STR(LANG_STATUS_BAR), status_bar }, + { STR(LANG_BUTTON_BAR), button_bar }, { STR(LANG_VOLUME_DISPLAY), volume_type }, { STR(LANG_BATTERY_DISPLAY), battery_type }, }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1095,7 +1109,7 @@ static bool display_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { #ifdef HAVE_LCD_BITMAP { STR(LANG_CUSTOM_FONT), font_browse }, #endif @@ -1108,7 +1122,8 @@ static bool display_settings_menu(void) #endif }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1125,7 +1140,7 @@ static bool battery_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { #ifdef HAVE_CHARGE_CTRL { STR(LANG_DISCHARGE), deep_discharge }, { STR(LANG_TRICKLE_CHARGE), trickle_charge }, @@ -1135,7 +1150,8 @@ static bool battery_settings_menu(void) #endif }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1146,14 +1162,15 @@ static bool disk_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_SPINDOWN), spindown }, #ifdef HAVE_ATA_POWER_OFF { STR(LANG_POWEROFF), poweroff }, #endif }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1165,12 +1182,13 @@ static bool time_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_TIME), timedate_set }, { STR(LANG_TIMEFORMAT), timeformat_set }, }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1182,14 +1200,15 @@ static bool manage_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_CUSTOM_CFG), custom_cfg_browse }, { STR(LANG_FIRMWARE), firmware_browse }, { STR(LANG_RESET), reset_settings }, { STR(LANG_SAVE_SETTINGS), settings_save_config }, }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1200,12 +1219,13 @@ static bool limits_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_MAX_FILES_IN_DIR), max_files_in_dir }, { STR(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist }, }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1217,7 +1237,7 @@ static bool system_settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_BATTERY_MENU), battery_settings_menu }, { STR(LANG_DISK_MENU), disk_settings_menu }, #ifdef HAVE_RTC @@ -1236,7 +1256,8 @@ static bool system_settings_menu(void) { STR(LANG_MANAGE_MENU), manage_settings_menu }, }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; @@ -1247,7 +1268,7 @@ bool settings_menu(void) int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_PLAYBACK), playback_settings_menu }, { STR(LANG_FILE), fileview_settings_menu }, { STR(LANG_DISPLAY), display_settings_menu }, @@ -1256,7 +1277,8 @@ bool settings_menu(void) { STR(LANG_LANGUAGE), language_browse }, }; - m=menu_init( items, sizeof(items) / sizeof(*items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); return result; diff --git a/apps/sound_menu.c b/apps/sound_menu.c index 34904e0aa0..17f6eb5072 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -346,7 +346,7 @@ bool sound_menu(void) { int m; bool result; - struct menu_items items[] = { + struct menu_item items[] = { { STR(LANG_VOLUME), volume }, { STR(LANG_BASS), bass }, { STR(LANG_TREBLE), treble }, @@ -359,7 +359,8 @@ bool sound_menu(void) #endif }; - m=menu_init( items, sizeof items / sizeof(struct menu_items), NULL ); + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); result = menu_run(m); menu_exit(m); @@ -371,37 +372,37 @@ bool recording_menu(bool no_source) { int m; int i = 0; - struct menu_items menu[8]; + struct menu_item items[8]; bool result; - menu[i].desc = str(LANG_RECORDING_QUALITY); - menu[i].voice_id = LANG_RECORDING_QUALITY; - menu[i++].function = recquality; - menu[i].desc = str(LANG_RECORDING_FREQUENCY); - menu[i].voice_id = LANG_RECORDING_FREQUENCY; - menu[i++].function = recfrequency; + items[i].desc = str(LANG_RECORDING_QUALITY); + items[i].voice_id = LANG_RECORDING_QUALITY; + items[i++].function = recquality; + items[i].desc = str(LANG_RECORDING_FREQUENCY); + items[i].voice_id = LANG_RECORDING_FREQUENCY; + items[i++].function = recfrequency; if(!no_source) { - menu[i].desc = str(LANG_RECORDING_SOURCE); - menu[i].voice_id = LANG_RECORDING_SOURCE; - menu[i++].function = recsource; + items[i].desc = str(LANG_RECORDING_SOURCE); + items[i].voice_id = LANG_RECORDING_SOURCE; + items[i++].function = recsource; } - menu[i].desc = str(LANG_RECORDING_CHANNELS); - menu[i].voice_id = LANG_RECORDING_CHANNELS; - menu[i++].function = recchannels; - menu[i].desc = str(LANG_RECORDING_EDITABLE); - menu[i].voice_id = LANG_RECORDING_EDITABLE; - menu[i++].function = receditable; - menu[i].desc = str(LANG_RECORD_TIMESPLIT); - menu[i].voice_id = LANG_RECORD_TIMESPLIT; - menu[i++].function = rectimesplit; - menu[i].desc = str(LANG_RECORD_PRERECORD_TIME); - menu[i].voice_id = LANG_RECORD_PRERECORD_TIME; - menu[i++].function = recprerecord; - menu[i].desc = str(LANG_RECORD_DIRECTORY); - menu[i].voice_id = LANG_RECORD_DIRECTORY; - menu[i++].function = recdirectory; - - m=menu_init( menu, i, NULL ); + items[i].desc = str(LANG_RECORDING_CHANNELS); + items[i].voice_id = LANG_RECORDING_CHANNELS; + items[i++].function = recchannels; + items[i].desc = str(LANG_RECORDING_EDITABLE); + items[i].voice_id = LANG_RECORDING_EDITABLE; + items[i++].function = receditable; + items[i].desc = str(LANG_RECORD_TIMESPLIT); + items[i].voice_id = LANG_RECORD_TIMESPLIT; + items[i++].function = rectimesplit; + items[i].desc = str(LANG_RECORD_PRERECORD_TIME); + items[i].voice_id = LANG_RECORD_PRERECORD_TIME; + items[i++].function = recprerecord; + items[i].desc = str(LANG_RECORD_DIRECTORY); + items[i].voice_id = LANG_RECORD_DIRECTORY; + items[i++].function = recdirectory; + + m=menu_init( items, i, NULL, NULL, NULL, NULL); result = menu_run(m); menu_exit(m); diff --git a/apps/status.c b/apps/status.c index a7f37a9f9f..09f777725e 100644 --- a/apps/status.c +++ b/apps/status.c @@ -260,12 +260,29 @@ static char stored_caption3[8]; void buttonbar_set(char* caption1, char *caption2, char *caption3) { - strncpy(stored_caption1, caption1, 7); - stored_caption1[7] = 0; - strncpy(stored_caption2, caption2, 7); - stored_caption2[7] = 0; - strncpy(stored_caption3, caption3, 7); - stored_caption3[7] = 0; + buttonbar_unset(); + if(caption1) + { + strncpy(stored_caption1, caption1, 7); + stored_caption1[7] = 0; + } + if(caption2) + { + strncpy(stored_caption2, caption2, 7); + stored_caption2[7] = 0; + } + if(caption3) + { + strncpy(stored_caption3, caption3, 7); + stored_caption3[7] = 0; + } +} + +void buttonbar_unset(void) +{ + stored_caption1[0] = 0; + stored_caption2[0] = 0; + stored_caption3[0] = 0; } void buttonbar_draw(void) @@ -275,4 +292,14 @@ void buttonbar_draw(void) draw_buttonbar_btn(1, stored_caption2); draw_buttonbar_btn(2, stored_caption3); } + +bool buttonbar_isset(void) +{ + /* If all buttons are unset, the button bar is considered disabled */ + return (global_settings.buttonbar && + ((stored_caption1[0] != 0) || + (stored_caption2[0] != 0) || + (stored_caption3[0] != 0))); +} + #endif diff --git a/apps/status.h b/apps/status.h index 72a490f499..3c501e019b 100644 --- a/apps/status.h +++ b/apps/status.h @@ -35,7 +35,11 @@ void status_set_playmode(enum playmode mode); #ifdef HAVE_LCD_BITMAP bool statusbar(bool state); void buttonbar_set(char* caption1, char* caption2, char* caption3); +void buttonbar_unset(void); +bool buttonbar_isset(void); void buttonbar_draw(void); + +#define BUTTONBAR_HEIGHT 8 #endif void status_draw(bool force_redraw); diff --git a/apps/tree.c b/apps/tree.c index 7a7ba3a2f9..18758e3570 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -387,6 +387,24 @@ struct entry* load_and_sort_directory(char *dirname, int *dirfilter, return dircache; } +#ifdef HAVE_LCD_BITMAP +static int recalc_screen_height(void) +{ + int fw, fh; + int height = LCD_HEIGHT; + + lcd_setfont(FONT_UI); + lcd_getstringsize("A", &fw, &fh); + if(global_settings.statusbar) + height -= STATUSBAR_HEIGHT; + + if(global_settings.buttonbar) + height -= BUTTONBAR_HEIGHT; + + return height / fh; +} +#endif + static int showdir(char *path, int start, int *dirfilter) { int icon_type = 0; @@ -399,7 +417,7 @@ static int showdir(char *path, int start, int *dirfilter) int fw, fh; lcd_setfont(FONT_UI); lcd_getstringsize("A", &fw, &fh); - tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; + tree_max_on_screen = recalc_screen_height(); line_height = fh; #else tree_max_on_screen = TREE_MAX_ON_SCREEN; @@ -536,10 +554,18 @@ static int showdir(char *path, int start, int *dirfilter) #ifdef HAVE_LCD_BITMAP if (global_settings.scrollbar && (filesindir > tree_max_on_screen)) scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1, - LCD_HEIGHT - SCROLLBAR_Y, filesindir, start, + tree_max_on_screen * line_height, filesindir, start, start + tree_max_on_screen, VERTICAL); + + if(global_settings.buttonbar) { + buttonbar_set(str(LANG_DIRBROWSE_F1), + str(LANG_DIRBROWSE_F2), + str(LANG_DIRBROWSE_F3)); + buttonbar_draw(); + } #endif status_draw(true); + return filesindir; } @@ -852,10 +878,7 @@ static bool dirbrowse(char *root, int *dirfilter) has been refreshed on screen */ #ifdef HAVE_LCD_BITMAP - int fw, fh; - lcd_setfont(FONT_UI); - lcd_getstringsize("A", &fw, &fh); - tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; + tree_max_on_screen = recalc_screen_height(); #else tree_max_on_screen = TREE_MAX_ON_SCREEN; #endif @@ -1065,8 +1088,7 @@ static bool dirbrowse(char *root, int *dirfilter) lcd_update(); /* maybe we have a new font */ - lcd_getstringsize("A", &fw, &fh); - tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; + tree_max_on_screen = recalc_screen_height(); /* make sure cursor is on screen */ while ( dircursor > tree_max_on_screen ) { @@ -1114,8 +1136,7 @@ static bool dirbrowse(char *root, int *dirfilter) set_file(buf, global_settings.font_file, MAX_FILENAME); - lcd_getstringsize("A", &fw, &fh); - tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; + tree_max_on_screen = recalc_screen_height(); /* make sure cursor is on screen */ while ( dircursor > tree_max_on_screen ) { dircursor--; @@ -1291,7 +1312,7 @@ static bool dirbrowse(char *root, int *dirfilter) reload_root = true; #ifdef HAVE_LCD_BITMAP - tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; + tree_max_on_screen = recalc_screen_height(); #endif restore = true; } @@ -1318,7 +1339,7 @@ static bool dirbrowse(char *root, int *dirfilter) if (wps_show() == SYS_USB_CONNECTED) reload_root = true; #ifdef HAVE_LCD_BITMAP - tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; + tree_max_on_screen = recalc_screen_height(); #endif restore = true; start_wps=false;