1
0
Fork 0
forked from len0rd/rockbox

dont allow the volume setting to wrap

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11445 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2006-11-06 10:11:51 +00:00
parent 2f444aac29
commit 6a1161b634
11 changed files with 46 additions and 19 deletions

View file

@ -720,18 +720,32 @@ void gui_synclist_scroll_left(struct gui_synclist * lists)
} }
#endif /* HAVE_LCD_BITMAP */ #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 #ifdef HAVE_LCD_BITMAP
static bool scrolling_left = false; static bool scrolling_left = false;
#endif #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) switch(button)
{ {
case ACTION_STD_PREV: case ACTION_STD_PREV:
gui_synclist_limit_scroll(lists, false);
case ACTION_STD_PREVREPEAT: case ACTION_STD_PREVREPEAT:
gui_synclist_select_previous(lists); gui_synclist_select_previous(lists);
gui_synclist_draw(lists); gui_synclist_draw(lists);
@ -739,8 +753,6 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
return ACTION_STD_PREV; return ACTION_STD_PREV;
case ACTION_STD_NEXT: case ACTION_STD_NEXT:
gui_synclist_limit_scroll(lists, false);
case ACTION_STD_NEXTREPEAT: case ACTION_STD_NEXTREPEAT:
gui_synclist_select_next(lists); gui_synclist_select_next(lists);
gui_synclist_draw(lists); gui_synclist_draw(lists);

View file

@ -26,6 +26,12 @@
#define SCROLLBAR_WIDTH 6 #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 * The gui_list is based on callback functions, if you want the list
* to display something you have to provide it a function that * 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 * returns the action taken if any, 0 else
* - lists : the synchronized lists * - lists : the synchronized lists
* - button : the keycode of a pressed button * - button : the keycode of a pressed button
* - specifies weather to allow the list to wrap or not, values at top of page
* returned value : * returned value :
* - ACTION_STD_NEXT when moving forward (next item or pgup) * - ACTION_STD_NEXT when moving forward (next item or pgup)
* - ACTION_STD_PREV when moving backward (previous item or pgdown) * - 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_ */ #endif /* _GUI_LIST_H_ */

View file

@ -141,7 +141,7 @@ int menu_show(int m)
if( menus[m].callback != NULL ) if( menus[m].callback != NULL )
key = menus[m].callback(key, m); key = menus[m].callback(key, m);
/* If moved, "say" the entry under the cursor */ /* 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); menu_talk_selected(m);
switch( key ) { switch( key ) {
case ACTION_STD_OK: case ACTION_STD_OK:

View file

@ -248,7 +248,7 @@ static int display_playlists(char* playlist, bool view)
int button = get_action(CONTEXT_LIST,HZ/2); int button = get_action(CONTEXT_LIST,HZ/2);
char* sel_file; 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)]; sel_file = playlists[gui_synclist_get_sel_pos(&playlist_lists)];

View file

@ -664,7 +664,7 @@ bool playlist_viewer_ex(char* filename)
/* Timeout so we can determine if play status has changed */ /* Timeout so we can determine if play status has changed */
button = get_action(CONTEXT_TREE,HZ/2); button = get_action(CONTEXT_TREE,HZ/2);
int list_action; 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); viewer.selected_track=gui_synclist_get_sel_pos(&playlist_lists);
if(playlist_buffer_needs_reload(&viewer.buffer, if(playlist_buffer_needs_reload(&viewer.buffer,
@ -847,7 +847,7 @@ bool search_playlist(void)
while (!exit) while (!exit)
{ {
button = get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 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; continue;
switch (button) switch (button)
{ {

View file

@ -275,7 +275,8 @@ struct plugin_api {
void (*gui_synclist_scroll_right)(struct gui_synclist * lists); void (*gui_synclist_scroll_right)(struct gui_synclist * lists);
void (*gui_synclist_scroll_left)(struct gui_synclist * lists); void (*gui_synclist_scroll_left)(struct gui_synclist * lists);
#endif #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 */ /* button */
long (*button_get)(bool block); long (*button_get)(bool block);

View file

@ -184,7 +184,7 @@ void edit_list(void)
{ {
rb->gui_synclist_draw(&lists); rb->gui_synclist_draw(&lists);
button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 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; continue;
selection = rb->gui_synclist_get_sel_pos(&lists); selection = rb->gui_synclist_get_sel_pos(&lists);
switch (button) switch (button)

View file

@ -349,7 +349,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->gui_synclist_draw(&lists); rb->gui_synclist_draw(&lists);
cur_sel = rb->gui_synclist_get_sel_pos(&lists); cur_sel = rb->gui_synclist_get_sel_pos(&lists);
button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); 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; continue;
#ifdef HAVE_ADJUSTABLE_CPU_FREQ #ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(0); rb->cpu_boost(0);

View file

@ -1241,7 +1241,7 @@ bool browse_id3(void)
gui_syncstatusbar_draw(&statusbars, false); gui_syncstatusbar_draw(&statusbars, false);
key = get_action(CONTEXT_LIST,HZ/2); key = get_action(CONTEXT_LIST,HZ/2);
if(key!=ACTION_NONE && key!=ACTION_UNKNOWN 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(); action_signalscreenchange();
return(default_event_handler(key) == SYS_USB_CONNECTED); return(default_event_handler(key) == SYS_USB_CONNECTED);

View file

@ -1982,9 +1982,14 @@ bool do_set_setting(const unsigned char* string, void *variable,
bool done = false; bool done = false;
struct gui_synclist lists; struct gui_synclist lists;
int oldvalue; int oldvalue;
bool allow_wrap = true;
if (cb_data->type == INT) if (cb_data->type == INT)
oldvalue = *(int*)variable; {
oldvalue = *(int*)variable;
if (variable == &global_settings.volume)
allow_wrap = false;
}
else oldvalue = *(bool*)variable; else oldvalue = *(bool*)variable;
gui_synclist_init(&lists,value_setting_get_name_cb,(void*)cb_data,false,1); 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); action = get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
if (action == ACTION_NONE) if (action == ACTION_NONE)
continue; 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) if (global_settings.talk_menu)
{ {

View file

@ -674,7 +674,7 @@ static bool dirbrowse(void)
} }
#endif #endif
button = get_action(CONTEXT_TREE,HZ/5); 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) if (returned_button)
need_update = true; need_update = true;
if (returned_button == ACTION_STD_CANCEL) if (returned_button == ACTION_STD_CANCEL)