summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-09-17 10:08:50 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-09-17 10:08:50 +0000
commitcf1cef5f573ca6961041c9ab53649ac52f6b1e93 (patch)
treef4be937b805d829c354e0ad723b4cf3b7089f29b /apps/gui
parent344f45165f4b1f76b95883895be3634225a10cbb (diff)
downloadrockbox-cf1cef5f573ca6961041c9ab53649ac52f6b1e93.zip
rockbox-cf1cef5f573ca6961041c9ab53649ac52f6b1e93.tar.gz
rockbox-cf1cef5f573ca6961041c9ab53649ac52f6b1e93.tar.bz2
rockbox-cf1cef5f573ca6961041c9ab53649ac52f6b1e93.tar.xz
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
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/list.c44
-rw-r--r--apps/gui/list.h13
-rw-r--r--apps/gui/option_select.c2
3 files changed, 32 insertions, 27 deletions
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 @@ 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;
}
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 @@ 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_ */
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 @@ 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);