summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/lcd-bitmap-common.c
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/drivers/lcd-bitmap-common.c
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/drivers/lcd-bitmap-common.c')
-rw-r--r--firmware/drivers/lcd-bitmap-common.c34
1 files changed, 16 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, ...)
static void LCDFN(putsxyofs_style)(int xpos, int ypos,
const unsigned char *str, int style,
- int w, int h, int offset)
+ int h, int offset)
{
int lastmode = current_vp->drawmode;
- int xrect = xpos + MAX(w - offset, 0);
- int x = VP_IS_RTL(current_vp) ? xpos : xrect;
+ int text_ypos = ypos;
+ int line_height = font_get(current_vp->font)->height;
+ text_ypos += h/2 - line_height/2; /* center the text in the line */
#if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR)
int oldfgcolor = current_vp->fg_pattern;
int oldbgcolor = current_vp->bg_pattern;
@@ -284,21 +285,21 @@ static void LCDFN(putsxyofs_style)(int xpos, int ypos,
current_vp->fg_pattern = current_vp->lst_pattern;
}
else {
- lcd_fillrect(x, ypos, current_vp->width - xrect, h);
+ lcd_fillrect(xpos, ypos, current_vp->width - xpos, h);
current_vp->drawmode = (style & STYLE_INVERT) ?
(DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
}
if (str[0])
- lcd_putsxyofs(xpos, ypos, offset, str);
+ lcd_putsxyofs(xpos, text_ypos, offset, str);
current_vp->fg_pattern = oldfgcolor;
current_vp->bg_pattern = oldbgcolor;
#else
current_vp->drawmode = DRMODE_SOLID | ((style & STYLE_INVERT) ?
0 : DRMODE_INVERSEVID);
- LCDFN(fillrect)(x, ypos, current_vp->width - xrect, h);
+ LCDFN(fillrect)(xpos, ypos, current_vp->width - xpos, h);
current_vp->drawmode ^= DRMODE_INVERSEVID;
if (str[0])
- LCDFN(putsxyofs)(xpos, ypos, offset, str);
+ LCDFN(putsxyofs)(xpos, text_ypos, offset, str);
#endif
current_vp->drawmode = lastmode;
}
@@ -309,15 +310,15 @@ static void LCDFN(putsxyofs_style)(int xpos, int ypos,
void LCDFN(puts_style_xyoffset)(int x, int y, const unsigned char *str,
int style, int x_offset, int y_offset)
{
- int xpos, ypos, w, h;
+ int xpos, ypos, h;
LCDFN(scroll_stop_line)(current_vp, y);
if(!str)
return;
- LCDFN(getstringsize)(str, &w, &h);
+ h = current_vp->line_height ?: (int)font_get(current_vp->font)->height;
xpos = x * LCDFN(getstringsize)(" ", NULL, NULL);
ypos = y * h + y_offset;
- LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, x_offset);
+ LCDFN(putsxyofs_style)(xpos, ypos, str, style, h, x_offset);
}
void 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,
void LCDFN(scroll_fn)(void)
{
- struct font* pf;
struct scrollinfo* s;
int index;
- int xpos, ypos;
+ int xpos, ypos, height;
struct viewport* old_vp = current_vp;
bool makedelay;
@@ -451,15 +451,15 @@ void LCDFN(scroll_fn)(void)
continue;
LCDFN(set_viewport)(s->vp);
+ height = s->vp->line_height;
if (s->backward)
s->offset -= LCDFN(scroll_info).step;
else
s->offset += LCDFN(scroll_info).step;
- pf = font_get(current_vp->font);
xpos = s->startx;
- ypos = s->y * pf->height + s->y_offset;
+ ypos = s->y * height + s->y_offset;
makedelay = false;
if (s->bidir) { /* scroll bidirectional */
@@ -488,10 +488,8 @@ void LCDFN(scroll_fn)(void)
s->start_tick = current_tick + LCDFN(scroll_info).delay +
LCDFN(scroll_info).ticks;
- LCDFN(putsxyofs_style)(xpos, ypos, s->line, s->style, s->width,
- pf->height, s->offset);
- LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width - xpos,
- pf->height);
+ LCDFN(putsxyofs_style)(xpos, ypos, s->line, s->style, height, s->offset);
+ LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width-xpos, height);
}
LCDFN(set_viewport)(old_vp);
}