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
diff --git a/apps/bookmark.c b/apps/bookmark.c
index b2c2713..4522859 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -659,7 +659,7 @@
}
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)
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index 79a07a7..d5fbc54 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -296,7 +296,7 @@
{
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)
{
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index d5c0b81..40c0fcc 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -162,7 +162,7 @@
{
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);
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 21ce17c..5e72fca 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -476,7 +476,7 @@
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)
{
diff --git a/apps/gui/list.c b/apps/gui/list.c
index f12d8a3..a8bbce8 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -889,9 +889,10 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
}
diff --git a/apps/gui/list.h b/apps/gui/list.h
index d0bc59b..1046492 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -218,16 +218,11 @@
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_ */
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 474c459..b8b1cc5 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -381,7 +381,7 @@
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);
diff --git a/apps/menu.c b/apps/menu.c
index 201bbdf..e369f4d 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -345,7 +345,7 @@
}
}
- 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;
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index a85024e..bbc2505 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -491,7 +491,7 @@
{
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)
{
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index 266da7c..fda91bb 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -249,7 +249,7 @@
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)];
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index a466b7e..8452f43 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -605,14 +605,13 @@
/* 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 @@
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)
{
diff --git a/apps/plugin.h b/apps/plugin.h
index 2580d43..3971a13 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -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 @@
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 */
diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c
index fb04f6a..3780e32 100644
--- a/apps/plugins/chessbox/chessbox_pgn.c
+++ b/apps/plugins/chessbox/chessbox_pgn.c
@@ -808,7 +808,7 @@
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) {
diff --git a/apps/plugins/lib/oldmenuapi.c b/apps/plugins/lib/oldmenuapi.c
index 742d394..07681a0 100644
--- a/apps/plugins/lib/oldmenuapi.c
+++ b/apps/plugins/lib/oldmenuapi.c
@@ -107,7 +107,7 @@
*/
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));
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index 932e5bc..ca18d49 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -318,7 +318,7 @@
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)
{
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index 6ed36c6..656daea 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -288,7 +288,7 @@
{
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)
diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c
index 3b28b4b..f61177f 100644
--- a/apps/plugins/shortcuts/shortcuts_view.c
+++ b/apps/plugins/shortcuts/shortcuts_view.c
@@ -59,7 +59,7 @@
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
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c
index 3ac8cab..dd5f4b7 100644
--- a/apps/plugins/text_editor.c
+++ b/apps/plugins/text_editor.c
@@ -374,7 +374,7 @@
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)
{
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index b95bffe..5042305 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -1266,7 +1266,7 @@
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:
diff --git a/apps/screens.c b/apps/screens.c
index ee804b2..b725bea 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -1282,7 +1282,7 @@
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 @@
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) {
diff --git a/apps/tree.c b/apps/tree.c
index 5122f55..fb2ed8d 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -552,7 +552,7 @@
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 @@
}
#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 @@
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;
}