1
0
Fork 0
forked from len0rd/rockbox

Use helper function vp_puts_center() in time_menu.c

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22979 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomer Shalev 2009-10-06 08:17:36 +00:00
parent a092b9ce92
commit a1dfe6441d

View file

@ -160,10 +160,25 @@ static void talk_timedate(void)
}
}
static void vp_puts_center(struct viewport *vp, struct screen *display, int line,
char *str)
{
int w, offset;
display->getstringsize(str, &w, NULL);
if (w > vp->width)
display->puts_scroll(0, line, str);
else
{
offset = (vp->width - w)/2;
display->putsxy(offset, line * font_get(vp->font)->height, str);
}
}
static void draw_timedate(struct viewport *vp, struct screen *display)
{
struct tm *tm = get_time();
int w, line;
int line;
char time[16], date[16];
if (vp->height == 0)
return;
@ -193,18 +208,11 @@ static void draw_timedate(struct viewport *vp, struct screen *display)
snprintf(time, 16, "%s", "--:--:--");
snprintf(date, 16, "%s", str(LANG_UNKNOWN));
}
display->getstringsize(time, &w, NULL);
if (w > vp->width)
display->puts_scroll(0, line, time);
else
display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, time);
line++;
display->getstringsize(date, &w, NULL);
if (w > vp->width)
display->puts_scroll(0, line, date);
else
display->putsxy((vp->width - w)/2, line*font_get(vp->font)->height, date);
vp_puts_center(vp, display, line, time);
line++;
vp_puts_center(vp, display, line, date);
display->update_viewport();
}