diff options
author | Tomer Shalev <shalev.tomer@gmail.com> | 2009-10-12 04:29:47 +0000 |
---|---|---|
committer | Tomer Shalev <shalev.tomer@gmail.com> | 2009-10-12 04:29:47 +0000 |
commit | 461903d80eb51439bfa25bad84cd0e061768a448 (patch) | |
tree | 30812edc9cff4c03d18d00b6f4f83993714a24a4 /firmware/drivers/lcd-bitmap-common.c | |
parent | aee690195355aa2644bba8b4c0a110440669290c (diff) |
LCD scrolling - reduce one 'if' nesting level
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23125 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd-bitmap-common.c')
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 8fc7c1b18c..e768801961 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c @@ -214,6 +214,8 @@ void LCDFN(puts_offset)(int x, int y, const unsigned char *str, int offset) void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, int style, int offset) { + struct scrollinfo* s; + char *end; int w, h; if ((unsigned)y >= (unsigned)current_vp->height) @@ -229,48 +231,46 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, LCDFN(getstringsize)(string, &w, &h); - if (current_vp->width - x * 8 < w) { - /* prepare scroll line */ - struct scrollinfo* s; - s = &LCDFN(scroll_info).scroll[LCDFN(scroll_info).lines]; - s->start_tick = current_tick + LCDFN(scroll_info).delay; - s->style = style; + if (current_vp->width - x * 8 >= w) + return; - char *end; + /* prepare scroll line */ + s = &LCDFN(scroll_info).scroll[LCDFN(scroll_info).lines]; + s->start_tick = current_tick + LCDFN(scroll_info).delay; + s->style = style; - memset(s->line, 0, sizeof s->line); - strcpy(s->line, string); + memset(s->line, 0, sizeof s->line); + strcpy(s->line, string); - /* get width */ - s->width = LCDFN(getstringsize)(s->line, &w, &h); + /* get width */ + s->width = LCDFN(getstringsize)(s->line, &w, &h); - /* scroll bidirectional or forward only depending on the string - width */ - if ( LCDFN(scroll_info).bidir_limit ) { - s->bidir = s->width < (current_vp->width) * - (100 + LCDFN(scroll_info).bidir_limit) / 100; - } - else - s->bidir = false; + /* scroll bidirectional or forward only depending on the string + width */ + if ( LCDFN(scroll_info).bidir_limit ) { + s->bidir = s->width < (current_vp->width) * + (100 + LCDFN(scroll_info).bidir_limit) / 100; + } + else + s->bidir = false; - if (!s->bidir) { /* add spaces if scrolling in the round */ - strcat(s->line, " "); - /* get new width incl. spaces */ - s->width = LCDFN(getstringsize)(s->line, &w, &h); - } + if (!s->bidir) { /* add spaces if scrolling in the round */ + strcat(s->line, " "); + /* get new width incl. spaces */ + s->width = LCDFN(getstringsize)(s->line, &w, &h); + } - end = strchr(s->line, '\0'); - strlcpy(end, string, current_vp->width/2); + end = strchr(s->line, '\0'); + strlcpy(end, string, current_vp->width/2); - s->vp = current_vp; - s->y = y; - s->len = utf8length(string); - s->offset = offset; - s->startx = x * s->width / s->len; - s->backward = false; + s->vp = current_vp; + s->y = y; + s->len = utf8length(string); + s->offset = offset; + s->startx = x * s->width / s->len; + s->backward = false; - LCDFN(scroll_info).lines++; - } + LCDFN(scroll_info).lines++; } void LCDFN(puts_scroll)(int x, int y, const unsigned char *string) |