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:
parent
344f45165f
commit
cf1cef5f57
21 changed files with 61 additions and 59 deletions
|
@ -659,7 +659,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
if (bookmarks->show_dont_resume)
|
||||
|
|
|
@ -296,7 +296,7 @@ void browse_cuesheet(struct cuesheet *cue)
|
|||
{
|
||||
gui_synclist_draw(&lists);
|
||||
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;
|
||||
switch (action)
|
||||
{
|
||||
|
|
|
@ -162,7 +162,7 @@ static bool dbg_list(struct action_callback_info *info)
|
|||
{
|
||||
gui_syncstatusbar_draw(&statusbars, true);
|
||||
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;
|
||||
if (info->action_callback)
|
||||
action = info->action_callback(action, info);
|
||||
|
|
|
@ -476,7 +476,7 @@ int filetype_list_viewers(const char* current_file)
|
|||
gui_syncstatusbar_draw(&statusbars, true);
|
||||
action = get_action(CONTEXT_MAINMENU,HZ);
|
||||
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;
|
||||
else if (action == ACTION_STD_OK)
|
||||
{
|
||||
|
|
|
@ -889,9 +889,10 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists)
|
|||
|
||||
extern intptr_t get_action_data(void);
|
||||
|
||||
unsigned gui_synclist_do_button(struct gui_synclist * lists,
|
||||
unsigned button,enum list_wrap wrap)
|
||||
bool gui_synclist_do_button(struct gui_synclist * lists,
|
||||
unsigned *actionptr, enum list_wrap wrap)
|
||||
{
|
||||
int action = *actionptr;
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
static bool scrolling_left = false;
|
||||
#endif
|
||||
|
@ -937,16 +938,16 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
|
|||
gui_synclist_limit_scroll(lists, true);
|
||||
break;
|
||||
case LIST_WRAP_UNLESS_HELD:
|
||||
if (button == ACTION_STD_PREVREPEAT ||
|
||||
button == ACTION_STD_NEXTREPEAT ||
|
||||
button == ACTION_LISTTREE_PGUP ||
|
||||
button == ACTION_LISTTREE_PGDOWN)
|
||||
if (action == ACTION_STD_PREVREPEAT ||
|
||||
action == ACTION_STD_NEXTREPEAT ||
|
||||
action == ACTION_LISTTREE_PGUP ||
|
||||
action == ACTION_LISTTREE_PGDOWN)
|
||||
gui_synclist_limit_scroll(lists, true);
|
||||
else gui_synclist_limit_scroll(lists, false);
|
||||
break;
|
||||
};
|
||||
|
||||
switch(button)
|
||||
switch (action)
|
||||
{
|
||||
#ifdef HAVE_VOLUME_IN_LIST
|
||||
case ACTION_LIST_VOLUP:
|
||||
|
@ -955,7 +956,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
|
|||
case ACTION_LIST_VOLDOWN:
|
||||
global_settings.volume--;
|
||||
setvol();
|
||||
return button;
|
||||
return true;
|
||||
#endif
|
||||
case ACTION_STD_PREV:
|
||||
case ACTION_STD_PREVREPEAT:
|
||||
|
@ -968,7 +969,8 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
|
|||
gui_synclist_draw(lists);
|
||||
}
|
||||
yield();
|
||||
return ACTION_STD_PREV;
|
||||
*actionptr = ACTION_STD_PREV;
|
||||
return true;
|
||||
|
||||
case ACTION_STD_NEXT:
|
||||
case ACTION_STD_NEXTREPEAT:
|
||||
|
@ -981,13 +983,14 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists,
|
|||
gui_synclist_draw(lists);
|
||||
}
|
||||
yield();
|
||||
return ACTION_STD_NEXT;
|
||||
*actionptr = ACTION_STD_NEXT;
|
||||
return true;
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
case ACTION_TREE_PGRIGHT:
|
||||
gui_synclist_scroll_right(lists);
|
||||
gui_synclist_draw(lists);
|
||||
return ACTION_TREE_PGRIGHT;
|
||||
return true;
|
||||
case ACTION_TREE_ROOT_INIT:
|
||||
/* After this button press ACTION_TREE_PGLEFT is allowed
|
||||
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)
|
||||
{
|
||||
scrolling_left = false;
|
||||
return ACTION_STD_CANCEL;
|
||||
*actionptr = ACTION_STD_CANCEL;
|
||||
return true;
|
||||
}
|
||||
*actionptr = ACTION_TREE_PGLEFT;
|
||||
case ACTION_TREE_PGLEFT:
|
||||
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_draw(lists);
|
||||
scrolling_left = true; /* stop ACTION_TREE_PAGE_LEFT
|
||||
skipping to root */
|
||||
return ACTION_TREE_PGLEFT;
|
||||
return true;
|
||||
#endif
|
||||
|
||||
/* 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_draw(lists);
|
||||
yield();
|
||||
*actionptr = ACTION_STD_NEXT;
|
||||
}
|
||||
return ACTION_STD_NEXT;
|
||||
return true;
|
||||
|
||||
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_draw(lists);
|
||||
yield();
|
||||
*actionptr = ACTION_STD_PREV;
|
||||
}
|
||||
return ACTION_STD_PREV;
|
||||
return true;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -218,16 +218,11 @@ extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
|
|||
bool hide);
|
||||
/*
|
||||
* Do the action implied by the given button,
|
||||
* 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)
|
||||
* returns true if the action was handled.
|
||||
* NOTE: *action may be changed regardless of return value
|
||||
*/
|
||||
extern unsigned gui_synclist_do_button(struct gui_synclist * lists,
|
||||
unsigned button,
|
||||
extern bool gui_synclist_do_button(struct gui_synclist * lists,
|
||||
unsigned *action,
|
||||
enum list_wrap);
|
||||
|
||||
#endif /* _GUI_LIST_H_ */
|
||||
|
|
|
@ -381,7 +381,7 @@ bool option_screen(struct settings_list *setting,
|
|||
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))
|
||||
{
|
||||
selected = gui_synclist_get_sel_pos(&lists);
|
||||
|
|
|
@ -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);
|
||||
continue;
|
||||
|
|
|
@ -491,7 +491,7 @@ int usbdriver_menuitem(void)
|
|||
{
|
||||
gui_syncstatusbar_draw(&statusbars, true);
|
||||
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;
|
||||
if (action == ACTION_STD_CANCEL)
|
||||
{
|
||||
|
|
|
@ -249,7 +249,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,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)];
|
||||
|
||||
|
|
|
@ -605,14 +605,13 @@ 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,LIST_WRAP_UNLESS_HELD))!=0 )
|
||||
if( (gui_synclist_do_button(&playlist_lists, &button,LIST_WRAP_UNLESS_HELD)) )
|
||||
{
|
||||
viewer.selected_track=gui_synclist_get_sel_pos(&playlist_lists);
|
||||
if(playlist_buffer_needs_reload(&viewer.buffer,
|
||||
viewer.selected_track))
|
||||
playlist_buffer_load_entries_screen(&viewer.buffer,
|
||||
list_action==ACTION_STD_NEXT?
|
||||
button==ACTION_STD_NEXT?
|
||||
FORWARD
|
||||
:
|
||||
BACKWARD
|
||||
|
@ -778,7 +777,7 @@ bool search_playlist(void)
|
|||
while (!exit)
|
||||
{
|
||||
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;
|
||||
switch (button)
|
||||
{
|
||||
|
|
|
@ -112,12 +112,12 @@
|
|||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||
|
||||
/* 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
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
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 */
|
||||
enum plugin_status {
|
||||
|
@ -280,8 +280,8 @@ struct plugin_api {
|
|||
void (*gui_synclist_del_item)(struct gui_synclist * lists);
|
||||
void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
|
||||
void (*gui_synclist_flash)(struct gui_synclist * lists);
|
||||
unsigned (*gui_synclist_do_button)(struct gui_synclist * lists,
|
||||
unsigned button,enum list_wrap wrap);
|
||||
bool (*gui_synclist_do_button)(struct gui_synclist * lists,
|
||||
unsigned *action, enum list_wrap wrap);
|
||||
void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, int icon);
|
||||
|
||||
/* button */
|
||||
|
|
|
@ -808,7 +808,7 @@ struct pgn_game_node* pgn_show_game_list(struct plugin_api* api,
|
|||
rb->gui_synclist_draw(&games_list);
|
||||
curr_selection = rb->gui_synclist_get_sel_pos(&games_list);
|
||||
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;
|
||||
}
|
||||
switch (button) {
|
||||
|
|
|
@ -107,7 +107,7 @@ int menu_show(int m)
|
|||
*/
|
||||
if( menus[m].callback != NULL )
|
||||
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 ) {
|
||||
case ACTION_STD_OK:
|
||||
return rb->gui_synclist_get_sel_pos(&(menus[m].synclist));
|
||||
|
|
|
@ -318,7 +318,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file)
|
|||
while(!quit)
|
||||
{
|
||||
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;
|
||||
switch(button)
|
||||
{
|
||||
|
|
|
@ -288,7 +288,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,LIST_WRAP_UNLESS_HELD))
|
||||
if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD))
|
||||
continue;
|
||||
selection = rb->gui_synclist_get_sel_pos(&lists);
|
||||
switch (button)
|
||||
|
|
|
@ -59,7 +59,7 @@ enum sc_list_action_type draw_sc_list(struct gui_synclist gui_sc)
|
|||
rb->gui_syncstatusbar_draw(rb->statusbars, true);
|
||||
/* user input */
|
||||
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)) {
|
||||
/* automatic handling of user input.
|
||||
* _UNLESS_HELD can be _ON or _OFF also
|
||||
|
|
|
@ -374,7 +374,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,LIST_WRAP_UNLESS_HELD))
|
||||
if (rb->gui_synclist_do_button(&lists,&button,LIST_WRAP_UNLESS_HELD))
|
||||
continue;
|
||||
switch (button)
|
||||
{
|
||||
|
|
|
@ -1266,7 +1266,7 @@ static int handle_radio_presets(void)
|
|||
gui_syncstatusbar_draw(&statusbars, true);
|
||||
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)
|
||||
{
|
||||
case ACTION_STD_MENU:
|
||||
|
|
|
@ -1282,7 +1282,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,LIST_WRAP_UNLESS_HELD))
|
||||
&& !gui_synclist_do_button(&id3_lists, &key,LIST_WRAP_UNLESS_HELD))
|
||||
{
|
||||
return(default_event_handler(key) == SYS_USB_CONNECTED);
|
||||
}
|
||||
|
@ -1342,7 +1342,7 @@ bool view_runtime(void)
|
|||
gui_synclist_draw(&lists);
|
||||
gui_syncstatusbar_draw(&statusbars, true);
|
||||
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)
|
||||
break;
|
||||
if(action == ACTION_STD_OK) {
|
||||
|
|
14
apps/tree.c
14
apps/tree.c
|
@ -552,7 +552,7 @@ static int dirbrowse()
|
|||
int numentries=0;
|
||||
char buf[MAX_PATH];
|
||||
int lasti = -1;
|
||||
unsigned button, returned_button;
|
||||
unsigned button, oldbutton;
|
||||
bool reload_root = false;
|
||||
int lastfilter = *tc.dirfilter;
|
||||
bool lastsortcase = global_settings.sort_case;
|
||||
|
@ -605,12 +605,8 @@ static int dirbrowse()
|
|||
}
|
||||
#endif
|
||||
button = get_action(CONTEXT_TREE,HZ/5);
|
||||
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)
|
||||
button = ACTION_STD_CANCEL;
|
||||
|
||||
oldbutton = button;
|
||||
need_update = gui_synclist_do_button(&tree_lists, &button,LIST_WRAP_UNLESS_HELD);
|
||||
tc.selected_item = gui_synclist_get_sel_pos(&tree_lists);
|
||||
switch ( button ) {
|
||||
case ACTION_STD_OK:
|
||||
|
@ -640,9 +636,11 @@ static int dirbrowse()
|
|||
if ((*tc.dirfilter == SHOW_ID3DB && tc.dirlevel == 0) ||
|
||||
((*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;
|
||||
else
|
||||
#endif
|
||||
return GO_TO_ROOT;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue