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->scroll_all=scroll_all;
gui_list->selected_size=selected_size; gui_list->selected_size=selected_size;
gui_list->title = NULL; gui_list->title = NULL;
gui_list->title_width = 0;
} }
void gui_list_set_display(struct gui_list * gui_list, struct screen * display) 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,
gui_list->start_item + display->nb_lines, VERTICAL); gui_list->start_item + display->nb_lines, VERTICAL);
} }
#endif
if (gui_list->title) if (gui_list->title)
{ {
int start = ((display->width/display->char_width) - strlen(gui_list->title))/2; /* Scroll if the title is too large, otherwise center */
display->puts(start, 0, gui_list->title); if (gui_list->title_width > gui_list->display->width) {
} display->puts_scroll(0, 0, gui_list->title);
#else /* char cell display */ } else {
if (gui_list->title) #ifdef HAVE_LCD_BITMAP
display->puts(0, 0, gui_list->title); /* dont center title */ 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 #endif
}
}
gui_textarea_update(display); gui_textarea_update(display);
} }
@ -513,10 +521,17 @@ void gui_list_screen_scroll_out_of_view(bool enable)
offset_out_of_view = false; offset_out_of_view = false;
} }
#endif /* HAVE_LCD_BITMAP */ #endif /* HAVE_LCD_BITMAP */
void gui_list_set_title(struct gui_list *gui_list , char* title)
void gui_list_set_title(struct gui_list * gui_list, char * title)
{ {
gui_list->title = 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 * Synchronized lists stuffs
*/ */

View file

@ -170,6 +170,8 @@ struct gui_list
void * data; void * data;
/* The optional title, set to NULL for none */ /* The optional title, set to NULL for none */
char *title; char *title;
/* Cache the width of the title string in pixels/characters */
int title_width;
}; };
/* /*
@ -337,7 +339,7 @@ extern void gui_list_flash(struct gui_list * gui_list);
/* /*
* Set the title of the list, setting to NULL disables the title * Set the title of the list, setting to NULL disables the title
*/ */
extern void gui_list_set_title(struct gui_list *gui_list , char* title); extern void gui_list_set_title(struct gui_list *gui_list, char* title);
/* /*
* This part handles as many lists as there are connected screens * This part handles as many lists as there are connected screens
* (the api is similar to the ones above) * (the api is similar to the ones above)

View file

@ -347,10 +347,13 @@ static int update_dir(void)
gui_syncsplash(HZ, true, str(LANG_SHOWDIR_BUFFER_FULL)); gui_syncsplash(HZ, true, str(LANG_SHOWDIR_BUFFER_FULL));
} }
} }
if (global_settings.show_path_in_browser == SHOW_PATH_FULL) { if (!id3db) {
gui_synclist_set_title(&tree_lists, tc.currdir); if (global_settings.show_path_in_browser == SHOW_PATH_FULL) {
} else if (global_settings.show_path_in_browser == SHOW_PATH_CURRENT) { gui_synclist_set_title(&tree_lists, tc.currdir);
gui_synclist_set_title(&tree_lists, strrchr(tc.currdir, '/')); } else if (global_settings.show_path_in_browser == SHOW_PATH_CURRENT) {
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_nb_items(&tree_lists, tc.filesindir);
gui_synclist_set_icon_callback(&tree_lists, gui_synclist_set_icon_callback(&tree_lists,