A few changes and fixes for the title in the file view: disable title string in tagcache view, strip leading / from current directory title, center title properly, scroll title if it's too long.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10581 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dan Everton 2006-08-15 12:23:55 +00:00
parent 8570911e4e
commit c0f8b18770
3 changed files with 32 additions and 12 deletions

View file

@ -68,6 +68,7 @@ void gui_list_init(struct gui_list * gui_list,
gui_list->scroll_all=scroll_all;
gui_list->selected_size=selected_size;
gui_list->title = NULL;
gui_list->title_width = 0;
}
void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
@ -305,15 +306,22 @@ void gui_list_draw(struct gui_list * gui_list)
gui_list->start_item,
gui_list->start_item + display->nb_lines, VERTICAL);
}
#endif
if (gui_list->title)
{
int start = ((display->width/display->char_width) - strlen(gui_list->title))/2;
display->puts(start, 0, gui_list->title);
}
#else /* char cell display */
if (gui_list->title)
display->puts(0, 0, gui_list->title); /* dont center title */
/* Scroll if the title is too large, otherwise center */
if (gui_list->title_width > gui_list->display->width) {
display->puts_scroll(0, 0, gui_list->title);
} else {
#ifdef HAVE_LCD_BITMAP
display->putsxy((display->width - gui_list->title_width) / 2,
gui_textarea_get_ystart(display), gui_list->title);
#else
display->puts((display->width - gui_list->title_width) / 2, 0,
gui_list->title);
#endif
}
}
gui_textarea_update(display);
}
@ -513,10 +521,17 @@ void gui_list_screen_scroll_out_of_view(bool enable)
offset_out_of_view = false;
}
#endif /* HAVE_LCD_BITMAP */
void gui_list_set_title(struct gui_list * gui_list, char * title)
{
gui_list->title = title;
#ifdef HAVE_LCD_BITMAP
gui_list->display->getstringsize(title, &gui_list->title_width, NULL);
#else
gui_list->title_width = strlen(title);
#endif
}
/*
* Synchronized lists stuffs
*/

View file

@ -170,6 +170,8 @@ struct gui_list
void * data;
/* The optional title, set to NULL for none */
char *title;
/* Cache the width of the title string in pixels/characters */
int title_width;
};
/*

View file

@ -347,10 +347,13 @@ static int update_dir(void)
gui_syncsplash(HZ, true, str(LANG_SHOWDIR_BUFFER_FULL));
}
}
if (!id3db) {
if (global_settings.show_path_in_browser == SHOW_PATH_FULL) {
gui_synclist_set_title(&tree_lists, tc.currdir);
} else if (global_settings.show_path_in_browser == SHOW_PATH_CURRENT) {
gui_synclist_set_title(&tree_lists, strrchr(tc.currdir, '/'));
gui_synclist_set_title(&tree_lists,
tc.dirlevel > 0 ? strrchr(tc.currdir, '/') + 1 : "/");
}
}
gui_synclist_set_nb_items(&tree_lists, tc.filesindir);
gui_synclist_set_icon_callback(&tree_lists,