summaryrefslogtreecommitdiffstats
path: root/apps/gui/list.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2012-01-12 22:28:36 +1100
committerJonathan Gordon <rockbox@jdgordon.info>2012-01-12 22:28:36 +1100
commiteb2ea7f9ad4c4e2cce390f8fe73e17698fa9a906 (patch)
tree64cd1f227d75a5758b52d9b49ae7bdf23f6dbf83 /apps/gui/list.c
parent5ef27368f1bcbe31fb27072983d7a29df8de6845 (diff)
downloadrockbox-eb2ea7f9ad4c4e2cce390f8fe73e17698fa9a906.tar.gz
rockbox-eb2ea7f9ad4c4e2cce390f8fe73e17698fa9a906.tar.bz2
rockbox-eb2ea7f9ad4c4e2cce390f8fe73e17698fa9a906.zip
keyclick: Add a callback so screens can cancel a click. Add a generic list callback to stop clicks when we are at the end of the list
Change-Id: Iabb44a861dd7506cd883c1bdb0241303fa646746
Diffstat (limited to 'apps/gui/list.c')
-rw-r--r--apps/gui/list.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index c53a1f559c..d1b2748a60 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -576,6 +576,25 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists)
}
#endif /* HAVE_LCD_BITMAP */
+#if CONFIG_CODEC == SWCODEC
+bool gui_synclist_keyclick_callback(int action, void* data)
+{
+ struct gui_synclist *lists = (struct gui_synclist *)data;
+
+ /* block the beep if we are at the end of the list and we are not wrapping.
+ * CAVEAT: mosts lists don't set limit_scroll untill it sees a repeat
+ * press at the end of the list so this can cause an extra beep.
+ */
+ if (lists->limit_scroll == false)
+ return true;
+ if (lists->selected_item == 0)
+ return (action != ACTION_STD_PREV && action != ACTION_STD_PREVREPEAT);
+ if (lists->selected_item == lists->nb_items - lists->selected_size)
+ return (action != ACTION_STD_NEXT && action != ACTION_STD_NEXTREPEAT);
+
+ return action != ACTION_NONE;
+}
+#endif
bool gui_synclist_do_button(struct gui_synclist * lists,
int *actionptr, enum list_wrap wrap)
@@ -774,6 +793,9 @@ bool list_do_action(int context, int timeout,
do_button, and places the action from get_action in *action. */
{
timeout = list_do_action_timeout(lists, timeout);
+#if CONFIG_CODEC == SWCODEC
+ keyclick_set_callback(gui_synclist_keyclick_callback, lists);
+#endif
*action = get_action(context, timeout);
return gui_synclist_do_button(lists, action, wrap);
}