1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Kevin Ferrare
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
33 #include "screen_access.h"
35 #include "scrollbar.h"
41 #include "appevents.h"
43 #ifdef HAVE_LCD_CHARCELLS
44 #define SCROLL_LIMIT 1
46 #define SCROLL_LIMIT (nb_lines<3?1:2)
49 /* The minimum number of pending button events in queue before starting
50 * to limit list drawing interval.
52 #define FRAMEDROP_TRIGGER 6
54 #ifdef HAVE_LCD_BITMAP
55 static int offset_step
= 16; /* pixels per screen scroll step */
56 /* should lines scroll out of the screen */
57 static bool offset_out_of_view
= false;
60 static void gui_list_select_at_offset(struct gui_synclist
* gui_list
,
62 void list_draw(struct screen
*display
, struct gui_synclist
*list
);
64 #ifdef HAVE_LCD_BITMAP
65 static int list_need_reinit
= false;
66 static struct viewport parent
[NB_SCREENS
];
68 static void list_force_reinit(void *param
)
71 list_need_reinit
= true;
76 add_event(GUI_EVENT_THEME_CHANGED
, false, list_force_reinit
);
79 static void list_init_viewports(struct gui_synclist
*list
)
86 parent_used
= (*list
->parent
!= &parent
[SCREEN_MAIN
]);
92 list
->parent
[i
] = &parent
[i
];
93 viewport_set_defaults(&parent
[i
], i
);
95 if (screens
[i
].has_buttonbar
)
96 list
->parent
[i
]->height
-= BUTTONBAR_HEIGHT
;
100 list_need_reinit
= false;
103 #define list_init_viewports(a)
106 #ifdef HAVE_LCD_BITMAP
107 bool list_display_title(struct gui_synclist
*list
, enum screen_type screen
)
109 return list
->title
!= NULL
&&
110 viewport_get_nb_lines(list
->parent
[screen
]) > 2;
113 static int list_get_nb_lines(struct gui_synclist
*list
, enum screen_type screen
)
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
);
121 static struct viewport parent
[NB_SCREENS
] =
131 #define list_display_title(l, i) false
132 #define list_get_nb_lines(list, screen) \
133 viewport_get_nb_lines((list)->parent[(screen)]);
137 * Initializes a scrolling list
138 * - gui_list : the list structure to initialize
139 * - callback_get_item_name : pointer to a function that associates a label
140 * to a given item number
141 * - data : extra data passed to the list callback
144 * - parent : the parent viewports to use. NULL means the full screen minus
145 * statusbar if enabled. NOTE: new screens should NOT set this to NULL.
147 void gui_synclist_init(struct gui_synclist
* gui_list
,
148 list_get_name callback_get_item_name
,
151 int selected_size
, struct viewport list_parent
[NB_SCREENS
]
155 gui_list
->callback_get_item_icon
= NULL
;
156 gui_list
->callback_get_item_name
= callback_get_item_name
;
157 gui_list
->callback_speak_item
= NULL
;
158 gui_list
->nb_items
= 0;
159 gui_list
->selected_item
= 0;
162 gui_list
->start_item
[i
] = 0;
163 gui_list
->last_displayed_start_item
[i
] = -1 ;
164 #ifdef HAVE_LCD_BITMAP
165 gui_list
->offset_position
[i
] = 0;
168 gui_list
->parent
[i
] = &list_parent
[i
];
170 gui_list
->parent
[i
] = &parent
[i
];
172 list_init_viewports(gui_list
);
173 gui_list
->limit_scroll
= false;
174 gui_list
->data
= data
;
175 gui_list
->scroll_all
= scroll_all
;
176 gui_list
->selected_size
= selected_size
;
177 gui_list
->title
= NULL
;
178 gui_list
->title_width
= 0;
179 gui_list
->title_icon
= Icon_NOICON
;
181 gui_list
->scheduled_talk_tick
= gui_list
->last_talked_tick
= 0;
182 gui_list
->show_selection_marker
= true;
183 gui_list
->last_displayed_selected_item
= -1;
185 #ifdef HAVE_LCD_COLOR
186 gui_list
->title_color
= -1;
187 gui_list
->callback_get_item_color
= NULL
;
191 /* this toggles the selection bar or cursor */
192 void gui_synclist_hide_selection_marker(struct gui_synclist
* lists
, bool hide
)
194 lists
->show_selection_marker
= !hide
;
198 #ifdef HAVE_LCD_BITMAP
199 int gui_list_get_item_offset(struct gui_synclist
* gui_list
,
202 struct screen
* display
,
207 if (offset_out_of_view
)
209 item_offset
= gui_list
->offset_position
[display
->screen_type
];
213 /* if text is smaller than view */
214 if (item_width
<= vp
->width
- text_pos
)
218 /* if text got out of view */
219 else if (gui_list
->offset_position
[display
->screen_type
] >
220 item_width
- (vp
->width
- text_pos
))
222 item_offset
= item_width
- (vp
->width
- text_pos
);
225 item_offset
= gui_list
->offset_position
[display
->screen_type
];
233 * Force a full screen update.
235 void gui_synclist_draw(struct gui_synclist
*gui_list
)
238 #ifdef HAVE_LCD_BITMAP
239 if (list_need_reinit
)
241 list_init_viewports(gui_list
);
242 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
247 list_draw(&screens
[i
], gui_list
);
251 /* sets up the list so the selection is shown correctly on the screen */
252 static void gui_list_put_selection_on_screen(struct gui_synclist
* gui_list
,
253 enum screen_type screen
)
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
];
258 int difference
= gui_list
->selected_item
- gui_list
->start_item
[screen
];
260 /* edge case, selected last item */
261 if (gui_list
->selected_item
== gui_list
->nb_items
-1)
263 new_start_item
= bottom
;
265 /* selected first item */
266 else if (gui_list
->selected_item
== 0)
270 else if (difference
< SCROLL_LIMIT
) /* list moved up */
272 if (global_settings
.scroll_paginated
)
274 if (new_start_item
> gui_list
->selected_item
)
275 new_start_item
= (gui_list
->selected_item
/nb_lines
)*nb_lines
;
279 new_start_item
= gui_list
->selected_item
- SCROLL_LIMIT
+ 1;
282 else if (difference
> nb_lines
- SCROLL_LIMIT
) /* list moved down */
284 /* always move the screen if selection isnt "visible" */
285 if (gui_list
->show_selection_marker
== false)
287 new_start_item
+= 2*gui_list
->selected_size
;
289 else if (global_settings
.scroll_paginated
)
291 if (new_start_item
+ nb_lines
<= gui_list
->selected_item
)
292 new_start_item
= (gui_list
->selected_item
/nb_lines
)*nb_lines
;
296 new_start_item
= gui_list
->selected_item
+ SCROLL_LIMIT
- nb_lines
;
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
;
304 gui_list
->start_item
[screen
] = new_start_item
;
308 * Selects an item in the list
309 * - gui_list : the list structure
310 * - item_number : the number of the item which will be selected
312 void gui_synclist_select_item(struct gui_synclist
* gui_list
, int item_number
)
315 if (item_number
>= gui_list
->nb_items
|| item_number
< 0)
317 gui_list
->selected_item
= item_number
;
319 gui_list_put_selection_on_screen(gui_list
, i
);
322 static void gui_list_select_at_offset(struct gui_synclist
* gui_list
,
326 if (gui_list
->selected_size
> 1)
328 offset
*= gui_list
->selected_size
;
329 /* always select the first item of multi-line lists */
330 offset
-= offset
%gui_list
->selected_size
;
332 new_selection
= gui_list
->selected_item
+ offset
;
333 if (new_selection
>= gui_list
->nb_items
)
335 gui_list
->selected_item
= gui_list
->limit_scroll
?
336 gui_list
->nb_items
- gui_list
->selected_size
: 0;
338 else if (new_selection
< 0)
340 gui_list
->selected_item
= gui_list
->limit_scroll
?
341 0 : gui_list
->nb_items
- gui_list
->selected_size
;
343 else if (gui_list
->show_selection_marker
== false)
345 int i
, nb_lines
, screen_top
;
348 nb_lines
= list_get_nb_lines(gui_list
, i
);
351 screen_top
= MAX(0, gui_list
->nb_items
- nb_lines
);
352 gui_list
->start_item
[i
] = MIN(screen_top
, gui_list
->start_item
[i
] +
353 gui_list
->selected_size
);
354 gui_list
->selected_item
= gui_list
->start_item
[i
];
358 gui_list
->start_item
[i
] = MAX(0, gui_list
->start_item
[i
] -
359 gui_list
->selected_size
);
360 gui_list
->selected_item
= gui_list
->start_item
[i
] + nb_lines
;
365 else gui_list
->selected_item
+= offset
;
366 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
370 * Adds an item to the list (the callback will be asked for one more item)
371 * - gui_list : the list structure
373 void gui_synclist_add_item(struct gui_synclist
* gui_list
)
375 gui_list
->nb_items
++;
376 /* if only one item in the list, select it */
377 if (gui_list
->nb_items
== 1)
378 gui_list
->selected_item
= 0;
382 * Removes an item to the list (the callback will be asked for one less item)
383 * - gui_list : the list structure
385 void gui_synclist_del_item(struct gui_synclist
* gui_list
)
387 if (gui_list
->nb_items
> 0)
389 if (gui_list
->selected_item
== gui_list
->nb_items
-1)
390 gui_list
->selected_item
--;
391 gui_list
->nb_items
--;
392 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
396 #ifdef HAVE_LCD_BITMAP
397 void gui_list_screen_scroll_step(int ofs
)
402 void gui_list_screen_scroll_out_of_view(bool enable
)
404 offset_out_of_view
= enable
;
406 #endif /* HAVE_LCD_BITMAP */
409 * Set the title and title icon of the list. Setting title to NULL disables
410 * both the title and icon. Use NOICON if there is no icon.
412 void gui_synclist_set_title(struct gui_synclist
* gui_list
,
413 char * title
, enum themable_icons icon
)
415 gui_list
->title
= title
;
416 gui_list
->title_icon
= icon
;
419 #ifdef HAVE_LCD_BITMAP
422 screens
[i
].getstringsize(title
, &gui_list
->title_width
, NULL
);
424 gui_list
->title_width
= strlen(title
);
429 gui_list
->title_width
= 0;
433 void gui_synclist_set_nb_items(struct gui_synclist
* lists
, int nb_items
)
435 #ifdef HAVE_LCD_BITMAP
438 lists
->nb_items
= nb_items
;
439 #ifdef HAVE_LCD_BITMAP
442 lists
->offset_position
[i
] = 0;
446 int gui_synclist_get_nb_items(struct gui_synclist
* lists
)
448 return lists
->nb_items
;
450 int gui_synclist_get_sel_pos(struct gui_synclist
* lists
)
452 return lists
->selected_item
;
454 void gui_synclist_set_icon_callback(struct gui_synclist
* lists
,
455 list_get_icon icon_callback
)
457 lists
->callback_get_item_icon
= icon_callback
;
460 void gui_synclist_set_voice_callback(struct gui_synclist
* lists
,
461 list_speak_item voice_callback
)
463 lists
->callback_speak_item
= voice_callback
;
466 #ifdef HAVE_LCD_COLOR
467 void gui_synclist_set_color_callback(struct gui_synclist
* lists
,
468 list_get_color color_callback
)
470 lists
->callback_get_item_color
= color_callback
;
474 static void gui_synclist_select_next_page(struct gui_synclist
* lists
,
475 enum screen_type screen
)
477 int nb_lines
= list_get_nb_lines(lists
, screen
);
478 gui_list_select_at_offset(lists
, nb_lines
);
481 static void gui_synclist_select_previous_page(struct gui_synclist
* lists
,
482 enum screen_type screen
)
484 int nb_lines
= list_get_nb_lines(lists
, screen
);
485 gui_list_select_at_offset(lists
, -nb_lines
);
488 void gui_synclist_limit_scroll(struct gui_synclist
* lists
, bool scroll
)
490 lists
->limit_scroll
= scroll
;
493 #ifdef HAVE_LCD_BITMAP
495 * Makes all the item in the list scroll by one step to the right.
496 * Should stop increasing the value when reaching the widest item value
499 static void gui_synclist_scroll_right(struct gui_synclist
* lists
)
504 /* FIXME: This is a fake right boundry limiter. there should be some
505 * callback function to find the longest item on the list in pixels,
506 * to stop the list from scrolling past that point */
507 lists
->offset_position
[i
] += offset_step
;
508 if (lists
->offset_position
[i
] > 1000)
509 lists
->offset_position
[i
] = 1000;
514 * Makes all the item in the list scroll by one step to the left.
515 * stops at starting position.
517 static void gui_synclist_scroll_left(struct gui_synclist
* lists
)
522 lists
->offset_position
[i
] -= offset_step
;
523 if (lists
->offset_position
[i
] < 0)
524 lists
->offset_position
[i
] = 0;
527 #endif /* HAVE_LCD_BITMAP */
529 static void _gui_synclist_speak_item(struct gui_synclist
*lists
, bool repeating
)
531 list_speak_item
*cb
= lists
->callback_speak_item
;
532 if(cb
&& gui_synclist_get_nb_items(lists
) != 0)
534 int sel
= gui_synclist_get_sel_pos(lists
);
536 /* If we got a repeating key action, or we have just very
537 recently started talking, then we want to stay silent for a
538 while until things settle. Likewise if we already had a
539 pending scheduled announcement not yet due: we need to
542 || (lists
->scheduled_talk_tick
543 && TIME_BEFORE(current_tick
, lists
->scheduled_talk_tick
))
544 || (lists
->last_talked_tick
545 && TIME_BEFORE(current_tick
, lists
->last_talked_tick
+HZ
/4)))
547 lists
->scheduled_talk_tick
= current_tick
+HZ
/4;
550 lists
->scheduled_talk_tick
= 0; /* work done */
551 cb(sel
, lists
->data
);
552 lists
->last_talked_tick
= current_tick
;
556 void gui_synclist_speak_item(struct gui_synclist
* lists
)
557 /* The list user should call this to speak the first item on entering
558 the list, and whenever the list is updated. */
560 if(gui_synclist_get_nb_items(lists
) == 0 && global_settings
.talk_menu
)
561 talk_id(VOICE_EMPTY_LIST
, true);
562 else _gui_synclist_speak_item(lists
, false);
565 bool gui_synclist_do_button(struct gui_synclist
* lists
,
566 int *actionptr
, enum list_wrap wrap
)
568 int action
= *actionptr
;
569 #ifdef HAVE_LCD_BITMAP
570 static bool scrolling_left
= false;
573 #ifdef HAVE_WHEEL_ACCELERATION
574 int next_item_modifier
= button_apply_acceleration(get_action_data());
576 static int next_item_modifier
= 1;
577 static int last_accel_tick
= 0;
579 if (global_settings
.list_accel_start_delay
)
581 int start_delay
= global_settings
.list_accel_start_delay
* (HZ
/2);
582 int accel_wait
= global_settings
.list_accel_wait
* HZ
/2;
584 if (get_action_statuscode(NULL
)&ACTION_REPEAT
)
586 if (!last_accel_tick
)
587 last_accel_tick
= current_tick
+ start_delay
;
588 else if (TIME_AFTER(current_tick
, last_accel_tick
+ accel_wait
))
590 last_accel_tick
= current_tick
;
591 next_item_modifier
++;
594 else if (last_accel_tick
)
596 next_item_modifier
= 1;
602 #if defined(HAVE_TOUCHSCREEN)
603 if (action
== ACTION_TOUCHSCREEN
)
604 action
= *actionptr
= gui_synclist_do_touchscreen(lists
);
610 gui_synclist_limit_scroll(lists
, false);
613 gui_synclist_limit_scroll(lists
, true);
615 case LIST_WRAP_UNLESS_HELD
:
616 if (action
== ACTION_STD_PREVREPEAT
||
617 action
== ACTION_STD_NEXTREPEAT
||
618 action
== ACTION_LISTTREE_PGUP
||
619 action
== ACTION_LISTTREE_PGDOWN
)
620 gui_synclist_limit_scroll(lists
, true);
621 else gui_synclist_limit_scroll(lists
, false);
628 gui_synclist_draw(lists
);
631 #ifdef HAVE_VOLUME_IN_LIST
632 case ACTION_LIST_VOLUP
:
633 global_settings
.volume
+= 2;
634 /* up two because the falthrough brings it down one */
635 case ACTION_LIST_VOLDOWN
:
636 global_settings
.volume
--;
640 case ACTION_STD_PREV
:
641 case ACTION_STD_PREVREPEAT
:
642 gui_list_select_at_offset(lists
, -next_item_modifier
);
643 #ifndef HAVE_WHEEL_ACCELERATION
644 if (button_queue_count() < FRAMEDROP_TRIGGER
)
646 gui_synclist_draw(lists
);
647 _gui_synclist_speak_item(lists
,
648 action
== ACTION_STD_PREVREPEAT
649 || next_item_modifier
> 1);
651 *actionptr
= ACTION_STD_PREV
;
654 case ACTION_STD_NEXT
:
655 case ACTION_STD_NEXTREPEAT
:
656 gui_list_select_at_offset(lists
, next_item_modifier
);
657 #ifndef HAVE_WHEEL_ACCELERATION
658 if (button_queue_count() < FRAMEDROP_TRIGGER
)
660 gui_synclist_draw(lists
);
661 _gui_synclist_speak_item(lists
,
662 action
== ACTION_STD_NEXTREPEAT
663 || next_item_modifier
>1);
665 *actionptr
= ACTION_STD_NEXT
;
668 #ifdef HAVE_LCD_BITMAP
669 case ACTION_TREE_PGRIGHT
:
670 gui_synclist_scroll_right(lists
);
671 gui_synclist_draw(lists
);
673 case ACTION_TREE_ROOT_INIT
:
674 /* After this button press ACTION_TREE_PGLEFT is allowed
675 to skip to root. ACTION_TREE_ROOT_INIT must be defined in the
676 keymaps as a repeated button press (the same as the repeated
677 ACTION_TREE_PGLEFT) with the pre condition being the non-repeated
679 if (lists
->offset_position
[0] == 0)
681 scrolling_left
= false;
682 *actionptr
= ACTION_STD_CANCEL
;
685 *actionptr
= ACTION_TREE_PGLEFT
;
686 case ACTION_TREE_PGLEFT
:
687 if(!scrolling_left
&& (lists
->offset_position
[0] == 0))
689 *actionptr
= ACTION_STD_CANCEL
;
692 gui_synclist_scroll_left(lists
);
693 gui_synclist_draw(lists
);
694 scrolling_left
= true; /* stop ACTION_TREE_PAGE_LEFT
698 /* for pgup / pgdown, we are obliged to have a different behaviour depending
699 * on the screen for which the user pressed the key since for example, remote
700 * and main screen doesn't have the same number of lines */
701 case ACTION_LISTTREE_PGUP
:
704 #ifdef HAVE_REMOTE_LCD
705 get_action_statuscode(NULL
)&ACTION_REMOTE
?
709 gui_synclist_select_previous_page(lists
, screen
);
710 gui_synclist_draw(lists
);
711 _gui_synclist_speak_item(lists
, false);
713 *actionptr
= ACTION_STD_NEXT
;
717 case ACTION_LISTTREE_PGDOWN
:
720 #ifdef HAVE_REMOTE_LCD
721 get_action_statuscode(NULL
)&ACTION_REMOTE
?
725 gui_synclist_select_next_page(lists
, screen
);
726 gui_synclist_draw(lists
);
727 _gui_synclist_speak_item(lists
, false);
729 *actionptr
= ACTION_STD_PREV
;
733 if(lists
->scheduled_talk_tick
734 && TIME_AFTER(current_tick
, lists
->scheduled_talk_tick
))
735 /* scheduled postponed item announcement is due */
736 _gui_synclist_speak_item(lists
, false);
740 int list_do_action_timeout(struct gui_synclist
*lists
, int timeout
)
741 /* Returns the lowest of timeout or the delay until a postponed
742 scheduled announcement is due (if any). */
744 if(lists
->scheduled_talk_tick
)
746 long delay
= lists
->scheduled_talk_tick
-current_tick
+1;
747 /* +1 because the trigger condition uses TIME_AFTER(), which
748 is implemented as strictly greater than. */
751 if(timeout
> delay
|| timeout
== TIMEOUT_BLOCK
)
757 bool list_do_action(int context
, int timeout
,
758 struct gui_synclist
*lists
, int *action
,
760 /* Combines the get_action() (with possibly overridden timeout) and
761 gui_synclist_do_button() calls. Returns the list action from
762 do_button, and places the action from get_action in *action. */
764 timeout
= list_do_action_timeout(lists
, timeout
);
765 *action
= get_action(context
, timeout
);
766 return gui_synclist_do_button(lists
, action
, wrap
);
769 bool gui_synclist_item_is_onscreen(struct gui_synclist
*lists
,
770 enum screen_type screen
, int item
)
772 int nb_lines
= list_get_nb_lines(lists
, screen
);
773 return (unsigned)(item
- lists
->start_item
[screen
]) < (unsigned) nb_lines
;
776 /* Simple use list implementation */
777 static int simplelist_line_count
= 0;
778 static char simplelist_text
[SIMPLELIST_MAX_LINES
][SIMPLELIST_MAX_LINELENGTH
];
779 /* set the amount of lines shown in the list */
780 void simplelist_set_line_count(int lines
)
783 simplelist_line_count
= 0;
784 else if (lines
>= SIMPLELIST_MAX_LINES
)
785 simplelist_line_count
= SIMPLELIST_MAX_LINES
;
787 simplelist_line_count
= lines
;
789 /* get the current amount of lines shown */
790 int simplelist_get_line_count(void)
792 return simplelist_line_count
;
794 /* add/edit a line in the list.
795 if line_number > number of lines shown it adds the line,
796 else it edits the line */
797 void simplelist_addline(int line_number
, const char *fmt
, ...)
801 if (line_number
> simplelist_line_count
)
803 if (simplelist_line_count
< SIMPLELIST_MAX_LINES
)
804 line_number
= simplelist_line_count
++;
809 vsnprintf(simplelist_text
[line_number
], SIMPLELIST_MAX_LINELENGTH
, fmt
, ap
);
813 static const char* simplelist_static_getname(int item
,
818 (void)data
; (void)buffer
; (void)buffer_len
;
819 return simplelist_text
[item
];
822 bool simplelist_show_list(struct simplelist_info
*info
)
824 struct gui_synclist lists
;
825 int action
, old_line_count
= simplelist_line_count
, i
;
826 const char* (*getname
)(int item
, void * data
, char *buffer
, size_t buffer_len
);
827 int wrap
= LIST_WRAP_UNLESS_HELD
;
829 getname
= info
->get_name
;
831 getname
= simplelist_static_getname
;
834 viewportmanager_theme_enable(i
, true, NULL
);
836 gui_synclist_init(&lists
, getname
, info
->callback_data
,
837 info
->scroll_all
, info
->selection_size
, NULL
);
840 gui_synclist_set_title(&lists
, info
->title
, NOICON
);
842 gui_synclist_set_icon_callback(&lists
, info
->get_icon
);
844 gui_synclist_set_voice_callback(&lists
, info
->get_talk
);
846 if (info
->hide_selection
)
848 gui_synclist_hide_selection_marker(&lists
, true);
849 wrap
= LIST_WRAP_OFF
;
852 if (info
->action_callback
)
853 info
->action_callback(ACTION_REDRAW
, &lists
);
855 if (info
->get_name
== NULL
)
856 gui_synclist_set_nb_items(&lists
,
857 simplelist_line_count
*info
->selection_size
);
859 gui_synclist_set_nb_items(&lists
, info
->count
*info
->selection_size
);
861 gui_synclist_select_item(&lists
, info
->selection
);
863 gui_synclist_draw(&lists
);
864 gui_synclist_speak_item(&lists
);
868 list_do_action(CONTEXT_STD
, info
->timeout
,
869 &lists
, &action
, wrap
);
871 /* We must yield in this case or no other thread can run */
872 if (info
->timeout
== TIMEOUT_NOBLOCK
)
875 if (info
->action_callback
)
877 bool stdok
= action
==ACTION_STD_OK
;
878 action
= info
->action_callback(action
, &lists
);
879 if (stdok
&& action
== ACTION_STD_CANCEL
)
881 /* callback asked us to exit */
882 info
->selection
= gui_synclist_get_sel_pos(&lists
);
886 if (info
->get_name
== NULL
)
887 gui_synclist_set_nb_items(&lists
,
888 simplelist_line_count
*info
->selection_size
);
890 if (action
== ACTION_STD_CANCEL
)
892 info
->selection
= -1;
895 else if ((action
== ACTION_REDRAW
) ||
896 (old_line_count
!= simplelist_line_count
))
898 if (info
->get_name
== NULL
)
900 gui_synclist_set_nb_items(&lists
,
901 simplelist_line_count
*info
->selection_size
);
903 gui_synclist_draw(&lists
);
904 old_line_count
= simplelist_line_count
;
906 else if(default_event_handler(action
) == SYS_USB_CONNECTED
)
911 viewportmanager_theme_undo(i
);
915 void simplelist_info_init(struct simplelist_info
*info
, char* title
,
916 int count
, void* data
)
920 info
->selection_size
= 1;
921 info
->hide_selection
= false;
922 info
->scroll_all
= false;
923 info
->timeout
= HZ
/10;
925 info
->action_callback
= NULL
;
926 info
->get_icon
= NULL
;
927 info
->get_name
= NULL
;
928 info
->get_talk
= NULL
;
929 info
->callback_data
= data
;