lcd-common: Remove support for custom line heights from viewport.

Since scrolling is now pixel-based this is not necessary anymore. custom line
height is handled by put_line() but can also possible to implement with
lcd_puts_scroll_func().

Change-Id: Iee9b12bf99afac93d95d2a1a6f5d5b4db237b21c
This commit is contained in:
Thomas Martitz 2013-04-16 16:06:13 +02:00
parent 9a4686b563
commit 4978094480
5 changed files with 10 additions and 16 deletions

View file

@ -225,9 +225,7 @@ static bool is_theme_enabled(enum screen_type screen)
int viewport_get_nb_lines(const struct viewport *vp) int viewport_get_nb_lines(const struct viewport *vp)
{ {
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
if (!vp->line_height) return vp->height/font_get(vp->font)->height;
return vp->height/font_get(vp->font)->height;
return vp->height/vp->line_height;
#else #else
(void)vp; (void)vp;
return 2; return 2;
@ -322,7 +320,6 @@ void viewport_set_fullscreen(struct viewport *vp,
set_default_align_flags(vp); set_default_align_flags(vp);
#endif #endif
vp->font = screens[screen].getuifont(); vp->font = screens[screen].getuifont();
vp->line_height = 0; /* calculate from font height */
vp->drawmode = DRMODE_SOLID; vp->drawmode = DRMODE_SOLID;
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD

View file

@ -265,7 +265,7 @@ int time_screen(void* ignored)
/* force time to be drawn centered */ /* force time to be drawn centered */
clock_vps[i].flags |= VP_FLAG_ALIGN_CENTER; clock_vps[i].flags |= VP_FLAG_ALIGN_CENTER;
font_h = clock_vps[i].line_height ?: (int)font_get(clock_vps[i].font)->height; font_h = font_get(clock_vps[i].font)->height;
nb_lines -= 2; /* at least 2 lines for menu */ nb_lines -= 2; /* at least 2 lines for menu */
if (nb_lines > 4) if (nb_lines > 4)
nb_lines = 4; nb_lines = 4;

View file

@ -140,8 +140,7 @@ void touchbutton_draw(struct touchbutton *data, int num_buttons) {
*/ */
lcd->set_viewport(&data[i].vp); lcd->set_viewport(&data[i].vp);
/* Set line_height to height, then it'll center for us */ /* TODO: Center text vert*/
data[i].vp.line_height = data[i].vp.height;
data[i].vp.flags |= VP_FLAG_ALIGN_CENTER; data[i].vp.flags |= VP_FLAG_ALIGN_CENTER;
/* If the width offset was 0, use a scrolling puts, else center and /* If the width offset was 0, use a scrolling puts, else center and

View file

@ -387,12 +387,11 @@ void LCDFN(putsxyf)(int x, int y, const unsigned char *fmt, ...)
static void LCDFN(putsxyofs_style)(int xpos, int ypos, static void LCDFN(putsxyofs_style)(int xpos, int ypos,
const unsigned char *str, int style, const unsigned char *str, int style,
int h, int offset) int offset)
{ {
int lastmode = current_vp->drawmode; int lastmode = current_vp->drawmode;
int text_ypos = ypos; int text_ypos = ypos;
int line_height = font_get(current_vp->font)->height; int h = font_get(current_vp->font)->height;
text_ypos += h/2 - line_height/2; /* center the text in the line */
if ((style & STYLE_MODE_MASK) == STYLE_NONE) { if ((style & STYLE_MODE_MASK) == STYLE_NONE) {
if (str[0]) if (str[0])
@ -452,7 +451,7 @@ static void LCDFN(putsofs_style)(int x, int y, const unsigned char *str,
if(!str) if(!str)
return; return;
h = current_vp->line_height ?: (int)font_get(current_vp->font)->height; h = font_get(current_vp->font)->height;
if ((style&STYLE_XY_PIXELS) == 0) if ((style&STYLE_XY_PIXELS) == 0)
{ {
xpos = x * LCDFN(getstringsize)(" ", NULL, NULL); xpos = x * LCDFN(getstringsize)(" ", NULL, NULL);
@ -464,7 +463,7 @@ static void LCDFN(putsofs_style)(int x, int y, const unsigned char *str,
ypos = y; ypos = y;
} }
LCDFN(scroll_stop_viewport_rect)(current_vp, xpos, ypos, current_vp->width - xpos, h); LCDFN(scroll_stop_viewport_rect)(current_vp, xpos, ypos, current_vp->width - xpos, h);
LCDFN(putsxyofs_style)(xpos, ypos+y_offset, str, style, h, x_offset); LCDFN(putsxyofs_style)(xpos, ypos+y_offset, str, style, x_offset);
} }
void LCDFN(puts)(int x, int y, const unsigned char *str) void LCDFN(puts)(int x, int y, const unsigned char *str)
@ -501,7 +500,7 @@ static struct scrollinfo* find_scrolling_line(int x, int y)
void LCDFN(scroll_fn)(struct scrollinfo* s) void LCDFN(scroll_fn)(struct scrollinfo* s)
{ {
LCDFN(putsxyofs_style)(s->x, s->y, s->line, s->style, s->height, s->offset); LCDFN(putsxyofs_style)(s->x, s->y, s->line, s->style, s->offset);
} }
static void LCDFN(puts_scroll_worker)(int x, int y, const unsigned char *string, static void LCDFN(puts_scroll_worker)(int x, int y, const unsigned char *string,
@ -521,7 +520,7 @@ static void LCDFN(puts_scroll_worker)(int x, int y, const unsigned char *string,
/* prepare rectangle for scrolling. x and y must be calculated early /* prepare rectangle for scrolling. x and y must be calculated early
* for find_scrolling_line() to work */ * for find_scrolling_line() to work */
cwidth = font_get(current_vp->font)->maxwidth; cwidth = font_get(current_vp->font)->maxwidth;
height = current_vp->line_height ?: (int)font_get(current_vp->font)->height; height = font_get(current_vp->font)->height;
y = y * (linebased ? height : 1) + y_offset; y = y * (linebased ? height : 1) + y_offset;
x = x * (linebased ? cwidth : 1); x = x * (linebased ? cwidth : 1);
width = current_vp->width - x; width = current_vp->width - x;
@ -535,7 +534,7 @@ static void LCDFN(puts_scroll_worker)(int x, int y, const unsigned char *string,
if (restart) { if (restart) {
/* remove any previously scrolling line at the same location */ /* remove any previously scrolling line at the same location */
LCDFN(scroll_stop_viewport_rect)(current_vp, x, y, width, height); LCDFN(scroll_stop_viewport_rect)(current_vp, x, y, width, height);
LCDFN(putsxyofs_style)(x, y, string, style, height, x_offset); LCDFN(putsxyofs_style)(x, y, string, style, x_offset);
if (LCDFN(scroll_info).lines >= LCDM(SCROLLABLE_LINES)) if (LCDFN(scroll_info).lines >= LCDM(SCROLLABLE_LINES))
return; return;

View file

@ -43,7 +43,6 @@ struct viewport {
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
int flags; int flags;
int font; int font;
int line_height; /* 0 for using font height */
int drawmode; int drawmode;
#endif #endif
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1