summaryrefslogtreecommitdiff
path: root/apps/gui/list.c
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2007-06-17 21:16:34 +0000
committerBrandon Low <lostlogic@rockbox.org>2007-06-17 21:16:34 +0000
commit74cbb0a1b24a5d2e32d2667b236483b5e7253e98 (patch)
tree4a9bd83a01bbb822305e3a567362fb3b36dfc28b /apps/gui/list.c
parentb57806237d275b54380be5b73e3d783bd6972bf8 (diff)
downloadrockbox-74cbb0a1b24a5d2e32d2667b236483b5e7253e98.tar.gz
rockbox-74cbb0a1b24a5d2e32d2667b236483b5e7253e98.zip
Give color targets the ability to display each LCD line a different color and use this newfangled ability to provide themable colored file types. See the comments on read_color_theme_file and the sample.colors file provided for how to use this. .colors files go in themes directory for now. This separate line color function should be trivial to add to menus and wpss.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13656 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/list.c')
-rw-r--r--apps/gui/list.c75
1 files changed, 52 insertions, 23 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 1aa189d9bf..5e073cc93b 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -63,11 +63,11 @@ static void gui_list_select_at_offset(struct gui_list * gui_list, int offset);
63/* 63/*
64 * Initializes a scrolling list 64 * Initializes a scrolling list
65 * - gui_list : the list structure to initialize 65 * - gui_list : the list structure to initialize
66 * - callback_get_item_icon : pointer to a function that associates an icon
67 * to a given item number
68 * - callback_get_item_name : pointer to a function that associates a label 66 * - callback_get_item_name : pointer to a function that associates a label
69 * to a given item number 67 * to a given item number
70 * - data : extra data passed to the list callback 68 * - data : extra data passed to the list callback
69 * - scroll_all :
70 * - selected_size :
71 */ 71 */
72static void gui_list_init(struct gui_list * gui_list, 72static void gui_list_init(struct gui_list * gui_list,
73 list_get_name callback_get_item_name, 73 list_get_name callback_get_item_name,
@@ -97,6 +97,11 @@ static void gui_list_init(struct gui_list * gui_list,
97 gui_list->last_displayed_selected_item = -1 ; 97 gui_list->last_displayed_selected_item = -1 ;
98 gui_list->last_displayed_start_item = -1 ; 98 gui_list->last_displayed_start_item = -1 ;
99 gui_list->show_selection_marker = true; 99 gui_list->show_selection_marker = true;
100
101#ifdef HAVE_LCD_COLOR
102 gui_list->title_color = -1;
103 gui_list->callback_get_item_color = NULL;
104#endif
100} 105}
101 106
102/* this toggles the selection bar or cursor */ 107/* this toggles the selection bar or cursor */
@@ -274,13 +279,23 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
274 } 279 }
275 280
276#ifdef HAVE_LCD_BITMAP 281#ifdef HAVE_LCD_BITMAP
282 int title_style = STYLE_DEFAULT;
283#ifdef HAVE_LCD_COLOR
284 if (gui_list->title_color >= 0)
285 {
286 title_style |= STYLE_COLORED;
287 title_style |= gui_list->title_color;
288 }
289#endif
277 screen_set_xmargin(display, text_pos); /* margin for title */ 290 screen_set_xmargin(display, text_pos); /* margin for title */
278 item_offset = gui_list_get_item_offset(gui_list, gui_list->title_width, 291 item_offset = gui_list_get_item_offset(gui_list, gui_list->title_width,
279 text_pos); 292 text_pos);
280 if (item_offset > gui_list->title_width - (display->width - text_pos)) 293 if (item_offset > gui_list->title_width - (display->width - text_pos))
281 display->puts_offset(0, 0, gui_list->title, item_offset); 294 display->puts_style_offset(0, 0, gui_list->title,
295 title_style, item_offset);
282 else 296 else
283 display->puts_scroll_offset(0, 0, gui_list->title, item_offset); 297 display->puts_scroll_style_offset(0, 0, gui_list->title,
298 title_style, item_offset);
284#else 299#else
285 display->puts_scroll(text_pos, 0, gui_list->title); 300 display->puts_scroll(text_pos, 0, gui_list->title);
286#endif 301#endif
@@ -333,6 +348,7 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
333 unsigned char *entry_name; 348 unsigned char *entry_name;
334 int current_item = gui_list->start_item + 349 int current_item = gui_list->start_item +
335 (SHOW_LIST_TITLE ? i-1 : i); 350 (SHOW_LIST_TITLE ? i-1 : i);
351 int style = STYLE_DEFAULT;
336 352
337 /* When there are less items to display than the 353 /* When there are less items to display than the
338 * current available space on the screen, we stop*/ 354 * current available space on the screen, we stop*/
@@ -350,6 +366,21 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
350 item_offset = gui_list_get_item_offset(gui_list, item_width, text_pos); 366 item_offset = gui_list_get_item_offset(gui_list, item_width, text_pos);
351#endif 367#endif
352 368
369#ifdef HAVE_LCD_COLOR
370 /* if the list has a color callback */
371 if (gui_list->callback_get_item_color)
372 {
373 int color = gui_list->callback_get_item_color(current_item,
374 gui_list->data);
375 /* if color selected */
376 if (color >= 0)
377 {
378 style |= STYLE_COLORED;
379 style |= color;
380 }
381 }
382#endif
383
353 if(gui_list->show_selection_marker && 384 if(gui_list->show_selection_marker &&
354 current_item >= gui_list->selected_item && 385 current_item >= gui_list->selected_item &&
355 current_item < gui_list->selected_item + gui_list->selected_size) 386 current_item < gui_list->selected_item + gui_list->selected_size)
@@ -357,29 +388,25 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
357#ifdef HAVE_LCD_BITMAP 388#ifdef HAVE_LCD_BITMAP
358 if (global_settings.invert_cursor)/* Display inverted-line-style*/ 389 if (global_settings.invert_cursor)/* Display inverted-line-style*/
359 { 390 {
360 /* if text got out of view */ 391 style |= STYLE_INVERT;
361 if (item_offset > item_width - (display->width - text_pos))
362 {
363 /* don't scroll */
364 display->puts_style_offset(0, i, entry_name,
365 STYLE_INVERT,item_offset);
366 }
367 else
368 {
369 display->puts_scroll_style_offset(0, i, entry_name,
370 STYLE_INVERT,
371 item_offset);
372 }
373 } 392 }
374 else /* if (!global_settings.invert_cursor) */ 393 else /* if (!global_settings.invert_cursor) */
375 { 394 {
376 if (item_offset > item_width - (display->width - text_pos))
377 display->puts_offset(0, i, entry_name,item_offset);
378 else
379 display->puts_scroll_offset(0, i, entry_name,item_offset);
380 if (current_item % gui_list->selected_size != 0) 395 if (current_item % gui_list->selected_size != 0)
381 draw_cursor = false; 396 draw_cursor = false;
382 } 397 }
398 /* if the text is smaller than the viewport size */
399 if (item_offset > item_width - (display->width - text_pos))
400 {
401 /* don't scroll */
402 display->puts_style_offset(0, i, entry_name,
403 style, item_offset);
404 }
405 else
406 {
407 display->puts_scroll_style_offset(0, i, entry_name,
408 style, item_offset);
409 }
383#else 410#else
384 display->puts_scroll(text_pos, i, entry_name); 411 display->puts_scroll(text_pos, i, entry_name);
385#endif 412#endif
@@ -397,7 +424,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
397 if(gui_list->scroll_all) 424 if(gui_list->scroll_all)
398 { 425 {
399#ifdef HAVE_LCD_BITMAP 426#ifdef HAVE_LCD_BITMAP
400 display->puts_scroll_offset(0, i, entry_name,item_offset); 427 display->puts_scroll_style_offset(0, i, entry_name,
428 style, item_offset);
401#else 429#else
402 display->puts_scroll(text_pos, i, entry_name); 430 display->puts_scroll(text_pos, i, entry_name);
403#endif 431#endif
@@ -405,7 +433,8 @@ static void gui_list_draw_smart(struct gui_list *gui_list)
405 else 433 else
406 { 434 {
407#ifdef HAVE_LCD_BITMAP 435#ifdef HAVE_LCD_BITMAP
408 display->puts_offset(0, i, entry_name,item_offset); 436 display->puts_style_offset(0, i, entry_name,
437 style, item_offset);
409#else 438#else
410 display->puts(text_pos, i, entry_name); 439 display->puts(text_pos, i, entry_name);
411#endif 440#endif