summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-10-17 17:38:10 +0000
committerThomas Martitz <kugel@rockbox.org>2011-10-17 17:38:10 +0000
commit3b12634e6bc966cb2b2e7f21e9a435cdd20f0bc4 (patch)
tree2f103d5b58b4a22f65e9fd02de4a720022034121 /firmware
parent859cd4b627a48cab8273d8f4d04e2afeb0ee7c87 (diff)
downloadrockbox-3b12634e6bc966cb2b2e7f21e9a435cdd20f0bc4.tar.gz
rockbox-3b12634e6bc966cb2b2e7f21e9a435cdd20f0bc4.zip
Commit FS#12321 - Touchscreen: List line padding, to more easily select lines
This adds line padding to lists on touchscreens, in order to make lists reasonably useful without huge fonts. It's configurable: * Automatic (default, line height calculated using a lcd dpi aware function) * Off (status quo, line height = font height) * X pixels (from 2 to 50 in even steps) The automatic setting should/aims to Just Work Out Of The Box on all targets git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30773 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/lcd-bitmap-common.c34
-rw-r--r--firmware/export/lcd.h1
2 files changed, 17 insertions, 18 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index fc84fdd6a1..8d95825858 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -254,11 +254,12 @@ void LCDFN(putsxyf)(int x, int y, const unsigned char *fmt, ...)
254 254
255static void LCDFN(putsxyofs_style)(int xpos, int ypos, 255static void LCDFN(putsxyofs_style)(int xpos, int ypos,
256 const unsigned char *str, int style, 256 const unsigned char *str, int style,
257 int w, int h, int offset) 257 int h, int offset)
258{ 258{
259 int lastmode = current_vp->drawmode; 259 int lastmode = current_vp->drawmode;
260 int xrect = xpos + MAX(w - offset, 0); 260 int text_ypos = ypos;
261 int x = VP_IS_RTL(current_vp) ? xpos : xrect; 261 int line_height = font_get(current_vp->font)->height;
262 text_ypos += h/2 - line_height/2; /* center the text in the line */
262#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) 263#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
263 int oldfgcolor = current_vp->fg_pattern; 264 int oldfgcolor = current_vp->fg_pattern;
264 int oldbgcolor = current_vp->bg_pattern; 265 int oldbgcolor = current_vp->bg_pattern;
@@ -284,21 +285,21 @@ static void LCDFN(putsxyofs_style)(int xpos, int ypos,
284 current_vp->fg_pattern = current_vp->lst_pattern; 285 current_vp->fg_pattern = current_vp->lst_pattern;
285 } 286 }
286 else { 287 else {
287 lcd_fillrect(x, ypos, current_vp->width - xrect, h); 288 lcd_fillrect(xpos, ypos, current_vp->width - xpos, h);
288 current_vp->drawmode = (style & STYLE_INVERT) ? 289 current_vp->drawmode = (style & STYLE_INVERT) ?
289 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; 290 (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
290 } 291 }
291 if (str[0]) 292 if (str[0])
292 lcd_putsxyofs(xpos, ypos, offset, str); 293 lcd_putsxyofs(xpos, text_ypos, offset, str);
293 current_vp->fg_pattern = oldfgcolor; 294 current_vp->fg_pattern = oldfgcolor;
294 current_vp->bg_pattern = oldbgcolor; 295 current_vp->bg_pattern = oldbgcolor;
295#else 296#else
296 current_vp->drawmode = DRMODE_SOLID | ((style & STYLE_INVERT) ? 297 current_vp->drawmode = DRMODE_SOLID | ((style & STYLE_INVERT) ?
297 0 : DRMODE_INVERSEVID); 298 0 : DRMODE_INVERSEVID);
298 LCDFN(fillrect)(x, ypos, current_vp->width - xrect, h); 299 LCDFN(fillrect)(xpos, ypos, current_vp->width - xpos, h);
299 current_vp->drawmode ^= DRMODE_INVERSEVID; 300 current_vp->drawmode ^= DRMODE_INVERSEVID;
300 if (str[0]) 301 if (str[0])
301 LCDFN(putsxyofs)(xpos, ypos, offset, str); 302 LCDFN(putsxyofs)(xpos, text_ypos, offset, str);
302#endif 303#endif
303 current_vp->drawmode = lastmode; 304 current_vp->drawmode = lastmode;
304} 305}
@@ -309,15 +310,15 @@ static void LCDFN(putsxyofs_style)(int xpos, int ypos,
309void LCDFN(puts_style_xyoffset)(int x, int y, const unsigned char *str, 310void LCDFN(puts_style_xyoffset)(int x, int y, const unsigned char *str,
310 int style, int x_offset, int y_offset) 311 int style, int x_offset, int y_offset)
311{ 312{
312 int xpos, ypos, w, h; 313 int xpos, ypos, h;
313 LCDFN(scroll_stop_line)(current_vp, y); 314 LCDFN(scroll_stop_line)(current_vp, y);
314 if(!str) 315 if(!str)
315 return; 316 return;
316 317
317 LCDFN(getstringsize)(str, &w, &h); 318 h = current_vp->line_height ?: (int)font_get(current_vp->font)->height;
318 xpos = x * LCDFN(getstringsize)(" ", NULL, NULL); 319 xpos = x * LCDFN(getstringsize)(" ", NULL, NULL);
319 ypos = y * h + y_offset; 320 ypos = y * h + y_offset;
320 LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, x_offset); 321 LCDFN(putsxyofs_style)(xpos, ypos, str, style, h, x_offset);
321} 322}
322 323
323void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, 324void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str,
@@ -436,10 +437,9 @@ void LCDFN(puts_scroll_offset)(int x, int y, const unsigned char *string,
436 437
437void LCDFN(scroll_fn)(void) 438void LCDFN(scroll_fn)(void)
438{ 439{
439 struct font* pf;
440 struct scrollinfo* s; 440 struct scrollinfo* s;
441 int index; 441 int index;
442 int xpos, ypos; 442 int xpos, ypos, height;
443 struct viewport* old_vp = current_vp; 443 struct viewport* old_vp = current_vp;
444 bool makedelay; 444 bool makedelay;
445 445
@@ -451,15 +451,15 @@ void LCDFN(scroll_fn)(void)
451 continue; 451 continue;
452 452
453 LCDFN(set_viewport)(s->vp); 453 LCDFN(set_viewport)(s->vp);
454 height = s->vp->line_height;
454 455
455 if (s->backward) 456 if (s->backward)
456 s->offset -= LCDFN(scroll_info).step; 457 s->offset -= LCDFN(scroll_info).step;
457 else 458 else
458 s->offset += LCDFN(scroll_info).step; 459 s->offset += LCDFN(scroll_info).step;
459 460
460 pf = font_get(current_vp->font);
461 xpos = s->startx; 461 xpos = s->startx;
462 ypos = s->y * pf->height + s->y_offset; 462 ypos = s->y * height + s->y_offset;
463 463
464 makedelay = false; 464 makedelay = false;
465 if (s->bidir) { /* scroll bidirectional */ 465 if (s->bidir) { /* scroll bidirectional */
@@ -488,10 +488,8 @@ void LCDFN(scroll_fn)(void)
488 s->start_tick = current_tick + LCDFN(scroll_info).delay + 488 s->start_tick = current_tick + LCDFN(scroll_info).delay +
489 LCDFN(scroll_info).ticks; 489 LCDFN(scroll_info).ticks;
490 490
491 LCDFN(putsxyofs_style)(xpos, ypos, s->line, s->style, s->width, 491 LCDFN(putsxyofs_style)(xpos, ypos, s->line, s->style, height, s->offset);
492 pf->height, s->offset); 492 LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width-xpos, height);
493 LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width - xpos,
494 pf->height);
495 } 493 }
496 LCDFN(set_viewport)(old_vp); 494 LCDFN(set_viewport)(old_vp);
497} 495}
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index e6e19b1597..56e19ddefa 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -43,6 +43,7 @@ struct viewport {
43#ifdef HAVE_LCD_BITMAP 43#ifdef HAVE_LCD_BITMAP
44 int flags; 44 int flags;
45 int font; 45 int font;
46 int line_height;
46 int drawmode; 47 int drawmode;
47#endif 48#endif
48#if LCD_DEPTH > 1 49#if LCD_DEPTH > 1