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 ****************************************************************************/
34 #include "screen_access.h"
36 #include "scrollbar.h"
42 #include "appevents.h"
43 #include "statusbar-skinned.h"
45 /* The minimum number of pending button events in queue before starting
46 * to limit list drawing interval.
48 #define FRAMEDROP_TRIGGER 6
50 #ifdef HAVE_LCD_BITMAP
51 static int offset_step
= 16; /* pixels per screen scroll step */
52 /* should lines scroll out of the screen */
53 static bool offset_out_of_view
= false;
56 static void gui_list_select_at_offset(struct gui_synclist
* gui_list
,
58 void list_draw(struct screen
*display
, struct gui_synclist
*list
);
60 #ifdef HAVE_LCD_BITMAP
61 static int list_need_reinit
= false;
62 static struct viewport parent
[NB_SCREENS
];
64 static void list_force_reinit(void *param
)
67 list_need_reinit
= true;
72 add_event(GUI_EVENT_THEME_CHANGED
, false, list_force_reinit
);
75 static void list_init_viewports(struct gui_synclist
*list
)
82 parent_used
= (*list
->parent
!= &parent
[SCREEN_MAIN
]);
88 list
->parent
[i
] = &parent
[i
];
89 viewport_set_defaults(&parent
[i
], i
);
91 if (screens
[i
].has_buttonbar
)
92 list
->parent
[i
]->height
-= BUTTONBAR_HEIGHT
;
96 list_need_reinit
= false;
99 static struct viewport parent
[NB_SCREENS
] =
110 #define list_init_viewports(a)
113 #ifdef HAVE_LCD_BITMAP
114 bool list_display_title(struct gui_synclist
*list
, enum screen_type screen
)
116 return list
->title
!= NULL
&&
117 !sb_set_title_text(list
->title
, list
->title_icon
, screen
) &&
118 viewport_get_nb_lines(list
->parent
[screen
]) > 2;
121 static int list_get_nb_lines(struct gui_synclist
*list
, enum screen_type screen
)
123 struct viewport vp
= *list
->parent
[screen
];
124 if (list_display_title(list
, screen
))
125 vp
.height
-= font_get(list
->parent
[screen
]->font
)->height
;
126 return viewport_get_nb_lines(&vp
);
129 #define list_display_title(l, i) false
130 #define list_get_nb_lines(list, screen) \
131 viewport_get_nb_lines((list)->parent[(screen)]);
135 * Initializes a scrolling list
136 * - gui_list : the list structure to initialize
137 * - callback_get_item_name : pointer to a function that associates a label
138 * to a given item number
139 * - data : extra data passed to the list callback
142 * - parent : the parent viewports to use. NULL means the full screen minus
143 * statusbar if enabled. NOTE: new screens should NOT set this to NULL.
145 void gui_synclist_init(struct gui_synclist
* gui_list
,
146 list_get_name callback_get_item_name
,
149 int selected_size
, struct viewport list_parent
[NB_SCREENS
]
153 gui_list
->callback_get_item_icon
= NULL
;
154 gui_list
->callback_get_item_name
= callback_get_item_name
;
155 gui_list
->callback_speak_item
= NULL
;
156 gui_list
->nb_items
= 0;
157 gui_list
->selected_item
= 0;
160 gui_list
->start_item
[i
] = 0;
161 #ifdef HAVE_LCD_BITMAP
162 gui_list
->offset_position
[i
] = 0;
165 gui_list
->parent
[i
] = &list_parent
[i
];
167 gui_list
->parent
[i
] = &parent
[i
];
169 list_init_viewports(gui_list
);
170 gui_list
->limit_scroll
= false;
171 gui_list
->data
= data
;
172 gui_list
->scroll_all
= scroll_all
;
173 gui_list
->selected_size
= selected_size
;
174 gui_list
->title
= NULL
;
175 gui_list
->title_icon
= Icon_NOICON
;
177 gui_list
->scheduled_talk_tick
= gui_list
->last_talked_tick
= 0;
178 gui_list
->show_selection_marker
= true;
180 #ifdef HAVE_LCD_COLOR
181 gui_list
->title_color
= -1;
182 gui_list
->callback_get_item_color
= NULL
;
186 /* this toggles the selection bar or cursor */
187 void gui_synclist_hide_selection_marker(struct gui_synclist
* lists
, bool hide
)
189 lists
->show_selection_marker
= !hide
;
193 #ifdef HAVE_LCD_BITMAP
194 int gui_list_get_item_offset(struct gui_synclist
* gui_list
,
197 struct screen
* display
,
202 if (offset_out_of_view
)
204 item_offset
= gui_list
->offset_position
[display
->screen_type
];
208 /* if text is smaller than view */
209 if (item_width
<= vp
->width
- text_pos
)
213 /* if text got out of view */
214 else if (gui_list
->offset_position
[display
->screen_type
] >
215 item_width
- (vp
->width
- text_pos
))
217 item_offset
= item_width
- (vp
->width
- text_pos
);
220 item_offset
= gui_list
->offset_position
[display
->screen_type
];
228 * Force a full screen update.
230 void gui_synclist_draw(struct gui_synclist
*gui_list
)
233 #ifdef HAVE_LCD_BITMAP
234 if (list_need_reinit
)
236 list_init_viewports(gui_list
);
237 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
242 list_draw(&screens
[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
)
250 int nb_lines
= list_get_nb_lines(gui_list
, screen
);
251 int bottom
= MAX(0, gui_list
->nb_items
- nb_lines
);
252 int new_start_item
= gui_list
->start_item
[screen
];
253 int difference
= gui_list
->selected_item
- gui_list
->start_item
[screen
];
254 #ifdef HAVE_LCD_CHARCELLS
255 const int scroll_limit_up
= 0;
256 const int scroll_limit_down
= 1;
258 const int scroll_limit_up
= (nb_lines
< gui_list
->selected_size
+2 ? 0:1);
259 const int scroll_limit_down
= (scroll_limit_up
+gui_list
->selected_size
);
262 if (gui_list
->show_selection_marker
== false)
264 new_start_item
= gui_list
->selected_item
;
266 else if (gui_list
->selected_size
>= nb_lines
)
268 new_start_item
= gui_list
->selected_item
;
270 else if (global_settings
.scroll_paginated
)
272 nb_lines
-= nb_lines
%gui_list
->selected_size
;
273 if (difference
< 0 || difference
>= nb_lines
)
275 new_start_item
= gui_list
->selected_item
-
276 (gui_list
->selected_item
%nb_lines
);
279 else if (difference
<= scroll_limit_up
) /* list moved up */
281 new_start_item
= gui_list
->selected_item
- scroll_limit_up
;
283 else if (difference
> nb_lines
- scroll_limit_down
) /* list moved down */
285 new_start_item
= gui_list
->selected_item
+ scroll_limit_down
- nb_lines
;
287 if (new_start_item
< 0)
288 gui_list
->start_item
[screen
] = 0;
289 else if (new_start_item
> bottom
)
290 gui_list
->start_item
[screen
] = bottom
;
292 gui_list
->start_item
[screen
] = new_start_item
;
295 static void _gui_synclist_speak_item(struct gui_synclist
*lists
)
297 list_speak_item
*cb
= lists
->callback_speak_item
;
298 if (cb
&& lists
->nb_items
!= 0)
301 /* If we have just very recently started talking, then we want
302 to stay silent for a while until things settle. Likewise if
303 we already had a pending scheduled announcement not yet due
304 we need to reschedule it. */
305 if ((lists
->scheduled_talk_tick
&&
306 TIME_BEFORE(current_tick
, lists
->scheduled_talk_tick
)) ||
307 (lists
->last_talked_tick
&&
308 TIME_BEFORE(current_tick
, lists
->last_talked_tick
+ HZ
/5)))
310 lists
->scheduled_talk_tick
= current_tick
+ HZ
/5;
314 lists
->scheduled_talk_tick
= 0; /* work done */
315 cb(lists
->selected_item
, lists
->data
);
316 lists
->last_talked_tick
= current_tick
;
321 void gui_synclist_speak_item(struct gui_synclist
*lists
)
323 if (global_settings
.talk_menu
)
325 if (lists
->nb_items
== 0)
326 talk_id(VOICE_EMPTY_LIST
, true);
328 _gui_synclist_speak_item(lists
);
333 * Selects an item in the list
334 * - gui_list : the list structure
335 * - item_number : the number of the item which will be selected
337 void gui_synclist_select_item(struct gui_synclist
* gui_list
, int item_number
)
340 if (item_number
>= gui_list
->nb_items
|| item_number
< 0)
342 if (item_number
!= gui_list
->selected_item
)
344 gui_list
->selected_item
= item_number
;
345 _gui_synclist_speak_item(gui_list
);
348 gui_list_put_selection_on_screen(gui_list
, i
);
351 static void gui_list_select_at_offset(struct gui_synclist
* gui_list
,
355 if (gui_list
->selected_size
> 1)
357 offset
*= gui_list
->selected_size
;
360 new_selection
= gui_list
->selected_item
+ offset
;
362 if (new_selection
>= gui_list
->nb_items
)
364 new_selection
= gui_list
->limit_scroll
?
365 gui_list
->nb_items
- gui_list
->selected_size
: 0;
367 else if (new_selection
< 0)
369 new_selection
= gui_list
->limit_scroll
?
370 0 : gui_list
->nb_items
- gui_list
->selected_size
;
372 else if (gui_list
->show_selection_marker
== false)
374 int i
, nb_lines
, screen_top
;
377 nb_lines
= list_get_nb_lines(gui_list
, i
);
380 screen_top
= MAX(0, gui_list
->nb_items
- nb_lines
);
381 gui_list
->start_item
[i
] = MIN(screen_top
, gui_list
->start_item
[i
] +
382 gui_list
->selected_size
);
383 gui_list
->selected_item
= gui_list
->start_item
[i
];
387 gui_list
->start_item
[i
] = MAX(0, gui_list
->start_item
[i
] -
388 gui_list
->selected_size
);
389 gui_list
->selected_item
= gui_list
->start_item
[i
] + nb_lines
;
394 gui_synclist_select_item(gui_list
, new_selection
);
398 * Adds an item to the list (the callback will be asked for one more item)
399 * - gui_list : the list structure
401 void gui_synclist_add_item(struct gui_synclist
* gui_list
)
403 gui_list
->nb_items
++;
404 /* if only one item in the list, select it */
405 if (gui_list
->nb_items
== 1)
406 gui_list
->selected_item
= 0;
410 * Removes an item to the list (the callback will be asked for one less item)
411 * - gui_list : the list structure
413 void gui_synclist_del_item(struct gui_synclist
* gui_list
)
415 if (gui_list
->nb_items
> 0)
417 if (gui_list
->selected_item
== gui_list
->nb_items
-1)
418 gui_list
->selected_item
--;
419 gui_list
->nb_items
--;
420 gui_synclist_select_item(gui_list
, gui_list
->selected_item
);
424 #ifdef HAVE_LCD_BITMAP
425 void gui_list_screen_scroll_step(int ofs
)
430 void gui_list_screen_scroll_out_of_view(bool enable
)
432 offset_out_of_view
= enable
;
434 #endif /* HAVE_LCD_BITMAP */
437 * Set the title and title icon of the list. Setting title to NULL disables
438 * both the title and icon. Use NOICON if there is no icon.
440 void gui_synclist_set_title(struct gui_synclist
* gui_list
,
441 char * title
, enum themable_icons icon
)
443 gui_list
->title
= title
;
444 gui_list
->title_icon
= icon
;
445 #ifdef HAVE_LCD_BITMAP
448 sb_set_title_text(title
, icon
, i
);
450 send_event(GUI_EVENT_ACTIONUPDATE
, (void*)1);
453 void gui_synclist_set_nb_items(struct gui_synclist
* lists
, int nb_items
)
455 #ifdef HAVE_LCD_BITMAP
458 lists
->nb_items
= nb_items
;
459 #ifdef HAVE_LCD_BITMAP
462 lists
->offset_position
[i
] = 0;
466 int gui_synclist_get_nb_items(struct gui_synclist
* lists
)
468 return lists
->nb_items
;
470 int gui_synclist_get_sel_pos(struct gui_synclist
* lists
)
472 return lists
->selected_item
;
474 void gui_synclist_set_icon_callback(struct gui_synclist
* lists
,
475 list_get_icon icon_callback
)
477 lists
->callback_get_item_icon
= icon_callback
;
480 void gui_synclist_set_voice_callback(struct gui_synclist
* lists
,
481 list_speak_item voice_callback
)
483 lists
->callback_speak_item
= voice_callback
;
486 #ifdef HAVE_LCD_COLOR
487 void gui_synclist_set_color_callback(struct gui_synclist
* lists
,
488 list_get_color color_callback
)
490 lists
->callback_get_item_color
= color_callback
;
494 static void gui_synclist_select_next_page(struct gui_synclist
* lists
,
495 enum screen_type screen
)
497 int nb_lines
= list_get_nb_lines(lists
, screen
);
498 if (lists
->selected_size
> 1)
499 nb_lines
= MAX(1, nb_lines
/lists
->selected_size
);
500 gui_list_select_at_offset(lists
, nb_lines
);
503 static void gui_synclist_select_previous_page(struct gui_synclist
* lists
,
504 enum screen_type screen
)
506 int nb_lines
= list_get_nb_lines(lists
, screen
);
507 if (lists
->selected_size
> 1)
508 nb_lines
= MAX(1, nb_lines
/lists
->selected_size
);
509 gui_list_select_at_offset(lists
, -nb_lines
);
512 void gui_synclist_limit_scroll(struct gui_synclist
* lists
, bool scroll
)
514 lists
->limit_scroll
= scroll
;
517 #ifdef HAVE_LCD_BITMAP
519 * Makes all the item in the list scroll by one step to the right.
520 * Should stop increasing the value when reaching the widest item value
523 static void gui_synclist_scroll_right(struct gui_synclist
* lists
)
528 /* FIXME: This is a fake right boundry limiter. there should be some
529 * callback function to find the longest item on the list in pixels,
530 * to stop the list from scrolling past that point */
531 lists
->offset_position
[i
] += offset_step
;
532 if (lists
->offset_position
[i
] > 1000)
533 lists
->offset_position
[i
] = 1000;
538 * Makes all the item in the list scroll by one step to the left.
539 * stops at starting position.
541 static void gui_synclist_scroll_left(struct gui_synclist
* lists
)
546 lists
->offset_position
[i
] -= offset_step
;
547 if (lists
->offset_position
[i
] < 0)
548 lists
->offset_position
[i
] = 0;
551 #endif /* HAVE_LCD_BITMAP */
553 bool gui_synclist_do_button(struct gui_synclist
* lists
,
554 int *actionptr
, enum list_wrap wrap
)
556 int action
= *actionptr
;
557 #ifdef HAVE_LCD_BITMAP
558 static bool scrolling_left
= false;
561 #ifdef HAVE_WHEEL_ACCELERATION
562 int next_item_modifier
= button_apply_acceleration(get_action_data());
564 static int next_item_modifier
= 1;
565 static int last_accel_tick
= 0;
566 if (global_settings
.list_accel_start_delay
)
568 int start_delay
= global_settings
.list_accel_start_delay
* (HZ
/2);
569 int accel_wait
= global_settings
.list_accel_wait
* HZ
/2;
571 if (get_action_statuscode(NULL
)&ACTION_REPEAT
)
573 if (!last_accel_tick
)
574 last_accel_tick
= current_tick
+ start_delay
;
575 else if (TIME_AFTER(current_tick
, last_accel_tick
+ accel_wait
))
577 last_accel_tick
= current_tick
;
578 next_item_modifier
++;
581 else if (last_accel_tick
)
583 next_item_modifier
= 1;
589 #if defined(HAVE_TOUCHSCREEN)
590 if (action
== ACTION_TOUCHSCREEN
)
591 action
= *actionptr
= gui_synclist_do_touchscreen(lists
);
597 gui_synclist_limit_scroll(lists
, false);
600 gui_synclist_limit_scroll(lists
, true);
602 case LIST_WRAP_UNLESS_HELD
:
603 if (action
== ACTION_STD_PREVREPEAT
||
604 action
== ACTION_STD_NEXTREPEAT
||
605 action
== ACTION_LISTTREE_PGUP
||
606 action
== ACTION_LISTTREE_PGDOWN
)
607 gui_synclist_limit_scroll(lists
, true);
608 else gui_synclist_limit_scroll(lists
, false);
615 gui_synclist_draw(lists
);
618 #ifdef HAVE_VOLUME_IN_LIST
619 case ACTION_LIST_VOLUP
:
620 global_settings
.volume
+= 2;
621 /* up two because the falthrough brings it down one */
622 case ACTION_LIST_VOLDOWN
:
623 global_settings
.volume
--;
627 case ACTION_STD_PREV
:
628 case ACTION_STD_PREVREPEAT
:
629 gui_list_select_at_offset(lists
, -next_item_modifier
);
630 #ifndef HAVE_WHEEL_ACCELERATION
631 if (button_queue_count() < FRAMEDROP_TRIGGER
)
633 gui_synclist_draw(lists
);
635 *actionptr
= ACTION_STD_PREV
;
638 case ACTION_STD_NEXT
:
639 case ACTION_STD_NEXTREPEAT
:
640 gui_list_select_at_offset(lists
, next_item_modifier
);
641 #ifndef HAVE_WHEEL_ACCELERATION
642 if (button_queue_count() < FRAMEDROP_TRIGGER
)
644 gui_synclist_draw(lists
);
646 *actionptr
= ACTION_STD_NEXT
;
649 #ifdef HAVE_LCD_BITMAP
650 case ACTION_TREE_PGRIGHT
:
651 gui_synclist_scroll_right(lists
);
652 gui_synclist_draw(lists
);
654 case ACTION_TREE_ROOT_INIT
:
655 /* After this button press ACTION_TREE_PGLEFT is allowed
656 to skip to root. ACTION_TREE_ROOT_INIT must be defined in the
657 keymaps as a repeated button press (the same as the repeated
658 ACTION_TREE_PGLEFT) with the pre condition being the non-repeated
660 if (lists
->offset_position
[0] == 0)
662 scrolling_left
= false;
663 *actionptr
= ACTION_STD_CANCEL
;
666 *actionptr
= ACTION_TREE_PGLEFT
;
667 case ACTION_TREE_PGLEFT
:
668 if(!scrolling_left
&& (lists
->offset_position
[0] == 0))
670 *actionptr
= ACTION_STD_CANCEL
;
673 gui_synclist_scroll_left(lists
);
674 gui_synclist_draw(lists
);
675 scrolling_left
= true; /* stop ACTION_TREE_PAGE_LEFT
679 /* for pgup / pgdown, we are obliged to have a different behaviour depending
680 * on the screen for which the user pressed the key since for example, remote
681 * and main screen doesn't have the same number of lines */
682 case ACTION_LISTTREE_PGUP
:
685 #ifdef HAVE_REMOTE_LCD
686 get_action_statuscode(NULL
)&ACTION_REMOTE
?
690 gui_synclist_select_previous_page(lists
, screen
);
691 gui_synclist_draw(lists
);
693 *actionptr
= ACTION_STD_NEXT
;
697 case ACTION_LISTTREE_PGDOWN
:
700 #ifdef HAVE_REMOTE_LCD
701 get_action_statuscode(NULL
)&ACTION_REMOTE
?
705 gui_synclist_select_next_page(lists
, screen
);
706 gui_synclist_draw(lists
);
708 *actionptr
= ACTION_STD_PREV
;
712 if(lists
->scheduled_talk_tick
713 && TIME_AFTER(current_tick
, lists
->scheduled_talk_tick
))
714 /* scheduled postponed item announcement is due */
715 _gui_synclist_speak_item(lists
);
719 int list_do_action_timeout(struct gui_synclist
*lists
, int timeout
)
720 /* Returns the lowest of timeout or the delay until a postponed
721 scheduled announcement is due (if any). */
723 if(lists
->scheduled_talk_tick
)
725 long delay
= lists
->scheduled_talk_tick
-current_tick
+1;
726 /* +1 because the trigger condition uses TIME_AFTER(), which
727 is implemented as strictly greater than. */
730 if(timeout
> delay
|| timeout
== TIMEOUT_BLOCK
)
736 bool list_do_action(int context
, int timeout
,
737 struct gui_synclist
*lists
, int *action
,
739 /* Combines the get_action() (with possibly overridden timeout) and
740 gui_synclist_do_button() calls. Returns the list action from
741 do_button, and places the action from get_action in *action. */
743 timeout
= list_do_action_timeout(lists
, timeout
);
744 *action
= get_action(context
, timeout
);
745 return gui_synclist_do_button(lists
, action
, wrap
);
748 bool gui_synclist_item_is_onscreen(struct gui_synclist
*lists
,
749 enum screen_type screen
, int item
)
751 int nb_lines
= list_get_nb_lines(lists
, screen
);
752 return (unsigned)(item
- lists
->start_item
[screen
]) < (unsigned) nb_lines
;
755 /* Simple use list implementation */
756 static int simplelist_line_count
= 0;
757 static char simplelist_text
[SIMPLELIST_MAX_LINES
][SIMPLELIST_MAX_LINELENGTH
];
758 /* set the amount of lines shown in the list */
759 void simplelist_set_line_count(int lines
)
762 simplelist_line_count
= 0;
763 else if (lines
>= SIMPLELIST_MAX_LINES
)
764 simplelist_line_count
= SIMPLELIST_MAX_LINES
;
766 simplelist_line_count
= lines
;
768 /* get the current amount of lines shown */
769 int simplelist_get_line_count(void)
771 return simplelist_line_count
;
773 /* add/edit a line in the list.
774 if line_number > number of lines shown it adds the line,
775 else it edits the line */
776 void simplelist_addline(int line_number
, const char *fmt
, ...)
780 if (line_number
> simplelist_line_count
)
782 if (simplelist_line_count
< SIMPLELIST_MAX_LINES
)
783 line_number
= simplelist_line_count
++;
788 vsnprintf(simplelist_text
[line_number
], SIMPLELIST_MAX_LINELENGTH
, fmt
, ap
);
792 static const char* simplelist_static_getname(int item
,
797 (void)data
; (void)buffer
; (void)buffer_len
;
798 return simplelist_text
[item
];
801 bool simplelist_show_list(struct simplelist_info
*info
)
803 struct gui_synclist lists
;
804 int action
, old_line_count
= simplelist_line_count
, i
;
805 list_get_name
*getname
;
806 int wrap
= LIST_WRAP_UNLESS_HELD
;
808 getname
= info
->get_name
;
810 getname
= simplelist_static_getname
;
813 viewportmanager_theme_enable(i
, true, NULL
);
815 gui_synclist_init(&lists
, getname
, info
->callback_data
,
816 info
->scroll_all
, info
->selection_size
, NULL
);
819 gui_synclist_set_title(&lists
, info
->title
, NOICON
);
821 gui_synclist_set_icon_callback(&lists
, info
->get_icon
);
823 gui_synclist_set_voice_callback(&lists
, info
->get_talk
);
825 if (info
->hide_selection
)
827 gui_synclist_hide_selection_marker(&lists
, true);
828 wrap
= LIST_WRAP_OFF
;
831 if (info
->action_callback
)
832 info
->action_callback(ACTION_REDRAW
, &lists
);
834 if (info
->get_name
== NULL
)
835 gui_synclist_set_nb_items(&lists
,
836 simplelist_line_count
*info
->selection_size
);
838 gui_synclist_set_nb_items(&lists
, info
->count
*info
->selection_size
);
840 gui_synclist_select_item(&lists
, info
->selection
);
842 gui_synclist_draw(&lists
);
843 gui_synclist_speak_item(&lists
);
847 list_do_action(CONTEXT_LIST
, info
->timeout
,
848 &lists
, &action
, wrap
);
850 /* We must yield in this case or no other thread can run */
851 if (info
->timeout
== TIMEOUT_NOBLOCK
)
854 if (info
->action_callback
)
856 bool stdok
= action
==ACTION_STD_OK
;
857 action
= info
->action_callback(action
, &lists
);
858 if (stdok
&& action
== ACTION_STD_CANCEL
)
860 /* callback asked us to exit */
861 info
->selection
= gui_synclist_get_sel_pos(&lists
);
865 if (info
->get_name
== NULL
)
866 gui_synclist_set_nb_items(&lists
,
867 simplelist_line_count
*info
->selection_size
);
869 if (action
== ACTION_STD_CANCEL
)
871 info
->selection
= -1;
874 else if ((action
== ACTION_REDRAW
) ||
875 (old_line_count
!= simplelist_line_count
))
877 if (info
->get_name
== NULL
)
879 gui_synclist_set_nb_items(&lists
,
880 simplelist_line_count
*info
->selection_size
);
882 gui_synclist_draw(&lists
);
883 old_line_count
= simplelist_line_count
;
885 else if(default_event_handler(action
) == SYS_USB_CONNECTED
)
890 viewportmanager_theme_undo(i
, false);
894 void simplelist_info_init(struct simplelist_info
*info
, char* title
,
895 int count
, void* data
)
899 info
->selection_size
= 1;
900 info
->hide_selection
= false;
901 info
->scroll_all
= false;
902 info
->timeout
= HZ
/10;
904 info
->action_callback
= NULL
;
905 info
->get_icon
= NULL
;
906 info
->get_name
= NULL
;
907 info
->get_talk
= NULL
;
908 info
->callback_data
= data
;
909 simplelist_line_count
= 0;