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.c127
1 files changed, 119 insertions, 8 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 83a1fbfb22..2ae5f995f4 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -37,7 +37,8 @@
37#define SCROLL_LIMIT 2 37#define SCROLL_LIMIT 2
38#endif 38#endif
39 39
40 40static int offset_step = 15;
41static bool offset_outof_view = false;
41 42
42void gui_list_init(struct gui_list * gui_list, 43void gui_list_init(struct gui_list * gui_list,
43 list_get_name callback_get_item_name, 44 list_get_name callback_get_item_name,
@@ -53,6 +54,7 @@ void gui_list_init(struct gui_list * gui_list,
53 gui_list->limit_scroll = false; 54 gui_list->limit_scroll = false;
54 gui_list->data=data; 55 gui_list->data=data;
55 gui_list->cursor_flash_state=false; 56 gui_list->cursor_flash_state=false;
57 gui_list->offsetval = 0;
56} 58}
57 59
58void gui_list_set_display(struct gui_list * gui_list, struct screen * display) 60void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
@@ -179,14 +181,47 @@ void gui_list_draw(struct gui_list * gui_list)
179 entry_name = gui_list->callback_get_item_name(current_item, 181 entry_name = gui_list->callback_get_item_name(current_item,
180 gui_list->data, 182 gui_list->data,
181 entry_buffer); 183 entry_buffer);
182 if(current_item == gui_list->selected_item) 184
183 {
184 /* The selected item must be displayed scrolling */
185#ifdef HAVE_LCD_BITMAP 185#ifdef HAVE_LCD_BITMAP
186 if (global_settings.invert_cursor)/* Display inverted-line-style*/ 186 /* position the string at the right offset place */
187 display->puts_scroll_style(0, i, entry_name, STYLE_INVERT); 187 int item_offset;
188 int str_width,h;
189 display->getstringsize(entry_name, &str_width, &h);
190
191 if (offset_outof_view)
192 item_offset = gui_list->offsetval;
193 else
194 /* if text is smaller then view */
195 if (str_width <= display->width - text_pos)
196 item_offset = 0;
197 else
198 /* if text got out of view */
199 if (gui_list->offsetval > str_width - (display->width - text_pos))
200 item_offset = str_width - (display->width - text_pos);
188 else 201 else
189 display->puts_scroll(0, i, entry_name); 202 item_offset = gui_list->offsetval;
203
204#endif
205
206 if(current_item == gui_list->selected_item) {
207 /* The selected item must be displayed scrolling */
208#ifdef HAVE_LCD_BITMAP
209 if (global_settings.invert_cursor) /* Display inverted-line-style*/
210
211 /* if text got out of view */
212 if (item_offset > str_width - (display->width - text_pos))
213 /* don't scroll */
214 display->puts_style_offset(0, i, entry_name, STYLE_INVERT,item_offset);
215 else
216 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
190#else 225#else
191 display->puts_scroll(text_pos, i, entry_name); 226 display->puts_scroll(text_pos, i, entry_name);
192#endif 227#endif
@@ -197,7 +232,7 @@ void gui_list_draw(struct gui_list * gui_list)
197 else 232 else
198 {/* normal item */ 233 {/* normal item */
199#ifdef HAVE_LCD_BITMAP 234#ifdef HAVE_LCD_BITMAP
200 display->puts(0, i, entry_name); 235 display->puts_offset(0, i, entry_name,item_offset);
201#else 236#else
202 display->puts(text_pos, i, entry_name); 237 display->puts(text_pos, i, entry_name);
203#endif 238#endif
@@ -229,6 +264,40 @@ void gui_list_draw(struct gui_list * gui_list)
229 gui_textarea_update(display); 264 gui_textarea_update(display);
230} 265}
231 266
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
232void gui_list_select_item(struct gui_list * gui_list, int item_number) 301void gui_list_select_item(struct gui_list * gui_list, int item_number)
233{ 302{
234 if( item_number > gui_list->nb_items-1 || item_number < 0 ) 303 if( item_number > gui_list->nb_items-1 || item_number < 0 )
@@ -384,6 +453,7 @@ void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
384 FOR_NB_SCREENS(i) 453 FOR_NB_SCREENS(i)
385 { 454 {
386 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;
387 } 457 }
388} 458}
389void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback) 459void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback)
@@ -432,6 +502,22 @@ void gui_synclist_select_next_page(struct gui_synclist * lists,
432 screens[screen].nb_lines); 502 screens[screen].nb_lines);
433} 503}
434 504
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
435void gui_synclist_select_previous_page(struct gui_synclist * lists, 521void gui_synclist_select_previous_page(struct gui_synclist * lists,
436 enum screen_type screen) 522 enum screen_type screen)
437{ 523{
@@ -502,6 +588,31 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
502 gui_synclist_select_next(lists); 588 gui_synclist_select_next(lists);
503 gui_synclist_draw(lists); 589 gui_synclist_draw(lists);
504 return LIST_NEXT; 590 return LIST_NEXT;
591
592#ifdef LIST_PGRIGHT
593 case LIST_PGRIGHT:
594 case LIST_PGRIGHT | BUTTON_REPEAT:
595#ifdef LIST_RC_PGRIGHT
596 case LIST_RC_PGRIGHT:
597 case LIST_RC_PGRIGHT | BUTTON_REPEAT:
598#endif
599 gui_synclist_offset_right(lists);
600 gui_synclist_draw(lists);
601 return true;
602#endif
603
604#ifdef LIST_PGLEFT
605 case LIST_PGLEFT:
606 case LIST_PGLEFT | BUTTON_REPEAT:
607#ifdef LIST_RC_PGLEFT
608 case LIST_RC_PGLEFT:
609 case LIST_RC_PGLEFT | BUTTON_REPEAT:
610#endif
611 gui_synclist_offset_left(lists);
612 gui_synclist_draw(lists);
613 return true;
614#endif
615
505/* for pgup / pgdown, we are obliged to have a different behaviour depending on the screen 616/* for pgup / pgdown, we are obliged to have a different behaviour depending on the screen
506 * for which the user pressed the key since for example, remote and main screen doesn't 617 * for which the user pressed the key since for example, remote and main screen doesn't
507 * have the same number of lines*/ 618 * have the same number of lines*/