diff options
-rw-r--r-- | apps/gui/icon.h | 6 | ||||
-rw-r--r-- | apps/gui/list.c | 122 | ||||
-rw-r--r-- | apps/gui/list.h | 14 | ||||
-rw-r--r-- | apps/settings.c | 2 | ||||
-rw-r--r-- | apps/tree.c | 31 |
5 files changed, 117 insertions, 58 deletions
diff --git a/apps/gui/icon.h b/apps/gui/icon.h index 1eefc4850c..14b66d3c51 100644 --- a/apps/gui/icon.h +++ b/apps/gui/icon.h | |||
@@ -23,9 +23,11 @@ | |||
23 | /* Defines a type for the icons since it's not the same thing on | 23 | /* Defines a type for the icons since it's not the same thing on |
24 | * char-based displays and bitmap displays */ | 24 | * char-based displays and bitmap displays */ |
25 | #ifdef HAVE_LCD_BITMAP | 25 | #ifdef HAVE_LCD_BITMAP |
26 | typedef const unsigned char * ICON; | 26 | typedef const unsigned char * ICON; |
27 | #define NOICON NULL | ||
27 | #else | 28 | #else |
28 | typedef short ICON; | 29 | typedef short ICON; |
30 | #define NOICON -1 | ||
29 | #endif | 31 | #endif |
30 | 32 | ||
31 | #define CURSOR_CHAR 0x92 | 33 | #define CURSOR_CHAR 0x92 |
diff --git a/apps/gui/list.c b/apps/gui/list.c index 8a5c2060ba..94150176dc 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c | |||
@@ -70,6 +70,7 @@ void gui_list_init(struct gui_list * gui_list, | |||
70 | gui_list->selected_size=selected_size; | 70 | gui_list->selected_size=selected_size; |
71 | gui_list->title = NULL; | 71 | gui_list->title = NULL; |
72 | gui_list->title_width = 0; | 72 | gui_list->title_width = 0; |
73 | gui_list->title_icon = NOICON; | ||
73 | } | 74 | } |
74 | 75 | ||
75 | void gui_list_set_display(struct gui_list * gui_list, struct screen * display) | 76 | void gui_list_set_display(struct gui_list * gui_list, struct screen * display) |
@@ -144,6 +145,39 @@ void gui_list_put_selection_in_screen(struct gui_list * gui_list, | |||
144 | gui_list->start_item = 0; | 145 | gui_list->start_item = 0; |
145 | } | 146 | } |
146 | 147 | ||
148 | #ifdef HAVE_LCD_BITMAP | ||
149 | int gui_list_get_item_offset(struct gui_list * gui_list, int item_width, | ||
150 | int text_pos) | ||
151 | { | ||
152 | struct screen * display=gui_list->display; | ||
153 | int item_offset; | ||
154 | |||
155 | if (offset_out_of_view) | ||
156 | { | ||
157 | item_offset = gui_list->offset_position; | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | /* if text is smaller then view */ | ||
162 | if (item_width <= display->width - text_pos) | ||
163 | { | ||
164 | item_offset = 0; | ||
165 | } | ||
166 | else | ||
167 | { | ||
168 | /* if text got out of view */ | ||
169 | if (gui_list->offset_position > | ||
170 | item_width - (display->width - text_pos)) | ||
171 | item_offset = item_width - (display->width - text_pos); | ||
172 | else | ||
173 | item_offset = gui_list->offset_position; | ||
174 | } | ||
175 | } | ||
176 | |||
177 | return item_offset; | ||
178 | } | ||
179 | #endif | ||
180 | |||
147 | void gui_list_draw(struct gui_list * gui_list) | 181 | void gui_list_draw(struct gui_list * gui_list) |
148 | { | 182 | { |
149 | struct screen * display=gui_list->display; | 183 | struct screen * display=gui_list->display; |
@@ -154,30 +188,62 @@ void gui_list_draw(struct gui_list * gui_list) | |||
154 | bool draw_cursor; | 188 | bool draw_cursor; |
155 | int i; | 189 | int i; |
156 | int lines; | 190 | int lines; |
191 | #ifdef HAVE_LCD_BITMAP | ||
192 | int item_offset; | ||
193 | #endif | ||
194 | |||
195 | gui_textarea_clear(display); | ||
157 | 196 | ||
158 | /* Adjust the position of icon, cursor, text */ | 197 | /* position and draw the list title & icon */ |
159 | if (gui_list->title) | 198 | if (gui_list->title) |
160 | { | 199 | { |
161 | i = 1; | 200 | i = 1; |
162 | lines = display->nb_lines - 1; | 201 | lines = display->nb_lines - 1; |
202 | |||
203 | if (gui_list->title_icon != NOICON && draw_icons) | ||
204 | { | ||
205 | screen_put_iconxy(display, 0, 0, gui_list->title_icon); | ||
206 | #ifdef HAVE_LCD_BITMAP | ||
207 | text_pos = 8; /* pixels */ | ||
208 | #else | ||
209 | text_pos = 1; /* chars */ | ||
210 | #endif | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | text_pos = 0; | ||
215 | } | ||
216 | |||
217 | #ifdef HAVE_LCD_BITMAP | ||
218 | screen_set_xmargin(display, text_pos); /* margin for title */ | ||
219 | item_offset = gui_list_get_item_offset(gui_list, gui_list->title_width, | ||
220 | text_pos); | ||
221 | if (item_offset > gui_list->title_width - (display->width - text_pos)) | ||
222 | display->puts_offset(0, 0, gui_list->title, item_offset); | ||
223 | else | ||
224 | display->puts_scroll_offset(0, 0, gui_list->title, item_offset); | ||
225 | #else | ||
226 | display->puts_scroll(text_pos, 0, gui_list->title); | ||
227 | #endif | ||
163 | } | 228 | } |
164 | else | 229 | else |
165 | { | 230 | { |
166 | i = 0; | 231 | i = 0; |
167 | lines = display->nb_lines; | 232 | lines = display->nb_lines; |
168 | } | 233 | } |
234 | |||
235 | /* Adjust the position of icon, cursor, text for the list */ | ||
169 | #ifdef HAVE_LCD_BITMAP | 236 | #ifdef HAVE_LCD_BITMAP |
170 | display->setfont(FONT_UI); | 237 | display->setfont(FONT_UI); |
171 | gui_textarea_update_nblines(display); | 238 | gui_textarea_update_nblines(display); |
172 | bool draw_scrollbar; | 239 | bool draw_scrollbar; |
173 | 240 | ||
174 | |||
175 | draw_scrollbar = (global_settings.scrollbar && | 241 | draw_scrollbar = (global_settings.scrollbar && |
176 | lines < gui_list->nb_items); | 242 | lines < gui_list->nb_items); |
177 | 243 | ||
178 | draw_cursor = !global_settings.invert_cursor; | 244 | draw_cursor = !global_settings.invert_cursor; |
179 | text_pos = 0; /* here it's in pixels */ | 245 | text_pos = 0; /* here it's in pixels */ |
180 | if(draw_scrollbar) | 246 | if(draw_scrollbar || gui_list->title) /* indent if there's a title */ |
181 | { | 247 | { |
182 | cursor_pos++; | 248 | cursor_pos++; |
183 | icon_pos++; | 249 | icon_pos++; |
@@ -198,12 +264,10 @@ void gui_list_draw(struct gui_list * gui_list) | |||
198 | text_pos = 1; | 264 | text_pos = 1; |
199 | #endif | 265 | #endif |
200 | 266 | ||
201 | gui_textarea_clear(display); | ||
202 | #ifdef HAVE_LCD_BITMAP | 267 | #ifdef HAVE_LCD_BITMAP |
203 | screen_set_xmargin(display, text_pos); | 268 | screen_set_xmargin(display, text_pos); /* margin for list */ |
204 | #endif | 269 | #endif |
205 | 270 | ||
206 | |||
207 | while (i < display->nb_lines) | 271 | while (i < display->nb_lines) |
208 | { | 272 | { |
209 | char entry_buffer[MAX_PATH]; | 273 | char entry_buffer[MAX_PATH]; |
@@ -219,26 +283,13 @@ void gui_list_draw(struct gui_list * gui_list) | |||
219 | entry_buffer); | 283 | entry_buffer); |
220 | #ifdef HAVE_LCD_BITMAP | 284 | #ifdef HAVE_LCD_BITMAP |
221 | /* position the string at the correct offset place */ | 285 | /* position the string at the correct offset place */ |
222 | int item_offset; | ||
223 | int item_width,h; | 286 | int item_width,h; |
224 | display->getstringsize(entry_name, &item_width, &h); | 287 | display->getstringsize(entry_name, &item_width, &h); |
225 | 288 | item_offset = gui_list_get_item_offset(gui_list, item_width, text_pos); | |
226 | if (offset_out_of_view) | ||
227 | item_offset = gui_list->offset_position; | ||
228 | else | ||
229 | /* if text is smaller then view */ | ||
230 | if (item_width <= display->width - text_pos) | ||
231 | item_offset = 0; | ||
232 | else | ||
233 | /* if text got out of view */ | ||
234 | if (gui_list->offset_position > | ||
235 | item_width - (display->width - text_pos)) | ||
236 | item_offset = item_width - (display->width - text_pos); | ||
237 | else | ||
238 | item_offset = gui_list->offset_position; | ||
239 | |||
240 | #endif | 289 | #endif |
241 | if(current_item >= gui_list->selected_item && current_item < gui_list->selected_item+gui_list->selected_size) | 290 | |
291 | if(current_item >= gui_list->selected_item && | ||
292 | current_item < gui_list->selected_item + gui_list->selected_size) | ||
242 | {/* The selected item must be displayed scrolling */ | 293 | {/* The selected item must be displayed scrolling */ |
243 | #ifdef HAVE_LCD_BITMAP | 294 | #ifdef HAVE_LCD_BITMAP |
244 | if (global_settings.invert_cursor)/* Display inverted-line-style*/ | 295 | if (global_settings.invert_cursor)/* Display inverted-line-style*/ |
@@ -308,21 +359,7 @@ void gui_list_draw(struct gui_list * gui_list) | |||
308 | gui_list->start_item + display->nb_lines, VERTICAL); | 359 | gui_list->start_item + display->nb_lines, VERTICAL); |
309 | } | 360 | } |
310 | #endif | 361 | #endif |
311 | if (gui_list->title) | 362 | |
312 | { | ||
313 | /* Scroll if the title is too large, otherwise center */ | ||
314 | if (gui_list->title_width > gui_list->display->width) { | ||
315 | display->puts_scroll(0, 0, gui_list->title); | ||
316 | } else { | ||
317 | #ifdef HAVE_LCD_BITMAP | ||
318 | display->putsxy((display->width - gui_list->title_width) / 2, | ||
319 | gui_textarea_get_ystart(display), gui_list->title); | ||
320 | #else | ||
321 | display->puts((display->width - gui_list->title_width) / 2, 0, | ||
322 | gui_list->title); | ||
323 | #endif | ||
324 | } | ||
325 | } | ||
326 | gui_textarea_update(display); | 363 | gui_textarea_update(display); |
327 | } | 364 | } |
328 | 365 | ||
@@ -522,9 +559,10 @@ void gui_list_screen_scroll_out_of_view(bool enable) | |||
522 | } | 559 | } |
523 | #endif /* HAVE_LCD_BITMAP */ | 560 | #endif /* HAVE_LCD_BITMAP */ |
524 | 561 | ||
525 | void gui_list_set_title(struct gui_list * gui_list, char * title) | 562 | void gui_list_set_title(struct gui_list * gui_list, char * title, ICON icon) |
526 | { | 563 | { |
527 | gui_list->title = title; | 564 | gui_list->title = title; |
565 | gui_list->title_icon = icon; | ||
528 | if (title) { | 566 | if (title) { |
529 | #ifdef HAVE_LCD_BITMAP | 567 | #ifdef HAVE_LCD_BITMAP |
530 | gui_list->display->getstringsize(title, &gui_list->title_width, NULL); | 568 | gui_list->display->getstringsize(title, &gui_list->title_width, NULL); |
@@ -652,11 +690,11 @@ void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll) | |||
652 | gui_list_limit_scroll(&(lists->gui_list[i]), scroll); | 690 | gui_list_limit_scroll(&(lists->gui_list[i]), scroll); |
653 | } | 691 | } |
654 | 692 | ||
655 | void gui_synclist_set_title(struct gui_synclist * lists, char* title) | 693 | void gui_synclist_set_title(struct gui_synclist * lists, char * title, ICON icon) |
656 | { | 694 | { |
657 | int i; | 695 | int i; |
658 | FOR_NB_SCREENS(i) | 696 | FOR_NB_SCREENS(i) |
659 | gui_list_set_title(&(lists->gui_list[i]), title); | 697 | gui_list_set_title(&(lists->gui_list[i]), title, icon); |
660 | } | 698 | } |
661 | 699 | ||
662 | void gui_synclist_flash(struct gui_synclist * lists) | 700 | void gui_synclist_flash(struct gui_synclist * lists) |
diff --git a/apps/gui/list.h b/apps/gui/list.h index 2a80298379..914563a597 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h | |||
@@ -88,7 +88,9 @@ struct gui_list | |||
88 | /* The optional title, set to NULL for none */ | 88 | /* The optional title, set to NULL for none */ |
89 | char *title; | 89 | char *title; |
90 | /* Cache the width of the title string in pixels/characters */ | 90 | /* Cache the width of the title string in pixels/characters */ |
91 | int title_width; | 91 | int title_width; |
92 | /* Optional title icon */ | ||
93 | ICON title_icon; | ||
92 | }; | 94 | }; |
93 | 95 | ||
94 | /* | 96 | /* |
@@ -254,9 +256,12 @@ extern void gui_list_del_item(struct gui_list * gui_list); | |||
254 | extern void gui_list_flash(struct gui_list * gui_list); | 256 | extern void gui_list_flash(struct gui_list * gui_list); |
255 | 257 | ||
256 | /* | 258 | /* |
257 | * Set the title of the list, setting to NULL disables the title | 259 | * Set the title and title icon of the list. Setting title to NULL disables |
260 | * both the title and icon. Use NOICON if there is no icon. | ||
258 | */ | 261 | */ |
259 | extern void gui_list_set_title(struct gui_list *gui_list, char* title); | 262 | extern void gui_list_set_title(struct gui_list *gui_list, char* title, |
263 | ICON icon); | ||
264 | |||
260 | /* | 265 | /* |
261 | * This part handles as many lists as there are connected screens | 266 | * This part handles as many lists as there are connected screens |
262 | * (the api is similar to the ones above) | 267 | * (the api is similar to the ones above) |
@@ -297,7 +302,8 @@ extern void gui_synclist_add_item(struct gui_synclist * lists); | |||
297 | extern void gui_synclist_del_item(struct gui_synclist * lists); | 302 | extern void gui_synclist_del_item(struct gui_synclist * lists); |
298 | extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll); | 303 | extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll); |
299 | extern void gui_synclist_flash(struct gui_synclist * lists); | 304 | extern void gui_synclist_flash(struct gui_synclist * lists); |
300 | extern void gui_synclist_set_title(struct gui_synclist * lists, char* title); | 305 | extern void gui_synclist_set_title(struct gui_synclist * lists, char * title, |
306 | ICON icon); | ||
301 | void gui_synclist_scroll_right(struct gui_synclist * lists); | 307 | void gui_synclist_scroll_right(struct gui_synclist * lists); |
302 | void gui_synclist_scroll_left(struct gui_synclist * lists); | 308 | void gui_synclist_scroll_left(struct gui_synclist * lists); |
303 | 309 | ||
diff --git a/apps/settings.c b/apps/settings.c index b277fd7f3e..49b8f9826b 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -1903,7 +1903,7 @@ bool do_set_setting(const unsigned char* string, void *variable, | |||
1903 | else oldvalue = *(bool*)variable; | 1903 | else oldvalue = *(bool*)variable; |
1904 | 1904 | ||
1905 | gui_synclist_init(&lists,value_setting_get_name_cb,(void*)cb_data,false,1); | 1905 | gui_synclist_init(&lists,value_setting_get_name_cb,(void*)cb_data,false,1); |
1906 | gui_synclist_set_title(&lists, (char*)string); | 1906 | gui_synclist_set_title(&lists, (char*)string, NOICON); |
1907 | gui_synclist_set_icon_callback(&lists,NULL); | 1907 | gui_synclist_set_icon_callback(&lists,NULL); |
1908 | gui_synclist_set_nb_items(&lists,nb_items); | 1908 | gui_synclist_set_nb_items(&lists,nb_items); |
1909 | gui_synclist_limit_scroll(&lists,true); | 1909 | gui_synclist_limit_scroll(&lists,true); |
diff --git a/apps/tree.c b/apps/tree.c index 21405c9f46..4558cd59a4 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -349,20 +349,33 @@ static int update_dir(void) | |||
349 | } | 349 | } |
350 | } | 350 | } |
351 | if (!id3db) { | 351 | if (!id3db) { |
352 | if (global_settings.show_path_in_browser == SHOW_PATH_FULL) { | 352 | if (global_settings.show_path_in_browser == SHOW_PATH_FULL) |
353 | gui_synclist_set_title(&tree_lists, tc.currdir); | 353 | { |
354 | } else if (global_settings.show_path_in_browser == SHOW_PATH_CURRENT) { | 354 | gui_synclist_set_title(&tree_lists, tc.currdir, |
355 | gui_synclist_set_title(&tree_lists, | 355 | filetype_get_icon(ATTR_DIRECTORY)); |
356 | tc.dirlevel > 0 ? strrchr(tc.currdir, '/') + 1 : "/"); | 356 | } |
357 | } else { | 357 | else if (global_settings.show_path_in_browser == SHOW_PATH_CURRENT) |
358 | /* Must clear the title as the list is reused */ | 358 | { |
359 | gui_synclist_set_title(&tree_lists, NULL); | 359 | char *title = strrchr(tc.currdir, '/') + 1; |
360 | if (*title == '\0') | ||
361 | { | ||
362 | /* Display nothing for the root dir */ | ||
363 | gui_synclist_set_title(&tree_lists, NULL, NOICON); | ||
364 | } | ||
365 | else | ||
366 | gui_synclist_set_title(&tree_lists, title, | ||
367 | filetype_get_icon(ATTR_DIRECTORY)); | ||
360 | } | 368 | } |
369 | else | ||
370 | { | ||
371 | /* Must clear the title as the list is reused */ | ||
372 | gui_synclist_set_title(&tree_lists, NULL, NOICON); | ||
373 | } | ||
361 | } | 374 | } |
362 | else | 375 | else |
363 | { | 376 | { |
364 | /* This currently doesn't work too well in id3db so turn it off */ | 377 | /* This currently doesn't work too well in id3db so turn it off */ |
365 | gui_synclist_set_title(&tree_lists, NULL); | 378 | gui_synclist_set_title(&tree_lists, NULL, NOICON); |
366 | } | 379 | } |
367 | gui_synclist_set_nb_items(&tree_lists, tc.filesindir); | 380 | gui_synclist_set_nb_items(&tree_lists, tc.filesindir); |
368 | gui_synclist_set_icon_callback(&tree_lists, | 381 | gui_synclist_set_icon_callback(&tree_lists, |