diff options
-rw-r--r-- | apps/debug_menu.c | 8 | ||||
-rw-r--r-- | apps/filetypes.c | 2 | ||||
-rw-r--r-- | apps/gui/list.c | 509 | ||||
-rw-r--r-- | apps/gui/list.h | 22 | ||||
-rw-r--r-- | apps/menus/main_menu.c | 2 | ||||
-rw-r--r-- | apps/tree.c | 2 |
6 files changed, 206 insertions, 339 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index a8eb786f83..8f24ac95f6 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -1449,11 +1449,11 @@ static char* tsc2100_debug_getname(int selected_item, void * data, char *buffer) | |||
1449 | } | 1449 | } |
1450 | static int tsc2100debug_action_callback(int action, struct gui_synclist *lists) | 1450 | static int tsc2100debug_action_callback(int action, struct gui_synclist *lists) |
1451 | { | 1451 | { |
1452 | int *page = (int*)lists->gui_list[SCREEN_MAIN].data; | 1452 | int *page = (int*)lists->data; |
1453 | if (action == ACTION_STD_OK) | 1453 | if (action == ACTION_STD_OK) |
1454 | { | 1454 | { |
1455 | *page = (*page+1)%3; | 1455 | *page = (*page+1)%3; |
1456 | snprintf(lists->gui_list[SCREEN_MAIN].title, 32, | 1456 | snprintf(lists->title, 32, |
1457 | "tsc2100 registers - Page %d", *page); | 1457 | "tsc2100 registers - Page %d", *page); |
1458 | return ACTION_REDRAW; | 1458 | return ACTION_REDRAW; |
1459 | } | 1459 | } |
@@ -1667,10 +1667,10 @@ static bool view_battery(void) | |||
1667 | static int disk_callback(int btn, struct gui_synclist *lists) | 1667 | static int disk_callback(int btn, struct gui_synclist *lists) |
1668 | { | 1668 | { |
1669 | tCardInfo *card; | 1669 | tCardInfo *card; |
1670 | int *cardnum = (int*)lists->gui_list[SCREEN_MAIN].data; | 1670 | int *cardnum = (int*)lists->data; |
1671 | unsigned char card_name[7]; | 1671 | unsigned char card_name[7]; |
1672 | unsigned char pbuf[32]; | 1672 | unsigned char pbuf[32]; |
1673 | char *title = lists->gui_list[SCREEN_MAIN].title; | 1673 | char *title = lists->title; |
1674 | static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; | 1674 | static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; |
1675 | static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; | 1675 | static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; |
1676 | static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; | 1676 | static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; |
diff --git a/apps/filetypes.c b/apps/filetypes.c index 5c74103cf1..db463d7ff4 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -443,7 +443,7 @@ char * openwith_get_name(int selected_item, void * data, char * buffer) | |||
443 | } | 443 | } |
444 | int openwith_action_callback(int action, struct gui_synclist *lists) | 444 | int openwith_action_callback(int action, struct gui_synclist *lists) |
445 | { | 445 | { |
446 | struct cb_data *info = (struct cb_data *)lists->gui_list[SCREEN_MAIN].data; | 446 | struct cb_data *info = (struct cb_data *)lists->data; |
447 | int *items = info->items; | 447 | int *items = info->items; |
448 | int i; | 448 | int i; |
449 | if (action == ACTION_STD_OK) | 449 | if (action == ACTION_STD_OK) |
diff --git a/apps/gui/list.c b/apps/gui/list.c index 86ef97cf4d..6fdc7a10a5 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c | |||
@@ -54,12 +54,13 @@ static int offset_step = 16; /* pixels per screen scroll step */ | |||
54 | /* should lines scroll out of the screen */ | 54 | /* should lines scroll out of the screen */ |
55 | static bool offset_out_of_view = false; | 55 | static bool offset_out_of_view = false; |
56 | #endif | 56 | #endif |
57 | static struct gui_list* last_list_displayed[NB_SCREENS]; | 57 | static struct gui_synclist* last_list_displayed; |
58 | 58 | ||
59 | #define SHOW_LIST_TITLE ((gui_list->title != NULL) && \ | 59 | #define SHOW_LIST_TITLE ((gui_list->title != NULL) && \ |
60 | (gui_list->display->nb_lines > 2)) | 60 | (display->nb_lines > 2)) |
61 | 61 | ||
62 | static void gui_list_select_at_offset(struct gui_list * gui_list, int offset); | 62 | static void gui_list_select_at_offset(struct gui_synclist * gui_list, |
63 | int offset); | ||
63 | 64 | ||
64 | /* | 65 | /* |
65 | * Initializes a scrolling list | 66 | * Initializes a scrolling list |
@@ -70,35 +71,38 @@ static void gui_list_select_at_offset(struct gui_list * gui_list, int offset); | |||
70 | * - scroll_all : | 71 | * - scroll_all : |
71 | * - selected_size : | 72 | * - selected_size : |
72 | */ | 73 | */ |
73 | static void gui_list_init(struct gui_list * gui_list, | 74 | void gui_synclist_init(struct gui_synclist * gui_list, |
74 | list_get_name callback_get_item_name, | 75 | list_get_name callback_get_item_name, |
75 | void * data, | 76 | void * data, |
76 | bool scroll_all, | 77 | bool scroll_all, |
77 | int selected_size | 78 | int selected_size |
78 | ) | 79 | ) |
79 | { | 80 | { |
81 | int i; | ||
80 | gui_list->callback_get_item_icon = NULL; | 82 | gui_list->callback_get_item_icon = NULL; |
81 | gui_list->callback_get_item_name = callback_get_item_name; | 83 | gui_list->callback_get_item_name = callback_get_item_name; |
82 | gui_list->callback_speak_item = NULL; | 84 | gui_list->callback_speak_item = NULL; |
83 | gui_list->display = NULL; | ||
84 | gui_list_set_nb_items(gui_list, 0); | 85 | gui_list_set_nb_items(gui_list, 0); |
85 | gui_list->selected_item = 0; | 86 | gui_list->selected_item = 0; |
86 | gui_list->start_item = 0; | 87 | FOR_NB_SCREENS(i) |
87 | gui_list->limit_scroll = false; | 88 | { |
88 | gui_list->data=data; | 89 | gui_list->start_item[i] = 0; |
90 | gui_list->last_displayed_start_item[i] = -1 ; | ||
89 | #ifdef HAVE_LCD_BITMAP | 91 | #ifdef HAVE_LCD_BITMAP |
90 | gui_list->offset_position = 0; | 92 | gui_list->offset_position[i] = 0; |
91 | #endif | 93 | #endif |
94 | } | ||
95 | gui_list->limit_scroll = false; | ||
96 | gui_list->data=data; | ||
92 | gui_list->scroll_all=scroll_all; | 97 | gui_list->scroll_all=scroll_all; |
93 | gui_list->selected_size=selected_size; | 98 | gui_list->selected_size=selected_size; |
94 | gui_list->title = NULL; | 99 | gui_list->title = NULL; |
95 | gui_list->title_width = 0; | 100 | gui_list->title_width = 0; |
96 | gui_list->title_icon = Icon_NOICON; | 101 | gui_list->title_icon = Icon_NOICON; |
97 | 102 | ||
98 | gui_list->last_displayed_selected_item = -1 ; | ||
99 | gui_list->last_displayed_start_item = -1 ; | ||
100 | gui_list->scheduled_talk_tick = gui_list->last_talked_tick = 0; | 103 | gui_list->scheduled_talk_tick = gui_list->last_talked_tick = 0; |
101 | gui_list->show_selection_marker = true; | 104 | gui_list->show_selection_marker = true; |
105 | gui_list->last_displayed_selected_item = -1 ; | ||
102 | 106 | ||
103 | #ifdef HAVE_LCD_COLOR | 107 | #ifdef HAVE_LCD_COLOR |
104 | gui_list->title_color = -1; | 108 | gui_list->title_color = -1; |
@@ -109,38 +113,19 @@ static void gui_list_init(struct gui_list * gui_list, | |||
109 | /* this toggles the selection bar or cursor */ | 113 | /* this toggles the selection bar or cursor */ |
110 | void gui_synclist_hide_selection_marker(struct gui_synclist * lists, bool hide) | 114 | void gui_synclist_hide_selection_marker(struct gui_synclist * lists, bool hide) |
111 | { | 115 | { |
112 | int i; | 116 | lists->show_selection_marker = !hide; |
113 | FOR_NB_SCREENS(i) | ||
114 | lists->gui_list[i].show_selection_marker = !hide; | ||
115 | } | 117 | } |
116 | 118 | ||
117 | /* | ||
118 | * Attach the scrolling list to a screen | ||
119 | * (The previous screen attachement is lost) | ||
120 | * - gui_list : the list structure | ||
121 | * - display : the screen to attach | ||
122 | */ | ||
123 | static void gui_list_set_display(struct gui_list * gui_list, struct screen * display) | ||
124 | { | ||
125 | if(gui_list->display != 0) /* we switched from a previous display */ | ||
126 | gui_list->display->stop_scroll(); | ||
127 | gui_list->display = display; | ||
128 | #ifdef HAVE_LCD_CHARCELLS | ||
129 | display->double_height(false); | ||
130 | #endif | ||
131 | gui_list_select_at_offset(gui_list, 0); | ||
132 | } | ||
133 | 119 | ||
134 | #ifdef HAVE_LCD_BITMAP | 120 | #ifdef HAVE_LCD_BITMAP |
135 | static int gui_list_get_item_offset(struct gui_list * gui_list, int item_width, | 121 | static int gui_list_get_item_offset(struct gui_synclist * gui_list, int item_width, |
136 | int text_pos) | 122 | int text_pos, struct screen * display) |
137 | { | 123 | { |
138 | struct screen * display=gui_list->display; | ||
139 | int item_offset; | 124 | int item_offset; |
140 | 125 | ||
141 | if (offset_out_of_view) | 126 | if (offset_out_of_view) |
142 | { | 127 | { |
143 | item_offset = gui_list->offset_position; | 128 | item_offset = gui_list->offset_position[display->screen_type]; |
144 | } | 129 | } |
145 | else | 130 | else |
146 | { | 131 | { |
@@ -152,11 +137,11 @@ static int gui_list_get_item_offset(struct gui_list * gui_list, int item_width, | |||
152 | else | 137 | else |
153 | { | 138 | { |
154 | /* if text got out of view */ | 139 | /* if text got out of view */ |
155 | if (gui_list->offset_position > | 140 | if (gui_list->offset_position[display->screen_type] > |
156 | item_width - (display->width - text_pos)) | 141 | item_width - (display->width - text_pos)) |
157 | item_offset = item_width - (display->width - text_pos); | 142 | item_offset = item_width - (display->width - text_pos); |
158 | else | 143 | else |
159 | item_offset = gui_list->offset_position; | 144 | item_offset = gui_list->offset_position[display->screen_type]; |
160 | } | 145 | } |
161 | } | 146 | } |
162 | 147 | ||
@@ -168,9 +153,8 @@ static int gui_list_get_item_offset(struct gui_list * gui_list, int item_width, | |||
168 | * Draws the list on the attached screen | 153 | * Draws the list on the attached screen |
169 | * - gui_list : the list structure | 154 | * - gui_list : the list structure |
170 | */ | 155 | */ |
171 | static void gui_list_draw_smart(struct gui_list *gui_list) | 156 | static void gui_list_draw_smart(struct gui_synclist *gui_list, struct screen * display) |
172 | { | 157 | { |
173 | struct screen * display=gui_list->display; | ||
174 | int text_pos; | 158 | int text_pos; |
175 | bool draw_icons = (gui_list->callback_get_item_icon != NULL && global_settings.show_icons); | 159 | bool draw_icons = (gui_list->callback_get_item_icon != NULL && global_settings.show_icons); |
176 | bool draw_cursor; | 160 | bool draw_cursor; |
@@ -189,8 +173,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
189 | gui_textarea_update_nblines(display); | 173 | gui_textarea_update_nblines(display); |
190 | #endif | 174 | #endif |
191 | /* Speed up UI by drawing the changed contents only. */ | 175 | /* Speed up UI by drawing the changed contents only. */ |
192 | if (gui_list == last_list_displayed[gui_list->display->screen_type] | 176 | if (gui_list == last_list_displayed |
193 | && gui_list->last_displayed_start_item == gui_list->start_item | 177 | && gui_list->last_displayed_start_item[display->screen_type] == gui_list->start_item[display->screen_type] |
194 | && gui_list->selected_size == 1) | 178 | && gui_list->selected_size == 1) |
195 | { | 179 | { |
196 | partial_draw = true; | 180 | partial_draw = true; |
@@ -205,8 +189,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
205 | 189 | ||
206 | if (partial_draw) | 190 | if (partial_draw) |
207 | { | 191 | { |
208 | end = gui_list->last_displayed_selected_item - gui_list->start_item; | 192 | end = gui_list->last_displayed_selected_item - gui_list->start_item[display->screen_type]; |
209 | i = gui_list->selected_item - gui_list->start_item; | 193 | i = gui_list->selected_item - gui_list->start_item[display->screen_type]; |
210 | if (i < end ) | 194 | if (i < end ) |
211 | { | 195 | { |
212 | start = i; | 196 | start = i; |
@@ -223,8 +207,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
223 | gui_textarea_clear(display); | 207 | gui_textarea_clear(display); |
224 | start = 0; | 208 | start = 0; |
225 | end = display->nb_lines; | 209 | end = display->nb_lines; |
226 | gui_list->last_displayed_start_item = gui_list->start_item; | 210 | gui_list->last_displayed_start_item[display->screen_type] = gui_list->start_item[display->screen_type]; |
227 | last_list_displayed[gui_list->display->screen_type] = gui_list; | 211 | last_list_displayed = gui_list; |
228 | } | 212 | } |
229 | 213 | ||
230 | gui_list->last_displayed_selected_item = gui_list->selected_item; | 214 | gui_list->last_displayed_selected_item = gui_list->selected_item; |
@@ -257,7 +241,7 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
257 | #endif | 241 | #endif |
258 | screen_set_xmargin(display, text_pos); /* margin for title */ | 242 | screen_set_xmargin(display, text_pos); /* margin for title */ |
259 | item_offset = gui_list_get_item_offset(gui_list, gui_list->title_width, | 243 | item_offset = gui_list_get_item_offset(gui_list, gui_list->title_width, |
260 | text_pos); | 244 | text_pos, display); |
261 | if (item_offset > gui_list->title_width - (display->width - text_pos)) | 245 | if (item_offset > gui_list->title_width - (display->width - text_pos)) |
262 | display->puts_style_offset(0, 0, gui_list->title, | 246 | display->puts_style_offset(0, 0, gui_list->title, |
263 | title_style, item_offset); | 247 | title_style, item_offset); |
@@ -317,7 +301,7 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
317 | unsigned char *s; | 301 | unsigned char *s; |
318 | char entry_buffer[MAX_PATH]; | 302 | char entry_buffer[MAX_PATH]; |
319 | unsigned char *entry_name; | 303 | unsigned char *entry_name; |
320 | int current_item = gui_list->start_item + | 304 | int current_item = gui_list->start_item[display->screen_type] + |
321 | (SHOW_LIST_TITLE ? i-1 : i); | 305 | (SHOW_LIST_TITLE ? i-1 : i); |
322 | 306 | ||
323 | /* When there are less items to display than the | 307 | /* When there are less items to display than the |
@@ -334,7 +318,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
334 | /* position the string at the correct offset place */ | 318 | /* position the string at the correct offset place */ |
335 | int item_width,h; | 319 | int item_width,h; |
336 | display->getstringsize(entry_name, &item_width, &h); | 320 | display->getstringsize(entry_name, &item_width, &h); |
337 | item_offset = gui_list_get_item_offset(gui_list, item_width, text_pos); | 321 | item_offset = gui_list_get_item_offset(gui_list, item_width, |
322 | text_pos, display); | ||
338 | #endif | 323 | #endif |
339 | 324 | ||
340 | #ifdef HAVE_LCD_COLOR | 325 | #ifdef HAVE_LCD_COLOR |
@@ -466,8 +451,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
466 | lines + y_start; | 451 | lines + y_start; |
467 | gui_scrollbar_draw(display, 0, y_start, SCROLLBAR_WIDTH-1, | 452 | gui_scrollbar_draw(display, 0, y_start, SCROLLBAR_WIDTH-1, |
468 | scrollbar_y_end - y_start, gui_list->nb_items, | 453 | scrollbar_y_end - y_start, gui_list->nb_items, |
469 | gui_list->start_item, | 454 | gui_list->start_item[display->screen_type], |
470 | gui_list->start_item + lines, VERTICAL); | 455 | gui_list->start_item[display->screen_type] + lines, VERTICAL); |
471 | } | 456 | } |
472 | 457 | ||
473 | screen_set_xmargin(display, old_margin); | 458 | screen_set_xmargin(display, old_margin); |
@@ -479,175 +464,149 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
479 | /* | 464 | /* |
480 | * Force a full screen update. | 465 | * Force a full screen update. |
481 | */ | 466 | */ |
482 | static void gui_list_draw(struct gui_list *gui_list) | 467 | void gui_synclist_draw(struct gui_synclist *gui_list) |
483 | { | 468 | { |
484 | last_list_displayed[gui_list->display->screen_type] = NULL; | 469 | int i; |
485 | return gui_list_draw_smart(gui_list); | 470 | FOR_NB_SCREENS(i) |
471 | { | ||
472 | last_list_displayed = NULL; | ||
473 | gui_list_draw_smart(gui_list, &screens[i]); | ||
474 | } | ||
486 | } | 475 | } |
487 | 476 | ||
488 | /* | ||
489 | * Selects an item in the list | ||
490 | * - gui_list : the list structure | ||
491 | * - item_number : the number of the item which will be selected | ||
492 | */ | ||
493 | static void gui_list_select_item(struct gui_list * gui_list, int item_number) | ||
494 | { | ||
495 | if( item_number > gui_list->nb_items-1 || item_number < 0 ) | ||
496 | return; | ||
497 | gui_list->selected_item = item_number; | ||
498 | gui_list_select_at_offset(gui_list, 0); | ||
499 | } | ||
500 | 477 | ||
501 | /* select an item above the current one */ | 478 | |
502 | static void gui_list_select_above(struct gui_list * gui_list, | 479 | /* sets up the list so the selection is shown correctly on the screen */ |
503 | int items, int nb_lines) | 480 | static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list, |
481 | enum screen_type screen) | ||
504 | { | 482 | { |
505 | gui_list->selected_item -= items; | 483 | struct screen *display = &screens[screen]; |
484 | int nb_lines = display->nb_lines - SHOW_LIST_TITLE; | ||
485 | int difference = gui_list->selected_item - gui_list->start_item[screen]; | ||
506 | 486 | ||
507 | /* in bottom "3rd" of the screen, so dont move the start item. | 487 | /* edge case,, selected last item */ |
508 | by 3rd I mean above SCROLL_LIMIT lines above the end of the screen */ | 488 | if (gui_list->selected_item == gui_list->nb_items -1) |
509 | if (items && gui_list->start_item + SCROLL_LIMIT < gui_list->selected_item) | ||
510 | { | 489 | { |
511 | if (gui_list->show_selection_marker == false) | 490 | gui_list->start_item[screen] = MAX(0, gui_list->nb_items - nb_lines); |
512 | { | ||
513 | gui_list->start_item -= items; | ||
514 | if (gui_list->start_item < 0) | ||
515 | gui_list->start_item = 0; | ||
516 | } | ||
517 | return; | ||
518 | } | 491 | } |
519 | if (gui_list->selected_item < 0) | 492 | /* selected first item */ |
493 | else if (gui_list->selected_item == 0) | ||
520 | { | 494 | { |
521 | if(gui_list->limit_scroll) | 495 | gui_list->start_item[screen] = 0; |
522 | { | ||
523 | gui_list->selected_item = 0; | ||
524 | gui_list->start_item = 0; | ||
525 | } | ||
526 | else | ||
527 | { | ||
528 | gui_list->selected_item += gui_list->nb_items; | ||
529 | if (global_settings.scroll_paginated) | ||
530 | { | ||
531 | gui_list->start_item = gui_list->nb_items - nb_lines; | ||
532 | } | ||
533 | } | ||
534 | } | 496 | } |
535 | if (gui_list->nb_items > nb_lines) | 497 | else if (difference < SCROLL_LIMIT) /* list moved up */ |
536 | { | 498 | { |
537 | if (global_settings.scroll_paginated) | 499 | if (global_settings.scroll_paginated) |
538 | { | 500 | { |
539 | if (gui_list->start_item > gui_list->selected_item) | 501 | if (gui_list->start_item[screen] > gui_list->selected_item) |
540 | gui_list->start_item = MAX(0, gui_list->start_item - nb_lines); | 502 | gui_list->start_item[screen] = MAX(0, gui_list->start_item[screen] - nb_lines); |
541 | } | 503 | } |
542 | else | 504 | else |
543 | { | 505 | { |
544 | int top_of_screen = gui_list->selected_item - SCROLL_LIMIT; | 506 | int top_of_screen = gui_list->selected_item - SCROLL_LIMIT; |
545 | int temp = MIN(top_of_screen, gui_list->nb_items - nb_lines); | 507 | int temp = MIN(top_of_screen, gui_list->nb_items - nb_lines); |
546 | gui_list->start_item = MAX(0, temp); | 508 | gui_list->start_item[screen] = MAX(0, temp); |
547 | } | 509 | } |
548 | } | 510 | } |
549 | else gui_list->start_item = 0; | 511 | else if (difference > nb_lines - SCROLL_LIMIT) /* list moved down */ |
550 | if (gui_list->selected_size > 1) | ||
551 | { | ||
552 | if (gui_list->start_item + nb_lines == gui_list->selected_item) | ||
553 | gui_list->start_item++; | ||
554 | } | ||
555 | } | ||
556 | /* select an item below the current one */ | ||
557 | static void gui_list_select_below(struct gui_list * gui_list, | ||
558 | int items, int nb_lines) | ||
559 | { | ||
560 | int bottom; | ||
561 | |||
562 | gui_list->selected_item += items; | ||
563 | bottom = gui_list->nb_items - nb_lines; | ||
564 | |||
565 | /* always move the screen if selection isnt "visible" */ | ||
566 | if (items && gui_list->show_selection_marker == false) | ||
567 | { | ||
568 | if (bottom < 0) | ||
569 | bottom = 0; | ||
570 | gui_list->start_item = MIN(bottom, gui_list->start_item + | ||
571 | items); | ||
572 | return; | ||
573 | } | ||
574 | /* in top "3rd" of the screen, so dont move the start item */ | ||
575 | if (items && | ||
576 | (gui_list->start_item + nb_lines - SCROLL_LIMIT > gui_list->selected_item) | ||
577 | && (gui_list->selected_item < gui_list->nb_items)) | ||
578 | { | 512 | { |
513 | int bottom = gui_list->nb_items - nb_lines; | ||
514 | /* always move the screen if selection isnt "visible" */ | ||
579 | if (gui_list->show_selection_marker == false) | 515 | if (gui_list->show_selection_marker == false) |
580 | { | 516 | { |
581 | if (bottom < 0) | 517 | if (bottom < 0) |
582 | bottom = 0; | 518 | bottom = 0; |
583 | gui_list->start_item = MIN(bottom, | 519 | gui_list->start_item[screen] = MIN(bottom, gui_list->start_item[screen] + |
584 | gui_list->start_item + items); | 520 | 2*gui_list->selected_size); |
585 | } | ||
586 | return; | ||
587 | } | ||
588 | |||
589 | if (gui_list->selected_item >= gui_list->nb_items) | ||
590 | { | ||
591 | if(gui_list->limit_scroll) | ||
592 | { | ||
593 | gui_list->selected_item = gui_list->nb_items-gui_list->selected_size; | ||
594 | gui_list->start_item = MAX(0,gui_list->nb_items - nb_lines); | ||
595 | } | ||
596 | else | ||
597 | { | ||
598 | gui_list->selected_item = 0; | ||
599 | gui_list->start_item = 0; | ||
600 | } | 521 | } |
601 | return; | 522 | else if (global_settings.scroll_paginated) |
602 | } | ||
603 | |||
604 | if (gui_list->nb_items > nb_lines) | ||
605 | { | ||
606 | if (global_settings.scroll_paginated) | ||
607 | { | 523 | { |
608 | if (gui_list->start_item + nb_lines <= gui_list->selected_item) | 524 | if (gui_list->start_item[screen] + nb_lines <= gui_list->selected_item) |
609 | gui_list->start_item = MIN(bottom, gui_list->selected_item); | 525 | gui_list->start_item[screen] = MIN(bottom, gui_list->selected_item); |
610 | } | 526 | } |
611 | else | 527 | else |
612 | { | 528 | { |
613 | int top_of_screen = gui_list->selected_item + SCROLL_LIMIT - nb_lines; | 529 | int top_of_screen = gui_list->selected_item + SCROLL_LIMIT - nb_lines; |
614 | int temp = MAX(0, top_of_screen); | 530 | int temp = MAX(0, top_of_screen); |
615 | gui_list->start_item = MIN(bottom, temp); | 531 | gui_list->start_item[screen] = MIN(bottom, temp); |
616 | } | 532 | } |
617 | } | 533 | } |
618 | else gui_list->start_item = 0; | 534 | } |
535 | /* | ||
536 | * Selects an item in the list | ||
537 | * - gui_list : the list structure | ||
538 | * - item_number : the number of the item which will be selected | ||
539 | */ | ||
540 | void gui_synclist_select_item(struct gui_synclist * gui_list, int item_number) | ||
541 | { | ||
542 | int i; | ||
543 | if( item_number > gui_list->nb_items-1 || item_number < 0 ) | ||
544 | return; | ||
545 | gui_list->selected_item = item_number; | ||
546 | FOR_NB_SCREENS(i) | ||
547 | gui_list_put_selection_on_screen(gui_list, i); | ||
619 | } | 548 | } |
620 | 549 | ||
621 | static void gui_list_select_at_offset(struct gui_list * gui_list, int offset) | 550 | static void gui_list_select_at_offset(struct gui_synclist * gui_list, |
551 | int offset) | ||
622 | { | 552 | { |
623 | /* do this here instead of in both select_above and select_below */ | 553 | int new_selection = gui_list->selected_item + offset; |
624 | int nb_lines = gui_list->display->nb_lines; | ||
625 | if (SHOW_LIST_TITLE) | ||
626 | nb_lines--; | ||
627 | |||
628 | if (gui_list->selected_size > 1) | 554 | if (gui_list->selected_size > 1) |
629 | { | 555 | { |
630 | offset *= gui_list->selected_size; | 556 | offset *= gui_list->selected_size; |
631 | /* always select the first item of multi-line lists */ | 557 | /* always select the first item of multi-line lists */ |
632 | offset -= offset%gui_list->selected_size; | 558 | offset -= offset%gui_list->selected_size; |
633 | } | 559 | } |
634 | if (offset == 0 && global_settings.scroll_paginated && | 560 | if (new_selection >= gui_list->nb_items) |
635 | (gui_list->nb_items > nb_lines)) | ||
636 | { | 561 | { |
637 | int bottom = gui_list->nb_items - nb_lines; | 562 | if (gui_list->limit_scroll) |
638 | gui_list->start_item = MIN(gui_list->selected_item, bottom); | 563 | gui_list->selected_item = gui_list->nb_items - 1; |
564 | else | ||
565 | gui_list->selected_item = new_selection - gui_list->nb_items; | ||
639 | } | 566 | } |
640 | else if (offset < 0) | 567 | else if (new_selection < 0) |
641 | gui_list_select_above(gui_list, -offset, nb_lines); | 568 | { |
642 | else | 569 | if (gui_list->limit_scroll) |
643 | gui_list_select_below(gui_list, offset, nb_lines); | 570 | gui_list->selected_item = 0; |
571 | else | ||
572 | gui_list->selected_item = new_selection + gui_list->nb_items; | ||
573 | } | ||
574 | else if (gui_list->show_selection_marker == false) | ||
575 | { | ||
576 | /* NOTE: this part doesnt work as well as it used to, the problem is | ||
577 | we want to scroll the lists seperatly but we only have one | ||
578 | selected item now, I dont think this is such a big deal though */ | ||
579 | int i, nb_lines, screen_top; | ||
580 | FOR_NB_SCREENS(i) | ||
581 | { | ||
582 | struct screen *display = &screens[i]; | ||
583 | nb_lines = display->nb_lines - SHOW_LIST_TITLE; | ||
584 | if (offset > 0) | ||
585 | { | ||
586 | screen_top = gui_list->nb_items-nb_lines; | ||
587 | if (screen_top < 0) | ||
588 | screen_top = 0; | ||
589 | gui_list->start_item[i] = MIN(screen_top, gui_list->start_item[i] + | ||
590 | gui_list->selected_size); | ||
591 | } | ||
592 | else | ||
593 | { | ||
594 | gui_list->start_item[i] = MAX(0, gui_list->start_item[i] - | ||
595 | gui_list->selected_size); | ||
596 | } | ||
597 | } | ||
598 | return; | ||
599 | } | ||
600 | else gui_list->selected_item += offset; | ||
601 | gui_synclist_select_item(gui_list, gui_list->selected_item); | ||
602 | |||
644 | } | 603 | } |
645 | 604 | ||
646 | /* | 605 | /* |
647 | * Adds an item to the list (the callback will be asked for one more item) | 606 | * Adds an item to the list (the callback will be asked for one more item) |
648 | * - gui_list : the list structure | 607 | * - gui_list : the list structure |
649 | */ | 608 | */ |
650 | static void gui_list_add_item(struct gui_list * gui_list) | 609 | void gui_synclist_add_item(struct gui_synclist * gui_list) |
651 | { | 610 | { |
652 | gui_list->nb_items++; | 611 | gui_list->nb_items++; |
653 | /* if only one item in the list, select it */ | 612 | /* if only one item in the list, select it */ |
@@ -659,58 +618,29 @@ static void gui_list_add_item(struct gui_list * gui_list) | |||
659 | * Removes an item to the list (the callback will be asked for one less item) | 618 | * Removes an item to the list (the callback will be asked for one less item) |
660 | * - gui_list : the list structure | 619 | * - gui_list : the list structure |
661 | */ | 620 | */ |
662 | static void gui_list_del_item(struct gui_list * gui_list) | 621 | void gui_synclist_del_item(struct gui_synclist * gui_list) |
663 | { | 622 | { |
623 | int i; | ||
664 | if(gui_list->nb_items > 0) | 624 | if(gui_list->nb_items > 0) |
665 | { | 625 | { |
666 | gui_textarea_update_nblines(gui_list->display); | 626 | if (gui_list->selected_item == gui_list->nb_items-1) |
667 | int nb_lines = gui_list->display->nb_lines; | ||
668 | |||
669 | int dist_selected_from_end = gui_list->nb_items | ||
670 | - gui_list->selected_item - 1; | ||
671 | int dist_start_from_end = gui_list->nb_items | ||
672 | - gui_list->start_item - 1; | ||
673 | if(dist_selected_from_end == 0) | ||
674 | { | ||
675 | /* Oops we are removing the selected item, | ||
676 | select the previous one */ | ||
677 | gui_list->selected_item--; | 627 | gui_list->selected_item--; |
628 | FOR_NB_SCREENS(i) | ||
629 | { | ||
630 | gui_textarea_update_nblines(&screens[i]); | ||
631 | int nb_lines = screens[i].nb_lines; | ||
632 | int dist_start_from_end = gui_list->nb_items | ||
633 | - gui_list->start_item[i] - 1; | ||
634 | |||
635 | /* scroll the list if needed */ | ||
636 | if( (dist_start_from_end < nb_lines) && (gui_list->start_item[i] != 0) ) | ||
637 | gui_list->start_item[i]--; | ||
678 | } | 638 | } |
679 | gui_list->nb_items--; | 639 | gui_list->nb_items--; |
680 | |||
681 | /* scroll the list if needed */ | ||
682 | if( (dist_start_from_end < nb_lines) && (gui_list->start_item != 0) ) | ||
683 | gui_list->start_item--; | ||
684 | } | 640 | } |
685 | } | 641 | } |
686 | 642 | ||
687 | #ifdef HAVE_LCD_BITMAP | 643 | #ifdef HAVE_LCD_BITMAP |
688 | |||
689 | /* | ||
690 | * Makes all the item in the list scroll by one step to the right. | ||
691 | * Should stop increasing the value when reaching the widest item value | ||
692 | * in the list. | ||
693 | */ | ||
694 | static void gui_list_scroll_right(struct gui_list * gui_list) | ||
695 | { | ||
696 | /* FIXME: This is a fake right boundry limiter. there should be some | ||
697 | * callback function to find the longest item on the list in pixels, | ||
698 | * to stop the list from scrolling past that point */ | ||
699 | gui_list->offset_position+=offset_step; | ||
700 | if (gui_list->offset_position > 1000) | ||
701 | gui_list->offset_position = 1000; | ||
702 | } | ||
703 | |||
704 | /* | ||
705 | * Makes all the item in the list scroll by one step to the left. | ||
706 | * stops at starting position. | ||
707 | */ | ||
708 | static void gui_list_scroll_left(struct gui_list * gui_list) | ||
709 | { | ||
710 | gui_list->offset_position-=offset_step; | ||
711 | if (gui_list->offset_position < 0) | ||
712 | gui_list->offset_position = 0; | ||
713 | } | ||
714 | void gui_list_screen_scroll_step(int ofs) | 644 | void gui_list_screen_scroll_step(int ofs) |
715 | { | 645 | { |
716 | offset_step = ofs; | 646 | offset_step = ofs; |
@@ -729,14 +659,16 @@ void gui_list_screen_scroll_out_of_view(bool enable) | |||
729 | * Set the title and title icon of the list. Setting title to NULL disables | 659 | * Set the title and title icon of the list. Setting title to NULL disables |
730 | * both the title and icon. Use NOICON if there is no icon. | 660 | * both the title and icon. Use NOICON if there is no icon. |
731 | */ | 661 | */ |
732 | static void gui_list_set_title(struct gui_list * gui_list, | 662 | void gui_synclist_set_title(struct gui_synclist * gui_list, |
733 | char * title, enum themable_icons icon) | 663 | char * title, enum themable_icons icon) |
734 | { | 664 | { |
735 | gui_list->title = title; | 665 | gui_list->title = title; |
736 | gui_list->title_icon = icon; | 666 | gui_list->title_icon = icon; |
737 | if (title) { | 667 | if (title) { |
738 | #ifdef HAVE_LCD_BITMAP | 668 | #ifdef HAVE_LCD_BITMAP |
739 | gui_list->display->getstringsize(title, &gui_list->title_width, NULL); | 669 | int i; |
670 | FOR_NB_SCREENS(i) | ||
671 | screens[i].getstringsize(title, &gui_list->title_width, NULL); | ||
740 | #else | 672 | #else |
741 | gui_list->title_width = strlen(title); | 673 | gui_list->title_width = strlen(title); |
742 | #endif | 674 | #endif |
@@ -745,143 +677,96 @@ static void gui_list_set_title(struct gui_list * gui_list, | |||
745 | } | 677 | } |
746 | } | 678 | } |
747 | 679 | ||
748 | /* | ||
749 | * Synchronized lists stuffs | ||
750 | */ | ||
751 | void gui_synclist_init( | ||
752 | struct gui_synclist * lists, | ||
753 | list_get_name callback_get_item_name, | ||
754 | void * data, | ||
755 | bool scroll_all, | ||
756 | int selected_size | ||
757 | ) | ||
758 | { | ||
759 | int i; | ||
760 | FOR_NB_SCREENS(i) | ||
761 | { | ||
762 | gui_list_init(&(lists->gui_list[i]), | ||
763 | callback_get_item_name, | ||
764 | data, scroll_all, selected_size); | ||
765 | gui_list_set_display(&(lists->gui_list[i]), &(screens[i])); | ||
766 | } | ||
767 | } | ||
768 | 680 | ||
769 | void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items) | 681 | void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items) |
770 | { | 682 | { |
683 | #ifdef HAVE_LCD_BITMAP | ||
771 | int i; | 684 | int i; |
685 | #endif | ||
686 | lists->nb_items = nb_items; | ||
687 | #ifdef HAVE_LCD_BITMAP | ||
772 | FOR_NB_SCREENS(i) | 688 | FOR_NB_SCREENS(i) |
773 | { | 689 | { |
774 | gui_list_set_nb_items(&(lists->gui_list[i]), nb_items); | 690 | lists->offset_position[i] = 0; |
775 | #ifdef HAVE_LCD_BITMAP | ||
776 | lists->gui_list[i].offset_position = 0; | ||
777 | #endif | ||
778 | } | 691 | } |
692 | #endif | ||
779 | } | 693 | } |
780 | int gui_synclist_get_nb_items(struct gui_synclist * lists) | 694 | int gui_synclist_get_nb_items(struct gui_synclist * lists) |
781 | { | 695 | { |
782 | return gui_list_get_nb_items(&((lists)->gui_list[0])); | 696 | return lists->nb_items; |
783 | } | 697 | } |
784 | int gui_synclist_get_sel_pos(struct gui_synclist * lists) | 698 | int gui_synclist_get_sel_pos(struct gui_synclist * lists) |
785 | { | 699 | { |
786 | return gui_list_get_sel_pos(&((lists)->gui_list[0])); | 700 | return lists->selected_item; |
787 | } | 701 | } |
788 | void gui_synclist_set_icon_callback(struct gui_synclist * lists, | 702 | void gui_synclist_set_icon_callback(struct gui_synclist * lists, |
789 | list_get_icon icon_callback) | 703 | list_get_icon icon_callback) |
790 | { | 704 | { |
791 | int i; | 705 | lists->callback_get_item_icon = icon_callback; |
792 | FOR_NB_SCREENS(i) | ||
793 | { | ||
794 | gui_list_set_icon_callback(&(lists->gui_list[i]), icon_callback); | ||
795 | } | ||
796 | } | 706 | } |
797 | 707 | ||
798 | void gui_synclist_set_voice_callback(struct gui_synclist * lists, | 708 | void gui_synclist_set_voice_callback(struct gui_synclist * lists, |
799 | list_speak_item voice_callback) | 709 | list_speak_item voice_callback) |
800 | { | 710 | { |
801 | gui_list_set_voice_callback(&(lists->gui_list[0]), voice_callback); | 711 | lists->callback_speak_item = voice_callback; |
802 | } | ||
803 | |||
804 | void gui_synclist_draw(struct gui_synclist * lists) | ||
805 | { | ||
806 | int i; | ||
807 | FOR_NB_SCREENS(i) | ||
808 | gui_list_draw(&(lists->gui_list[i])); | ||
809 | } | ||
810 | |||
811 | void gui_synclist_select_item(struct gui_synclist * lists, int item_number) | ||
812 | { | ||
813 | int i; | ||
814 | FOR_NB_SCREENS(i) | ||
815 | gui_list_select_item(&(lists->gui_list[i]), item_number); | ||
816 | } | 712 | } |
817 | 713 | ||
818 | static void gui_synclist_select_next_page(struct gui_synclist * lists, | 714 | static void gui_synclist_select_next_page(struct gui_synclist * lists, |
819 | enum screen_type screen) | 715 | enum screen_type screen) |
820 | { | 716 | { |
821 | int i; | 717 | gui_list_select_at_offset(lists, screens[screen].nb_lines); |
822 | FOR_NB_SCREENS(i) | ||
823 | gui_list_select_at_offset(&(lists->gui_list[i]), | ||
824 | screens[screen].nb_lines); | ||
825 | } | 718 | } |
826 | 719 | ||
827 | static void gui_synclist_select_previous_page(struct gui_synclist * lists, | 720 | static void gui_synclist_select_previous_page(struct gui_synclist * lists, |
828 | enum screen_type screen) | 721 | enum screen_type screen) |
829 | { | 722 | { |
830 | int i; | 723 | gui_list_select_at_offset(lists, -screens[screen].nb_lines); |
831 | FOR_NB_SCREENS(i) | ||
832 | gui_list_select_at_offset(&(lists->gui_list[i]), | ||
833 | -screens[screen].nb_lines); | ||
834 | } | ||
835 | |||
836 | void gui_synclist_add_item(struct gui_synclist * lists) | ||
837 | { | ||
838 | int i; | ||
839 | FOR_NB_SCREENS(i) | ||
840 | gui_list_add_item(&(lists->gui_list[i])); | ||
841 | } | ||
842 | |||
843 | void gui_synclist_del_item(struct gui_synclist * lists) | ||
844 | { | ||
845 | int i; | ||
846 | FOR_NB_SCREENS(i) | ||
847 | gui_list_del_item(&(lists->gui_list[i])); | ||
848 | } | 724 | } |
849 | 725 | ||
850 | void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll) | 726 | void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll) |
851 | { | 727 | { |
852 | int i; | 728 | lists->limit_scroll = scroll; |
853 | FOR_NB_SCREENS(i) | ||
854 | gui_list_limit_scroll(&(lists->gui_list[i]), scroll); | ||
855 | } | ||
856 | |||
857 | void gui_synclist_set_title(struct gui_synclist * lists, | ||
858 | char * title, enum themable_icons icon) | ||
859 | { | ||
860 | int i; | ||
861 | FOR_NB_SCREENS(i) | ||
862 | gui_list_set_title(&(lists->gui_list[i]), title, icon); | ||
863 | } | 729 | } |
864 | 730 | ||
865 | #ifdef HAVE_LCD_BITMAP | 731 | #ifdef HAVE_LCD_BITMAP |
732 | /* | ||
733 | * Makes all the item in the list scroll by one step to the right. | ||
734 | * Should stop increasing the value when reaching the widest item value | ||
735 | * in the list. | ||
736 | */ | ||
866 | static void gui_synclist_scroll_right(struct gui_synclist * lists) | 737 | static void gui_synclist_scroll_right(struct gui_synclist * lists) |
867 | { | 738 | { |
868 | int i; | 739 | int i; |
869 | FOR_NB_SCREENS(i) | 740 | FOR_NB_SCREENS(i) |
870 | gui_list_scroll_right(&(lists->gui_list[i])); | 741 | { |
742 | /* FIXME: This is a fake right boundry limiter. there should be some | ||
743 | * callback function to find the longest item on the list in pixels, | ||
744 | * to stop the list from scrolling past that point */ | ||
745 | lists->offset_position[i]+=offset_step; | ||
746 | if (lists->offset_position[i] > 1000) | ||
747 | lists->offset_position[i] = 1000; | ||
748 | } | ||
871 | } | 749 | } |
872 | 750 | ||
751 | /* | ||
752 | * Makes all the item in the list scroll by one step to the left. | ||
753 | * stops at starting position. | ||
754 | */ | ||
873 | static void gui_synclist_scroll_left(struct gui_synclist * lists) | 755 | static void gui_synclist_scroll_left(struct gui_synclist * lists) |
874 | { | 756 | { |
875 | int i; | 757 | int i; |
876 | FOR_NB_SCREENS(i) | 758 | FOR_NB_SCREENS(i) |
877 | gui_list_scroll_left(&(lists->gui_list[i])); | 759 | { |
760 | lists->offset_position[i]-=offset_step; | ||
761 | if (lists->offset_position[i] < 0) | ||
762 | lists->offset_position[i] = 0; | ||
763 | } | ||
878 | } | 764 | } |
879 | #endif /* HAVE_LCD_BITMAP */ | 765 | #endif /* HAVE_LCD_BITMAP */ |
880 | 766 | ||
881 | static void _gui_synclist_speak_item(struct gui_synclist *lists, bool repeating) | 767 | static void _gui_synclist_speak_item(struct gui_synclist *lists, bool repeating) |
882 | { | 768 | { |
883 | struct gui_list *l = &lists->gui_list[0]; | 769 | list_speak_item *cb = lists->callback_speak_item; |
884 | list_speak_item *cb = l->callback_speak_item; | ||
885 | if(cb && gui_synclist_get_nb_items(lists) != 0) | 770 | if(cb && gui_synclist_get_nb_items(lists) != 0) |
886 | { | 771 | { |
887 | int sel = gui_synclist_get_sel_pos(lists); | 772 | int sel = gui_synclist_get_sel_pos(lists); |
@@ -892,17 +777,17 @@ static void _gui_synclist_speak_item(struct gui_synclist *lists, bool repeating) | |||
892 | pending scheduled announcement not yet due: we need to | 777 | pending scheduled announcement not yet due: we need to |
893 | reschedule it. */ | 778 | reschedule it. */ |
894 | if(repeating | 779 | if(repeating |
895 | || (l->scheduled_talk_tick | 780 | || (lists->scheduled_talk_tick |
896 | && TIME_BEFORE(current_tick, l->scheduled_talk_tick)) | 781 | && TIME_BEFORE(current_tick, lists->scheduled_talk_tick)) |
897 | || (l->last_talked_tick | 782 | || (lists->last_talked_tick |
898 | && TIME_BEFORE(current_tick, l->last_talked_tick +HZ/4))) | 783 | && TIME_BEFORE(current_tick, lists->last_talked_tick +HZ/4))) |
899 | { | 784 | { |
900 | l->scheduled_talk_tick = current_tick +HZ/4; | 785 | lists->scheduled_talk_tick = current_tick +HZ/4; |
901 | return; | 786 | return; |
902 | } else { | 787 | } else { |
903 | l->scheduled_talk_tick = 0; /* work done */ | 788 | lists->scheduled_talk_tick = 0; /* work done */ |
904 | cb(sel, l->data); | 789 | cb(sel, lists->data); |
905 | l->last_talked_tick = current_tick; | 790 | lists->last_talked_tick = current_tick; |
906 | } | 791 | } |
907 | } | 792 | } |
908 | } | 793 | } |
@@ -1014,7 +899,6 @@ bool gui_synclist_do_button(struct gui_synclist * lists, | |||
1014 | #ifdef HAVE_LCD_BITMAP | 899 | #ifdef HAVE_LCD_BITMAP |
1015 | static bool scrolling_left = false; | 900 | static bool scrolling_left = false; |
1016 | #endif | 901 | #endif |
1017 | int i; | ||
1018 | 902 | ||
1019 | #ifdef HAVE_SCROLLWHEEL | 903 | #ifdef HAVE_SCROLLWHEEL |
1020 | int next_item_modifier = button_apply_acceleration(get_action_data()); | 904 | int next_item_modifier = button_apply_acceleration(get_action_data()); |
@@ -1086,8 +970,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, | |||
1086 | #endif | 970 | #endif |
1087 | case ACTION_STD_PREV: | 971 | case ACTION_STD_PREV: |
1088 | case ACTION_STD_PREVREPEAT: | 972 | case ACTION_STD_PREVREPEAT: |
1089 | FOR_NB_SCREENS(i) | 973 | gui_list_select_at_offset(lists, -next_item_modifier); |
1090 | gui_list_select_at_offset(&(lists->gui_list[i]), -next_item_modifier); | ||
1091 | #ifndef HAVE_SCROLLWHEEL | 974 | #ifndef HAVE_SCROLLWHEEL |
1092 | if (queue_count(&button_queue) < FRAMEDROP_TRIGGER) | 975 | if (queue_count(&button_queue) < FRAMEDROP_TRIGGER) |
1093 | #endif | 976 | #endif |
@@ -1101,8 +984,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, | |||
1101 | 984 | ||
1102 | case ACTION_STD_NEXT: | 985 | case ACTION_STD_NEXT: |
1103 | case ACTION_STD_NEXTREPEAT: | 986 | case ACTION_STD_NEXTREPEAT: |
1104 | FOR_NB_SCREENS(i) | 987 | gui_list_select_at_offset(lists, next_item_modifier); |
1105 | gui_list_select_at_offset(&(lists->gui_list[i]), next_item_modifier); | ||
1106 | #ifndef HAVE_SCROLLWHEEL | 988 | #ifndef HAVE_SCROLLWHEEL |
1107 | if (queue_count(&button_queue) < FRAMEDROP_TRIGGER) | 989 | if (queue_count(&button_queue) < FRAMEDROP_TRIGGER) |
1108 | #endif | 990 | #endif |
@@ -1125,7 +1007,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, | |||
1125 | keymaps as a repeated button press (the same as the repeated | 1007 | keymaps as a repeated button press (the same as the repeated |
1126 | ACTION_TREE_PGLEFT) with the pre condition being the non-repeated | 1008 | ACTION_TREE_PGLEFT) with the pre condition being the non-repeated |
1127 | button press */ | 1009 | button press */ |
1128 | if (lists->gui_list[0].offset_position == 0) | 1010 | if (lists->offset_position[0] == 0) |
1129 | { | 1011 | { |
1130 | scrolling_left = false; | 1012 | scrolling_left = false; |
1131 | *actionptr = ACTION_STD_CANCEL; | 1013 | *actionptr = ACTION_STD_CANCEL; |
@@ -1133,7 +1015,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, | |||
1133 | } | 1015 | } |
1134 | *actionptr = ACTION_TREE_PGLEFT; | 1016 | *actionptr = ACTION_TREE_PGLEFT; |
1135 | case ACTION_TREE_PGLEFT: | 1017 | case ACTION_TREE_PGLEFT: |
1136 | if(!scrolling_left && (lists->gui_list[0].offset_position == 0)) | 1018 | if(!scrolling_left && (lists->offset_position[0] == 0)) |
1137 | { | 1019 | { |
1138 | *actionptr = ACTION_STD_CANCEL; | 1020 | *actionptr = ACTION_STD_CANCEL; |
1139 | return false; | 1021 | return false; |
@@ -1144,7 +1026,6 @@ bool gui_synclist_do_button(struct gui_synclist * lists, | |||
1144 | skipping to root */ | 1026 | skipping to root */ |
1145 | return true; | 1027 | return true; |
1146 | #endif | 1028 | #endif |
1147 | |||
1148 | /* for pgup / pgdown, we are obliged to have a different behaviour depending | 1029 | /* for pgup / pgdown, we are obliged to have a different behaviour depending |
1149 | * on the screen for which the user pressed the key since for example, remote | 1030 | * on the screen for which the user pressed the key since for example, remote |
1150 | * and main screen doesn't have the same number of lines */ | 1031 | * and main screen doesn't have the same number of lines */ |
@@ -1180,8 +1061,8 @@ bool gui_synclist_do_button(struct gui_synclist * lists, | |||
1180 | } | 1061 | } |
1181 | return true; | 1062 | return true; |
1182 | } | 1063 | } |
1183 | if(lists->gui_list[0].scheduled_talk_tick | 1064 | if(lists->scheduled_talk_tick |
1184 | && TIME_AFTER(current_tick, lists->gui_list[0].scheduled_talk_tick)) | 1065 | && TIME_AFTER(current_tick, lists->scheduled_talk_tick)) |
1185 | /* scheduled postponed item announcement is due */ | 1066 | /* scheduled postponed item announcement is due */ |
1186 | _gui_synclist_speak_item(lists, false); | 1067 | _gui_synclist_speak_item(lists, false); |
1187 | return false; | 1068 | return false; |
@@ -1191,9 +1072,9 @@ int list_do_action_timeout(struct gui_synclist *lists, int timeout) | |||
1191 | /* Returns the lowest of timeout or the delay until a postponed | 1072 | /* Returns the lowest of timeout or the delay until a postponed |
1192 | scheduled announcement is due (if any). */ | 1073 | scheduled announcement is due (if any). */ |
1193 | { | 1074 | { |
1194 | if(lists->gui_list[0].scheduled_talk_tick) | 1075 | if(lists->scheduled_talk_tick) |
1195 | { | 1076 | { |
1196 | long delay = lists->gui_list[0].scheduled_talk_tick -current_tick +1; | 1077 | long delay = lists->scheduled_talk_tick -current_tick +1; |
1197 | /* +1 because the trigger condition uses TIME_AFTER(), which | 1078 | /* +1 because the trigger condition uses TIME_AFTER(), which |
1198 | is implemented as strictly greater than. */ | 1079 | is implemented as strictly greater than. */ |
1199 | if(delay < 0) | 1080 | if(delay < 0) |
diff --git a/apps/gui/list.h b/apps/gui/list.h index 742e30dbaa..3bd3d25c49 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h | |||
@@ -82,7 +82,7 @@ typedef int list_speak_item(int selected_item, void * data); | |||
82 | typedef int list_get_color(int selected_item, void * data); | 82 | typedef int list_get_color(int selected_item, void * data); |
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | struct gui_list | 85 | struct gui_synclist |
86 | { | 86 | { |
87 | /* defines wether the list should stop when reaching the top/bottom | 87 | /* defines wether the list should stop when reaching the top/bottom |
88 | * or should continue (by going to bottom/top) */ | 88 | * or should continue (by going to bottom/top) */ |
@@ -93,15 +93,15 @@ struct gui_list | |||
93 | 93 | ||
94 | int nb_items; | 94 | int nb_items; |
95 | int selected_item; | 95 | int selected_item; |
96 | int start_item; /* the item that is displayed at the top of the screen */ | 96 | int start_item[NB_SCREENS]; /* the item that is displayed at the top of the screen */ |
97 | /* the number of lines that are selected at the same time */ | 97 | /* the number of lines that are selected at the same time */ |
98 | int selected_size; | 98 | int selected_size; |
99 | /* These are used to calculate how much of the screen content we need | 99 | /* These are used to calculate how much of the screen content we need |
100 | to redraw. */ | 100 | to redraw. */ |
101 | int last_displayed_selected_item; | 101 | int last_displayed_selected_item; |
102 | int last_displayed_start_item; | 102 | int last_displayed_start_item[NB_SCREENS]; |
103 | #ifdef HAVE_LCD_BITMAP | 103 | #ifdef HAVE_LCD_BITMAP |
104 | int offset_position; /* the list's screen scroll placement in pixels */ | 104 | int offset_position[NB_SCREENS]; /* the list's screen scroll placement in pixels */ |
105 | #endif | 105 | #endif |
106 | /* Cache the width of the title string in pixels/characters */ | 106 | /* Cache the width of the title string in pixels/characters */ |
107 | int title_width; | 107 | int title_width; |
@@ -111,7 +111,6 @@ struct gui_list | |||
111 | list_get_name *callback_get_item_name; | 111 | list_get_name *callback_get_item_name; |
112 | list_speak_item *callback_speak_item; | 112 | list_speak_item *callback_speak_item; |
113 | 113 | ||
114 | struct screen * display; | ||
115 | /* The data that will be passed to the callback function YOU implement */ | 114 | /* The data that will be passed to the callback function YOU implement */ |
116 | void * data; | 115 | void * data; |
117 | /* The optional title, set to NULL for none */ | 116 | /* The optional title, set to NULL for none */ |
@@ -195,19 +194,6 @@ extern void gui_list_screen_scroll_out_of_view(bool enable); | |||
195 | #define gui_list_limit_scroll(gui_list, scroll) \ | 194 | #define gui_list_limit_scroll(gui_list, scroll) \ |
196 | (gui_list)->limit_scroll=scroll | 195 | (gui_list)->limit_scroll=scroll |
197 | 196 | ||
198 | /* | ||
199 | * This part handles as many lists as there are connected screens | ||
200 | * (the api is similar to the ones above) | ||
201 | * The lists on the screens are synchronized ; | ||
202 | * theirs items and selected items are the same, but of course, | ||
203 | * they can be displayed on screens with different sizes | ||
204 | * The final aim is to let the programmer handle many lists in one | ||
205 | * function call and make its code independant from the number of screens | ||
206 | */ | ||
207 | struct gui_synclist | ||
208 | { | ||
209 | struct gui_list gui_list[NB_SCREENS]; | ||
210 | }; | ||
211 | 197 | ||
212 | extern void gui_synclist_init( | 198 | extern void gui_synclist_init( |
213 | struct gui_synclist * lists, | 199 | struct gui_synclist * lists, |
diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 93d937e6db..a0786f9bc6 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c | |||
@@ -361,7 +361,7 @@ static int info_action_callback(int action, struct gui_synclist *lists) | |||
361 | ) | 361 | ) |
362 | { | 362 | { |
363 | #ifndef SIMULATOR | 363 | #ifndef SIMULATOR |
364 | struct info_data *info = (struct info_data *)lists->gui_list[SCREEN_MAIN].data; | 364 | struct info_data *info = (struct info_data *)lists->data; |
365 | info->new_data = true; | 365 | info->new_data = true; |
366 | gui_syncsplash(0, ID2P(LANG_SCANNING_DISK)); | 366 | gui_syncsplash(0, ID2P(LANG_SCANNING_DISK)); |
367 | fat_recalc_free(IF_MV(0)); | 367 | fat_recalc_free(IF_MV(0)); |
diff --git a/apps/tree.c b/apps/tree.c index b800833c7d..35fa05364a 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -330,7 +330,7 @@ void tree_gui_init(void) | |||
330 | gui_synclist_set_voice_callback(&tree_lists, tree_voice_cb); | 330 | gui_synclist_set_voice_callback(&tree_lists, tree_voice_cb); |
331 | gui_synclist_set_icon_callback(&tree_lists, &tree_get_fileicon); | 331 | gui_synclist_set_icon_callback(&tree_lists, &tree_get_fileicon); |
332 | #ifdef HAVE_LCD_COLOR | 332 | #ifdef HAVE_LCD_COLOR |
333 | gui_list_set_color_callback(&tree_lists.gui_list[SCREEN_MAIN], | 333 | gui_list_set_color_callback(&tree_lists, |
334 | &tree_get_filecolor); | 334 | &tree_get_filecolor); |
335 | #endif | 335 | #endif |
336 | } | 336 | } |