diff options
-rw-r--r-- | apps/gui/bitmap/list.c | 16 | ||||
-rw-r--r-- | apps/gui/list.c | 39 | ||||
-rw-r--r-- | apps/gui/list.h | 29 |
3 files changed, 79 insertions, 5 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index 27121eac56..1d2df73e09 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c | |||
@@ -228,8 +228,6 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
228 | int line_indent = 0; | 228 | int line_indent = 0; |
229 | int style = STYLE_DEFAULT; | 229 | int style = STYLE_DEFAULT; |
230 | bool is_selected = false; | 230 | bool is_selected = false; |
231 | icon = list->callback_get_item_icon ? | ||
232 | list->callback_get_item_icon(i, list->data) : Icon_NOICON; | ||
233 | s = list->callback_get_item_name(i, list->data, entry_buffer, | 231 | s = list->callback_get_item_name(i, list->data, entry_buffer, |
234 | sizeof(entry_buffer)); | 232 | sizeof(entry_buffer)); |
235 | entry_name = P2STR(s); | 233 | entry_name = P2STR(s); |
@@ -265,6 +263,17 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
265 | && i < list->selected_item + list->selected_size | 263 | && i < list->selected_item + list->selected_size |
266 | && list->show_selection_marker) | 264 | && list->show_selection_marker) |
267 | {/* The selected item must be displayed scrolling */ | 265 | {/* The selected item must be displayed scrolling */ |
266 | #ifdef HAVE_LCD_COLOR | ||
267 | if (list->selection_color) | ||
268 | { | ||
269 | /* Display gradient line selector */ | ||
270 | style = STYLE_GRADIENT; | ||
271 | linedes.text_color = list->selection_color->text_color; | ||
272 | linedes.line_color = list->selection_color->line_color; | ||
273 | linedes.line_end_color = list->selection_color->line_end_color; | ||
274 | } | ||
275 | else | ||
276 | #endif | ||
268 | if (global_settings.cursor_style == 1 | 277 | if (global_settings.cursor_style == 1 |
269 | #ifdef HAVE_REMOTE_LCD | 278 | #ifdef HAVE_REMOTE_LCD |
270 | /* the global_settings.cursor_style check is here to make | 279 | /* the global_settings.cursor_style check is here to make |
@@ -313,7 +322,8 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
313 | linedes.style = style; | 322 | linedes.style = style; |
314 | linedes.scroll = is_selected ? true : list->scroll_all; | 323 | linedes.scroll = is_selected ? true : list->scroll_all; |
315 | linedes.line = i % list->selected_size; | 324 | linedes.line = i % list->selected_size; |
316 | 325 | icon = list->callback_get_item_icon ? | |
326 | list->callback_get_item_icon(i, list->data) : Icon_NOICON; | ||
317 | /* the list can have both, one of or neither of cursor and item icons, | 327 | /* the list can have both, one of or neither of cursor and item icons, |
318 | * if both don't apply icon padding twice between the icons */ | 328 | * if both don't apply icon padding twice between the icons */ |
319 | if (show_cursor && have_icons) | 329 | if (show_cursor && have_icons) |
diff --git a/apps/gui/list.c b/apps/gui/list.c index 29145eb3ca..36dbe44445 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c | |||
@@ -178,6 +178,7 @@ void gui_synclist_init(struct gui_synclist * gui_list, | |||
178 | #ifdef HAVE_LCD_COLOR | 178 | #ifdef HAVE_LCD_COLOR |
179 | gui_list->title_color = -1; | 179 | gui_list->title_color = -1; |
180 | gui_list->callback_get_item_color = NULL; | 180 | gui_list->callback_get_item_color = NULL; |
181 | gui_list->selection_color = NULL; | ||
181 | #endif | 182 | #endif |
182 | } | 183 | } |
183 | 184 | ||
@@ -513,6 +514,22 @@ void gui_synclist_set_color_callback(struct gui_synclist * lists, | |||
513 | { | 514 | { |
514 | lists->callback_get_item_color = color_callback; | 515 | lists->callback_get_item_color = color_callback; |
515 | } | 516 | } |
517 | |||
518 | void gui_synclist_set_sel_color(struct gui_synclist * lists, | ||
519 | struct list_selection_color *list_sel_color) | ||
520 | { | ||
521 | lists->selection_color = list_sel_color; | ||
522 | if(list_sel_color) | ||
523 | { | ||
524 | FOR_NB_SCREENS(i) /* might need to be only SCREEN_MAIN */ | ||
525 | { | ||
526 | lists->parent[i]->fg_pattern = list_sel_color->fg_color; | ||
527 | lists->parent[i]->bg_pattern = list_sel_color->bg_color; | ||
528 | } | ||
529 | } | ||
530 | else | ||
531 | list_init_viewports(lists); | ||
532 | } | ||
516 | #endif | 533 | #endif |
517 | 534 | ||
518 | static void gui_synclist_select_next_page(struct gui_synclist * lists, | 535 | static void gui_synclist_select_next_page(struct gui_synclist * lists, |
@@ -890,7 +907,7 @@ bool simplelist_show_list(struct simplelist_info *info) | |||
890 | getname = simplelist_static_getname; | 907 | getname = simplelist_static_getname; |
891 | 908 | ||
892 | FOR_NB_SCREENS(i) | 909 | FOR_NB_SCREENS(i) |
893 | viewportmanager_theme_enable(i, true, NULL); | 910 | viewportmanager_theme_enable(i, !info->hide_theme, NULL); |
894 | 911 | ||
895 | gui_synclist_init(&lists, getname, info->callback_data, | 912 | gui_synclist_init(&lists, getname, info->callback_data, |
896 | info->scroll_all, info->selection_size, NULL); | 913 | info->scroll_all, info->selection_size, NULL); |
@@ -904,6 +921,8 @@ bool simplelist_show_list(struct simplelist_info *info) | |||
904 | #ifdef HAVE_LCD_COLOR | 921 | #ifdef HAVE_LCD_COLOR |
905 | if (info->get_color) | 922 | if (info->get_color) |
906 | gui_synclist_set_color_callback(&lists, info->get_color); | 923 | gui_synclist_set_color_callback(&lists, info->get_color); |
924 | if (info->selection_color) | ||
925 | gui_synclist_set_sel_color(&lists, info->selection_color); | ||
907 | #endif | 926 | #endif |
908 | 927 | ||
909 | if (info->hide_selection) | 928 | if (info->hide_selection) |
@@ -924,7 +943,9 @@ bool simplelist_show_list(struct simplelist_info *info) | |||
924 | gui_synclist_select_item(&lists, info->selection); | 943 | gui_synclist_select_item(&lists, info->selection); |
925 | 944 | ||
926 | gui_synclist_draw(&lists); | 945 | gui_synclist_draw(&lists); |
927 | gui_synclist_speak_item(&lists); | 946 | |
947 | if (info->speak_onshow) | ||
948 | gui_synclist_speak_item(&lists); | ||
928 | 949 | ||
929 | while(1) | 950 | while(1) |
930 | { | 951 | { |
@@ -955,6 +976,11 @@ bool simplelist_show_list(struct simplelist_info *info) | |||
955 | info->selection = -1; | 976 | info->selection = -1; |
956 | break; | 977 | break; |
957 | } | 978 | } |
979 | else if (action == ACTION_STD_OK) | ||
980 | { | ||
981 | info->selection = gui_synclist_get_sel_pos(&lists); | ||
982 | break; | ||
983 | } | ||
958 | else if ((action == ACTION_REDRAW) || | 984 | else if ((action == ACTION_REDRAW) || |
959 | (list_is_dirty(&lists)) || | 985 | (list_is_dirty(&lists)) || |
960 | (old_line_count != simplelist_line_count)) | 986 | (old_line_count != simplelist_line_count)) |
@@ -971,6 +997,12 @@ bool simplelist_show_list(struct simplelist_info *info) | |||
971 | return true; | 997 | return true; |
972 | } | 998 | } |
973 | talk_shutup(); | 999 | talk_shutup(); |
1000 | |||
1001 | #ifdef HAVE_LCD_COLOR | ||
1002 | if (info->selection_color) | ||
1003 | gui_synclist_set_sel_color(&lists, NULL); | ||
1004 | #endif | ||
1005 | |||
974 | FOR_NB_SCREENS(i) | 1006 | FOR_NB_SCREENS(i) |
975 | viewportmanager_theme_undo(i, false); | 1007 | viewportmanager_theme_undo(i, false); |
976 | return false; | 1008 | return false; |
@@ -984,6 +1016,8 @@ void simplelist_info_init(struct simplelist_info *info, char* title, | |||
984 | info->selection_size = 1; | 1016 | info->selection_size = 1; |
985 | info->hide_selection = false; | 1017 | info->hide_selection = false; |
986 | info->scroll_all = false; | 1018 | info->scroll_all = false; |
1019 | info->hide_theme = false; | ||
1020 | info->speak_onshow = true; | ||
987 | info->timeout = HZ/10; | 1021 | info->timeout = HZ/10; |
988 | info->selection = 0; | 1022 | info->selection = 0; |
989 | info->action_callback = NULL; | 1023 | info->action_callback = NULL; |
@@ -993,6 +1027,7 @@ void simplelist_info_init(struct simplelist_info *info, char* title, | |||
993 | info->get_talk = NULL; | 1027 | info->get_talk = NULL; |
994 | #ifdef HAVE_LCD_COLOR | 1028 | #ifdef HAVE_LCD_COLOR |
995 | info->get_color = NULL; | 1029 | info->get_color = NULL; |
1030 | info->selection_color = NULL; | ||
996 | #endif | 1031 | #endif |
997 | info->callback_data = data; | 1032 | info->callback_data = data; |
998 | simplelist_line_count = 0; | 1033 | simplelist_line_count = 0; |
diff --git a/apps/gui/list.h b/apps/gui/list.h index f860e27bf9..3a613d0a67 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "icon.h" | 26 | #include "icon.h" |
27 | #include "screen_access.h" | 27 | #include "screen_access.h" |
28 | #include "skin_engine/skin_engine.h" | 28 | #include "skin_engine/skin_engine.h" |
29 | #include "line.h" | ||
29 | 30 | ||
30 | #define SCROLLBAR_WIDTH global_settings.scrollbar_width | 31 | #define SCROLLBAR_WIDTH global_settings.scrollbar_width |
31 | 32 | ||
@@ -85,6 +86,26 @@ typedef int list_speak_item(int selected_item, void * data); | |||
85 | * selected item, negative value for default coloring. | 86 | * selected item, negative value for default coloring. |
86 | */ | 87 | */ |
87 | typedef int list_get_color(int selected_item, void * data); | 88 | typedef int list_get_color(int selected_item, void * data); |
89 | |||
90 | struct list_selection_color | ||
91 | { | ||
92 | /* text color, in native lcd format | ||
93 | * (convert with LCD_RGBPACK() if necessary) */ | ||
94 | unsigned text_color; | ||
95 | /* only STYLE_GRADIENT supported set line_color & line_end_color the same | ||
96 | * for solid color, in native | ||
97 | * lcd format (convert with LCD_RGBPACK() if necessary) */ | ||
98 | unsigned line_color; | ||
99 | unsigned line_end_color; | ||
100 | /* viewport foreground and background, in native | ||
101 | * lcd format (convert with LCD_RGBPACK() if necessary) */ | ||
102 | unsigned fg_color; | ||
103 | unsigned bg_color; | ||
104 | /* To enable: | ||
105 | * call gui_synclist_set_sel_color(gui_synclist*, list_selection_color*) | ||
106 | * If using the default viewport you should call | ||
107 | * gui_synclist_set_sel_color(gui_synclist*, NULL) when finished */ | ||
108 | }; | ||
88 | #endif | 109 | #endif |
89 | 110 | ||
90 | struct gui_synclist | 111 | struct gui_synclist |
@@ -120,6 +141,7 @@ struct gui_synclist | |||
120 | #ifdef HAVE_LCD_COLOR | 141 | #ifdef HAVE_LCD_COLOR |
121 | int title_color; | 142 | int title_color; |
122 | list_get_color *callback_get_item_color; | 143 | list_get_color *callback_get_item_color; |
144 | struct list_selection_color *selection_color; | ||
123 | #endif | 145 | #endif |
124 | struct viewport *parent[NB_SCREENS]; | 146 | struct viewport *parent[NB_SCREENS]; |
125 | }; | 147 | }; |
@@ -146,6 +168,7 @@ extern void gui_synclist_set_voice_callback(struct gui_synclist * lists, list_sp | |||
146 | extern void gui_synclist_set_viewport_defaults(struct viewport *vp, enum screen_type screen); | 168 | extern void gui_synclist_set_viewport_defaults(struct viewport *vp, enum screen_type screen); |
147 | #ifdef HAVE_LCD_COLOR | 169 | #ifdef HAVE_LCD_COLOR |
148 | extern void gui_synclist_set_color_callback(struct gui_synclist * lists, list_get_color color_callback); | 170 | extern void gui_synclist_set_color_callback(struct gui_synclist * lists, list_get_color color_callback); |
171 | extern void gui_synclist_set_sel_color(struct gui_synclist * lists, struct list_selection_color *list_sel_color); | ||
149 | #endif | 172 | #endif |
150 | extern void gui_synclist_speak_item(struct gui_synclist * lists); | 173 | extern void gui_synclist_speak_item(struct gui_synclist * lists); |
151 | extern int gui_synclist_get_nb_items(struct gui_synclist * lists); | 174 | extern int gui_synclist_get_nb_items(struct gui_synclist * lists); |
@@ -232,6 +255,8 @@ struct simplelist_info { | |||
232 | int selection_size; /* list selection size, usually 1 */ | 255 | int selection_size; /* list selection size, usually 1 */ |
233 | bool hide_selection; | 256 | bool hide_selection; |
234 | bool scroll_all; | 257 | bool scroll_all; |
258 | bool hide_theme; | ||
259 | bool speak_onshow; /* list speaks first item or 'empty list' */ | ||
235 | int timeout; | 260 | int timeout; |
236 | int selection; /* the item to select when the list is first displayed */ | 261 | int selection; /* the item to select when the list is first displayed */ |
237 | /* when the list is exited, this will be set to the | 262 | /* when the list is exited, this will be set to the |
@@ -248,6 +273,7 @@ struct simplelist_info { | |||
248 | list_speak_item *get_talk; /* can be NULL to not speak */ | 273 | list_speak_item *get_talk; /* can be NULL to not speak */ |
249 | #ifdef HAVE_LCD_COLOR | 274 | #ifdef HAVE_LCD_COLOR |
250 | list_get_color *get_color; | 275 | list_get_color *get_color; |
276 | struct list_selection_color *selection_color; | ||
251 | #endif | 277 | #endif |
252 | void *callback_data; /* data for callbacks */ | 278 | void *callback_data; /* data for callbacks */ |
253 | }; | 279 | }; |
@@ -275,12 +301,15 @@ void simplelist_addline(const char *fmt, ...); | |||
275 | info.selection_size = 1; | 301 | info.selection_size = 1; |
276 | info.hide_selection = false; | 302 | info.hide_selection = false; |
277 | info.scroll_all = false; | 303 | info.scroll_all = false; |
304 | info.hide_theme = false; | ||
305 | info.speak_onshow = true; | ||
278 | info.action_callback = NULL; | 306 | info.action_callback = NULL; |
279 | info.title_icon = Icon_NOICON; | 307 | info.title_icon = Icon_NOICON; |
280 | info.get_icon = NULL; | 308 | info.get_icon = NULL; |
281 | info.get_name = NULL; | 309 | info.get_name = NULL; |
282 | info.get_voice = NULL; | 310 | info.get_voice = NULL; |
283 | info.get_color = NULL; | 311 | info.get_color = NULL; |
312 | info.list_selection_color = NULL; | ||
284 | info.timeout = HZ/10; | 313 | info.timeout = HZ/10; |
285 | info.selection = 0; | 314 | info.selection = 0; |
286 | */ | 315 | */ |