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 /* The minimum number of pending button events in queue before starting
44 * to limit list drawing interval.
46 #define FRAMEDROP_TRIGGER 6
48 #ifdef HAVE_LCD_BITMAP
49 static int offset_step
= 16; /* pixels per screen scroll step */
50 /* should lines scroll out of the screen */
51 static bool offset_out_of_view
= false;
54 static void gui_list_select_at_offset(struct gui_synclist
* gui_list
,
56 void list_draw(struct screen
*display
, struct gui_synclist
*list
);
58 #ifdef HAVE_LCD_BITMAP
59 static int list_need_reinit
= false;
60 static struct viewport parent
[NB_SCREENS
];
62 static void list_force_reinit(void *param
)
65 list_need_reinit
= true;
70 add_event(GUI_EVENT_THEME_CHANGED
, false, list_force_reinit
);
73 static void list_init_viewports(struct gui_synclist
*list
)
80 parent_used
= (*list
->parent
!= &parent
[SCREEN_MAIN
]);
86 list
->parent
[i
] = &parent
[i
];
87 viewport_set_defaults(&parent
[i
], i
);
89 if (screens
[i
].has_buttonbar
)
90 list
->parent
[i
]->height
-= BUTTONBAR_HEIGHT
;
94 list_need_reinit
= false;
97 static struct viewport parent
[NB_SCREENS
] =
108 #define list_init_viewports(a)
111 #ifdef HAVE_LCD_BITMAP
112 bool list_display_title(struct gui_synclist
*list
, enum screen_type screen
)
114 return list
->title
!= NULL
&&
115 viewport_get_nb_lines(list
->parent
[screen
]) > 2;
118 static int list_get_nb_lines(struct gui_synclist
*list
, enum screen_type screen
)
120 struct viewport vp
= *list
->parent
[screen
];
121 if (list_display_title(list
, screen
))
122 vp
.height
-= font_get(list
->parent
[screen
]->font
)->height
;
123 return viewport_get_nb_lines(&vp
);
126 #define list_display_title(l, i) false
127 #define list_get_nb_lines(list, screen) \
128 viewport_get_nb_lines((list)->parent[(screen)]);
132 * Initializes a scrolling list
133 * - gui_list : the list structure to initialize
134 * - callback_get_item_name : pointer to a function that associates a label
135 * to a given item number
136 * - data : extra data passed to the list callback
139 * - parent : the parent viewports to use. NULL means the full screen minus
140 * statusbar if enabled. NOTE: new screens should NOT set this to NULL.
142 void gui_synclist_init(struct gui_synclist
* gui_list
,
143 list_get_name callback_get_item_name
,
146 int selected_size
, struct viewport list_parent
[NB_SCREENS
]
150 gui_list
->callback_get_item_icon
= NULL
;
151 gui_list
->callback_get_item_name
= callback_get_item_name
;
152 gui_list
->callback_speak_item
= NULL
;
153 gui_list
->nb_items
= 0;
154 gui_list
->selected_item
= 0;
157 gui_list
->start_item
[i
] = 0;
158 #ifdef HAVE_LCD_BITMAP
159 gui_list
->offset_position
[i
] = 0;
162 gui_list
->parent
[i
] = &list_parent
[i
];
164 gui_list
->parent
[i
] = &parent
[i
];
166 list_init_viewports(gui_list
);
167 gui_list
->limit_scroll
= false;
168 gui_list
->data
= data
;
169 gui_list
->scroll_all
= scroll_all
;
170 gui_list
->selected_size
= selected_size
;
171 gui_list
->title
= NULL
;
172 gui_list
->title_icon
= Icon_NOICON
;
174 gui_list
->scheduled_talk_tick
= gui_list
->last_talked_tick
= 0;
175 gui_list
->show_selection_marker
= true;
177 #ifdef HAVE_LCD_COLOR
178 gui_list
->title_color
= -1;
179 gui_list
->callback_get_item_color
= NULL
;
183 /* this toggles the selection bar or cursor */
184 void gui_synclist_hide_selection_marker(struct gui_synclist
* lists
, bool hide
)
186 lists
->show_selection_marker
= !hide
;
190 #ifdef HAVE_LCD_BITMAP
191 int gui_list_get_item_offset(struct gui_synclist
* gui_list
,
194 struct screen
* display
,
199 if (offset_out_of_view
)
201 item_offset
= gui_list
->offset_position
[display
->screen_type
];
205 /* if text is smaller than view */
206 if (item_width
<= vp
->width
- text_pos
)
210 /* if text got out of view */
211 else if (gui_list
->offset_position
[display
->screen_type
] >
212 item_width
- (vp
->width
- text_pos
))
214 item_offset
= item_width
- (vp
->width
- text_pos
);
217 item_offset
= gui_list
->offset_position
[display
->screen_type
];
225 * Force a full screen update.
227 void gui_synclist_draw(struct gui_synclist
*gui_list
)
230 #ifdef HAVE_LCD_BITMAP
231 if (list_need_reinit
)
233 list_init_viewports(gui_list
);
234 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
239 list_draw(&screens
[i
], gui_list
);
243 /* sets up the list so the selection is shown correctly on the screen */
244 static void gui_list_put_selection_on_screen(struct gui_synclist
* gui_list
,
245 enum screen_type screen
)
247 int nb_lines
= list_get_nb_lines(gui_list
, screen
);
248 int bottom
= MAX(0, gui_list
->nb_items
- nb_lines
);
249 int new_start_item
= gui_list
->start_item
[screen
];
250 int difference
= gui_list
->selected_item
- gui_list
->start_item
[screen
];
251 #ifdef HAVE_LCD_CHARCELLS
252 const int scroll_limit_up
= 0;
253 const int scroll_limit_down
= 1;
255 const int scroll_limit_up
= (nb_lines
< gui_list
->selected_size
+2 ? 0:1);
256 const int scroll_limit_down
= (scroll_limit_up
+gui_list
->selected_size
);
259 if (gui_list
->show_selection_marker
== false)
261 new_start_item
= gui_list
->selected_item
;
263 else if (gui_list
->selected_size
>= nb_lines
)
265 new_start_item
= gui_list
->selected_item
;
267 else if (global_settings
.scroll_paginated
)
269 nb_lines
-= nb_lines
%gui_list
->selected_size
;
270 if (difference
< 0 || difference
>= nb_lines
)
272 new_start_item
= gui_list
->selected_item
-
273 (gui_list
->selected_item
%nb_lines
);
276 else if (difference
<= scroll_limit_up
) /* list moved up */
278 new_start_item
= gui_list
->selected_item
- scroll_limit_up
;
280 else if (difference
> nb_lines
- scroll_limit_down
) /* list moved down */
282 new_start_item
= gui_list
->selected_item
+ scroll_limit_down
- nb_lines
;
284 if (new_start_item
< 0)
285 gui_list
->start_item
[screen
] = 0;
286 else if (new_start_item
> bottom
)
287 gui_list
->start_item
[screen
] = bottom
;
289 gui_list
->start_item
[screen
] = new_start_item
;
293 * Selects an item in the list
294 * - gui_list : the list structure
295 * - item_number : the number of the item which will be selected
297 void gui_synclist_select_item(struct gui_synclist
* gui_list
, int item_number
)
300 if (item_number
>= gui_list
->nb_items
|| item_number
< 0)
302 gui_list
->selected_item
= item_number
;
304 gui_list_put_selection_on_screen(gui_list
, i
);
307 static void gui_list_select_at_offset(struct gui_synclist
* gui_list
,
311 if (gui_list
->selected_size
> 1)
313 offset
*= gui_list
->selected_size
;
316 new_selection
= gui_list
->selected_item
+ offset
;
318 if (new_selection
>= gui_list
->nb_items
)
320 gui_list
->selected_item
= gui_list
->limit_scroll
?
321 gui_list
->nb_items
- gui_list
->selected_size
: 0;
323 else if (new_selection
< 0)
325 gui_list
->selected_item
= gui_list
->limit_scroll
?
326 0 : gui_list
->nb_items
- gui_list
->selected_size
;
328 else if (gui_list
->show_selection_marker
== false)
330 int i
, nb_lines
, screen_top
;
333 nb_lines
= list_get_nb_lines(gui_list
, i
);
336 screen_top
= MAX(0, gui_list
->nb_items
- nb_lines
);
337 gui_list
->start_item
[i
] = MIN(screen_top
, gui_list
->start_item
[i
] +
338 gui_list
->selected_size
);
339 gui_list
->selected_item
= gui_list
->start_item
[i
];
343 gui_list
->start_item
[i
] = MAX(0, gui_list
->start_item
[i
] -
344 gui_list
->selected_size
);
345 gui_list
->selected_item
= gui_list
->start_item
[i
] + nb_lines
;
350 else gui_list
->selected_item
+= offset
;
351 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
355 * Adds an item to the list (the callback will be asked for one more item)
356 * - gui_list : the list structure
358 void gui_synclist_add_item(struct gui_synclist
* gui_list
)
360 gui_list
->nb_items
++;
361 /* if only one item in the list, select it */
362 if (gui_list
->nb_items
== 1)
363 gui_list
->selected_item
= 0;
367 * Removes an item to the list (the callback will be asked for one less item)
368 * - gui_list : the list structure
370 void gui_synclist_del_item(struct gui_synclist
* gui_list
)
372 if (gui_list
->nb_items
> 0)
374 if (gui_list
->selected_item
== gui_list
->nb_items
-1)
375 gui_list
->selected_item
--;
376 gui_list
->nb_items
--;
377 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
381 #ifdef HAVE_LCD_BITMAP
382 void gui_list_screen_scroll_step(int ofs
)
387 void gui_list_screen_scroll_out_of_view(bool enable
)
389 offset_out_of_view
= enable
;
391 #endif /* HAVE_LCD_BITMAP */
394 * Set the title and title icon of the list. Setting title to NULL disables
395 * both the title and icon. Use NOICON if there is no icon.
397 void gui_synclist_set_title(struct gui_synclist
* gui_list
,
398 char * title
, enum themable_icons icon
)
400 gui_list
->title
= title
;
401 gui_list
->title_icon
= icon
;
404 void gui_synclist_set_nb_items(struct gui_synclist
* lists
, int nb_items
)
406 #ifdef HAVE_LCD_BITMAP
409 lists
->nb_items
= nb_items
;
410 #ifdef HAVE_LCD_BITMAP
413 lists
->offset_position
[i
] = 0;
417 int gui_synclist_get_nb_items(struct gui_synclist
* lists
)
419 return lists
->nb_items
;
421 int gui_synclist_get_sel_pos(struct gui_synclist
* lists
)
423 return lists
->selected_item
;
425 void gui_synclist_set_icon_callback(struct gui_synclist
* lists
,
426 list_get_icon icon_callback
)
428 lists
->callback_get_item_icon
= icon_callback
;
431 void gui_synclist_set_voice_callback(struct gui_synclist
* lists
,
432 list_speak_item voice_callback
)
434 lists
->callback_speak_item
= voice_callback
;
437 #ifdef HAVE_LCD_COLOR
438 void gui_synclist_set_color_callback(struct gui_synclist
* lists
,
439 list_get_color color_callback
)
441 lists
->callback_get_item_color
= color_callback
;
445 static void gui_synclist_select_next_page(struct gui_synclist
* lists
,
446 enum screen_type screen
)
448 int nb_lines
= list_get_nb_lines(lists
, screen
);
449 if (lists
->selected_size
> 1)
450 nb_lines
= MAX(1, nb_lines
/lists
->selected_size
);
451 gui_list_select_at_offset(lists
, nb_lines
);
454 static void gui_synclist_select_previous_page(struct gui_synclist
* lists
,
455 enum screen_type screen
)
457 int nb_lines
= list_get_nb_lines(lists
, screen
);
458 if (lists
->selected_size
> 1)
459 nb_lines
= MAX(1, nb_lines
/lists
->selected_size
);
460 gui_list_select_at_offset(lists
, -nb_lines
);
463 void gui_synclist_limit_scroll(struct gui_synclist
* lists
, bool scroll
)
465 lists
->limit_scroll
= scroll
;
468 #ifdef HAVE_LCD_BITMAP
470 * Makes all the item in the list scroll by one step to the right.
471 * Should stop increasing the value when reaching the widest item value
474 static void gui_synclist_scroll_right(struct gui_synclist
* lists
)
479 /* FIXME: This is a fake right boundry limiter. there should be some
480 * callback function to find the longest item on the list in pixels,
481 * to stop the list from scrolling past that point */
482 lists
->offset_position
[i
] += offset_step
;
483 if (lists
->offset_position
[i
] > 1000)
484 lists
->offset_position
[i
] = 1000;
489 * Makes all the item in the list scroll by one step to the left.
490 * stops at starting position.
492 static void gui_synclist_scroll_left(struct gui_synclist
* lists
)
497 lists
->offset_position
[i
] -= offset_step
;
498 if (lists
->offset_position
[i
] < 0)
499 lists
->offset_position
[i
] = 0;
502 #endif /* HAVE_LCD_BITMAP */
504 static void _gui_synclist_speak_item(struct gui_synclist
*lists
, bool repeating
)
506 list_speak_item
*cb
= lists
->callback_speak_item
;
507 if(cb
&& gui_synclist_get_nb_items(lists
) != 0)
509 int sel
= gui_synclist_get_sel_pos(lists
);
511 /* If we got a repeating key action, or we have just very
512 recently started talking, then we want to stay silent for a
513 while until things settle. Likewise if we already had a
514 pending scheduled announcement not yet due: we need to
517 || (lists
->scheduled_talk_tick
518 && TIME_BEFORE(current_tick
, lists
->scheduled_talk_tick
))
519 || (lists
->last_talked_tick
520 && TIME_BEFORE(current_tick
, lists
->last_talked_tick
+HZ
/4)))
522 lists
->scheduled_talk_tick
= current_tick
+HZ
/4;
525 lists
->scheduled_talk_tick
= 0; /* work done */
526 cb(sel
, lists
->data
);
527 lists
->last_talked_tick
= current_tick
;
531 void gui_synclist_speak_item(struct gui_synclist
* lists
)
532 /* The list user should call this to speak the first item on entering
533 the list, and whenever the list is updated. */
535 if(gui_synclist_get_nb_items(lists
) == 0 && global_settings
.talk_menu
)
536 talk_id(VOICE_EMPTY_LIST
, true);
537 else _gui_synclist_speak_item(lists
, false);
540 bool gui_synclist_do_button(struct gui_synclist
* lists
,
541 int *actionptr
, enum list_wrap wrap
)
543 int action
= *actionptr
;
544 #ifdef HAVE_LCD_BITMAP
545 static bool scrolling_left
= false;
548 #ifdef HAVE_WHEEL_ACCELERATION
549 int next_item_modifier
= button_apply_acceleration(get_action_data());
551 static int next_item_modifier
= 1;
552 static int last_accel_tick
= 0;
554 if (global_settings
.list_accel_start_delay
)
556 int start_delay
= global_settings
.list_accel_start_delay
* (HZ
/2);
557 int accel_wait
= global_settings
.list_accel_wait
* HZ
/2;
559 if (get_action_statuscode(NULL
)&ACTION_REPEAT
)
561 if (!last_accel_tick
)
562 last_accel_tick
= current_tick
+ start_delay
;
563 else if (TIME_AFTER(current_tick
, last_accel_tick
+ accel_wait
))
565 last_accel_tick
= current_tick
;
566 next_item_modifier
++;
569 else if (last_accel_tick
)
571 next_item_modifier
= 1;
577 #if defined(HAVE_TOUCHSCREEN)
578 if (action
== ACTION_TOUCHSCREEN
)
579 action
= *actionptr
= gui_synclist_do_touchscreen(lists
);
585 gui_synclist_limit_scroll(lists
, false);
588 gui_synclist_limit_scroll(lists
, true);
590 case LIST_WRAP_UNLESS_HELD
:
591 if (action
== ACTION_STD_PREVREPEAT
||
592 action
== ACTION_STD_NEXTREPEAT
||
593 action
== ACTION_LISTTREE_PGUP
||
594 action
== ACTION_LISTTREE_PGDOWN
)
595 gui_synclist_limit_scroll(lists
, true);
596 else gui_synclist_limit_scroll(lists
, false);
603 gui_synclist_draw(lists
);
606 #ifdef HAVE_VOLUME_IN_LIST
607 case ACTION_LIST_VOLUP
:
608 global_settings
.volume
+= 2;
609 /* up two because the falthrough brings it down one */
610 case ACTION_LIST_VOLDOWN
:
611 global_settings
.volume
--;
615 case ACTION_STD_PREV
:
616 case ACTION_STD_PREVREPEAT
:
617 gui_list_select_at_offset(lists
, -next_item_modifier
);
618 #ifndef HAVE_WHEEL_ACCELERATION
619 if (button_queue_count() < FRAMEDROP_TRIGGER
)
621 gui_synclist_draw(lists
);
622 _gui_synclist_speak_item(lists
,
623 action
== ACTION_STD_PREVREPEAT
624 || next_item_modifier
> 1);
626 *actionptr
= ACTION_STD_PREV
;
629 case ACTION_STD_NEXT
:
630 case ACTION_STD_NEXTREPEAT
:
631 gui_list_select_at_offset(lists
, next_item_modifier
);
632 #ifndef HAVE_WHEEL_ACCELERATION
633 if (button_queue_count() < FRAMEDROP_TRIGGER
)
635 gui_synclist_draw(lists
);
636 _gui_synclist_speak_item(lists
,
637 action
== ACTION_STD_NEXTREPEAT
638 || next_item_modifier
>1);
640 *actionptr
= ACTION_STD_NEXT
;
643 #ifdef HAVE_LCD_BITMAP
644 case ACTION_TREE_PGRIGHT
:
645 gui_synclist_scroll_right(lists
);
646 gui_synclist_draw(lists
);
648 case ACTION_TREE_ROOT_INIT
:
649 /* After this button press ACTION_TREE_PGLEFT is allowed
650 to skip to root. ACTION_TREE_ROOT_INIT must be defined in the
651 keymaps as a repeated button press (the same as the repeated
652 ACTION_TREE_PGLEFT) with the pre condition being the non-repeated
654 if (lists
->offset_position
[0] == 0)
656 scrolling_left
= false;
657 *actionptr
= ACTION_STD_CANCEL
;
660 *actionptr
= ACTION_TREE_PGLEFT
;
661 case ACTION_TREE_PGLEFT
:
662 if(!scrolling_left
&& (lists
->offset_position
[0] == 0))
664 *actionptr
= ACTION_STD_CANCEL
;
667 gui_synclist_scroll_left(lists
);
668 gui_synclist_draw(lists
);
669 scrolling_left
= true; /* stop ACTION_TREE_PAGE_LEFT
673 /* for pgup / pgdown, we are obliged to have a different behaviour depending
674 * on the screen for which the user pressed the key since for example, remote
675 * and main screen doesn't have the same number of lines */
676 case ACTION_LISTTREE_PGUP
:
679 #ifdef HAVE_REMOTE_LCD
680 get_action_statuscode(NULL
)&ACTION_REMOTE
?
684 gui_synclist_select_previous_page(lists
, screen
);
685 gui_synclist_draw(lists
);
686 _gui_synclist_speak_item(lists
, false);
688 *actionptr
= ACTION_STD_NEXT
;
692 case ACTION_LISTTREE_PGDOWN
:
695 #ifdef HAVE_REMOTE_LCD
696 get_action_statuscode(NULL
)&ACTION_REMOTE
?
700 gui_synclist_select_next_page(lists
, screen
);
701 gui_synclist_draw(lists
);
702 _gui_synclist_speak_item(lists
, false);
704 *actionptr
= ACTION_STD_PREV
;
708 if(lists
->scheduled_talk_tick
709 && TIME_AFTER(current_tick
, lists
->scheduled_talk_tick
))
710 /* scheduled postponed item announcement is due */
711 _gui_synclist_speak_item(lists
, false);
715 int list_do_action_timeout(struct gui_synclist
*lists
, int timeout
)
716 /* Returns the lowest of timeout or the delay until a postponed
717 scheduled announcement is due (if any). */
719 if(lists
->scheduled_talk_tick
)
721 long delay
= lists
->scheduled_talk_tick
-current_tick
+1;
722 /* +1 because the trigger condition uses TIME_AFTER(), which
723 is implemented as strictly greater than. */
726 if(timeout
> delay
|| timeout
== TIMEOUT_BLOCK
)
732 bool list_do_action(int context
, int timeout
,
733 struct gui_synclist
*lists
, int *action
,
735 /* Combines the get_action() (with possibly overridden timeout) and
736 gui_synclist_do_button() calls. Returns the list action from
737 do_button, and places the action from get_action in *action. */
739 timeout
= list_do_action_timeout(lists
, timeout
);
740 *action
= get_action(context
, timeout
);
741 return gui_synclist_do_button(lists
, action
, wrap
);
744 bool gui_synclist_item_is_onscreen(struct gui_synclist
*lists
,
745 enum screen_type screen
, int item
)
747 int nb_lines
= list_get_nb_lines(lists
, screen
);
748 return (unsigned)(item
- lists
->start_item
[screen
]) < (unsigned) nb_lines
;
751 /* Simple use list implementation */
752 static int simplelist_line_count
= 0;
753 static char simplelist_text
[SIMPLELIST_MAX_LINES
][SIMPLELIST_MAX_LINELENGTH
];
754 /* set the amount of lines shown in the list */
755 void simplelist_set_line_count(int lines
)
758 simplelist_line_count
= 0;
759 else if (lines
>= SIMPLELIST_MAX_LINES
)
760 simplelist_line_count
= SIMPLELIST_MAX_LINES
;
762 simplelist_line_count
= lines
;
764 /* get the current amount of lines shown */
765 int simplelist_get_line_count(void)
767 return simplelist_line_count
;
769 /* add/edit a line in the list.
770 if line_number > number of lines shown it adds the line,
771 else it edits the line */
772 void simplelist_addline(int line_number
, const char *fmt
, ...)
776 if (line_number
> simplelist_line_count
)
778 if (simplelist_line_count
< SIMPLELIST_MAX_LINES
)
779 line_number
= simplelist_line_count
++;
784 vsnprintf(simplelist_text
[line_number
], SIMPLELIST_MAX_LINELENGTH
, fmt
, ap
);
788 static const char* simplelist_static_getname(int item
,
793 (void)data
; (void)buffer
; (void)buffer_len
;
794 return simplelist_text
[item
];
797 bool simplelist_show_list(struct simplelist_info
*info
)
799 struct gui_synclist lists
;
800 int action
, old_line_count
= simplelist_line_count
, i
;
801 const char* (*getname
)(int item
, void * data
, char *buffer
, size_t buffer_len
);
802 int wrap
= LIST_WRAP_UNLESS_HELD
;
804 getname
= info
->get_name
;
806 getname
= simplelist_static_getname
;
809 viewportmanager_theme_enable(i
, true, NULL
);
811 gui_synclist_init(&lists
, getname
, info
->callback_data
,
812 info
->scroll_all
, info
->selection_size
, NULL
);
815 gui_synclist_set_title(&lists
, info
->title
, NOICON
);
817 gui_synclist_set_icon_callback(&lists
, info
->get_icon
);
819 gui_synclist_set_voice_callback(&lists
, info
->get_talk
);
821 if (info
->hide_selection
)
823 gui_synclist_hide_selection_marker(&lists
, true);
824 wrap
= LIST_WRAP_OFF
;
827 if (info
->action_callback
)
828 info
->action_callback(ACTION_REDRAW
, &lists
);
830 if (info
->get_name
== NULL
)
831 gui_synclist_set_nb_items(&lists
,
832 simplelist_line_count
*info
->selection_size
);
834 gui_synclist_set_nb_items(&lists
, info
->count
*info
->selection_size
);
836 gui_synclist_select_item(&lists
, info
->selection
);
838 gui_synclist_draw(&lists
);
839 gui_synclist_speak_item(&lists
);
843 list_do_action(CONTEXT_STD
, info
->timeout
,
844 &lists
, &action
, wrap
);
846 /* We must yield in this case or no other thread can run */
847 if (info
->timeout
== TIMEOUT_NOBLOCK
)
850 if (info
->action_callback
)
852 bool stdok
= action
==ACTION_STD_OK
;
853 action
= info
->action_callback(action
, &lists
);
854 if (stdok
&& action
== ACTION_STD_CANCEL
)
856 /* callback asked us to exit */
857 info
->selection
= gui_synclist_get_sel_pos(&lists
);
861 if (info
->get_name
== NULL
)
862 gui_synclist_set_nb_items(&lists
,
863 simplelist_line_count
*info
->selection_size
);
865 if (action
== ACTION_STD_CANCEL
)
867 info
->selection
= -1;
870 else if ((action
== ACTION_REDRAW
) ||
871 (old_line_count
!= simplelist_line_count
))
873 if (info
->get_name
== NULL
)
875 gui_synclist_set_nb_items(&lists
,
876 simplelist_line_count
*info
->selection_size
);
878 gui_synclist_draw(&lists
);
879 old_line_count
= simplelist_line_count
;
881 else if(default_event_handler(action
) == SYS_USB_CONNECTED
)
886 viewportmanager_theme_undo(i
, false);
890 void simplelist_info_init(struct simplelist_info
*info
, char* title
,
891 int count
, void* data
)
895 info
->selection_size
= 1;
896 info
->hide_selection
= false;
897 info
->scroll_all
= false;
898 info
->timeout
= HZ
/10;
900 info
->action_callback
= NULL
;
901 info
->get_icon
= NULL
;
902 info
->get_name
= NULL
;
903 info
->get_talk
= NULL
;
904 info
->callback_data
= data
;