summaryrefslogtreecommitdiff
path: root/apps/gui/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/list.c')
-rw-r--r--apps/gui/list.c172
1 files changed, 87 insertions, 85 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 2ae5f995f4..ce2a3354e4 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -37,8 +37,13 @@
37#define SCROLL_LIMIT 2 37#define SCROLL_LIMIT 2
38#endif 38#endif
39 39
40static int offset_step = 15; 40#ifdef HAVE_LCD_BITMAP
41static bool offset_outof_view = false; 41static int offset_step = 16; /* pixels per screen scroll step */
42/* should lines scroll out of the screen */
43static bool offset_out_of_view = false;
44#endif
45
46
42 47
43void gui_list_init(struct gui_list * gui_list, 48void gui_list_init(struct gui_list * gui_list,
44 list_get_name callback_get_item_name, 49 list_get_name callback_get_item_name,
@@ -54,7 +59,9 @@ void gui_list_init(struct gui_list * gui_list,
54 gui_list->limit_scroll = false; 59 gui_list->limit_scroll = false;
55 gui_list->data=data; 60 gui_list->data=data;
56 gui_list->cursor_flash_state=false; 61 gui_list->cursor_flash_state=false;
57 gui_list->offsetval = 0; 62#ifdef HAVE_LCD_BITMAP
63 gui_list->offset_position = 0;
64#endif
58} 65}
59 66
60void gui_list_set_display(struct gui_list * gui_list, struct screen * display) 67void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
@@ -181,47 +188,43 @@ void gui_list_draw(struct gui_list * gui_list)
181 entry_name = gui_list->callback_get_item_name(current_item, 188 entry_name = gui_list->callback_get_item_name(current_item,
182 gui_list->data, 189 gui_list->data,
183 entry_buffer); 190 entry_buffer);
184
185#ifdef HAVE_LCD_BITMAP 191#ifdef HAVE_LCD_BITMAP
186 /* position the string at the right offset place */ 192 /* position the string at the correct offset place */
187 int item_offset; 193 int item_offset;
188 int str_width,h; 194 int item_width,h;
189 display->getstringsize(entry_name, &str_width, &h); 195 display->getstringsize(entry_name, &item_width, &h);
190 196
191 if (offset_outof_view) 197 if (offset_out_of_view)
192 item_offset = gui_list->offsetval; 198 item_offset = gui_list->offset_position;
193 else
194 /* if text is smaller then view */
195 if (str_width <= display->width - text_pos)
196 item_offset = 0;
197 else 199 else
198 /* if text got out of view */ 200 /* if text is smaller then view */
199 if (gui_list->offsetval > str_width - (display->width - text_pos)) 201 if (item_width <= display->width - text_pos)
200 item_offset = str_width - (display->width - text_pos); 202 item_offset = 0;
201 else 203 else
202 item_offset = gui_list->offsetval; 204 /* if text got out of view */
203 205 if (gui_list->offset_position >
204#endif 206 item_width - (display->width - text_pos))
207 item_offset = item_width - (display->width - text_pos);
208 else
209 item_offset = gui_list->offset_position;
205 210
211#endif
206 if(current_item == gui_list->selected_item) { 212 if(current_item == gui_list->selected_item) {
207 /* The selected item must be displayed scrolling */ 213 /* The selected item must be displayed scrolling */
208#ifdef HAVE_LCD_BITMAP 214#ifdef HAVE_LCD_BITMAP
209 if (global_settings.invert_cursor) /* Display inverted-line-style*/ 215 if (global_settings.invert_cursor)/* Display inverted-line-style*/
210
211 /* if text got out of view */ 216 /* if text got out of view */
212 if (item_offset > str_width - (display->width - text_pos)) 217 if (item_offset > item_width - (display->width - text_pos))
213 /* don't scroll */ 218 /* don't scroll */
214 display->puts_style_offset(0, i, entry_name, STYLE_INVERT,item_offset); 219 display->puts_style_offset(0, i, entry_name, STYLE_INVERT,item_offset);
215 else 220 else
216 display->puts_scroll_style_offset(0, i, entry_name, STYLE_INVERT,item_offset); 221 display->puts_scroll_style_offset(0, i, entry_name, STYLE_INVERT,item_offset);
217
218 else /* if (global_settings.invert_cursor) */
219
220 if (item_offset > str_width - (display->width - text_pos))
221 display->puts_offset(0, i, entry_name,item_offset);
222 else
223 display->puts_scroll_offset(0, i, entry_name,item_offset);
224 222
223 else /* if (!global_settings.invert_cursor) */
224 if (item_offset > item_width - (display->width - text_pos))
225 display->puts_offset(0, i, entry_name,item_offset);
226 else
227 display->puts_scroll_offset(0, i, entry_name,item_offset);
225#else 228#else
226 display->puts_scroll(text_pos, i, entry_name); 229 display->puts_scroll(text_pos, i, entry_name);
227#endif 230#endif
@@ -264,40 +267,6 @@ void gui_list_draw(struct gui_list * gui_list)
264 gui_textarea_update(display); 267 gui_textarea_update(display);
265} 268}
266 269
267#ifdef HAVE_LCD_BITMAP
268void gui_list_screen_scroll_step(int ofs)
269{
270 offset_step = ofs;
271}
272
273void gui_list_screen_scroll_out_of_view(bool enable)
274{
275 if (enable)
276 offset_outof_view = true;
277 else
278 offset_outof_view = false;
279}
280
281void gui_list_offset_right(struct gui_list * gui_list)
282{
283 /* there should be a callback to find out what's the longest item on the list,
284 * and then, by finding out the width with get_stringsize, we would stop the
285 * list from scrolling at that point */
286
287 gui_list->offsetval+=offset_step;
288 if (gui_list->offsetval > 1000)
289 gui_list->offsetval = 1000;
290}
291
292void gui_list_offset_left(struct gui_list * gui_list)
293{
294 gui_list->offsetval-=offset_step;
295 if (gui_list->offsetval < 0)
296 gui_list->offsetval = 0;
297
298}
299#endif /* HAVE_LCD_BITMAP */
300
301void gui_list_select_item(struct gui_list * gui_list, int item_number) 270void gui_list_select_item(struct gui_list * gui_list, int item_number)
302{ 271{
303 if( item_number > gui_list->nb_items-1 || item_number < 0 ) 272 if( item_number > gui_list->nb_items-1 || item_number < 0 )
@@ -428,6 +397,37 @@ void gui_list_del_item(struct gui_list * gui_list)
428 } 397 }
429} 398}
430 399
400#ifdef HAVE_LCD_BITMAP
401void gui_list_scroll_right(struct gui_list * gui_list)
402{
403 /* FIXME: This is a fake right boundry limiter. there should be some
404 * callback function to find the longest item on the list in pixels,
405 * to stop the list from scrolling past that point */
406 gui_list->offset_position+=offset_step;
407 if (gui_list->offset_position > 1000)
408 gui_list->offset_position = 1000;
409}
410
411void gui_list_scroll_left(struct gui_list * gui_list)
412{
413 gui_list->offset_position-=offset_step;
414 if (gui_list->offset_position < 0)
415 gui_list->offset_position = 0;
416}
417void gui_list_screen_scroll_step(int ofs)
418{
419 offset_step = ofs;
420}
421
422void gui_list_screen_scroll_out_of_view(bool enable)
423{
424 if (enable)
425 offset_out_of_view = true;
426 else
427 offset_out_of_view = false;
428}
429#endif /* HAVE_LCD_BITMAP */
430
431/* 431/*
432 * Synchronized lists stuffs 432 * Synchronized lists stuffs
433 */ 433 */
@@ -453,7 +453,9 @@ void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
453 FOR_NB_SCREENS(i) 453 FOR_NB_SCREENS(i)
454 { 454 {
455 gui_list_set_nb_items(&(lists->gui_list[i]), nb_items); 455 gui_list_set_nb_items(&(lists->gui_list[i]), nb_items);
456 lists->gui_list[i].offsetval = 0; 456#ifdef HAVE_LCD_BITMAP
457 lists->gui_list[i].offset_position = 0;
458#endif
457 } 459 }
458} 460}
459void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback) 461void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback)
@@ -502,22 +504,6 @@ void gui_synclist_select_next_page(struct gui_synclist * lists,
502 screens[screen].nb_lines); 504 screens[screen].nb_lines);
503} 505}
504 506
505#ifdef HAVE_LCD_BITMAP
506void gui_synclist_offset_right(struct gui_synclist * lists)
507{
508 int i;
509 FOR_NB_SCREENS(i)
510 gui_list_offset_right(&(lists->gui_list[i]));
511}
512
513void gui_synclist_offset_left(struct gui_synclist * lists)
514{
515 int i;
516 FOR_NB_SCREENS(i)
517 gui_list_offset_left(&(lists->gui_list[i]));
518}
519#endif /* HAVE_LCD_BITMAP */
520
521void gui_synclist_select_previous_page(struct gui_synclist * lists, 507void gui_synclist_select_previous_page(struct gui_synclist * lists,
522 enum screen_type screen) 508 enum screen_type screen)
523{ 509{
@@ -555,6 +541,22 @@ void gui_synclist_flash(struct gui_synclist * lists)
555 gui_list_flash(&(lists->gui_list[i])); 541 gui_list_flash(&(lists->gui_list[i]));
556} 542}
557 543
544#ifdef HAVE_LCD_BITMAP
545void gui_synclist_scroll_right(struct gui_synclist * lists)
546{
547 int i;
548 FOR_NB_SCREENS(i)
549 gui_list_scroll_right(&(lists->gui_list[i]));
550}
551
552void gui_synclist_scroll_left(struct gui_synclist * lists)
553{
554 int i;
555 FOR_NB_SCREENS(i)
556 gui_list_scroll_left(&(lists->gui_list[i]));
557}
558#endif /* HAVE_LCD_BITMAP */
559
558unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button) 560unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
559{ 561{
560 gui_synclist_limit_scroll(lists, true); 562 gui_synclist_limit_scroll(lists, true);
@@ -588,7 +590,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
588 gui_synclist_select_next(lists); 590 gui_synclist_select_next(lists);
589 gui_synclist_draw(lists); 591 gui_synclist_draw(lists);
590 return LIST_NEXT; 592 return LIST_NEXT;
591 593
592#ifdef LIST_PGRIGHT 594#ifdef LIST_PGRIGHT
593 case LIST_PGRIGHT: 595 case LIST_PGRIGHT:
594 case LIST_PGRIGHT | BUTTON_REPEAT: 596 case LIST_PGRIGHT | BUTTON_REPEAT:
@@ -596,7 +598,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
596 case LIST_RC_PGRIGHT: 598 case LIST_RC_PGRIGHT:
597 case LIST_RC_PGRIGHT | BUTTON_REPEAT: 599 case LIST_RC_PGRIGHT | BUTTON_REPEAT:
598#endif 600#endif
599 gui_synclist_offset_right(lists); 601 gui_synclist_scroll_right(lists);
600 gui_synclist_draw(lists); 602 gui_synclist_draw(lists);
601 return true; 603 return true;
602#endif 604#endif
@@ -608,7 +610,7 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
608 case LIST_RC_PGLEFT: 610 case LIST_RC_PGLEFT:
609 case LIST_RC_PGLEFT | BUTTON_REPEAT: 611 case LIST_RC_PGLEFT | BUTTON_REPEAT:
610#endif 612#endif
611 gui_synclist_offset_left(lists); 613 gui_synclist_scroll_left(lists);
612 gui_synclist_draw(lists); 614 gui_synclist_draw(lists);
613 return true; 615 return true;
614#endif 616#endif