summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-bitmap-common.c
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2009-10-12 04:29:47 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2009-10-12 04:29:47 +0000
commit461903d80eb51439bfa25bad84cd0e061768a448 (patch)
tree30812edc9cff4c03d18d00b6f4f83993714a24a4 /firmware/drivers/lcd-bitmap-common.c
parentaee690195355aa2644bba8b4c0a110440669290c (diff)
downloadrockbox-461903d80eb51439bfa25bad84cd0e061768a448.tar.gz
rockbox-461903d80eb51439bfa25bad84cd0e061768a448.zip
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.c68
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)
214void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, 214void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
215 int style, int offset) 215 int style, int offset)
216{ 216{
217 struct scrollinfo* s;
218 char *end;
217 int w, h; 219 int w, h;
218 220
219 if ((unsigned)y >= (unsigned)current_vp->height) 221 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,
229 231
230 LCDFN(getstringsize)(string, &w, &h); 232 LCDFN(getstringsize)(string, &w, &h);
231 233
232 if (current_vp->width - x * 8 < w) { 234 if (current_vp->width - x * 8 >= w)
233 /* prepare scroll line */ 235 return;
234 struct scrollinfo* s;
235 s = &LCDFN(scroll_info).scroll[LCDFN(scroll_info).lines];
236 s->start_tick = current_tick + LCDFN(scroll_info).delay;
237 s->style = style;
238 236
239 char *end; 237 /* prepare scroll line */
238 s = &LCDFN(scroll_info).scroll[LCDFN(scroll_info).lines];
239 s->start_tick = current_tick + LCDFN(scroll_info).delay;
240 s->style = style;
240 241
241 memset(s->line, 0, sizeof s->line); 242 memset(s->line, 0, sizeof s->line);
242 strcpy(s->line, string); 243 strcpy(s->line, string);
243 244
244 /* get width */ 245 /* get width */
245 s->width = LCDFN(getstringsize)(s->line, &w, &h); 246 s->width = LCDFN(getstringsize)(s->line, &w, &h);
246 247
247 /* scroll bidirectional or forward only depending on the string 248 /* scroll bidirectional or forward only depending on the string
248 width */ 249 width */
249 if ( LCDFN(scroll_info).bidir_limit ) { 250 if ( LCDFN(scroll_info).bidir_limit ) {
250 s->bidir = s->width < (current_vp->width) * 251 s->bidir = s->width < (current_vp->width) *
251 (100 + LCDFN(scroll_info).bidir_limit) / 100; 252 (100 + LCDFN(scroll_info).bidir_limit) / 100;
252 } 253 }
253 else 254 else
254 s->bidir = false; 255 s->bidir = false;
255 256
256 if (!s->bidir) { /* add spaces if scrolling in the round */ 257 if (!s->bidir) { /* add spaces if scrolling in the round */
257 strcat(s->line, " "); 258 strcat(s->line, " ");
258 /* get new width incl. spaces */ 259 /* get new width incl. spaces */
259 s->width = LCDFN(getstringsize)(s->line, &w, &h); 260 s->width = LCDFN(getstringsize)(s->line, &w, &h);
260 } 261 }
261 262
262 end = strchr(s->line, '\0'); 263 end = strchr(s->line, '\0');
263 strlcpy(end, string, current_vp->width/2); 264 strlcpy(end, string, current_vp->width/2);
264 265
265 s->vp = current_vp; 266 s->vp = current_vp;
266 s->y = y; 267 s->y = y;
267 s->len = utf8length(string); 268 s->len = utf8length(string);
268 s->offset = offset; 269 s->offset = offset;
269 s->startx = x * s->width / s->len; 270 s->startx = x * s->width / s->len;
270 s->backward = false; 271 s->backward = false;
271 272
272 LCDFN(scroll_info).lines++; 273 LCDFN(scroll_info).lines++;
273 }
274} 274}
275 275
276void LCDFN(puts_scroll)(int x, int y, const unsigned char *string) 276void LCDFN(puts_scroll)(int x, int y, const unsigned char *string)