minor update to gui_synclist_do_button() which will hopefully simplify things later.

Now returns true if the action was handled in that function instead of returning the handled action.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14733 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2007-09-17 10:08:50 +00:00
parent 344f45165f
commit cf1cef5f57
21 changed files with 61 additions and 59 deletions

View file

@ -659,7 +659,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
} }
action = get_action(CONTEXT_BOOKMARKSCREEN, HZ / 2); action = get_action(CONTEXT_BOOKMARKSCREEN, HZ / 2);
gui_synclist_do_button(&list, action, LIST_WRAP_UNLESS_HELD); gui_synclist_do_button(&list, &action, LIST_WRAP_UNLESS_HELD);
item = gui_synclist_get_sel_pos(&list) / 2; item = gui_synclist_get_sel_pos(&list) / 2;
if (bookmarks->show_dont_resume) if (bookmarks->show_dont_resume)

View file

@ -296,7 +296,7 @@ void browse_cuesheet(struct cuesheet *cue)
{ {
gui_synclist_draw(&lists); gui_synclist_draw(&lists);
action = get_action(CONTEXT_LIST,TIMEOUT_BLOCK); action = get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
if (gui_synclist_do_button(&lists,action,LIST_WRAP_UNLESS_HELD)) if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
continue; continue;
switch (action) switch (action)
{ {

View file

@ -162,7 +162,7 @@ static bool dbg_list(struct action_callback_info *info)
{ {
gui_syncstatusbar_draw(&statusbars, true); gui_syncstatusbar_draw(&statusbars, true);
action = get_action(CONTEXT_STD, HZ/5); action = get_action(CONTEXT_STD, HZ/5);
if (gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD)) if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
continue; continue;
if (info->action_callback) if (info->action_callback)
action = info->action_callback(action, info); action = info->action_callback(action, info);

View file

@ -476,7 +476,7 @@ int filetype_list_viewers(const char* current_file)
gui_syncstatusbar_draw(&statusbars, true); gui_syncstatusbar_draw(&statusbars, true);
action = get_action(CONTEXT_MAINMENU,HZ); action = get_action(CONTEXT_MAINMENU,HZ);
if ((action == ACTION_NONE) || if ((action == ACTION_NONE) ||
gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD)) gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
continue; continue;
else if (action == ACTION_STD_OK) else if (action == ACTION_STD_OK)
{ {

View file

@ -889,9 +889,10 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists)
extern intptr_t get_action_data(void); extern intptr_t get_action_data(void);
unsigned gui_synclist_do_button(struct gui_synclist * lists, bool gui_synclist_do_button(struct gui_synclist * lists,
unsigned button,enum list_wrap wrap) unsigned *actionptr, enum list_wrap wrap)
{ {
int action = *actionptr;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
static bool scrolling_left = false; static bool scrolling_left = false;
#endif #endif
@ -937,16 +938,16 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
gui_synclist_limit_scroll(lists, true); gui_synclist_limit_scroll(lists, true);
break; break;
case LIST_WRAP_UNLESS_HELD: case LIST_WRAP_UNLESS_HELD:
if (button == ACTION_STD_PREVREPEAT || if (action == ACTION_STD_PREVREPEAT ||
button == ACTION_STD_NEXTREPEAT || action == ACTION_STD_NEXTREPEAT ||
button == ACTION_LISTTREE_PGUP || action == ACTION_LISTTREE_PGUP ||
button == ACTION_LISTTREE_PGDOWN) action == ACTION_LISTTREE_PGDOWN)
gui_synclist_limit_scroll(lists, true); gui_synclist_limit_scroll(lists, true);
else gui_synclist_limit_scroll(lists, false); else gui_synclist_limit_scroll(lists, false);
break; break;
}; };
switch(button) switch (action)
{ {
#ifdef HAVE_VOLUME_IN_LIST #ifdef HAVE_VOLUME_IN_LIST
case ACTION_LIST_VOLUP: case ACTION_LIST_VOLUP:
@ -955,7 +956,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
case ACTION_LIST_VOLDOWN: case ACTION_LIST_VOLDOWN:
global_settings.volume--; global_settings.volume--;
setvol(); setvol();
return button; return true;
#endif #endif
case ACTION_STD_PREV: case ACTION_STD_PREV:
case ACTION_STD_PREVREPEAT: case ACTION_STD_PREVREPEAT:
@ -968,7 +969,8 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
gui_synclist_draw(lists); gui_synclist_draw(lists);
} }
yield(); yield();
return ACTION_STD_PREV; *actionptr = ACTION_STD_PREV;
return true;
case ACTION_STD_NEXT: case ACTION_STD_NEXT:
case ACTION_STD_NEXTREPEAT: case ACTION_STD_NEXTREPEAT:
@ -981,13 +983,14 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
gui_synclist_draw(lists); gui_synclist_draw(lists);
} }
yield(); yield();
return ACTION_STD_NEXT; *actionptr = ACTION_STD_NEXT;
return true;
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
case ACTION_TREE_PGRIGHT: case ACTION_TREE_PGRIGHT:
gui_synclist_scroll_right(lists); gui_synclist_scroll_right(lists);
gui_synclist_draw(lists); gui_synclist_draw(lists);
return ACTION_TREE_PGRIGHT; return true;
case ACTION_TREE_ROOT_INIT: case ACTION_TREE_ROOT_INIT:
/* After this button press ACTION_TREE_PGLEFT is allowed /* After this button press ACTION_TREE_PGLEFT is allowed
to skip to root. ACTION_TREE_ROOT_INIT must be defined in the to skip to root. ACTION_TREE_ROOT_INIT must be defined in the
@ -997,16 +1000,21 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
if (lists->gui_list[0].offset_position == 0) if (lists->gui_list[0].offset_position == 0)
{ {
scrolling_left = false; scrolling_left = false;
return ACTION_STD_CANCEL; *actionptr = ACTION_STD_CANCEL;
return true;
} }
*actionptr = ACTION_TREE_PGLEFT;
case ACTION_TREE_PGLEFT: case ACTION_TREE_PGLEFT:
if(!scrolling_left && (lists->gui_list[0].offset_position == 0)) if(!scrolling_left && (lists->gui_list[0].offset_position == 0))
return ACTION_STD_CANCEL; {
*actionptr = ACTION_STD_CANCEL;
return false;
}
gui_synclist_scroll_left(lists); gui_synclist_scroll_left(lists);
gui_synclist_draw(lists); gui_synclist_draw(lists);
scrolling_left = true; /* stop ACTION_TREE_PAGE_LEFT scrolling_left = true; /* stop ACTION_TREE_PAGE_LEFT
skipping to root */ skipping to root */
return ACTION_TREE_PGLEFT; return true;
#endif #endif
/* for pgup / pgdown, we are obliged to have a different behaviour depending /* for pgup / pgdown, we are obliged to have a different behaviour depending
@ -1023,8 +1031,9 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
gui_synclist_select_previous_page(lists, screen); gui_synclist_select_previous_page(lists, screen);
gui_synclist_draw(lists); gui_synclist_draw(lists);
yield(); yield();
*actionptr = ACTION_STD_NEXT;
} }
return ACTION_STD_NEXT; return true;
case ACTION_LISTTREE_PGDOWN: case ACTION_LISTTREE_PGDOWN:
{ {
@ -1037,8 +1046,9 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
gui_synclist_select_next_page(lists, screen); gui_synclist_select_next_page(lists, screen);
gui_synclist_draw(lists); gui_synclist_draw(lists);
yield(); yield();
*actionptr = ACTION_STD_PREV;
} }
return ACTION_STD_PREV; return true;
} }
return 0; return false;
} }

View file

@ -218,16 +218,11 @@ extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
bool hide); bool hide);
/* /*
* Do the action implied by the given button, * Do the action implied by the given button,
* returns the action taken if any, 0 else * returns true if the action was handled.
* - lists : the synchronized lists * NOTE: *action may be changed regardless of return value
* - 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, extern bool gui_synclist_do_button(struct gui_synclist * lists,
unsigned button, unsigned *action,
enum list_wrap); enum list_wrap);
#endif /* _GUI_LIST_H_ */ #endif /* _GUI_LIST_H_ */

View file

@ -381,7 +381,7 @@ bool option_screen(struct settings_list *setting,
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)) allow_wrap? LIST_WRAP_UNLESS_HELD: LIST_WRAP_OFF))
{ {
selected = gui_synclist_get_sel_pos(&lists); selected = gui_synclist_get_sel_pos(&lists);

View file

@ -345,7 +345,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
} }
} }
if (gui_synclist_do_button(&lists,action,LIST_WRAP_UNLESS_HELD)) if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
{ {
talk_menu_item(menu, &lists); talk_menu_item(menu, &lists);
continue; continue;

View file

@ -491,7 +491,7 @@ int usbdriver_menuitem(void)
{ {
gui_syncstatusbar_draw(&statusbars, true); gui_syncstatusbar_draw(&statusbars, true);
action = get_action(CONTEXT_STD, HZ/5); action = get_action(CONTEXT_STD, HZ/5);
if (gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD)) if (gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD))
continue; continue;
if (action == ACTION_STD_CANCEL) if (action == ACTION_STD_CANCEL)
{ {

View file

@ -249,7 +249,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,LIST_WRAP_UNLESS_HELD); 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

@ -605,14 +605,13 @@ 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; if( (gui_synclist_do_button(&playlist_lists, &button,LIST_WRAP_UNLESS_HELD)) )
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,
viewer.selected_track)) viewer.selected_track))
playlist_buffer_load_entries_screen(&viewer.buffer, playlist_buffer_load_entries_screen(&viewer.buffer,
list_action==ACTION_STD_NEXT? button==ACTION_STD_NEXT?
FORWARD FORWARD
: :
BACKWARD BACKWARD
@ -778,7 +777,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,LIST_WRAP_UNLESS_HELD)) if (gui_synclist_do_button(&playlist_lists, &button, LIST_WRAP_UNLESS_HELD))
continue; continue;
switch (button) switch (button)
{ {

View file

@ -112,12 +112,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 73 #define PLUGIN_API_VERSION 74
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 73 #define PLUGIN_MIN_API_VERSION 74
/* plugin return codes */ /* plugin return codes */
enum plugin_status { enum plugin_status {
@ -280,8 +280,8 @@ struct plugin_api {
void (*gui_synclist_del_item)(struct gui_synclist * lists); void (*gui_synclist_del_item)(struct gui_synclist * lists);
void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll); void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
void (*gui_synclist_flash)(struct gui_synclist * lists); void (*gui_synclist_flash)(struct gui_synclist * lists);
unsigned (*gui_synclist_do_button)(struct gui_synclist * lists, bool (*gui_synclist_do_button)(struct gui_synclist * lists,
unsigned button,enum list_wrap wrap); unsigned *action, enum list_wrap wrap);
void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, int icon); void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, int icon);
/* button */ /* button */

View file

@ -808,7 +808,7 @@ struct pgn_game_node* pgn_show_game_list(struct plugin_api* api,
rb->gui_synclist_draw(&games_list); rb->gui_synclist_draw(&games_list);
curr_selection = rb->gui_synclist_get_sel_pos(&games_list); curr_selection = rb->gui_synclist_get_sel_pos(&games_list);
button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
if (rb->gui_synclist_do_button(&games_list,button,LIST_WRAP_OFF)){ if (rb->gui_synclist_do_button(&games_list,&button,LIST_WRAP_OFF)){
continue; continue;
} }
switch (button) { switch (button) {

View file

@ -107,7 +107,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);
rb->gui_synclist_do_button(&(menus[m].synclist), key,LIST_WRAP_UNLESS_HELD); rb->gui_synclist_do_button(&(menus[m].synclist), &key,LIST_WRAP_UNLESS_HELD);
switch( key ) { switch( key ) {
case ACTION_STD_OK: case ACTION_STD_OK:
return rb->gui_synclist_get_sel_pos(&(menus[m].synclist)); return rb->gui_synclist_get_sel_pos(&(menus[m].synclist));

View file

@ -318,7 +318,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file)
while(!quit) while(!quit)
{ {
button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); button = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
if (rb->gui_synclist_do_button(&properties_lists,button,LIST_WRAP_ON)) if (rb->gui_synclist_do_button(&properties_lists,&button,LIST_WRAP_ON))
continue; continue;
switch(button) switch(button)
{ {

View file

@ -288,7 +288,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,LIST_WRAP_UNLESS_HELD)) 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

@ -59,7 +59,7 @@ enum sc_list_action_type draw_sc_list(struct gui_synclist gui_sc)
rb->gui_syncstatusbar_draw(rb->statusbars, true); rb->gui_syncstatusbar_draw(rb->statusbars, true);
/* user input */ /* user input */
button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK);
if (rb->gui_synclist_do_button(&gui_sc, button, if (rb->gui_synclist_do_button(&gui_sc, &button,
LIST_WRAP_UNLESS_HELD)) { LIST_WRAP_UNLESS_HELD)) {
/* automatic handling of user input. /* automatic handling of user input.
* _UNLESS_HELD can be _ON or _OFF also * _UNLESS_HELD can be _ON or _OFF also

View file

@ -374,7 +374,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,LIST_WRAP_UNLESS_HELD)) if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD))
continue; continue;
switch (button) switch (button)
{ {

View file

@ -1266,7 +1266,7 @@ static int handle_radio_presets(void)
gui_syncstatusbar_draw(&statusbars, true); gui_syncstatusbar_draw(&statusbars, true);
action = get_action(CONTEXT_STD, HZ); action = get_action(CONTEXT_STD, HZ);
gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD); gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD);
switch (action) switch (action)
{ {
case ACTION_STD_MENU: case ACTION_STD_MENU:

View file

@ -1282,7 +1282,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,LIST_WRAP_UNLESS_HELD)) && !gui_synclist_do_button(&id3_lists, &key,LIST_WRAP_UNLESS_HELD))
{ {
return(default_event_handler(key) == SYS_USB_CONNECTED); return(default_event_handler(key) == SYS_USB_CONNECTED);
} }
@ -1342,7 +1342,7 @@ bool view_runtime(void)
gui_synclist_draw(&lists); gui_synclist_draw(&lists);
gui_syncstatusbar_draw(&statusbars, true); gui_syncstatusbar_draw(&statusbars, true);
action = get_action(CONTEXT_STD, HZ); action = get_action(CONTEXT_STD, HZ);
gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD); gui_synclist_do_button(&lists, &action, LIST_WRAP_UNLESS_HELD);
if(action == ACTION_STD_CANCEL) if(action == ACTION_STD_CANCEL)
break; break;
if(action == ACTION_STD_OK) { if(action == ACTION_STD_OK) {

View file

@ -552,7 +552,7 @@ static int dirbrowse()
int numentries=0; int numentries=0;
char buf[MAX_PATH]; char buf[MAX_PATH];
int lasti = -1; int lasti = -1;
unsigned button, returned_button; unsigned button, oldbutton;
bool reload_root = false; bool reload_root = false;
int lastfilter = *tc.dirfilter; int lastfilter = *tc.dirfilter;
bool lastsortcase = global_settings.sort_case; bool lastsortcase = global_settings.sort_case;
@ -605,12 +605,8 @@ static int dirbrowse()
} }
#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,LIST_WRAP_UNLESS_HELD); oldbutton = button;
if (returned_button) need_update = gui_synclist_do_button(&tree_lists, &button,LIST_WRAP_UNLESS_HELD);
need_update = true;
if (returned_button == ACTION_STD_CANCEL)
button = ACTION_STD_CANCEL;
tc.selected_item = gui_synclist_get_sel_pos(&tree_lists); tc.selected_item = gui_synclist_get_sel_pos(&tree_lists);
switch ( button ) { switch ( button ) {
case ACTION_STD_OK: case ACTION_STD_OK:
@ -640,9 +636,11 @@ static int dirbrowse()
if ((*tc.dirfilter == SHOW_ID3DB && tc.dirlevel == 0) || if ((*tc.dirfilter == SHOW_ID3DB && tc.dirlevel == 0) ||
((*tc.dirfilter != SHOW_ID3DB && !strcmp(currdir,"/")))) ((*tc.dirfilter != SHOW_ID3DB && !strcmp(currdir,"/"))))
{ {
if (returned_button == ACTION_STD_CANCEL) #ifdef HAVE_LCD_BITMAP /* charcell doesnt have ACTION_TREE_PGLEFT so this isnt needed */
if (oldbutton == ACTION_TREE_PGLEFT)
break; break;
else else
#endif
return GO_TO_ROOT; return GO_TO_ROOT;
} }