summaryrefslogtreecommitdiff
path: root/apps/gui/list.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-09-19 12:48:15 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-10-05 11:22:55 -0400
commitd5a081cbd1b871baf4e5d2c276fbabbc30c7994b (patch)
treeaac3c9377be8433ad15c4ca2a733d3a7c81aad97 /apps/gui/list.c
parentff378deb69951a53b866f3d3c6ee13022e520436 (diff)
downloadrockbox-d5a081cbd1b871baf4e5d2c276fbabbc30c7994b.tar.gz
rockbox-d5a081cbd1b871baf4e5d2c276fbabbc30c7994b.zip
gui: Remove "enum list_wrap" from list action functions
Removing the "list_wrap" argument is actually pretty easy. In practice, almost all lists are using LIST_WRAP_UNLESS_HELD behavior so we can make that the default. A couple of lists disable wraparound with LIST_WRAP_OFF; this is now achieved by setting the list "wraparound" flag to false when setting up the list. LIST_WRAP_ON was unused and is of questionable value, so it has been removed entirely. This makes list wraparound behavior a property of the list, controlled solely by the "wraparound" flag. The result is a simpler list API and implementation, without changing the behavior of any lists. Change-Id: Ib55d17519e6d92fc95ae17b84ab0aaf4233bcb5a
Diffstat (limited to 'apps/gui/list.c')
-rw-r--r--apps/gui/list.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 713942af18..85404b7f0c 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -595,8 +595,7 @@ static void _lists_uiviewport_update_callback(unsigned short id, void *data)
595 gui_synclist_draw(current_lists); 595 gui_synclist_draw(current_lists);
596} 596}
597 597
598bool gui_synclist_do_button(struct gui_synclist * lists, 598bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr)
599 int *actionptr, enum list_wrap wrap)
600{ 599{
601 int action = *actionptr; 600 int action = *actionptr;
602 static bool pgleft_allow_cancel = false; 601 static bool pgleft_allow_cancel = false;
@@ -642,24 +641,15 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
642 641
643 /* Disable the skin redraw callback */ 642 /* Disable the skin redraw callback */
644 current_lists = NULL; 643 current_lists = NULL;
645 switch (wrap) 644
646 { 645 /* Prevent list wraparound by repeating actions */
647 case LIST_WRAP_ON: 646 if (action == ACTION_STD_PREVREPEAT ||
648 lists->limit_scroll = !lists->wraparound; 647 action == ACTION_STD_NEXTREPEAT ||
649 break; 648 action == ACTION_LISTTREE_PGUP ||
650 case LIST_WRAP_OFF: 649 action == ACTION_LISTTREE_PGDOWN)
651 lists->limit_scroll = true; 650 lists->limit_scroll = true;
652 break; 651 else
653 case LIST_WRAP_UNLESS_HELD: 652 lists->limit_scroll = !lists->wraparound;
654 if (action == ACTION_STD_PREVREPEAT ||
655 action == ACTION_STD_NEXTREPEAT ||
656 action == ACTION_LISTTREE_PGUP ||
657 action == ACTION_LISTTREE_PGDOWN)
658 lists->limit_scroll = true;
659 else
660 lists->limit_scroll = !lists->wraparound;
661 break;
662 };
663 653
664 switch (action) 654 switch (action)
665 { 655 {
@@ -795,8 +785,7 @@ int list_do_action_timeout(struct gui_synclist *lists, int timeout)
795} 785}
796 786
797bool list_do_action(int context, int timeout, 787bool list_do_action(int context, int timeout,
798 struct gui_synclist *lists, int *action, 788 struct gui_synclist *lists, int *action)
799 enum list_wrap wrap)
800/* Combines the get_action() (with possibly overridden timeout) and 789/* Combines the get_action() (with possibly overridden timeout) and
801 gui_synclist_do_button() calls. Returns the list action from 790 gui_synclist_do_button() calls. Returns the list action from
802 do_button, and places the action from get_action in *action. */ 791 do_button, and places the action from get_action in *action. */
@@ -804,7 +793,7 @@ bool list_do_action(int context, int timeout,
804 timeout = list_do_action_timeout(lists, timeout); 793 timeout = list_do_action_timeout(lists, timeout);
805 keyclick_set_callback(gui_synclist_keyclick_callback, lists); 794 keyclick_set_callback(gui_synclist_keyclick_callback, lists);
806 *action = get_action(context, timeout); 795 *action = get_action(context, timeout);
807 return gui_synclist_do_button(lists, action, wrap); 796 return gui_synclist_do_button(lists, action);
808} 797}
809 798
810bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, 799bool gui_synclist_item_is_onscreen(struct gui_synclist *lists,
@@ -871,7 +860,6 @@ bool simplelist_show_list(struct simplelist_info *info)
871 struct gui_synclist lists; 860 struct gui_synclist lists;
872 int action, old_line_count = simplelist_line_count; 861 int action, old_line_count = simplelist_line_count;
873 list_get_name *getname; 862 list_get_name *getname;
874 int wrap = global_settings.list_wraparound ? LIST_WRAP_UNLESS_HELD : LIST_WRAP_OFF;
875 if (info->get_name) 863 if (info->get_name)
876 getname = info->get_name; 864 getname = info->get_name;
877 else 865 else
@@ -914,8 +902,7 @@ bool simplelist_show_list(struct simplelist_info *info)
914 902
915 while(1) 903 while(1)
916 { 904 {
917 list_do_action(CONTEXT_LIST, info->timeout, 905 list_do_action(CONTEXT_LIST, info->timeout, &lists, &action);
918 &lists, &action, wrap);
919 906
920 /* We must yield in this case or no other thread can run */ 907 /* We must yield in this case or no other thread can run */
921 if (info->timeout == TIMEOUT_NOBLOCK) 908 if (info->timeout == TIMEOUT_NOBLOCK)