summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-09-19 11:10:54 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-10-02 09:21:25 -0400
commit9ce5b2a2eda5c7101898476adaa3533e0ba5db82 (patch)
treefacbfe9721d907b1a92f2b113b262374c6e2917e /apps/gui
parentc1d75a6bcb30260eba288f643261c4a57959f45f (diff)
downloadrockbox-9ce5b2a2eda5c7101898476adaa3533e0ba5db82.tar.gz
rockbox-9ce5b2a2eda5c7101898476adaa3533e0ba5db82.zip
gui: Remove show/hide selection option in lists
The implementation of the "show_selection_marker" option in lists isn't great. It's a cosmetic option used to hide the selection, but it causes the list to do funny things to the selected_item and doesn't play nice with voiced menus, since these rely on the selection to determine what item is spoken. There are only two user-facing lists that use the option, the "Rockbox Info" screen and a menu in the superdom plugin. The rest are debug screens, and cosmetics don't matter much there. Given how little used the option is, and its issues, removing it seems reasonable. Change-Id: I2c70b3e4c74ff3cc6dbac46366a371d271dd2d58
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/bitmap/list-skinned.c3
-rw-r--r--apps/gui/bitmap/list.c8
-rw-r--r--apps/gui/list.c45
-rw-r--r--apps/gui/list.h5
4 files changed, 4 insertions, 57 deletions
diff --git a/apps/gui/bitmap/list-skinned.c b/apps/gui/bitmap/list-skinned.c
index a67ac8cb0a..bebff821f8 100644
--- a/apps/gui/bitmap/list-skinned.c
+++ b/apps/gui/bitmap/list-skinned.c
@@ -213,8 +213,7 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list)
213 if (list_start_item+cur_line+1 > list->nb_items) 213 if (list_start_item+cur_line+1 > list->nb_items)
214 break; 214 break;
215 current_drawing_line = list_start_item+cur_line; 215 current_drawing_line = list_start_item+cur_line;
216 is_selected = list->show_selection_marker && 216 is_selected = list_start_item+cur_line == list->selected_item;
217 list_start_item+cur_line == list->selected_item;
218 217
219 for (viewport = SKINOFFSETTOPTR(get_skin_buffer(wps.data), listcfg[screen]->data->tree); 218 for (viewport = SKINOFFSETTOPTR(get_skin_buffer(wps.data), listcfg[screen]->data->tree);
220 viewport; 219 viewport;
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index b2987e9853..ca58d713d0 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -196,10 +196,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
196 const int list_start_item = list->start_item[screen]; 196 const int list_start_item = list->start_item[screen];
197 const bool scrollbar_in_left = (list->scrollbar == SCROLLBAR_LEFT); 197 const bool scrollbar_in_left = (list->scrollbar == SCROLLBAR_LEFT);
198 const bool scrollbar_in_right = (list->scrollbar == SCROLLBAR_RIGHT); 198 const bool scrollbar_in_right = (list->scrollbar == SCROLLBAR_RIGHT);
199 199 const bool show_cursor = (list->cursor_style == SYNCLIST_CURSOR_NOSTYLE);
200 const bool show_cursor = list->show_selection_marker &&
201 (list->cursor_style == SYNCLIST_CURSOR_NOSTYLE);
202
203 const bool have_icons = list->callback_get_item_icon && list->show_icons; 200 const bool have_icons = list->callback_get_item_icon && list->show_icons;
204 201
205 struct viewport *parent = (list->parent[screen]); 202 struct viewport *parent = (list->parent[screen]);
@@ -365,8 +362,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
365 !hide_selection && 362 !hide_selection &&
366#endif 363#endif
367 i >= list->selected_item 364 i >= list->selected_item
368 && i < list->selected_item + list->selected_size 365 && i < list->selected_item + list->selected_size)
369 && list->show_selection_marker)
370 {/* The selected item must be displayed scrolling */ 366 {/* The selected item must be displayed scrolling */
371#ifdef HAVE_LCD_COLOR 367#ifdef HAVE_LCD_COLOR
372 if (list->selection_color) 368 if (list->selection_color)
diff --git a/apps/gui/list.c b/apps/gui/list.c
index df5df22ca1..98e9fe0ada 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -191,7 +191,6 @@ void gui_synclist_init(struct gui_synclist * gui_list,
191 191
192 gui_list->scheduled_talk_tick = gui_list->last_talked_tick = 0; 192 gui_list->scheduled_talk_tick = gui_list->last_talked_tick = 0;
193 gui_list->dirty_tick = current_tick; 193 gui_list->dirty_tick = current_tick;
194 gui_list->show_selection_marker = true;
195 194
196#ifdef HAVE_LCD_COLOR 195#ifdef HAVE_LCD_COLOR
197 gui_list->title_color = -1; 196 gui_list->title_color = -1;
@@ -200,13 +199,6 @@ void gui_synclist_init(struct gui_synclist * gui_list,
200#endif 199#endif
201} 200}
202 201
203/* this toggles the selection bar or cursor */
204void gui_synclist_hide_selection_marker(struct gui_synclist * lists, bool hide)
205{
206 lists->show_selection_marker = !hide;
207}
208
209
210int gui_list_get_item_offset(struct gui_synclist * gui_list, 202int gui_list_get_item_offset(struct gui_synclist * gui_list,
211 int item_width, 203 int item_width,
212 int text_pos, 204 int text_pos,
@@ -269,11 +261,7 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
269 const int scroll_limit_up = (nb_lines < gui_list->selected_size+2 ? 0:1); 261 const int scroll_limit_up = (nb_lines < gui_list->selected_size+2 ? 0:1);
270 const int scroll_limit_down = (scroll_limit_up+gui_list->selected_size); 262 const int scroll_limit_down = (scroll_limit_up+gui_list->selected_size);
271 263
272 if (gui_list->show_selection_marker == false) 264 if (gui_list->selected_size >= nb_lines)
273 {
274 new_start_item = gui_list->selected_item;
275 }
276 else if (gui_list->selected_size >= nb_lines)
277 { 265 {
278 new_start_item = gui_list->selected_item; 266 new_start_item = gui_list->selected_item;
279 } 267 }
@@ -420,31 +408,7 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list,
420 0 : gui_list->nb_items - gui_list->selected_size; 408 0 : gui_list->nb_items - gui_list->selected_size;
421 edge_beep(gui_list, !gui_list->limit_scroll); 409 edge_beep(gui_list, !gui_list->limit_scroll);
422 } 410 }
423 else if (gui_list->show_selection_marker == false)
424 {
425 FOR_NB_SCREENS(i)
426 {
427 int nb_lines = list_get_nb_lines(gui_list, i);
428 if (offset > 0)
429 {
430 int screen_top = MAX(0, gui_list->nb_items - nb_lines);
431 gui_list->start_item[i] = MIN(screen_top, gui_list->start_item[i] +
432 gui_list->selected_size);
433 gui_list->selected_item = gui_list->start_item[i];
434 }
435 else
436 {
437 gui_list->start_item[i] = MAX(0, gui_list->start_item[i] -
438 gui_list->selected_size);
439 gui_list->selected_item = gui_list->start_item[i] + nb_lines;
440 }
441 411
442#ifdef HAVE_TOUCHSCREEN
443 gui_list->y_pos = gui_list->start_item[SCREEN_MAIN] * gui_list->line_height[SCREEN_MAIN];
444#endif
445 }
446 return;
447 }
448 gui_synclist_select_item(gui_list, new_selection); 412 gui_synclist_select_item(gui_list, new_selection);
449} 413}
450 414
@@ -950,12 +914,6 @@ bool simplelist_show_list(struct simplelist_info *info)
950 gui_synclist_set_sel_color(&lists, info->selection_color); 914 gui_synclist_set_sel_color(&lists, info->selection_color);
951#endif 915#endif
952 916
953 if (info->hide_selection)
954 {
955 gui_synclist_hide_selection_marker(&lists, true);
956 wrap = LIST_WRAP_OFF;
957 }
958
959 if (info->action_callback) 917 if (info->action_callback)
960 info->action_callback(ACTION_REDRAW, &lists); 918 info->action_callback(ACTION_REDRAW, &lists);
961 919
@@ -1039,7 +997,6 @@ void simplelist_info_init(struct simplelist_info *info, char* title,
1039 info->title = title; 997 info->title = title;
1040 info->count = count; 998 info->count = count;
1041 info->selection_size = 1; 999 info->selection_size = 1;
1042 info->hide_selection = false;
1043 info->scroll_all = false; 1000 info->scroll_all = false;
1044 info->hide_theme = false; 1001 info->hide_theme = false;
1045 info->speak_onshow = true; 1002 info->speak_onshow = true;
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 2df33b7541..388e3d2006 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -161,7 +161,6 @@ struct gui_synclist
161 /* whether the text of the whole items of the list have to be 161 /* whether the text of the whole items of the list have to be
162 * scrolled or only for the selected item */ 162 * scrolled or only for the selected item */
163 bool scroll_all; 163 bool scroll_all;
164 bool show_selection_marker; /* set to true by default */
165 int nb_items; 164 int nb_items;
166 int selected_item; 165 int selected_item;
167 166
@@ -235,8 +234,6 @@ extern void gui_synclist_del_item(struct gui_synclist * lists);
235extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll); 234extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll);
236extern void gui_synclist_set_title(struct gui_synclist * lists, const char * title, 235extern void gui_synclist_set_title(struct gui_synclist * lists, const char * title,
237 enum themable_icons icon); 236 enum themable_icons icon);
238extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
239 bool hide);
240extern bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, 237extern bool gui_synclist_item_is_onscreen(struct gui_synclist *lists,
241 enum screen_type screen, int item); 238 enum screen_type screen, int item);
242 239
@@ -304,7 +301,6 @@ struct simplelist_info {
304 const char *title; /* title to show on the list */ 301 const char *title; /* title to show on the list */
305 int count; /* number of items in the list, each item is selection_size high */ 302 int count; /* number of items in the list, each item is selection_size high */
306 int selection_size; /* list selection size, usually 1 */ 303 int selection_size; /* list selection size, usually 1 */
307 bool hide_selection;
308 bool scroll_all; 304 bool scroll_all;
309 bool hide_theme; 305 bool hide_theme;
310 bool speak_onshow; /* list speaks first item or 'empty list' */ 306 bool speak_onshow; /* list speaks first item or 'empty list' */
@@ -350,7 +346,6 @@ void simplelist_addline(const char *fmt, ...);
350/* setup the info struct. members not setup in this function need to be assigned manually 346/* setup the info struct. members not setup in this function need to be assigned manually
351 members set in this function: 347 members set in this function:
352 info.selection_size = 1; 348 info.selection_size = 1;
353 info.hide_selection = false;
354 info.scroll_all = false; 349 info.scroll_all = false;
355 info.hide_theme = false; 350 info.hide_theme = false;
356 info.speak_onshow = true; 351 info.speak_onshow = true;