From 6a1161b634e43225ae12bf669ad3bbe1ea1edab0 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Mon, 6 Nov 2006 10:11:51 +0000 Subject: dont allow the volume setting to wrap git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11445 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/list.c | 24 ++++++++++++++++++------ apps/gui/list.h | 11 ++++++++++- apps/menu.c | 2 +- apps/playlist_catalog.c | 2 +- apps/playlist_viewer.c | 4 ++-- apps/plugin.h | 3 ++- apps/plugins/random_folder_advance_config.c | 2 +- apps/plugins/text_editor.c | 2 +- apps/screens.c | 2 +- apps/settings.c | 11 ++++++++--- apps/tree.c | 2 +- 11 files changed, 46 insertions(+), 19 deletions(-) (limited to 'apps') diff --git a/apps/gui/list.c b/apps/gui/list.c index 0653343604..1f23ca5e68 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -720,18 +720,32 @@ void gui_synclist_scroll_left(struct gui_synclist * lists) } #endif /* HAVE_LCD_BITMAP */ -unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button) +unsigned gui_synclist_do_button(struct gui_synclist * lists, + unsigned button,enum list_wrap wrap) { #ifdef HAVE_LCD_BITMAP static bool scrolling_left = false; #endif - gui_synclist_limit_scroll(lists, true); + switch (wrap) + { + case LIST_WRAP_ON: + gui_synclist_limit_scroll(lists, false); + break; + case LIST_WRAP_OFF: + gui_synclist_limit_scroll(lists, true); + break; + case LIST_WRAP_UNLESS_HELD: + if (button == ACTION_STD_PREVREPEAT || + button == ACTION_STD_NEXTREPEAT) + gui_synclist_limit_scroll(lists, true); + else gui_synclist_limit_scroll(lists, false); + break; + }; + switch(button) { case ACTION_STD_PREV: - gui_synclist_limit_scroll(lists, false); - case ACTION_STD_PREVREPEAT: gui_synclist_select_previous(lists); gui_synclist_draw(lists); @@ -739,8 +753,6 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button) return ACTION_STD_PREV; case ACTION_STD_NEXT: - gui_synclist_limit_scroll(lists, false); - case ACTION_STD_NEXTREPEAT: gui_synclist_select_next(lists); gui_synclist_draw(lists); diff --git a/apps/gui/list.h b/apps/gui/list.h index 914563a597..e61780ffe3 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h @@ -26,6 +26,12 @@ #define SCROLLBAR_WIDTH 6 +enum list_wrap { + LIST_WRAP_ON = 0, + LIST_WRAP_OFF, + LIST_WRAP_UNLESS_HELD, +}; + /* * The gui_list is based on callback functions, if you want the list * to display something you have to provide it a function that @@ -312,10 +318,13 @@ void gui_synclist_scroll_left(struct gui_synclist * lists); * returns the action taken if any, 0 else * - lists : the synchronized lists * - button : the keycode of a pressed button + * - specifies weather to allow the list to wrap or not, values at top of page * returned value : * - ACTION_STD_NEXT when moving forward (next item or pgup) * - ACTION_STD_PREV when moving backward (previous item or pgdown) */ -extern unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button); +extern unsigned gui_synclist_do_button(struct gui_synclist * lists, + unsigned button, + enum list_wrap); #endif /* _GUI_LIST_H_ */ diff --git a/apps/menu.c b/apps/menu.c index e0a439e22e..faed2cc88a 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -141,7 +141,7 @@ int menu_show(int m) if( menus[m].callback != NULL ) key = menus[m].callback(key, m); /* If moved, "say" the entry under the cursor */ - if(gui_synclist_do_button(&(menus[m].synclist), key)) + if(gui_synclist_do_button(&(menus[m].synclist), key,LIST_WRAP_UNLESS_HELD)) menu_talk_selected(m); switch( key ) { case ACTION_STD_OK: diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c index 87034aad3b..0b047b0fee 100644 --- a/apps/playlist_catalog.c +++ b/apps/playlist_catalog.c @@ -248,7 +248,7 @@ static int display_playlists(char* playlist, bool view) int button = get_action(CONTEXT_LIST,HZ/2); char* sel_file; - gui_synclist_do_button(&playlist_lists, button); + gui_synclist_do_button(&playlist_lists, button,LIST_WRAP_UNLESS_HELD); sel_file = playlists[gui_synclist_get_sel_pos(&playlist_lists)]; diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 7c73b2bad9..87bbaa4b11 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -664,7 +664,7 @@ bool playlist_viewer_ex(char* filename) /* Timeout so we can determine if play status has changed */ button = get_action(CONTEXT_TREE,HZ/2); int list_action; - if( (list_action=gui_synclist_do_button(&playlist_lists, button))!=0 ) + if( (list_action=gui_synclist_do_button(&playlist_lists, button,LIST_WRAP_UNLESS_HELD))!=0 ) { viewer.selected_track=gui_synclist_get_sel_pos(&playlist_lists); if(playlist_buffer_needs_reload(&viewer.buffer, @@ -847,7 +847,7 @@ bool search_playlist(void) while (!exit) { button = get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (gui_synclist_do_button(&playlist_lists, button)) + if (gui_synclist_do_button(&playlist_lists, button,LIST_WRAP_UNLESS_HELD)) continue; switch (button) { diff --git a/apps/plugin.h b/apps/plugin.h index a7ed88985d..54d2702017 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -275,7 +275,8 @@ struct plugin_api { void (*gui_synclist_scroll_right)(struct gui_synclist * lists); void (*gui_synclist_scroll_left)(struct gui_synclist * lists); #endif - unsigned (*gui_synclist_do_button)(struct gui_synclist * lists, unsigned button); + unsigned (*gui_synclist_do_button)(struct gui_synclist * lists, + unsigned button,enum list_wrap wrap); /* button */ long (*button_get)(bool block); diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 7d055c4172..3b9f842873 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c @@ -184,7 +184,7 @@ void edit_list(void) { rb->gui_synclist_draw(&lists); button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&lists,button)) + if (rb->gui_synclist_do_button(&lists,button,LIST_WRAP_UNLESS_HELD)) continue; selection = rb->gui_synclist_get_sel_pos(&lists); switch (button) diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index 9f5412810d..449a88aa0a 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c @@ -349,7 +349,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) rb->gui_synclist_draw(&lists); cur_sel = rb->gui_synclist_get_sel_pos(&lists); button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&lists,button)) + if (rb->gui_synclist_do_button(&lists,button,LIST_WRAP_UNLESS_HELD)) continue; #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(0); diff --git a/apps/screens.c b/apps/screens.c index 50f1055f90..8b69fdfee2 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -1241,7 +1241,7 @@ bool browse_id3(void) gui_syncstatusbar_draw(&statusbars, false); key = get_action(CONTEXT_LIST,HZ/2); if(key!=ACTION_NONE && key!=ACTION_UNKNOWN - && !gui_synclist_do_button(&id3_lists, key)) + && !gui_synclist_do_button(&id3_lists, key,LIST_WRAP_UNLESS_HELD)) { action_signalscreenchange(); return(default_event_handler(key) == SYS_USB_CONNECTED); diff --git a/apps/settings.c b/apps/settings.c index da5a461d7d..a4320eda7b 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -1982,9 +1982,14 @@ bool do_set_setting(const unsigned char* string, void *variable, bool done = false; struct gui_synclist lists; int oldvalue; + bool allow_wrap = true; if (cb_data->type == INT) - oldvalue = *(int*)variable; + { + oldvalue = *(int*)variable; + if (variable == &global_settings.volume) + allow_wrap = false; + } else oldvalue = *(bool*)variable; gui_synclist_init(&lists,value_setting_get_name_cb,(void*)cb_data,false,1); @@ -2008,8 +2013,8 @@ bool do_set_setting(const unsigned char* string, void *variable, action = get_action(CONTEXT_LIST,TIMEOUT_BLOCK); if (action == ACTION_NONE) continue; - - if (gui_synclist_do_button(&lists,action)) + if (gui_synclist_do_button(&lists,action, + allow_wrap?LIST_WRAP_UNLESS_HELD:LIST_WRAP_OFF)) { if (global_settings.talk_menu) { diff --git a/apps/tree.c b/apps/tree.c index 772e2351bb..653da791a8 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -674,7 +674,7 @@ static bool dirbrowse(void) } #endif button = get_action(CONTEXT_TREE,HZ/5); - returned_button = gui_synclist_do_button(&tree_lists, button); + returned_button = gui_synclist_do_button(&tree_lists, button,LIST_WRAP_UNLESS_HELD); if (returned_button) need_update = true; if (returned_button == ACTION_STD_CANCEL) -- cgit v1.2.3