summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2009-10-27 13:18:54 +0000
committerTeruaki Kawashima <teru@rockbox.org>2009-10-27 13:18:54 +0000
commit478afc3d62bc576dac707594b3d4949d33ca0b8d (patch)
tree2e605bd786fdb84084fee8ae3194c86b2fb9374b /apps/gui
parent03f88d53ee3ac69add22d248103a9d468c0b36d2 (diff)
downloadrockbox-478afc3d62bc576dac707594b3d4949d33ca0b8d.tar.gz
rockbox-478afc3d62bc576dac707594b3d4949d33ca0b8d.zip
FS#10722: some improvements for gui/list.c
* Add function list_get_nb_lines and replace duplicated codes to calculate number of lines by it. * Refine calculation of start_item in function gui_list_put_selection_on_screen. - displays as many items as possible. hopefully fix FS#10054. * Fix checking bounds in function gui_synclist_item_is_onscreen. * Remove trailing spaces and fix indents. Flyspray: FS#10722 Author: myself git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23367 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/list.c194
1 files changed, 89 insertions, 105 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index a9d8ff6d9b..24ddcd6302 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -92,8 +92,8 @@ static void list_init_viewports(struct gui_synclist *list)
92 list->parent[i] = &parent[i]; 92 list->parent[i] = &parent[i];
93 viewport_set_defaults(&parent[i], i); 93 viewport_set_defaults(&parent[i], i);
94#ifdef HAVE_BUTTONBAR 94#ifdef HAVE_BUTTONBAR
95 if (screens[i].has_buttonbar && !viewport_ui_vp_get_state(i)) 95 if (screens[i].has_buttonbar && !viewport_ui_vp_get_state(i))
96 list->parent[i]->height -= BUTTONBAR_HEIGHT; 96 list->parent[i]->height -= BUTTONBAR_HEIGHT;
97#endif 97#endif
98 } 98 }
99 } 99 }
@@ -107,7 +107,15 @@ static void list_init_viewports(struct gui_synclist *list)
107bool list_display_title(struct gui_synclist *list, enum screen_type screen) 107bool list_display_title(struct gui_synclist *list, enum screen_type screen)
108{ 108{
109 return list->title != NULL && 109 return list->title != NULL &&
110 viewport_get_nb_lines(list->parent[screen])>2; 110 viewport_get_nb_lines(list->parent[screen]) > 2;
111}
112
113static int list_get_nb_lines(struct gui_synclist *list, enum screen_type screen)
114{
115 struct viewport vp = *list->parent[screen];
116 if (list_display_title(list, screen))
117 vp.height -= font_get(list->parent[screen]->font)->height;
118 return viewport_get_nb_lines(&vp);
111} 119}
112#else 120#else
113static struct viewport parent[NB_SCREENS] = 121static struct viewport parent[NB_SCREENS] =
@@ -121,6 +129,8 @@ static struct viewport parent[NB_SCREENS] =
121 }, 129 },
122}; 130};
123#define list_display_title(l, i) false 131#define list_display_title(l, i) false
132#define list_get_nb_lines(list, screen) \
133 viewport_get_nb_lines((list)->parent[(screen)]);
124#endif 134#endif
125 135
126/* 136/*
@@ -161,16 +171,16 @@ void gui_synclist_init(struct gui_synclist * gui_list,
161 } 171 }
162 list_init_viewports(gui_list); 172 list_init_viewports(gui_list);
163 gui_list->limit_scroll = false; 173 gui_list->limit_scroll = false;
164 gui_list->data=data; 174 gui_list->data = data;
165 gui_list->scroll_all=scroll_all; 175 gui_list->scroll_all = scroll_all;
166 gui_list->selected_size=selected_size; 176 gui_list->selected_size = selected_size;
167 gui_list->title = NULL; 177 gui_list->title = NULL;
168 gui_list->title_width = 0; 178 gui_list->title_width = 0;
169 gui_list->title_icon = Icon_NOICON; 179 gui_list->title_icon = Icon_NOICON;
170 180
171 gui_list->scheduled_talk_tick = gui_list->last_talked_tick = 0; 181 gui_list->scheduled_talk_tick = gui_list->last_talked_tick = 0;
172 gui_list->show_selection_marker = true; 182 gui_list->show_selection_marker = true;
173 gui_list->last_displayed_selected_item = -1 ; 183 gui_list->last_displayed_selected_item = -1;
174 184
175#ifdef HAVE_LCD_COLOR 185#ifdef HAVE_LCD_COLOR
176 gui_list->title_color = -1; 186 gui_list->title_color = -1;
@@ -200,29 +210,28 @@ int gui_list_get_item_offset(struct gui_synclist * gui_list,
200 } 210 }
201 else 211 else
202 { 212 {
203 /* if text is smaller then view */ 213 /* if text is smaller than view */
204 if (item_width <= vp->width - text_pos) 214 if (item_width <= vp->width - text_pos)
205 { 215 {
206 item_offset = 0; 216 item_offset = 0;
207 } 217 }
208 else 218 /* if text got out of view */
209 { 219 else if (gui_list->offset_position[display->screen_type] >
210 /* if text got out of view */
211 if (gui_list->offset_position[display->screen_type] >
212 item_width - (vp->width - text_pos)) 220 item_width - (vp->width - text_pos))
213 item_offset = item_width - (vp->width - text_pos); 221 {
214 else 222 item_offset = item_width - (vp->width - text_pos);
215 item_offset = gui_list->offset_position[display->screen_type];
216 } 223 }
224 else
225 item_offset = gui_list->offset_position[display->screen_type];
217 } 226 }
218 227
219 return item_offset; 228 return item_offset;
220} 229}
221#endif 230#endif
231
222/* 232/*
223 * Force a full screen update. 233 * Force a full screen update.
224 */ 234 */
225
226void gui_synclist_draw(struct gui_synclist *gui_list) 235void gui_synclist_draw(struct gui_synclist *gui_list)
227{ 236{
228 int i; 237 int i;
@@ -243,68 +252,58 @@ void gui_synclist_draw(struct gui_synclist *gui_list)
243static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list, 252static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
244 enum screen_type screen) 253 enum screen_type screen)
245{ 254{
246 int nb_lines; 255 int nb_lines = list_get_nb_lines(gui_list, screen);
256 int bottom = MAX(0, gui_list->nb_items - nb_lines);
257 int new_start_item = gui_list->start_item[screen];
247 int difference = gui_list->selected_item - gui_list->start_item[screen]; 258 int difference = gui_list->selected_item - gui_list->start_item[screen];
248 struct viewport vp = *gui_list->parent[screen]; 259
249#ifdef HAVE_LCD_BITMAP 260 /* edge case, selected last item */
250 if (list_display_title(gui_list, screen))
251 vp.height -= font_get(gui_list->parent[screen]->font)->height;
252#endif
253 nb_lines = viewport_get_nb_lines(&vp);
254
255 /* edge case,, selected last item */
256 if (gui_list->selected_item == gui_list->nb_items -1) 261 if (gui_list->selected_item == gui_list->nb_items -1)
257 { 262 {
258 gui_list->start_item[screen] = MAX(0, gui_list->nb_items - nb_lines); 263 new_start_item = bottom;
259 } 264 }
260 /* selected first item */ 265 /* selected first item */
261 else if (gui_list->selected_item == 0) 266 else if (gui_list->selected_item == 0)
262 { 267 {
263 gui_list->start_item[screen] = 0; 268 new_start_item = 0;
264 } 269 }
265 else if (difference < SCROLL_LIMIT) /* list moved up */ 270 else if (difference < SCROLL_LIMIT) /* list moved up */
266 { 271 {
267 if (global_settings.scroll_paginated) 272 if (global_settings.scroll_paginated)
268 { 273 {
269 if (gui_list->start_item[screen] > gui_list->selected_item) 274 if (new_start_item > gui_list->selected_item)
270 { 275 new_start_item = (gui_list->selected_item/nb_lines)*nb_lines;
271 gui_list->start_item[screen] = (gui_list->selected_item/nb_lines)
272 *nb_lines;
273 }
274 if (gui_list->nb_items <= nb_lines)
275 gui_list->start_item[screen] = 0;
276 } 276 }
277 else 277 else
278 { 278 {
279 int top_of_screen = gui_list->selected_item - SCROLL_LIMIT + 1; 279 new_start_item = gui_list->selected_item - SCROLL_LIMIT + 1;
280 int temp = MIN(top_of_screen, gui_list->nb_items - nb_lines);
281 gui_list->start_item[screen] = MAX(0, temp);
282 } 280 }
283 } 281 }
284 else if (difference > nb_lines - SCROLL_LIMIT) /* list moved down */ 282 else if (difference > nb_lines - SCROLL_LIMIT) /* list moved down */
285 { 283 {
286 int bottom = gui_list->nb_items - nb_lines;
287 /* always move the screen if selection isnt "visible" */ 284 /* always move the screen if selection isnt "visible" */
288 if (gui_list->show_selection_marker == false) 285 if (gui_list->show_selection_marker == false)
289 { 286 {
290 if (bottom < 0) 287 new_start_item += 2*gui_list->selected_size;
291 bottom = 0;
292 gui_list->start_item[screen] = MIN(bottom, gui_list->start_item[screen] +
293 2*gui_list->selected_size);
294 } 288 }
295 else if (global_settings.scroll_paginated) 289 else if (global_settings.scroll_paginated)
296 { 290 {
297 if (gui_list->start_item[screen] + nb_lines <= gui_list->selected_item) 291 if (new_start_item + nb_lines <= gui_list->selected_item)
298 gui_list->start_item[screen] = MIN(bottom, gui_list->selected_item); 292 new_start_item = (gui_list->selected_item/nb_lines)*nb_lines;
299 } 293 }
300 else 294 else
301 { 295 {
302 int top_of_screen = gui_list->selected_item + SCROLL_LIMIT - nb_lines; 296 new_start_item = gui_list->selected_item + SCROLL_LIMIT - nb_lines;
303 int temp = MAX(0, top_of_screen);
304 gui_list->start_item[screen] = MIN(bottom, temp);
305 } 297 }
306 } 298 }
299 if (new_start_item < 0)
300 gui_list->start_item[screen] = 0;
301 else if (new_start_item > bottom)
302 gui_list->start_item[screen] = bottom;
303 else
304 gui_list->start_item[screen] = new_start_item;
307} 305}
306
308/* 307/*
309 * Selects an item in the list 308 * Selects an item in the list
310 * - gui_list : the list structure 309 * - gui_list : the list structure
@@ -313,7 +312,7 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list,
313void gui_synclist_select_item(struct gui_synclist * gui_list, int item_number) 312void gui_synclist_select_item(struct gui_synclist * gui_list, int item_number)
314{ 313{
315 int i; 314 int i;
316 if( item_number > gui_list->nb_items-1 || item_number < 0 ) 315 if (item_number >= gui_list->nb_items || item_number < 0)
317 return; 316 return;
318 gui_list->selected_item = item_number; 317 gui_list->selected_item = item_number;
319 FOR_NB_SCREENS(i) 318 FOR_NB_SCREENS(i)
@@ -334,29 +333,22 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list,
334 if (new_selection >= gui_list->nb_items) 333 if (new_selection >= gui_list->nb_items)
335 { 334 {
336 gui_list->selected_item = gui_list->limit_scroll ? 335 gui_list->selected_item = gui_list->limit_scroll ?
337 gui_list->nb_items - gui_list->selected_size : 0; 336 gui_list->nb_items - gui_list->selected_size : 0;
338 } 337 }
339 else if (new_selection < 0) 338 else if (new_selection < 0)
340 { 339 {
341 gui_list->selected_item = gui_list->limit_scroll ? 340 gui_list->selected_item = gui_list->limit_scroll ?
342 0 : gui_list->nb_items - gui_list->selected_size; 341 0 : gui_list->nb_items - gui_list->selected_size;
343 } 342 }
344 else if (gui_list->show_selection_marker == false) 343 else if (gui_list->show_selection_marker == false)
345 { 344 {
346 int i, nb_lines, screen_top; 345 int i, nb_lines, screen_top;
347 FOR_NB_SCREENS(i) 346 FOR_NB_SCREENS(i)
348 { 347 {
349 struct viewport vp = *gui_list->parent[i]; 348 nb_lines = list_get_nb_lines(gui_list, i);
350#ifdef HAVE_LCD_BITMAP
351 if (list_display_title(gui_list, i))
352 vp.height -= font_get(gui_list->parent[i]->font)->height;
353#endif
354 nb_lines = viewport_get_nb_lines(&vp);
355 if (offset > 0) 349 if (offset > 0)
356 { 350 {
357 screen_top = gui_list->nb_items-nb_lines; 351 screen_top = MAX(0, gui_list->nb_items - nb_lines);
358 if (screen_top < 0)
359 screen_top = 0;
360 gui_list->start_item[i] = MIN(screen_top, gui_list->start_item[i] + 352 gui_list->start_item[i] = MIN(screen_top, gui_list->start_item[i] +
361 gui_list->selected_size); 353 gui_list->selected_size);
362 gui_list->selected_item = gui_list->start_item[i]; 354 gui_list->selected_item = gui_list->start_item[i];
@@ -382,7 +374,7 @@ void gui_synclist_add_item(struct gui_synclist * gui_list)
382{ 374{
383 gui_list->nb_items++; 375 gui_list->nb_items++;
384 /* if only one item in the list, select it */ 376 /* if only one item in the list, select it */
385 if(gui_list->nb_items == 1) 377 if (gui_list->nb_items == 1)
386 gui_list->selected_item = 0; 378 gui_list->selected_item = 0;
387} 379}
388 380
@@ -392,7 +384,7 @@ void gui_synclist_add_item(struct gui_synclist * gui_list)
392 */ 384 */
393void gui_synclist_del_item(struct gui_synclist * gui_list) 385void gui_synclist_del_item(struct gui_synclist * gui_list)
394{ 386{
395 if(gui_list->nb_items > 0) 387 if (gui_list->nb_items > 0)
396 { 388 {
397 if (gui_list->selected_item == gui_list->nb_items-1) 389 if (gui_list->selected_item == gui_list->nb_items-1)
398 gui_list->selected_item--; 390 gui_list->selected_item--;
@@ -404,7 +396,7 @@ void gui_synclist_del_item(struct gui_synclist * gui_list)
404#ifdef HAVE_LCD_BITMAP 396#ifdef HAVE_LCD_BITMAP
405void gui_list_screen_scroll_step(int ofs) 397void gui_list_screen_scroll_step(int ofs)
406{ 398{
407 offset_step = ofs; 399 offset_step = ofs;
408} 400}
409 401
410void gui_list_screen_scroll_out_of_view(bool enable) 402void gui_list_screen_scroll_out_of_view(bool enable)
@@ -413,16 +405,17 @@ void gui_list_screen_scroll_out_of_view(bool enable)
413} 405}
414#endif /* HAVE_LCD_BITMAP */ 406#endif /* HAVE_LCD_BITMAP */
415 407
416/* 408/*
417 * Set the title and title icon of the list. Setting title to NULL disables 409 * Set the title and title icon of the list. Setting title to NULL disables
418 * both the title and icon. Use NOICON if there is no icon. 410 * both the title and icon. Use NOICON if there is no icon.
419 */ 411 */
420void gui_synclist_set_title(struct gui_synclist * gui_list, 412void gui_synclist_set_title(struct gui_synclist * gui_list,
421 char * title, enum themable_icons icon) 413 char * title, enum themable_icons icon)
422{ 414{
423 gui_list->title = title; 415 gui_list->title = title;
424 gui_list->title_icon = icon; 416 gui_list->title_icon = icon;
425 if (title) { 417 if (title)
418 {
426#ifdef HAVE_LCD_BITMAP 419#ifdef HAVE_LCD_BITMAP
427 int i; 420 int i;
428 FOR_NB_SCREENS(i) 421 FOR_NB_SCREENS(i)
@@ -430,12 +423,13 @@ void gui_synclist_set_title(struct gui_synclist * gui_list,
430#else 423#else
431 gui_list->title_width = strlen(title); 424 gui_list->title_width = strlen(title);
432#endif 425#endif
433 } else { 426 }
427 else
428 {
434 gui_list->title_width = 0; 429 gui_list->title_width = 0;
435 } 430 }
436} 431}
437 432
438
439void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items) 433void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
440{ 434{
441#ifdef HAVE_LCD_BITMAP 435#ifdef HAVE_LCD_BITMAP
@@ -464,38 +458,30 @@ void gui_synclist_set_icon_callback(struct gui_synclist * lists,
464} 458}
465 459
466void gui_synclist_set_voice_callback(struct gui_synclist * lists, 460void gui_synclist_set_voice_callback(struct gui_synclist * lists,
467 list_speak_item voice_callback) 461 list_speak_item voice_callback)
468{ 462{
469 lists->callback_speak_item = voice_callback; 463 lists->callback_speak_item = voice_callback;
470} 464}
471 465
472#ifdef HAVE_LCD_COLOR 466#ifdef HAVE_LCD_COLOR
473void gui_synclist_set_color_callback(struct gui_synclist * lists, 467void gui_synclist_set_color_callback(struct gui_synclist * lists,
474 list_get_color color_callback) 468 list_get_color color_callback)
475{ 469{
476 lists->callback_get_item_color = color_callback; 470 lists->callback_get_item_color = color_callback;
477} 471}
478#endif 472#endif
479 473
480static void gui_synclist_select_next_page(struct gui_synclist * lists, 474static void gui_synclist_select_next_page(struct gui_synclist * lists,
481 enum screen_type screen) 475 enum screen_type screen)
482{ 476{
483 int nb_lines = viewport_get_nb_lines(lists->parent[screen]); 477 int nb_lines = list_get_nb_lines(lists, screen);
484#ifdef HAVE_LCD_BITMAP
485 if(list_display_title(lists, screen))
486 nb_lines--;
487#endif
488 gui_list_select_at_offset(lists, nb_lines); 478 gui_list_select_at_offset(lists, nb_lines);
489} 479}
490 480
491static void gui_synclist_select_previous_page(struct gui_synclist * lists, 481static void gui_synclist_select_previous_page(struct gui_synclist * lists,
492 enum screen_type screen) 482 enum screen_type screen)
493{ 483{
494 int nb_lines = viewport_get_nb_lines(lists->parent[screen]); 484 int nb_lines = list_get_nb_lines(lists, screen);
495#ifdef HAVE_LCD_BITMAP
496 if(list_display_title(lists, screen))
497 nb_lines--;
498#endif
499 gui_list_select_at_offset(lists, -nb_lines); 485 gui_list_select_at_offset(lists, -nb_lines);
500} 486}
501 487
@@ -518,7 +504,7 @@ static void gui_synclist_scroll_right(struct gui_synclist * lists)
518 /* FIXME: This is a fake right boundry limiter. there should be some 504 /* FIXME: This is a fake right boundry limiter. there should be some
519 * callback function to find the longest item on the list in pixels, 505 * callback function to find the longest item on the list in pixels,
520 * to stop the list from scrolling past that point */ 506 * to stop the list from scrolling past that point */
521 lists->offset_position[i]+=offset_step; 507 lists->offset_position[i] += offset_step;
522 if (lists->offset_position[i] > 1000) 508 if (lists->offset_position[i] > 1000)
523 lists->offset_position[i] = 1000; 509 lists->offset_position[i] = 1000;
524 } 510 }
@@ -533,7 +519,7 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists)
533 int i; 519 int i;
534 FOR_NB_SCREENS(i) 520 FOR_NB_SCREENS(i)
535 { 521 {
536 lists->offset_position[i]-=offset_step; 522 lists->offset_position[i] -= offset_step;
537 if (lists->offset_position[i] < 0) 523 if (lists->offset_position[i] < 0)
538 lists->offset_position[i] = 0; 524 lists->offset_position[i] = 0;
539 } 525 }
@@ -612,7 +598,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
612 } 598 }
613 } 599 }
614#endif 600#endif
615 601
616#if defined(HAVE_TOUCHSCREEN) 602#if defined(HAVE_TOUCHSCREEN)
617 if (action == ACTION_TOUCHSCREEN) 603 if (action == ACTION_TOUCHSCREEN)
618 action = *actionptr = gui_synclist_do_touchscreen(lists); 604 action = *actionptr = gui_synclist_do_touchscreen(lists);
@@ -641,10 +627,10 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
641 case ACTION_REDRAW: 627 case ACTION_REDRAW:
642 gui_synclist_draw(lists); 628 gui_synclist_draw(lists);
643 return true; 629 return true;
644 630
645#ifdef HAVE_VOLUME_IN_LIST 631#ifdef HAVE_VOLUME_IN_LIST
646 case ACTION_LIST_VOLUP: 632 case ACTION_LIST_VOLUP:
647 global_settings.volume += 2; 633 global_settings.volume += 2;
648 /* up two because the falthrough brings it down one */ 634 /* up two because the falthrough brings it down one */
649 case ACTION_LIST_VOLDOWN: 635 case ACTION_LIST_VOLDOWN:
650 global_settings.volume--; 636 global_settings.volume--;
@@ -653,21 +639,21 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
653#endif 639#endif
654 case ACTION_STD_PREV: 640 case ACTION_STD_PREV:
655 case ACTION_STD_PREVREPEAT: 641 case ACTION_STD_PREVREPEAT:
656 gui_list_select_at_offset(lists, -next_item_modifier); 642 gui_list_select_at_offset(lists, -next_item_modifier);
657#ifndef HAVE_WHEEL_ACCELERATION 643#ifndef HAVE_WHEEL_ACCELERATION
658 if (button_queue_count() < FRAMEDROP_TRIGGER) 644 if (button_queue_count() < FRAMEDROP_TRIGGER)
659#endif 645#endif
660 gui_synclist_draw(lists); 646 gui_synclist_draw(lists);
661 _gui_synclist_speak_item(lists, 647 _gui_synclist_speak_item(lists,
662 action == ACTION_STD_PREVREPEAT 648 action == ACTION_STD_PREVREPEAT
663 || next_item_modifier >1); 649 || next_item_modifier > 1);
664 yield(); 650 yield();
665 *actionptr = ACTION_STD_PREV; 651 *actionptr = ACTION_STD_PREV;
666 return true; 652 return true;
667 653
668 case ACTION_STD_NEXT: 654 case ACTION_STD_NEXT:
669 case ACTION_STD_NEXTREPEAT: 655 case ACTION_STD_NEXTREPEAT:
670 gui_list_select_at_offset(lists, next_item_modifier); 656 gui_list_select_at_offset(lists, next_item_modifier);
671#ifndef HAVE_WHEEL_ACCELERATION 657#ifndef HAVE_WHEEL_ACCELERATION
672 if (button_queue_count() < FRAMEDROP_TRIGGER) 658 if (button_queue_count() < FRAMEDROP_TRIGGER)
673#endif 659#endif
@@ -783,12 +769,8 @@ bool list_do_action(int context, int timeout,
783bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, 769bool gui_synclist_item_is_onscreen(struct gui_synclist *lists,
784 enum screen_type screen, int item) 770 enum screen_type screen, int item)
785{ 771{
786 struct viewport vp = *lists->parent[screen]; 772 int nb_lines = list_get_nb_lines(lists, screen);
787#ifdef HAVE_LCD_BITMAP 773 return (unsigned)(item - lists->start_item[screen]) < (unsigned) nb_lines;
788 if (list_display_title(lists, screen))
789 vp.height -= font_get(lists->parent[screen]->font)->height;
790#endif
791 return item <= (lists->start_item[screen] + viewport_get_nb_lines(&vp));
792} 774}
793 775
794/* Simple use list implementation */ 776/* Simple use list implementation */
@@ -810,7 +792,8 @@ int simplelist_get_line_count(void)
810 return simplelist_line_count; 792 return simplelist_line_count;
811} 793}
812/* add/edit a line in the list. 794/* add/edit a line in the list.
813 if line_number > number of lines shown it adds the line, else it edits the line */ 795 if line_number > number of lines shown it adds the line,
796 else it edits the line */
814void simplelist_addline(int line_number, const char *fmt, ...) 797void simplelist_addline(int line_number, const char *fmt, ...)
815{ 798{
816 va_list ap; 799 va_list ap;
@@ -819,8 +802,8 @@ void simplelist_addline(int line_number, const char *fmt, ...)
819 { 802 {
820 if (simplelist_line_count < SIMPLELIST_MAX_LINES) 803 if (simplelist_line_count < SIMPLELIST_MAX_LINES)
821 line_number = simplelist_line_count++; 804 line_number = simplelist_line_count++;
822 else 805 else
823 return; 806 return;
824 } 807 }
825 va_start(ap, fmt); 808 va_start(ap, fmt);
826 vsnprintf(simplelist_text[line_number], SIMPLELIST_MAX_LINELENGTH, fmt, ap); 809 vsnprintf(simplelist_text[line_number], SIMPLELIST_MAX_LINELENGTH, fmt, ap);
@@ -849,30 +832,31 @@ bool simplelist_show_list(struct simplelist_info *info)
849 getname = simplelist_static_getname; 832 getname = simplelist_static_getname;
850 gui_synclist_init(&lists, getname, info->callback_data, 833 gui_synclist_init(&lists, getname, info->callback_data,
851 info->scroll_all, info->selection_size, NULL); 834 info->scroll_all, info->selection_size, NULL);
852 835
853 if (info->title) 836 if (info->title)
854 gui_synclist_set_title(&lists, info->title, NOICON); 837 gui_synclist_set_title(&lists, info->title, NOICON);
855 if (info->get_icon) 838 if (info->get_icon)
856 gui_synclist_set_icon_callback(&lists, info->get_icon); 839 gui_synclist_set_icon_callback(&lists, info->get_icon);
857 if (info->get_talk) 840 if (info->get_talk)
858 gui_synclist_set_voice_callback(&lists, info->get_talk); 841 gui_synclist_set_voice_callback(&lists, info->get_talk);
859 842
860 if (info->hide_selection) 843 if (info->hide_selection)
861 { 844 {
862 gui_synclist_hide_selection_marker(&lists, true); 845 gui_synclist_hide_selection_marker(&lists, true);
863 wrap = LIST_WRAP_OFF; 846 wrap = LIST_WRAP_OFF;
864 } 847 }
865 848
866 if (info->action_callback) 849 if (info->action_callback)
867 info->action_callback(ACTION_REDRAW, &lists); 850 info->action_callback(ACTION_REDRAW, &lists);
868 851
869 if (info->get_name == NULL) 852 if (info->get_name == NULL)
870 gui_synclist_set_nb_items(&lists, simplelist_line_count*info->selection_size); 853 gui_synclist_set_nb_items(&lists,
854 simplelist_line_count*info->selection_size);
871 else 855 else
872 gui_synclist_set_nb_items(&lists, info->count*info->selection_size); 856 gui_synclist_set_nb_items(&lists, info->count*info->selection_size);
873 857
874 gui_synclist_select_item(&lists, info->selection); 858 gui_synclist_select_item(&lists, info->selection);
875 859
876 gui_synclist_draw(&lists); 860 gui_synclist_draw(&lists);
877 gui_synclist_speak_item(&lists); 861 gui_synclist_speak_item(&lists);
878 862
@@ -895,7 +879,7 @@ bool simplelist_show_list(struct simplelist_info *info)
895 info->selection = gui_synclist_get_sel_pos(&lists); 879 info->selection = gui_synclist_get_sel_pos(&lists);
896 break; 880 break;
897 } 881 }
898 882
899 if (info->get_name == NULL) 883 if (info->get_name == NULL)
900 gui_synclist_set_nb_items(&lists, 884 gui_synclist_set_nb_items(&lists,
901 simplelist_line_count*info->selection_size); 885 simplelist_line_count*info->selection_size);