summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-03-18 16:04:58 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-03-18 16:04:58 +0000
commit078f3285445bbc9d7da1db70ac70595eb6cc7208 (patch)
tree65df3b5cc65b650eb3ef287b1747b986f60b0796 /apps
parent6b6f97ddda86a1fe6c98a65312e1dc0c09da94ec (diff)
downloadrockbox-078f3285445bbc9d7da1db70ac70595eb6cc7208.tar.gz
rockbox-078f3285445bbc9d7da1db70ac70595eb6cc7208.zip
When you use splash() and a centered output, it will now put the text in
a centered "box" on the screen and will not clear the rest of the screen. This makes a neat "windows-effect", as can be seen on these demo-shots: http://www.contactor.se/~dast/splash3.png http://www.contactor.se/~dast/splash2.png http://www.contactor.se/~dast/splash.png Needless to say, current code that "pops-up" information should be moved to use splash() instead... git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3476 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/screens.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/apps/screens.c b/apps/screens.c
index f7ee443f4b..37b2f5e426 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -469,7 +469,7 @@ bool f3_screen(void)
469#endif 469#endif
470 470
471#ifdef HAVE_LCD_BITMAP 471#ifdef HAVE_LCD_BITMAP
472#define SPACE 4 /* pixels between words */ 472#define SPACE 3 /* pixels between words */
473#define MAXLETTERS 128 /* 16*8 */ 473#define MAXLETTERS 128 /* 16*8 */
474#define MAXLINES 10 474#define MAXLINES 10
475#else 475#else
@@ -499,13 +499,15 @@ void splash(int ticks, /* how long */
499 unsigned char widths[MAXLINES]; 499 unsigned char widths[MAXLINES];
500 int line=0; 500 int line=0;
501 bool first=true; 501 bool first=true;
502#ifdef HAVE_LCD_BITMAP
503 int maxw=0;
504#endif
502 505
503 va_start( ap, fmt ); 506 va_start( ap, fmt );
504 vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap ); 507 vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap );
505 508
506 lcd_clear_display();
507
508 if(center) { 509 if(center) {
510
509 /* first a pass to measure sizes */ 511 /* first a pass to measure sizes */
510 next = strtok_r(splash_buf, " ", &store); 512 next = strtok_r(splash_buf, " ", &store);
511 while (next) { 513 while (next) {
@@ -513,11 +515,11 @@ void splash(int ticks, /* how long */
513 lcd_getstringsize(next, &w, &h); 515 lcd_getstringsize(next, &w, &h);
514#else 516#else
515 w = strlen(next); 517 w = strlen(next);
516 h = 1; 518 h = 1; /* store height in characters */
517#endif 519#endif
518 if(!first) { 520 if(!first) {
519 if(x+w> LCD_WIDTH) { 521 if(x+w> LCD_WIDTH) {
520 /* too wide */ 522 /* Too wide, wrap */
521 y+=h; 523 y+=h;
522 line++; 524 line++;
523 if((y > (LCD_HEIGHT-h)) || (line > MAXLINES)) 525 if((y > (LCD_HEIGHT-h)) || (line > MAXLINES))
@@ -535,6 +537,11 @@ void splash(int ticks, /* how long */
535 537
536 x += w+SPACE; 538 x += w+SPACE;
537 widths[line]=x-SPACE; /* don't count the trailing space */ 539 widths[line]=x-SPACE; /* don't count the trailing space */
540#ifdef HAVE_LCD_BITMAP
541 /* store the widest line */
542 if(widths[line]>maxw)
543 maxw = widths[line];
544#endif
538 next = strtok_r(NULL, " ", &store); 545 next = strtok_r(NULL, " ", &store);
539 } 546 }
540#ifdef HAVE_LCD_BITMAP 547#ifdef HAVE_LCD_BITMAP
@@ -545,14 +552,37 @@ void splash(int ticks, /* how long */
545#else 552#else
546 y = 0; /* vertical center on 2 lines would be silly */ 553 y = 0; /* vertical center on 2 lines would be silly */
547#endif 554#endif
548 line=0;
549 first=true; 555 first=true;
556
557 /* Now recreate the string again since the strtok_r() above has ruined
558 the one we already have! Here's room for improvements! */
550 vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap ); 559 vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap );
551 } 560 }
552 va_end( ap ); 561 va_end( ap );
553 562
554 if(center) 563 if(center)
555 x = (LCD_WIDTH-widths[0])/2; 564 x = (LCD_WIDTH-widths[0])/2;
565
566#ifdef HAVE_LCD_BITMAP
567 /* If we center the display and it wouldn't cover the full screen,
568 then just clear the box we need and put a nice little frame and
569 put the text in there! */
570 if(center && (y > 2)) {
571 if(maxw < (LCD_WIDTH -4)) {
572 int xx = (LCD_WIDTH-maxw)/2 - 2;
573 lcd_clearrect(xx, y-2, maxw+4, LCD_HEIGHT-y*2+4);
574 lcd_drawrect(xx, y-2, maxw+4, LCD_HEIGHT-y*2+4);
575 }
576 else {
577 lcd_clearrect(0, y-2, LCD_WIDTH, LCD_HEIGHT-y*2+4);
578 lcd_drawline(0, y-2, LCD_WIDTH, y-2);
579 lcd_drawline(0, LCD_HEIGHT-y+2, LCD_WIDTH, LCD_HEIGHT-y+2);
580 }
581 }
582 else
583#endif
584 lcd_clear_display();
585 line=0;
556 next = strtok_r(splash_buf, " ", &store); 586 next = strtok_r(splash_buf, " ", &store);
557 while (next) { 587 while (next) {
558#ifdef HAVE_LCD_BITMAP 588#ifdef HAVE_LCD_BITMAP