From be7894509feb701630efa4a1a18a5af621068bac Mon Sep 17 00:00:00 2001 From: Christi Scarborough Date: Tue, 5 Jul 2005 22:27:54 +0000 Subject: (1) Patch 1231281: Alignment tags for the WPS by Per Holmaeng. Use %al for left align, %ac for centre, %ar for right. It is currently not possible to use more than one %a? tag per WPS line. (2) Lots of tabs removed. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7034 a1c6a512-1295-4272-9138-f99709370657 --- apps/wps-display.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to 'apps/wps-display.c') diff --git a/apps/wps-display.c b/apps/wps-display.c index 71f88672ec..d3838f4311 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c @@ -808,7 +808,22 @@ static void format_display(char* buf, case 0: *buf++ = '%'; break; - + case 'a': + ++fmt; + switch (*fmt) + { + case 'l': + *flags |= WPS_ALIGN_LEFT; + break; + case 'c': + *flags |= WPS_ALIGN_CENTER; + break; + case 'r': + *flags |= WPS_ALIGN_RIGHT; + break; + } + ++fmt; + break; case 's': *flags |= WPS_REFRESH_SCROLL; ++fmt; @@ -830,9 +845,11 @@ static void format_display(char* buf, /* Get filename */ pos = strchr(ptr, '|'); /* get the second '|' */ if ((pos - ptr) < (int)sizeof(temp_buf)) { - memcpy(temp_buf, ptr, pos - ptr); /* get the filename */ + memcpy(temp_buf, ptr, pos - ptr); + /* get the filename */ temp_buf[pos - ptr] = 0; - snprintf(imgname, MAX_PATH, "/.rockbox/%s", temp_buf); + snprintf(imgname, MAX_PATH, "/.rockbox/%s", + temp_buf); } else { /* filename too long! */ @@ -1110,8 +1127,27 @@ bool wps_refresh(struct mp3entry* id3, /* scroll line */ if ((refresh_mode & WPS_REFRESH_SCROLL) || new_subline_refresh) { - lcd_puts_scroll(0, i, buf); + int strw,strh; + int ypos,xpos; + + lcd_getstringsize(buf, &strw, &strh); + ypos = (i*strh)+lcd_getymargin(); update_line = true; + + if (strw>LCD_WIDTH) { + lcd_puts_scroll(0, i, buf); + } else { + if (flags & WPS_ALIGN_CENTER) + { + xpos = (LCD_WIDTH - strw) / 2; + lcd_putsxy(xpos, ypos, buf); + } else if (flags & WPS_ALIGN_RIGHT) { + xpos = (LCD_WIDTH - strw); + lcd_putsxy(xpos, ypos, buf); + } else { + lcd_putsxy(0, ypos, buf); + } + } } } else if (flags & (WPS_REFRESH_DYNAMIC | WPS_REFRESH_STATIC)) @@ -1120,8 +1156,21 @@ bool wps_refresh(struct mp3entry* id3, if ((refresh_mode & (WPS_REFRESH_DYNAMIC|WPS_REFRESH_STATIC)) || new_subline_refresh) { + int ypos,xpos; + int strw,strh; + + lcd_getstringsize(buf, &strw, &strh); + ypos = (i*strh)+lcd_getymargin(); update_line = true; - lcd_puts(0, i, buf); + if (flags & WPS_ALIGN_CENTER) { + xpos = (LCD_WIDTH - strw) / 2; + lcd_putsxy(xpos, ypos, buf); + } else if (flags & WPS_ALIGN_RIGHT) { + xpos = (LCD_WIDTH - strw); + lcd_putsxy(xpos, ypos, buf); + } else { + lcd_putsxy(0, ypos, buf); + } } } } -- cgit v1.2.3