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/alarm_menu.c | 10 +++---- apps/dsp.c | 6 ++-- apps/metadata.c | 88 +++++++++++++++++++++++++++--------------------------- apps/plugin.h | 2 +- apps/settings.h | 2 +- apps/sound_menu.c | 2 +- apps/status.c | 2 +- apps/wps-display.c | 59 ++++++++++++++++++++++++++++++++---- apps/wps-display.h | 5 ++++ apps/wps.c | 2 +- 10 files changed, 116 insertions(+), 62 deletions(-) (limited to 'apps') diff --git a/apps/alarm_menu.c b/apps/alarm_menu.c index 47d2c1226b..a3ddbeea79 100644 --- a/apps/alarm_menu.c +++ b/apps/alarm_menu.c @@ -46,7 +46,7 @@ bool alarm_screen(void) rtc_get_alarm(&h, &m); - if (m > 60 || h > 24) { /* after battery-change RTC-values are out of range */ + if (m > 60 || h > 24) { /* after battery-change RTC-values are out of range */ m = 0; h = 12; } else { @@ -86,7 +86,7 @@ bool alarm_screen(void) lcd_puts(0,1,str(LANG_ALARM_MOD_SHUTDOWN)); lcd_update(); sleep(HZ); - done = true; + done = true; } else { lcd_clear_display(); lcd_puts(0,0,str(LANG_ALARM_MOD_ERROR)); @@ -142,9 +142,9 @@ bool alarm_screen(void) case BUTTON_MENU: #endif lcd_clear_display(); - lcd_puts(0,0,str(LANG_ALARM_MOD_DISABLE)); - lcd_update(); - sleep(HZ); + lcd_puts(0,0,str(LANG_ALARM_MOD_DISABLE)); + lcd_update(); + sleep(HZ); rtc_enable_alarm(false); done = true; break; diff --git a/apps/dsp.c b/apps/dsp.c index b24e261371..404bd15d4f 100644 --- a/apps/dsp.c +++ b/apps/dsp.c @@ -39,8 +39,8 @@ static int fracbits; #define SAMPLE_DEPTH 16 /* - * NAME: prng() - * DESCRIPTION: 32-bit pseudo-random number generator + * NAME: prng() + * DESCRIPTION: 32-bit pseudo-random number generator */ static __inline unsigned long prng(unsigned long state) @@ -93,7 +93,7 @@ inline void dsp_clip(long *sample, long *output) /* * NAME: dither() - * DESCRIPTION: dither and scale sample + * DESCRIPTION: dither and scale sample */ inline int scale_dither_clip(long sample) { diff --git a/apps/metadata.c b/apps/metadata.c index 0e770dde7a..7b9bb89706 100644 --- a/apps/metadata.c +++ b/apps/metadata.c @@ -301,7 +301,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname, if (memcmp(&buf[i],"OggS",5)==0) { if (i < (j-17)) { totalsamples=(buf[i+6])|(buf[i+7]<<8)|(buf[i+8]<<16)|(buf[i+9]<<24); - last_serialno=(buf[i+14])|(buf[i+15]<<8)|(buf[i+16]<<16)|(buf[i+17]<<24); + last_serialno=(buf[i+14])|(buf[i+15]<<8)|(buf[i+16]<<16)|(buf[i+17]<<24); j=0; /* We can discard the rest of the buffer */ } else { break; @@ -321,11 +321,11 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname, /* This file has mutiple vorbis bitstreams (or is corrupt) */ /* FIXME we should display an error here */ if (serialno != last_serialno) { - track->taginfo_ready=false; - logf("serialno mismatch"); - logf("%ld", serialno); - logf("%ld", last_serialno); - return false; + track->taginfo_ready=false; + logf("serialno mismatch"); + logf("%ld", serialno); + logf("%ld", last_serialno); + return false; } track->id3.samples=totalsamples; @@ -794,24 +794,24 @@ static bool get_vorbis_comments (struct mp3entry *entry, int fd) * packet extends to the third page). */ for (i = 0; i < segments; i++) { - packet_remaining += temp[i]; - /* The last segment of a packet is always < 255 bytes */ - if (temp[i] < 255) { - break; - } + packet_remaining += temp[i]; + /* The last segment of a packet is always < 255 bytes */ + if (temp[i] < 255) { + break; + } } /* Now read in packet header (type and id string) */ if(read(fd, temp, 7) < 7) { - return false; + return false; } /* The first byte of a packet is the packet type; comment packets are * type 3. */ if ((temp[0] != 3) || (memcmp(temp + 1,"vorbis",6)!=0)) { - logf("Not a vorbis comment packet"); - return false; + logf("Not a vorbis comment packet"); + return false; } packet_remaining -= 7; @@ -831,7 +831,7 @@ static bool get_vorbis_comments (struct mp3entry *entry, int fd) little_endian_to_native(&comment_count, "L"); packet_remaining -= (vendor_length + 8); if ( packet_remaining <= 0 ) { - return true; + return true; } for ( i = 0; i < comment_count; i++ ) { @@ -843,10 +843,10 @@ static bool get_vorbis_comments (struct mp3entry *entry, int fd) little_endian_to_native(&comment_length, "L"); - /* Quit if we've passed the end of the page */ - packet_remaining -= (comment_length + 4); + /* Quit if we've passed the end of the page */ + packet_remaining -= (comment_length + 4); if ( packet_remaining <= 0 ) { - return true; + return true; } /* Skip comment if it won't fit in buffer */ @@ -876,37 +876,37 @@ static bool get_vorbis_comments (struct mp3entry *entry, int fd) name_length = 5; p = &(entry->genre_string); } else if (strncasecmp(temp, "DATE=", 5) == 0) { - int j=0; - /* verify that this is a number */ - /* Note: vorbis uses UTF-8 for its comments, so it is - * safe to compare the values against ASCII 0 and 9 - */ - while ( j < (comment_length - 5) ) { - if ( (temp[5+j] < '0') || (temp[5+j] > '9') ) { - break; - } - j++; - } - if ( j == (comment_length - 5) ) { + int j=0; + /* verify that this is a number */ + /* Note: vorbis uses UTF-8 for its comments, so it is + * safe to compare the values against ASCII 0 and 9 + */ + while ( j < (comment_length - 5) ) { + if ( (temp[5+j] < '0') || (temp[5+j] > '9') ) { + break; + } + j++; + } + if ( j == (comment_length - 5) ) { p = NULL; entry->year = atoi(temp + 5); - } + } } else if (strncasecmp(temp, "TRACKNUMBER=", 12) == 0) { - int j=0; - /* verify that this is a number */ - /* Note: vorbis uses UTF-8 for its comments, so it is - * safe to compare the values against ASCII 0 and 9 - */ - while ( j < (comment_length - 12) ) { - if ( (temp[12+j] < '0') || (temp[12+j] > '9') ) { - break; - } - j++; - } - if ( j == (comment_length - 12) ) { + int j=0; + /* verify that this is a number */ + /* Note: vorbis uses UTF-8 for its comments, so it is + * safe to compare the values against ASCII 0 and 9 + */ + while ( j < (comment_length - 12) ) { + if ( (temp[12+j] < '0') || (temp[12+j] > '9') ) { + break; + } + j++; + } + if ( j == (comment_length - 12) ) { p = NULL; entry->tracknum = atoi(temp + 12); - } + } } else { p = NULL; } diff --git a/apps/plugin.h b/apps/plugin.h index 3f3ed327ac..46308a1e0b 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -304,7 +304,7 @@ struct plugin_api { #endif #if CONFIG_HWCODEC == MASNONE void (*pcm_play_data)(const unsigned char *start, int size, - void (*get_more)(unsigned char** start, long*size)); + void (*get_more)(unsigned char** start, long*size)); void (*pcm_play_stop)(void); void (*pcm_set_frequency)(unsigned int frequency); bool (*pcm_is_playing)(void); diff --git a/apps/settings.h b/apps/settings.h index 46f410a2f4..35a848a208 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -312,7 +312,7 @@ struct user_settings int sort_dir; /* 0=alpha, 1=date (old first), 2=date (new first) */ #ifdef HAVE_REMOTE_LCD - /* remote lcd */ + /* remote lcd */ int remote_contrast; /* lcd contrast: 0-63 0=low 63=high */ bool remote_invert; /* invert display */ bool remote_flip_display; /* turn display (and button layout) by 180 degrees */ diff --git a/apps/sound_menu.c b/apps/sound_menu.c index 9a67033b54..1b19593b6f 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -380,7 +380,7 @@ static bool recdirectory(void) static bool reconstartup(void) { return set_bool(str(LANG_RECORD_STARTUP), - &global_settings.rec_startup); + &global_settings.rec_startup); } #endif /* MAS3587F */ diff --git a/apps/status.c b/apps/status.c index 03a69dd210..42204a6ee6 100644 --- a/apps/status.c +++ b/apps/status.c @@ -63,7 +63,7 @@ struct status_info { bool battery_safe; bool redraw_volume; /* true if the volume gauge needs updating */ #if CONFIG_LED == LED_VIRTUAL - bool led; /* disk LED simulation in the status bar */ + bool led; /* disk LED simulation in the status bar */ #endif #ifdef HAVE_USB_POWER bool usb_power; 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); + } } } } diff --git a/apps/wps-display.h b/apps/wps-display.h index 2c5651fbe2..b23c0d603d 100644 --- a/apps/wps-display.h +++ b/apps/wps-display.h @@ -32,6 +32,11 @@ /* to refresh only those lines that change over time */ #define WPS_REFRESH_NON_STATIC (WPS_REFRESH_ALL & ~WPS_REFRESH_STATIC & ~WPS_REFRESH_SCROLL) +/* alignments */ +#define WPS_ALIGN_RIGHT 32 +#define WPS_ALIGN_CENTER 64 +#define WPS_ALIGN_LEFT 128 + void wps_format_time(char* buf, int buf_size, long time); bool wps_refresh(struct mp3entry* id3, struct mp3entry* nid3, diff --git a/apps/wps.c b/apps/wps.c index 70af303bf0..922deb2647 100644 --- a/apps/wps.c +++ b/apps/wps.c @@ -660,7 +660,7 @@ long wps_show(void) if (quick_screen(CONTEXT_WPS, WPS_QUICK)) return SYS_USB_CONNECTED; restore = true; - lastbutton = 0; + lastbutton = 0; break; /* screen settings */ -- cgit v1.2.3