1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Kevin Ferrare
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
31 #include "screen_access.h"
33 #include "scrollbar.h"
34 #include "statusbar.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;
59 static int force_list_reinit
= false;
61 static void gui_list_select_at_offset(struct gui_synclist
* gui_list
,
63 void list_draw(struct screen
*display
, struct viewport
*parent
, struct gui_synclist
*list
);
65 #ifdef HAVE_LCD_BITMAP
66 static struct viewport parent
[NB_SCREENS
];
67 void list_init_viewports(struct gui_synclist
*list
)
75 viewport_set_defaults(vp
, i
);
76 else if (list
->parent
[i
] == vp
)
78 viewport_set_defaults(vp
, i
);
79 list
->parent
[i
]->y
= global_settings
.statusbar
?STATUSBAR_HEIGHT
:0;
80 list
->parent
[i
]->height
= screens
[i
].height
- list
->parent
[i
]->y
;
84 if (list
&& (list
->parent
[0] == &parent
[0]) && global_settings
.buttonbar
)
85 list
->parent
[0]->height
-= BUTTONBAR_HEIGHT
;
87 force_list_reinit
= false;
90 static struct viewport parent
[NB_SCREENS
] =
100 void list_init_viewports(struct gui_synclist
*list
)
106 #ifdef HAVE_LCD_BITMAP
107 bool list_display_title(struct gui_synclist
*list
, struct viewport
*vp
)
109 return list
->title
!= NULL
&& viewport_get_nb_lines(vp
)>2;
112 #define list_display_title(l,v) false
116 * Initializes a scrolling list
117 * - gui_list : the list structure to initialize
118 * - callback_get_item_name : pointer to a function that associates a label
119 * to a given item number
120 * - data : extra data passed to the list callback
123 * - parent : the parent viewports to use. NULL means the full screen minus
124 * statusbar if enabled. NOTE: new screens should NOT set this to NULL.
126 void gui_synclist_init(struct gui_synclist
* gui_list
,
127 list_get_name callback_get_item_name
,
130 int selected_size
, struct viewport list_parent
[NB_SCREENS
]
134 gui_list
->callback_get_item_icon
= NULL
;
135 gui_list
->callback_get_item_name
= callback_get_item_name
;
136 gui_list
->callback_speak_item
= NULL
;
137 gui_list
->nb_items
= 0;
138 gui_list
->selected_item
= 0;
141 gui_list
->start_item
[i
] = 0;
142 gui_list
->last_displayed_start_item
[i
] = -1 ;
143 #ifdef HAVE_LCD_BITMAP
144 gui_list
->offset_position
[i
] = 0;
147 gui_list
->parent
[i
] = &list_parent
[i
];
150 gui_list
->parent
[i
] = &parent
[i
];
153 list_init_viewports(gui_list
);
154 gui_list
->limit_scroll
= false;
156 gui_list
->scroll_all
=scroll_all
;
157 gui_list
->selected_size
=selected_size
;
158 gui_list
->title
= NULL
;
159 gui_list
->title_width
= 0;
160 gui_list
->title_icon
= Icon_NOICON
;
162 gui_list
->scheduled_talk_tick
= gui_list
->last_talked_tick
= 0;
163 gui_list
->show_selection_marker
= true;
164 gui_list
->last_displayed_selected_item
= -1 ;
166 #ifdef HAVE_LCD_COLOR
167 gui_list
->title_color
= -1;
168 gui_list
->callback_get_item_color
= NULL
;
170 force_list_reinit
= true;
173 /* this toggles the selection bar or cursor */
174 void gui_synclist_hide_selection_marker(struct gui_synclist
* lists
, bool hide
)
176 lists
->show_selection_marker
= !hide
;
180 #ifdef HAVE_LCD_BITMAP
181 int list_title_height(struct gui_synclist
*list
, struct viewport
*vp
);
183 int gui_list_get_item_offset(struct gui_synclist
* gui_list
, int item_width
,
184 int text_pos
, struct screen
* display
, struct viewport
*vp
)
188 if (offset_out_of_view
)
190 item_offset
= gui_list
->offset_position
[display
->screen_type
];
194 /* if text is smaller then view */
195 if (item_width
<= vp
->width
- text_pos
)
201 /* if text got out of view */
202 if (gui_list
->offset_position
[display
->screen_type
] >
203 item_width
- (vp
->width
- text_pos
))
204 item_offset
= item_width
- (vp
->width
- text_pos
);
206 item_offset
= gui_list
->offset_position
[display
->screen_type
];
214 * Force a full screen update.
217 void gui_synclist_draw(struct gui_synclist
*gui_list
)
220 static struct gui_synclist
*last_list
= NULL
;
221 static int last_count
= -1;
223 static bool last_buttonbar
= false;
225 if (force_list_reinit
||
227 last_buttonbar
!= screens
[SCREEN_MAIN
].has_buttonbar
||
229 last_list
!= gui_list
||
230 gui_list
->nb_items
!= last_count
)
232 list_init_viewports(gui_list
);
233 force_list_reinit
= false;
236 last_buttonbar
= screens
[SCREEN_MAIN
].has_buttonbar
;
238 last_count
= gui_list
->nb_items
;
239 last_list
= gui_list
;
242 list_draw(&screens
[i
], gui_list
->parent
[i
], gui_list
);
246 /* sets up the list so the selection is shown correctly on the screen */
247 static void gui_list_put_selection_on_screen(struct gui_synclist
* gui_list
,
248 enum screen_type screen
)
251 int difference
= gui_list
->selected_item
- gui_list
->start_item
[screen
];
252 struct viewport vp
= *gui_list
->parent
[screen
];
253 #ifdef HAVE_LCD_BITMAP
254 if (list_display_title(gui_list
, gui_list
->parent
[screen
]))
255 vp
.height
-= list_title_height(gui_list
,gui_list
->parent
[screen
]);
257 nb_lines
= viewport_get_nb_lines(&vp
);
259 /* edge case,, selected last item */
260 if (gui_list
->selected_item
== gui_list
->nb_items
-1)
262 gui_list
->start_item
[screen
] = MAX(0, gui_list
->nb_items
- nb_lines
);
264 /* selected first item */
265 else if (gui_list
->selected_item
== 0)
267 gui_list
->start_item
[screen
] = 0;
269 else if (difference
< SCROLL_LIMIT
) /* list moved up */
271 if (global_settings
.scroll_paginated
)
273 if (gui_list
->start_item
[screen
] > gui_list
->selected_item
)
274 gui_list
->start_item
[screen
] = (gui_list
->selected_item
/nb_lines
)*nb_lines
;
278 int top_of_screen
= gui_list
->selected_item
- SCROLL_LIMIT
;
279 int temp
= MIN(top_of_screen
, gui_list
->nb_items
- nb_lines
);
280 gui_list
->start_item
[screen
] = MAX(0, temp
);
283 else if (difference
> nb_lines
- SCROLL_LIMIT
) /* list moved down */
285 int bottom
= gui_list
->nb_items
- nb_lines
;
286 /* always move the screen if selection isnt "visible" */
287 if (gui_list
->show_selection_marker
== false)
291 gui_list
->start_item
[screen
] = MIN(bottom
, gui_list
->start_item
[screen
] +
292 2*gui_list
->selected_size
);
294 else if (global_settings
.scroll_paginated
)
296 if (gui_list
->start_item
[screen
] + nb_lines
<= gui_list
->selected_item
)
297 gui_list
->start_item
[screen
] = MIN(bottom
, gui_list
->selected_item
);
301 int top_of_screen
= gui_list
->selected_item
+ SCROLL_LIMIT
- nb_lines
;
302 int temp
= MAX(0, top_of_screen
);
303 gui_list
->start_item
[screen
] = MIN(bottom
, temp
);
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
-1 || 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 /* NOTE: this part doesnt work as well as it used to, the problem is
346 we want to scroll the lists seperatly but we only have one
347 selected item now, I dont think this is such a big deal though */
348 int i
, nb_lines
, screen_top
;
351 struct viewport vp
= *gui_list
->parent
[i
];
352 #ifdef HAVE_LCD_BITMAP
353 if (list_display_title(gui_list
, gui_list
->parent
[i
]))
354 vp
.height
-= list_title_height(gui_list
,gui_list
->parent
[i
]);
356 nb_lines
= viewport_get_nb_lines(&vp
);
359 screen_top
= gui_list
->nb_items
-nb_lines
;
362 gui_list
->start_item
[i
] = MIN(screen_top
, gui_list
->start_item
[i
] +
363 gui_list
->selected_size
);
367 gui_list
->start_item
[i
] = MAX(0, gui_list
->start_item
[i
] -
368 gui_list
->selected_size
);
373 else gui_list
->selected_item
+= offset
;
374 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
378 * Adds an item to the list (the callback will be asked for one more item)
379 * - gui_list : the list structure
381 void gui_synclist_add_item(struct gui_synclist
* gui_list
)
383 gui_list
->nb_items
++;
384 /* if only one item in the list, select it */
385 if(gui_list
->nb_items
== 1)
386 gui_list
->selected_item
= 0;
390 * Removes an item to the list (the callback will be asked for one less item)
391 * - gui_list : the list structure
393 void gui_synclist_del_item(struct gui_synclist
* gui_list
)
395 if(gui_list
->nb_items
> 0)
397 if (gui_list
->selected_item
== gui_list
->nb_items
-1)
398 gui_list
->selected_item
--;
399 gui_list
->nb_items
--;
400 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
404 #ifdef HAVE_LCD_BITMAP
405 void gui_list_screen_scroll_step(int ofs
)
410 void gui_list_screen_scroll_out_of_view(bool enable
)
413 offset_out_of_view
= true;
415 offset_out_of_view
= false;
417 #endif /* HAVE_LCD_BITMAP */
420 * Set the title and title icon of the list. Setting title to NULL disables
421 * both the title and icon. Use NOICON if there is no icon.
423 void gui_synclist_set_title(struct gui_synclist
* gui_list
,
424 char * title
, enum themable_icons icon
)
426 gui_list
->title
= title
;
427 gui_list
->title_icon
= icon
;
429 #ifdef HAVE_LCD_BITMAP
432 screens
[i
].getstringsize(title
, &gui_list
->title_width
, NULL
);
434 gui_list
->title_width
= strlen(title
);
437 gui_list
->title_width
= 0;
439 force_list_reinit
= true;
443 void gui_synclist_set_nb_items(struct gui_synclist
* lists
, int nb_items
)
445 #ifdef HAVE_LCD_BITMAP
448 lists
->nb_items
= nb_items
;
449 #ifdef HAVE_LCD_BITMAP
452 lists
->offset_position
[i
] = 0;
456 int gui_synclist_get_nb_items(struct gui_synclist
* lists
)
458 return lists
->nb_items
;
460 int gui_synclist_get_sel_pos(struct gui_synclist
* lists
)
462 return lists
->selected_item
;
464 void gui_synclist_set_icon_callback(struct gui_synclist
* lists
,
465 list_get_icon icon_callback
)
467 lists
->callback_get_item_icon
= icon_callback
;
470 void gui_synclist_set_voice_callback(struct gui_synclist
* lists
,
471 list_speak_item voice_callback
)
473 lists
->callback_speak_item
= voice_callback
;
476 #ifdef HAVE_LCD_COLOR
477 void gui_synclist_set_color_callback(struct gui_synclist
* lists
,
478 list_get_color color_callback
)
480 lists
->callback_get_item_color
= color_callback
;
484 static void gui_synclist_select_next_page(struct gui_synclist
* lists
,
485 enum screen_type screen
)
487 gui_list_select_at_offset(lists
, screens
[screen
].nb_lines
);
490 static void gui_synclist_select_previous_page(struct gui_synclist
* lists
,
491 enum screen_type screen
)
493 gui_list_select_at_offset(lists
, -screens
[screen
].nb_lines
);
496 void gui_synclist_limit_scroll(struct gui_synclist
* lists
, bool scroll
)
498 lists
->limit_scroll
= scroll
;
501 #ifdef HAVE_LCD_BITMAP
503 * Makes all the item in the list scroll by one step to the right.
504 * Should stop increasing the value when reaching the widest item value
507 static void gui_synclist_scroll_right(struct gui_synclist
* lists
)
512 /* FIXME: This is a fake right boundry limiter. there should be some
513 * callback function to find the longest item on the list in pixels,
514 * to stop the list from scrolling past that point */
515 lists
->offset_position
[i
]+=offset_step
;
516 if (lists
->offset_position
[i
] > 1000)
517 lists
->offset_position
[i
] = 1000;
522 * Makes all the item in the list scroll by one step to the left.
523 * stops at starting position.
525 static void gui_synclist_scroll_left(struct gui_synclist
* lists
)
530 lists
->offset_position
[i
]-=offset_step
;
531 if (lists
->offset_position
[i
] < 0)
532 lists
->offset_position
[i
] = 0;
535 #endif /* HAVE_LCD_BITMAP */
537 static void _gui_synclist_speak_item(struct gui_synclist
*lists
, bool repeating
)
539 list_speak_item
*cb
= lists
->callback_speak_item
;
540 if(cb
&& gui_synclist_get_nb_items(lists
) != 0)
542 int sel
= gui_synclist_get_sel_pos(lists
);
544 /* If we got a repeating key action, or we have just very
545 recently started talking, then we want to stay silent for a
546 while until things settle. Likewise if we already had a
547 pending scheduled announcement not yet due: we need to
550 || (lists
->scheduled_talk_tick
551 && TIME_BEFORE(current_tick
, lists
->scheduled_talk_tick
))
552 || (lists
->last_talked_tick
553 && TIME_BEFORE(current_tick
, lists
->last_talked_tick
+HZ
/4)))
555 lists
->scheduled_talk_tick
= current_tick
+HZ
/4;
558 lists
->scheduled_talk_tick
= 0; /* work done */
559 cb(sel
, lists
->data
);
560 lists
->last_talked_tick
= current_tick
;
564 void gui_synclist_speak_item(struct gui_synclist
* lists
)
565 /* The list user should call this to speak the first item on entering
566 the list, and whenever the list is updated. */
568 if(gui_synclist_get_nb_items(lists
) == 0 && global_settings
.talk_menu
)
569 talk_id(VOICE_EMPTY_LIST
, true);
570 else _gui_synclist_speak_item(lists
, false);
573 extern intptr_t get_action_data(void);
574 #if defined(HAVE_TOUCHPAD)
575 /* this needs to be fixed if we ever get more than 1 touchscreen on a target */
576 unsigned gui_synclist_do_touchpad(struct gui_synclist
* gui_list
, struct viewport
*parent
);
579 bool gui_synclist_do_button(struct gui_synclist
* lists
,
580 unsigned *actionptr
, enum list_wrap wrap
)
582 int action
= *actionptr
;
583 #ifdef HAVE_LCD_BITMAP
584 static bool scrolling_left
= false;
587 #ifdef HAVE_SCROLLWHEEL
588 int next_item_modifier
= button_apply_acceleration(get_action_data());
590 static int next_item_modifier
= 1;
591 static int last_accel_tick
= 0;
593 if (global_settings
.list_accel_start_delay
)
595 int start_delay
= global_settings
.list_accel_start_delay
* (HZ
/2);
596 int accel_wait
= global_settings
.list_accel_wait
* HZ
/2;
598 if (get_action_statuscode(NULL
)&ACTION_REPEAT
)
600 if (!last_accel_tick
)
601 last_accel_tick
= current_tick
+ start_delay
;
602 else if (current_tick
>=
603 last_accel_tick
+ accel_wait
)
605 last_accel_tick
= current_tick
;
606 next_item_modifier
++;
609 else if (last_accel_tick
)
611 next_item_modifier
= 1;
617 #if defined(HAVE_TOUCHPAD)
618 if (action
== ACTION_TOUCHPAD
)
619 action
= *actionptr
= gui_synclist_do_touchpad(lists
, &parent
[SCREEN_MAIN
]);
625 gui_synclist_limit_scroll(lists
, false);
628 gui_synclist_limit_scroll(lists
, true);
630 case LIST_WRAP_UNLESS_HELD
:
631 if (action
== ACTION_STD_PREVREPEAT
||
632 action
== ACTION_STD_NEXTREPEAT
||
633 action
== ACTION_LISTTREE_PGUP
||
634 action
== ACTION_LISTTREE_PGDOWN
)
635 gui_synclist_limit_scroll(lists
, true);
636 else gui_synclist_limit_scroll(lists
, false);
643 gui_synclist_draw(lists
);
646 #ifdef HAVE_VOLUME_IN_LIST
647 case ACTION_LIST_VOLUP
:
648 global_settings
.volume
+= 2;
649 /* up two because the falthrough brings it down one */
650 case ACTION_LIST_VOLDOWN
:
651 global_settings
.volume
--;
655 case ACTION_STD_PREV
:
656 case ACTION_STD_PREVREPEAT
:
657 gui_list_select_at_offset(lists
, -next_item_modifier
);
658 #ifndef HAVE_SCROLLWHEEL
659 if (queue_count(&button_queue
) < FRAMEDROP_TRIGGER
)
661 gui_synclist_draw(lists
);
662 _gui_synclist_speak_item(lists
,
663 action
== ACTION_STD_PREVREPEAT
664 || next_item_modifier
>1);
666 *actionptr
= ACTION_STD_PREV
;
669 case ACTION_STD_NEXT
:
670 case ACTION_STD_NEXTREPEAT
:
671 gui_list_select_at_offset(lists
, next_item_modifier
);
672 #ifndef HAVE_SCROLLWHEEL
673 if (queue_count(&button_queue
) < FRAMEDROP_TRIGGER
)
675 gui_synclist_draw(lists
);
676 _gui_synclist_speak_item(lists
,
677 action
== ACTION_STD_NEXTREPEAT
678 || next_item_modifier
>1);
680 *actionptr
= ACTION_STD_NEXT
;
683 #ifdef HAVE_LCD_BITMAP
684 case ACTION_TREE_PGRIGHT
:
685 gui_synclist_scroll_right(lists
);
686 gui_synclist_draw(lists
);
688 case ACTION_TREE_ROOT_INIT
:
689 /* After this button press ACTION_TREE_PGLEFT is allowed
690 to skip to root. ACTION_TREE_ROOT_INIT must be defined in the
691 keymaps as a repeated button press (the same as the repeated
692 ACTION_TREE_PGLEFT) with the pre condition being the non-repeated
694 if (lists
->offset_position
[0] == 0)
696 scrolling_left
= false;
697 *actionptr
= ACTION_STD_CANCEL
;
700 *actionptr
= ACTION_TREE_PGLEFT
;
701 case ACTION_TREE_PGLEFT
:
702 if(!scrolling_left
&& (lists
->offset_position
[0] == 0))
704 *actionptr
= ACTION_STD_CANCEL
;
707 gui_synclist_scroll_left(lists
);
708 gui_synclist_draw(lists
);
709 scrolling_left
= true; /* stop ACTION_TREE_PAGE_LEFT
713 /* for pgup / pgdown, we are obliged to have a different behaviour depending
714 * on the screen for which the user pressed the key since for example, remote
715 * and main screen doesn't have the same number of lines */
716 case ACTION_LISTTREE_PGUP
:
719 #ifdef HAVE_REMOTE_LCD
720 get_action_statuscode(NULL
)&ACTION_REMOTE
?
724 gui_synclist_select_previous_page(lists
, screen
);
725 gui_synclist_draw(lists
);
726 _gui_synclist_speak_item(lists
, false);
728 *actionptr
= ACTION_STD_NEXT
;
732 case ACTION_LISTTREE_PGDOWN
:
735 #ifdef HAVE_REMOTE_LCD
736 get_action_statuscode(NULL
)&ACTION_REMOTE
?
740 gui_synclist_select_next_page(lists
, screen
);
741 gui_synclist_draw(lists
);
742 _gui_synclist_speak_item(lists
, false);
744 *actionptr
= ACTION_STD_PREV
;
748 if(lists
->scheduled_talk_tick
749 && TIME_AFTER(current_tick
, lists
->scheduled_talk_tick
))
750 /* scheduled postponed item announcement is due */
751 _gui_synclist_speak_item(lists
, false);
755 int list_do_action_timeout(struct gui_synclist
*lists
, int timeout
)
756 /* Returns the lowest of timeout or the delay until a postponed
757 scheduled announcement is due (if any). */
759 if(lists
->scheduled_talk_tick
)
761 long delay
= lists
->scheduled_talk_tick
-current_tick
+1;
762 /* +1 because the trigger condition uses TIME_AFTER(), which
763 is implemented as strictly greater than. */
766 if(timeout
> delay
|| timeout
== TIMEOUT_BLOCK
)
772 bool list_do_action(int context
, int timeout
,
773 struct gui_synclist
*lists
, int *action
,
775 /* Combines the get_action() (with possibly overridden timeout) and
776 gui_synclist_do_button() calls. Returns the list action from
777 do_button, and places the action from get_action in *action. */
779 timeout
= list_do_action_timeout(lists
, timeout
);
780 *action
= get_action(context
, timeout
);
781 return gui_synclist_do_button(lists
, action
, wrap
);
784 /* Simple use list implementation */
785 static int simplelist_line_count
= 0;
786 static char simplelist_text
[SIMPLELIST_MAX_LINES
][SIMPLELIST_MAX_LINELENGTH
];
787 /* set the amount of lines shown in the list */
788 void simplelist_set_line_count(int lines
)
791 simplelist_line_count
= 0;
792 else if (lines
>= SIMPLELIST_MAX_LINES
)
793 simplelist_line_count
= SIMPLELIST_MAX_LINES
;
795 simplelist_line_count
= lines
;
797 /* get the current amount of lines shown */
798 int simplelist_get_line_count(void)
800 return simplelist_line_count
;
802 /* add/edit a line in the list.
803 if line_number > number of lines shown it adds the line, else it edits the line */
804 void simplelist_addline(int line_number
, const char *fmt
, ...)
808 if (line_number
> simplelist_line_count
)
810 if (simplelist_line_count
< SIMPLELIST_MAX_LINES
)
811 line_number
= simplelist_line_count
++;
816 vsnprintf(simplelist_text
[line_number
], SIMPLELIST_MAX_LINELENGTH
, fmt
, ap
);
820 static char* simplelist_static_getname(int item
,
825 (void)data
; (void)buffer
; (void)buffer_len
;
826 return simplelist_text
[item
];
829 bool simplelist_show_list(struct simplelist_info
*info
)
831 struct gui_synclist lists
;
832 struct viewport vp
[NB_SCREENS
];
833 int action
, old_line_count
= simplelist_line_count
,i
;
834 char* (*getname
)(int item
, void * data
, char *buffer
, size_t buffer_len
);
836 getname
= info
->get_name
;
838 getname
= simplelist_static_getname
;
841 viewport_set_defaults(&vp
[i
], i
);
843 gui_synclist_init(&lists
, getname
, info
->callback_data
,
844 info
->scroll_all
, info
->selection_size
, vp
);
847 gui_synclist_set_title(&lists
, info
->title
, NOICON
);
849 gui_synclist_set_icon_callback(&lists
, info
->get_icon
);
851 gui_synclist_set_voice_callback(&lists
, info
->get_talk
);
853 gui_synclist_hide_selection_marker(&lists
, info
->hide_selection
);
855 if (info
->action_callback
)
856 info
->action_callback(ACTION_REDRAW
, &lists
);
858 if (info
->get_name
== NULL
)
859 gui_synclist_set_nb_items(&lists
, simplelist_line_count
*info
->selection_size
);
861 gui_synclist_set_nb_items(&lists
, info
->count
*info
->selection_size
);
863 gui_synclist_select_item(&lists
, info
->start_selection
);
865 gui_synclist_draw(&lists
);
866 gui_synclist_speak_item(&lists
);
870 gui_syncstatusbar_draw(&statusbars
, true);
871 list_do_action(CONTEXT_STD
, info
->timeout
,
872 &lists
, &action
, LIST_WRAP_UNLESS_HELD
);
874 /* We must yield in this case or no other thread can run */
875 if (info
->timeout
== TIMEOUT_NOBLOCK
)
878 if (info
->action_callback
)
880 action
= info
->action_callback(action
, &lists
);
881 if (info
->get_name
== NULL
)
882 gui_synclist_set_nb_items(&lists
, simplelist_line_count
*info
->selection_size
);
884 if (action
== ACTION_STD_CANCEL
)
886 else if ((action
== ACTION_REDRAW
) ||
887 (old_line_count
!= simplelist_line_count
))
889 if (info
->get_name
== NULL
)
890 gui_synclist_set_nb_items(&lists
, simplelist_line_count
*info
->selection_size
);
891 gui_synclist_draw(&lists
);
892 if (action
!= ACTION_NONE
)
893 gui_synclist_speak_item(&lists
);
894 old_line_count
= simplelist_line_count
;
896 else if(default_event_handler(action
) == SYS_USB_CONNECTED
)
903 void simplelist_info_init(struct simplelist_info
*info
, char* title
,
904 int count
, void* data
)
908 info
->selection_size
= 1;
909 info
->hide_selection
= false;
910 info
->scroll_all
= false;
911 info
->timeout
= HZ
/10;
912 info
->start_selection
= 0;
913 info
->action_callback
= NULL
;
914 info
->get_icon
= NULL
;
915 info
->get_name
= NULL
;
916 info
->get_talk
= NULL
;
917 info
->callback_data
= data
;