1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Jonathan Gordon
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 ****************************************************************************/
22 /* This file contains the code to draw the list widget on BITMAP LCDs. */
36 #include "screen_access.h"
37 #include "scrollbar.h"
42 void gui_synclist_scroll_stop(struct gui_synclist
*lists
)
48 screens
[i
].stop_scroll();
52 void list_draw(struct screen
*display
, struct gui_synclist
*gui_list
)
55 bool draw_icons
= (gui_list
->callback_get_item_icon
!= NULL
&&
56 global_settings
.show_icons
);
62 display
->set_viewport(NULL
);
63 lines
= display
->getnblines();
65 display
->clear_display();
67 end
= display
->getnblines();
68 gui_list
->last_displayed_start_item
[display
->screen_type
] =
69 gui_list
->start_item
[display
->screen_type
];
71 gui_list
->last_displayed_selected_item
= gui_list
->selected_item
;
73 /* Adjust the position of icon, cursor, text for the list */
76 text_pos
= 2; /* here it's in chars */
80 for (i
= start
; i
< end
; i
++)
82 unsigned const char *s
;
83 char entry_buffer
[MAX_PATH
];
84 unsigned char *entry_name
;
85 int current_item
= gui_list
->start_item
[display
->screen_type
] + i
;
87 /* When there are less items to display than the
88 * current available space on the screen, we stop*/
89 if(current_item
>= gui_list
->nb_items
)
91 s
= gui_list
->callback_get_item_name(current_item
,
94 sizeof(entry_buffer
));
95 entry_name
= P2STR(s
);
98 if(gui_list
->show_selection_marker
&&
99 current_item
>= gui_list
->selected_item
&&
100 current_item
< gui_list
->selected_item
+ gui_list
->selected_size
)
101 {/* The selected item must be displayed scrolling */
102 display
->puts_scroll(text_pos
, i
, entry_name
);
106 screen_put_icon_with_offset(display
, 0, i
,
107 (draw_scrollbar
|| SHOW_LIST_TITLE
)?
114 if(gui_list
->scroll_all
)
116 display
->puts_scroll(text_pos
, i
, entry_name
);
120 display
->puts(text_pos
, i
, entry_name
);
126 enum themable_icons icon
;
127 icon
= gui_list
->callback_get_item_icon(current_item
,
129 if(icon
> Icon_NOICON
)
131 screen_put_icon(display
, 1, i
, icon
);
136 display
->update_viewport();