Fix buttonbar and line padding in time&date screen.

The time&date screen uses a custom parent for do_menu(), and doesn't
account for the buttonbar and list line height. Introduce
gui_synclist_set_viewport_defaults() to set those for viewports that are
going to be list parents and use that so that time&date screen doesn't need
to know about buttonbar/line padding.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30824 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2011-10-22 10:09:23 +00:00
parent 09d0b6fec4
commit 5c509d17db
3 changed files with 17 additions and 11 deletions

View file

@ -101,15 +101,7 @@ static void list_init_viewports(struct gui_synclist *list)
{
FOR_NB_SCREENS(i)
{
list->parent[i] = &parent[i];
viewport_set_defaults(&parent[i], i);
#ifdef HAVE_TOUCHSCREEN
parent[i].line_height = list_line_height(list->parent[i]);
#endif
#ifdef HAVE_BUTTONBAR
if (screens[i].has_buttonbar)
list->parent[i]->height -= BUTTONBAR_HEIGHT;
#endif
gui_synclist_set_viewport_defaults(list->parent[i], i);
}
}
list->dirty_tick = current_tick;
@ -502,6 +494,19 @@ void gui_synclist_set_voice_callback(struct gui_synclist * lists,
lists->callback_speak_item = voice_callback;
}
void gui_synclist_set_viewport_defaults(struct viewport *vp,
enum screen_type screen)
{
viewport_set_defaults(vp, screen);
#ifdef HAVE_TOUCHSCREEN
vp->line_height = list_line_height(vp);
#endif
#ifdef HAVE_BUTTONBAR
if (screens[screen].has_buttonbar)
vp->height -= BUTTONBAR_HEIGHT;
#endif
}
#ifdef HAVE_LCD_COLOR
void gui_synclist_set_color_callback(struct gui_synclist * lists,
list_get_color color_callback)

View file

@ -145,6 +145,7 @@ extern void gui_synclist_init(
extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items);
extern void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback);
extern void gui_synclist_set_voice_callback(struct gui_synclist * lists, list_speak_item voice_callback);
extern void gui_synclist_set_viewport_defaults(struct viewport *vp, enum screen_type screen);
#ifdef HAVE_LCD_COLOR
extern void gui_synclist_set_color_callback(struct gui_synclist * lists, list_get_color color_callback);
#endif

View file

@ -265,11 +265,11 @@ int time_screen(void* ignored)
#endif
nb_lines = viewport_get_nb_lines(&clock_vps[i]);
menu[i] = clock_vps[i];
gui_synclist_set_viewport_defaults(&menu[i], i);
/* force time to be drawn centered */
clock_vps[i].flags |= VP_FLAG_ALIGN_CENTER;
font_h = font_get(clock_vps[i].font)->height;
font_h = clock_vps[i].line_height;
nb_lines -= 2; /* at least 2 lines for menu */
if (nb_lines > 4)
nb_lines = 4;