From d5a081cbd1b871baf4e5d2c276fbabbc30c7994b Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Mon, 19 Sep 2022 12:48:15 +0100 Subject: 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 --- apps/plugins/calendar.c | 2 +- apps/plugins/chessbox/chessbox_pgn.c | 3 +-- apps/plugins/keybox.c | 2 +- apps/plugins/keyremap.c | 2 +- apps/plugins/lrcplayer.c | 3 +-- apps/plugins/main_menu_config.c | 2 +- apps/plugins/open_plugins.c | 4 ++-- apps/plugins/properties.c | 2 +- apps/plugins/puzzles/rockbox.c | 6 +++--- apps/plugins/random_folder_advance_config.c | 2 +- apps/plugins/rb_info.c | 2 +- apps/plugins/shopper.c | 2 +- apps/plugins/shortcuts/shortcuts_view.c | 7 +------ apps/plugins/text_editor.c | 2 +- 14 files changed, 17 insertions(+), 24 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c index 3299a81273..a70f47c34b 100644 --- a/apps/plugins/calendar.c +++ b/apps/plugins/calendar.c @@ -964,7 +964,7 @@ static bool view_events(int selected, struct shown *shown) while (!exit) { button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); - rb->gui_synclist_do_button(&gui_memos, &button, LIST_WRAP_UNLESS_HELD); + rb->gui_synclist_do_button(&gui_memos, &button); switch (button) { diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c index ccbcc7e91d..bb35bec726 100644 --- a/apps/plugins/chessbox/chessbox_pgn.c +++ b/apps/plugins/chessbox/chessbox_pgn.c @@ -686,9 +686,8 @@ struct pgn_game_node* pgn_show_game_list(struct pgn_game_node* first_game){ while (true) { 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)) continue; - } switch (button) { case ACTION_STD_OK: return get_game_info(curr_selection, first_game); diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c index 38783508e7..cb2e23a94a 100644 --- a/apps/plugins/keybox.c +++ b/apps/plugins/keybox.c @@ -567,7 +567,7 @@ static int keybox(void) { rb->gui_synclist_draw(&kb_list); button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&kb_list, &button, LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&kb_list, &button)) continue; switch (button) diff --git a/apps/plugins/keyremap.c b/apps/plugins/keyremap.c index aaf530318a..8699d86bd2 100644 --- a/apps/plugins/keyremap.c +++ b/apps/plugins/keyremap.c @@ -2054,7 +2054,7 @@ enum plugin_status plugin_start(const void* parameter) redraw = true; ret = menu_action_cb(&action, selected_item, &exit, &lists); - if (rb->gui_synclist_do_button(&lists,&action,LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&lists, &action)) continue; selected_item = rb->gui_synclist_get_sel_pos(&lists); diff --git a/apps/plugins/lrcplayer.c b/apps/plugins/lrcplayer.c index 6c26db7a33..32d001add9 100644 --- a/apps/plugins/lrcplayer.c +++ b/apps/plugins/lrcplayer.c @@ -2078,8 +2078,7 @@ static int timetag_editor(void) while (!exit) { button = rb->get_action(CONTEXT_TREE, TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&gui_editor, &button, - LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&gui_editor, &button)) continue; switch (button) diff --git a/apps/plugins/main_menu_config.c b/apps/plugins/main_menu_config.c index 9f651094b1..a5488ed2c0 100644 --- a/apps/plugins/main_menu_config.c +++ b/apps/plugins/main_menu_config.c @@ -188,7 +188,7 @@ enum plugin_status plugin_start(const void* parameter) { cur_sel = rb->gui_synclist_get_sel_pos(&list); action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&list,&action,LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&list, &action)) continue; switch (action) diff --git a/apps/plugins/open_plugins.c b/apps/plugins/open_plugins.c index 0bd9740fe7..7230387efb 100644 --- a/apps/plugins/open_plugins.c +++ b/apps/plugins/open_plugins.c @@ -681,7 +681,7 @@ static void edit_menu(int selection) { action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&lists,&action,LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&lists, &action)) continue; selected_item = rb->gui_synclist_get_sel_pos(&lists); switch (action) @@ -864,7 +864,7 @@ reopen_datfile: { action = rb->get_action(CONTEXT_LIST,TIMEOUT_BLOCK); - if (rb->gui_synclist_do_button(&lists,&action,LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&lists, &action)) continue; selection = rb->gui_synclist_get_sel_pos(&lists); switch (action) diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index 89ea722e9e..ff8c281bed 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c @@ -397,7 +397,7 @@ enum plugin_status plugin_start(const void* parameter) { button = rb->get_action(CONTEXT_LIST, HZ); /* HZ so the status bar redraws corectly */ - if (rb->gui_synclist_do_button(&properties_lists,&button,LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&properties_lists, &button)) continue; switch(button) { diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c index 09b247e184..563820ba23 100644 --- a/apps/plugins/puzzles/rockbox.c +++ b/apps/plugins/puzzles/rockbox.c @@ -2458,7 +2458,7 @@ static int list_choose(const char *list_str, const char *title, int sel) { rb->gui_synclist_draw(&list); int button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); - if(rb->gui_synclist_do_button(&list, &button, LIST_WRAP_UNLESS_HELD)) + if(rb->gui_synclist_do_button(&list, &button)) continue; switch(button) { @@ -2672,7 +2672,7 @@ static bool config_menu(void) { rb->gui_synclist_draw(&list); int button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); - if(rb->gui_synclist_do_button(&list, &button, LIST_WRAP_UNLESS_HELD)) + if(rb->gui_synclist_do_button(&list, &button)) continue; switch(button) { @@ -2757,7 +2757,7 @@ static int do_preset_menu(struct preset_menu *menu, char *title, int selected) { rb->gui_synclist_draw(&list); int button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK); - if(rb->gui_synclist_do_button(&list, &button, LIST_WRAP_UNLESS_HELD)) + if(rb->gui_synclist_do_button(&list, &button)) continue; switch(button) { diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 2c22298cd4..5688ff93d3 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c @@ -317,7 +317,7 @@ static int 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)) continue; selection = rb->gui_synclist_get_sel_pos(&lists); switch (button) diff --git a/apps/plugins/rb_info.c b/apps/plugins/rb_info.c index 1385a5a9fc..f123a623d2 100644 --- a/apps/plugins/rb_info.c +++ b/apps/plugins/rb_info.c @@ -557,7 +557,7 @@ enum plugin_status plugin_start(const void* parameter) else redraw = true; ret = menu_action_cb(&action, selected_item, &exit, &lists); - if (rb->gui_synclist_do_button(&lists,&action,LIST_WRAP_UNLESS_HELD)) + if (rb->gui_synclist_do_button(&lists, &action)) continue; selected_item = rb->gui_synclist_get_sel_pos(&lists); } diff --git a/apps/plugins/shopper.c b/apps/plugins/shopper.c index 31ef44b831..25a484a31e 100644 --- a/apps/plugins/shopper.c +++ b/apps/plugins/shopper.c @@ -315,7 +315,7 @@ enum plugin_status plugin_start(const 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)) continue; switch (button) { diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c index 9584731989..2a7970bebe 100644 --- a/apps/plugins/shortcuts/shortcuts_view.c +++ b/apps/plugins/shortcuts/shortcuts_view.c @@ -59,13 +59,8 @@ enum sc_list_action_type draw_sc_list(struct gui_synclist *gui_sc) /* user input */ button = rb->get_action(CONTEXT_LIST, HZ); /* HZ so the status bar redraws corectly */ - 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 - * selection changed, so redraw */ + if (rb->gui_synclist_do_button(gui_sc, &button)) continue; - } switch (button) { /* process the user input */ case ACTION_STD_OK: return SCLA_SELECT; diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index 748e872d0b..8740606c58 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c @@ -394,7 +394,7 @@ enum plugin_status plugin_start(const 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)) continue; switch (button) { -- cgit v1.2.3