summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-04-10 17:15:22 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2022-04-10 22:24:28 -0400
commitddcab156f7b7675560d4e5bf4fdfab3ca59a6173 (patch)
tree98ab2634e31d7b26548e5cdbd39eeada9c65b717
parent8dbc0914f6a09bea395f801f948b7a993d379493 (diff)
downloadrockbox-ddcab156f7b7675560d4e5bf4fdfab3ca59a6173.tar.gz
rockbox-ddcab156f7b7675560d4e5bf4fdfab3ca59a6173.zip
gui_synclist move global display settings to list struct
its really painful needing to override global settings in order to change some aspects of lists this patch moves: [scrollbar position, cursor type, talk_menus, keyclick, wrap around, scroll paginated] to variables within the synclist, it also makes updating after settings changes a necessity I think I have the static synclists in core covered (I think the one in gui/list-skinned can be left as is) this patch allows easy modification these flags on the fly Change-Id: Id0dcb8b05eb9ecd78929c0aff7678bf2ab4c70a7
-rw-r--r--apps/gui/bitmap/list.c46
-rw-r--r--apps/gui/list.c25
-rw-r--r--apps/gui/list.h23
-rw-r--r--apps/menus/theme_menu.c19
-rw-r--r--apps/tree.c2
5 files changed, 82 insertions, 33 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 1b051cd800..e11ca5386e 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -168,8 +168,10 @@ static bool draw_title(struct screen *display,
168 int icon = list->title_icon; 168 int icon = list->title_icon;
169 int icon_w = list_icon_width(display->screen_type); 169 int icon_w = list_icon_width(display->screen_type);
170 bool have_icons = false; 170 bool have_icons = false;
171 if (icon != Icon_NOICON && global_settings.show_icons) 171 if (icon != Icon_NOICON && list->show_icons)
172 {
172 have_icons = true; 173 have_icons = true;
174 }
173 175
174 struct list_putlineinfo_t list_info = 176 struct list_putlineinfo_t list_info =
175 { 177 {
@@ -192,11 +194,14 @@ void list_draw(struct screen *display, struct gui_synclist *list)
192 list_draw_item *callback_draw_item; 194 list_draw_item *callback_draw_item;
193 195
194 const int list_start_item = list->start_item[screen]; 196 const int list_start_item = list->start_item[screen];
195 const bool scrollbar_in_left = (global_settings.scrollbar == SCROLLBAR_LEFT); 197 const bool scrollbar_in_left = (list->scrollbar == SCROLLBAR_LEFT);
196 const bool scrollbar_in_right = (global_settings.scrollbar == SCROLLBAR_RIGHT); 198 const bool scrollbar_in_right = (list->scrollbar == SCROLLBAR_RIGHT);
197 const bool show_cursor = !global_settings.cursor_style && 199
198 list->show_selection_marker; 200 const bool show_cursor = list->show_selection_marker &&
199 const bool have_icons = global_settings.show_icons && list->callback_get_item_icon; 201 (list->cursor_style == SYNCLIST_CURSOR_NOSTYLE);
202
203 const bool have_icons = list->callback_get_item_icon && list->show_icons;
204
200 struct viewport *parent = (list->parent[screen]); 205 struct viewport *parent = (list->parent[screen]);
201 struct line_desc linedes = LINE_DESC_DEFINIT; 206 struct line_desc linedes = LINE_DESC_DEFINIT;
202 bool show_title; 207 bool show_title;
@@ -264,7 +269,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
264#endif 269#endif
265 270
266 /* draw the scrollbar if its needed */ 271 /* draw the scrollbar if its needed */
267 if (global_settings.scrollbar != SCROLLBAR_OFF) 272 if (list->scrollbar != SCROLLBAR_OFF)
268 { 273 {
269 /* if the scrollbar is shown the text viewport needs to shrink */ 274 /* if the scrollbar is shown the text viewport needs to shrink */
270 if (nb_lines < list->nb_items) 275 if (nb_lines < list->nb_items)
@@ -340,7 +345,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
340 } 345 }
341 if (line_indent) 346 if (line_indent)
342 { 347 {
343 if (global_settings.show_icons) 348 if (list->show_icons)
344 line_indent *= icon_w; 349 line_indent *= icon_w;
345 else 350 else
346 line_indent *= character_width; 351 line_indent *= character_width;
@@ -374,12 +379,12 @@ void list_draw(struct screen *display, struct gui_synclist *list)
374 } 379 }
375 else 380 else
376#endif 381#endif
377 if (global_settings.cursor_style == 1 382 if (list->cursor_style == SYNCLIST_CURSOR_INVERT
378#ifdef HAVE_REMOTE_LCD 383#ifdef HAVE_REMOTE_LCD
379 /* the global_settings.cursor_style check is here to make 384 /* the global_settings.cursor_style check is here to make
380 * sure if they want the cursor instead of bar it will work 385 * sure if they want the cursor instead of bar it will work
381 */ 386 */
382 || (display->depth < 16 && global_settings.cursor_style) 387 || (display->depth < 16 && list->cursor_style)
383#endif 388#endif
384 ) 389 )
385 { 390 {
@@ -387,14 +392,14 @@ void list_draw(struct screen *display, struct gui_synclist *list)
387 style = STYLE_INVERT; 392 style = STYLE_INVERT;
388 } 393 }
389#ifdef HAVE_LCD_COLOR 394#ifdef HAVE_LCD_COLOR
390 else if (global_settings.cursor_style == 2) 395 else if (list->cursor_style == SYNCLIST_CURSOR_COLOR)
391 { 396 {
392 /* Display colour line selector */ 397 /* Display colour line selector */
393 style = STYLE_COLORBAR; 398 style = STYLE_COLORBAR;
394 linedes.text_color = global_settings.lst_color; 399 linedes.text_color = global_settings.lst_color;
395 linedes.line_color = global_settings.lss_color; 400 linedes.line_color = global_settings.lss_color;
396 } 401 }
397 else if (global_settings.cursor_style == 3) 402 else if (list->cursor_style == SYNCLIST_CURSOR_GRADIENT)
398 { 403 {
399 /* Display gradient line selector */ 404 /* Display gradient line selector */
400 style = STYLE_GRADIENT; 405 style = STYLE_GRADIENT;
@@ -753,7 +758,7 @@ static int get_click_location(struct gui_synclist *list, int x, int y)
753 if (viewport_point_within_vp(title, x, y)) 758 if (viewport_point_within_vp(title, x, y))
754 retval = TITLE_TEXT; 759 retval = TITLE_TEXT;
755 /* check the icon too */ 760 /* check the icon too */
756 if (list->title_icon != Icon_NOICON && global_settings.show_icons) 761 if (list->title_icon != Icon_NOICON && (list->show_icons)
757 { 762 {
758 int width = list_icon_width(screen); 763 int width = list_icon_width(screen);
759 struct viewport vp = *title; 764 struct viewport vp = *title;
@@ -771,14 +776,19 @@ static int get_click_location(struct gui_synclist *list, int x, int y)
771 { 776 {
772 bool on_scrollbar_clicked; 777 bool on_scrollbar_clicked;
773 int adj_x = x - parent->x; 778 int adj_x = x - parent->x;
774 switch (global_settings.scrollbar) 779 switch (list->scrollbar)
775 { 780 {
781 case SCROLLBAR_OFF:
782 /*fall-through*/
783 default:
784 on_scrollbar_clicked = false;
785 break;
776 case SCROLLBAR_LEFT: 786 case SCROLLBAR_LEFT:
777 on_scrollbar_clicked = adj_x <= SCROLLBAR_WIDTH; break; 787 on_scrollbar_clicked = adj_x <= SCROLLBAR_WIDTH;
788 break;
778 case SCROLLBAR_RIGHT: 789 case SCROLLBAR_RIGHT:
779 on_scrollbar_clicked = adj_x > (title->x + title->width - SCROLLBAR_WIDTH); break; 790 on_scrollbar_clicked = adj_x > (title->x + title->width - SCROLLBAR_WIDTH);
780 default: 791 break;
781 on_scrollbar_clicked = false; break;
782 } 792 }
783 if (on_scrollbar_clicked) 793 if (on_scrollbar_clicked)
784 retval = SCROLLBAR; 794 retval = SCROLLBAR;
diff --git a/apps/gui/list.c b/apps/gui/list.c
index a8055c4581..29c80574c2 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -129,6 +129,18 @@ void list_init_item_height(struct gui_synclist *list, enum screen_type screen)
129#endif 129#endif
130} 130}
131 131
132void gui_synclist_init_display_settings(struct gui_synclist * list)
133{
134 struct user_settings *gs = &global_settings;
135 list->scrollbar = gs->scrollbar;
136 list->show_icons = gs->show_icons;
137 list->scroll_paginated = gs->scroll_paginated;
138 list->keyclick = gs->keyclick;
139 list->talk_menu = gs->talk_menu;
140 list->wraparound = gs->list_wraparound;
141 list->cursor_style = gs->cursor_style;
142}
143
132/* 144/*
133 * Initializes a scrolling list 145 * Initializes a scrolling list
134 * - gui_list : the list structure to initialize 146 * - gui_list : the list structure to initialize
@@ -153,6 +165,8 @@ void gui_synclist_init(struct gui_synclist * gui_list,
153 gui_list->callback_draw_item = NULL; 165 gui_list->callback_draw_item = NULL;
154 gui_list->nb_items = 0; 166 gui_list->nb_items = 0;
155 gui_list->selected_item = 0; 167 gui_list->selected_item = 0;
168 gui_synclist_init_display_settings(gui_list);
169
156#ifdef HAVE_TOUCHSCREEN 170#ifdef HAVE_TOUCHSCREEN
157 gui_list->y_pos = 0; 171 gui_list->y_pos = 0;
158#endif 172#endif
@@ -263,7 +277,7 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
263 { 277 {
264 new_start_item = gui_list->selected_item; 278 new_start_item = gui_list->selected_item;
265 } 279 }
266 else if (global_settings.scroll_paginated) 280 else if (gui_list->scroll_paginated)
267 { 281 {
268 nb_lines -= nb_lines%gui_list->selected_size; 282 nb_lines -= nb_lines%gui_list->selected_size;
269 if (difference < 0 || difference >= nb_lines) 283 if (difference < 0 || difference >= nb_lines)
@@ -293,7 +307,7 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
293 307
294static void edge_beep(struct gui_synclist * gui_list, bool wrap) 308static void edge_beep(struct gui_synclist * gui_list, bool wrap)
295{ 309{
296 if (global_settings.keyclick) 310 if (gui_list->keyclick)
297 { 311 {
298 list_speak_item *cb = gui_list->callback_speak_item; 312 list_speak_item *cb = gui_list->callback_speak_item;
299 if (!wrap) /* a bounce */ 313 if (!wrap) /* a bounce */
@@ -356,7 +370,7 @@ static void _gui_synclist_speak_item(struct gui_synclist *lists)
356 370
357void gui_synclist_speak_item(struct gui_synclist *lists) 371void gui_synclist_speak_item(struct gui_synclist *lists)
358{ 372{
359 if (global_settings.talk_menu) 373 if (lists->talk_menu)
360 { 374 {
361 if (lists->nb_items == 0) 375 if (lists->nb_items == 0)
362 talk_id(VOICE_EMPTY_LIST, true); 376 talk_id(VOICE_EMPTY_LIST, true);
@@ -683,11 +697,10 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
683 697
684 /* Disable the skin redraw callback */ 698 /* Disable the skin redraw callback */
685 current_lists = NULL; 699 current_lists = NULL;
686
687 switch (wrap) 700 switch (wrap)
688 { 701 {
689 case LIST_WRAP_ON: 702 case LIST_WRAP_ON:
690 gui_synclist_limit_scroll(lists, !global_settings.list_wraparound); 703 gui_synclist_limit_scroll(lists, !(lists->wraparound));
691 break; 704 break;
692 case LIST_WRAP_OFF: 705 case LIST_WRAP_OFF:
693 gui_synclist_limit_scroll(lists, true); 706 gui_synclist_limit_scroll(lists, true);
@@ -698,7 +711,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
698 action == ACTION_LISTTREE_PGUP || 711 action == ACTION_LISTTREE_PGUP ||
699 action == ACTION_LISTTREE_PGDOWN) 712 action == ACTION_LISTTREE_PGDOWN)
700 gui_synclist_limit_scroll(lists, true); 713 gui_synclist_limit_scroll(lists, true);
701 else gui_synclist_limit_scroll(lists, !global_settings.list_wraparound); 714 else gui_synclist_limit_scroll(lists, !(lists->wraparound));
702 break; 715 break;
703 }; 716 };
704 717
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 1f910577a1..4dc83a1b27 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -36,6 +36,14 @@ enum list_wrap {
36 LIST_WRAP_UNLESS_HELD, 36 LIST_WRAP_UNLESS_HELD,
37}; 37};
38 38
39enum synclist_cursor
40{
41 SYNCLIST_CURSOR_NOSTYLE = 0,
42 SYNCLIST_CURSOR_INVERT,
43 SYNCLIST_CURSOR_COLOR,
44 SYNCLIST_CURSOR_GRADIENT,
45};
46
39/* 47/*
40 * The gui_list is based on callback functions, if you want the list 48 * The gui_list is based on callback functions, if you want the list
41 * to display something you have to provide it a function that 49 * to display something you have to provide it a function that
@@ -139,14 +147,24 @@ struct list_selection_color
139 147
140struct gui_synclist 148struct gui_synclist
141{ 149{
150 /*flags to hold settings show: icons, scrollbar etc..*/
151 int scrollbar;
152 int cursor_style;
153 bool show_icons;
154 bool keyclick;
155 bool talk_menu;
156 bool wraparound;
157 bool scroll_paginated;
142 /* defines wether the list should stop when reaching the top/bottom 158 /* defines wether the list should stop when reaching the top/bottom
143 * or should continue (by going to bottom/top) */ 159 * or should continue (by going to bottom/top) */
144 bool limit_scroll; 160 bool limit_scroll;
145 /* wether 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
146 * scrolled or only for the selected item */ 162 * scrolled or only for the selected item */
147 bool scroll_all; 163 bool scroll_all;
164 bool show_selection_marker; /* set to true by default */
148 int nb_items; 165 int nb_items;
149 int selected_item; 166 int selected_item;
167
150#ifdef HAVE_TOUCHSCREEN 168#ifdef HAVE_TOUCHSCREEN
151 /* absolute Y coordinate, used for smooth scrolling */ 169 /* absolute Y coordinate, used for smooth scrolling */
152 int y_pos; 170 int y_pos;
@@ -170,7 +188,6 @@ struct gui_synclist
170 char * title; 188 char * title;
171 /* Optional title icon */ 189 /* Optional title icon */
172 enum themable_icons title_icon; 190 enum themable_icons title_icon;
173 bool show_selection_marker; /* set to true by default */
174 191
175#ifdef HAVE_LCD_COLOR 192#ifdef HAVE_LCD_COLOR
176 int title_color; 193 int title_color;
@@ -187,7 +204,7 @@ extern void gui_list_screen_scroll_step(int ofs);
187 204
188/* parse global setting to static bool */ 205/* parse global setting to static bool */
189extern void gui_list_screen_scroll_out_of_view(bool enable); 206extern void gui_list_screen_scroll_out_of_view(bool enable);
190 207extern void gui_synclist_init_display_settings(struct gui_synclist * list);
191extern void gui_synclist_init( 208extern void gui_synclist_init(
192 struct gui_synclist * lists, 209 struct gui_synclist * lists,
193 list_get_name callback_get_item_name, 210 list_get_name callback_get_item_name,
diff --git a/apps/menus/theme_menu.c b/apps/menus/theme_menu.c
index 2a50ed44b5..61a6937e3c 100644
--- a/apps/menus/theme_menu.c
+++ b/apps/menus/theme_menu.c
@@ -165,6 +165,15 @@ MAKE_MENU(colors_settings, ID2P(LANG_COLORS_MENU),
165/* BARS MENU */ 165/* BARS MENU */
166/* */ 166/* */
167 167
168static int list_update_callback(int action,
169 const struct menu_item_ex *this_item,
170 struct gui_synclist *this_list)
171{
172 (void)this_item;
173 if (action == ACTION_EXIT_MENUITEM)
174 gui_synclist_init_display_settings(this_list);
175 return ACTION_REDRAW;
176}
168 177
169static int statusbar_callback_ex(int action,const struct menu_item_ex *this_item, 178static int statusbar_callback_ex(int action,const struct menu_item_ex *this_item,
170 enum screen_type screen) 179 enum screen_type screen)
@@ -204,10 +213,9 @@ static int statusbar_callback(int action,
204 return statusbar_callback_ex(action, this_item, SCREEN_MAIN); 213 return statusbar_callback_ex(action, this_item, SCREEN_MAIN);
205} 214}
206 215
207MENUITEM_SETTING(scrollbar_item, &global_settings.scrollbar, NULL); 216MENUITEM_SETTING(scrollbar_item, &global_settings.scrollbar, list_update_callback);
208MENUITEM_SETTING(scrollbar_width, &global_settings.scrollbar_width, NULL); 217MENUITEM_SETTING(scrollbar_width, &global_settings.scrollbar_width, NULL);
209MENUITEM_SETTING(statusbar, &global_settings.statusbar, 218MENUITEM_SETTING(statusbar, &global_settings.statusbar, statusbar_callback);
210 statusbar_callback);
211#ifdef HAVE_REMOTE_LCD 219#ifdef HAVE_REMOTE_LCD
212MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar, 220MENUITEM_SETTING(remote_statusbar, &global_settings.remote_statusbar,
213 statusbar_callback_remote); 221 statusbar_callback_remote);
@@ -354,13 +362,11 @@ MENUITEM_FUNCTION(browse_rfms, MENU_FUNC_USEPARAM,
354#endif 362#endif
355#endif 363#endif
356 364
357
358static int showicons_callback(int action, 365static int showicons_callback(int action,
359 const struct menu_item_ex *this_item, 366 const struct menu_item_ex *this_item,
360 struct gui_synclist *this_list) 367 struct gui_synclist *this_list)
361{ 368{
362 (void)this_item; 369 (void)this_item;
363 (void)this_list;
364 static bool old_icons; 370 static bool old_icons;
365 switch (action) 371 switch (action)
366 { 372 {
@@ -370,6 +376,7 @@ static int showicons_callback(int action,
370 case ACTION_EXIT_MENUITEM: 376 case ACTION_EXIT_MENUITEM:
371 if (old_icons != global_settings.show_icons) 377 if (old_icons != global_settings.show_icons)
372 icons_init(); 378 icons_init();
379 gui_synclist_init_display_settings(this_list);
373 break; 380 break;
374 } 381 }
375 return ACTION_REDRAW; 382 return ACTION_REDRAW;
@@ -379,7 +386,7 @@ MENUITEM_SETTING(show_icons, &global_settings.show_icons, showicons_callback);
379MENUITEM_FUNCTION(browse_themes, MENU_FUNC_USEPARAM, 386MENUITEM_FUNCTION(browse_themes, MENU_FUNC_USEPARAM,
380 ID2P(LANG_CUSTOM_THEME), 387 ID2P(LANG_CUSTOM_THEME),
381 browse_folder, (void*)&themes, NULL, Icon_Config); 388 browse_folder, (void*)&themes, NULL, Icon_Config);
382MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, NULL); 389MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, list_update_callback);
383#if LCD_DEPTH > 1 390#if LCD_DEPTH > 1
384MENUITEM_SETTING(sep_menu, &global_settings.list_separator_height, NULL); 391MENUITEM_SETTING(sep_menu, &global_settings.list_separator_height, NULL);
385#endif 392#endif
diff --git a/apps/tree.c b/apps/tree.c
index 63363422ba..503cf47fc5 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -963,6 +963,8 @@ int rockbox_browse(struct browse_context *browse)
963 tc.dirfilter = &dirfilter; 963 tc.dirfilter = &dirfilter;
964 tc.sort_dir = global_settings.sort_dir; 964 tc.sort_dir = global_settings.sort_dir;
965 965
966 gui_synclist_init_display_settings(&tree_lists); /* grab updated settings */
967
966 reload_dir = true; 968 reload_dir = true;
967 if (*tc.dirfilter >= NUM_FILTER_MODES) 969 if (*tc.dirfilter >= NUM_FILTER_MODES)
968 { 970 {