From 05a67d021c8fbb10b2654f8378b549901dd4c520 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Mon, 6 May 2013 07:20:40 +0200 Subject: Touchscreen: Show a line separator in lists. This patch adds a configurable line separator between list items, very similar to lists in Android. Additionally, below the list item there is a thicker line. It can be disabled in the settings. Its color can be configured as well. Remote and monochrome displays are explicitly unsupported. If there is desire this can be changed but it doesn't seem useful to me. Change-Id: I005313b0d8f5ecd15864bf20e66ea4e3390d8b7d --- apps/gui/line.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'apps/gui/line.c') diff --git a/apps/gui/line.c b/apps/gui/line.c index 55100f715c..4a51c6e307 100644 --- a/apps/gui/line.c +++ b/apps/gui/line.c @@ -305,6 +305,28 @@ static void style_line(struct screen *display, int style = line->style; int width = display->getwidth(); int height = line->height == -1 ? display->getcharheight() : line->height; + int bar_height = height; + + /* mask out gradient and colorbar styles for non-color displays */ + if (display->depth < 16 && (style & (STYLE_COLORBAR|STYLE_GRADIENT))) + { + style &= ~(STYLE_COLORBAR|STYLE_GRADIENT); + style |= STYLE_INVERT; + } + + if (line->separator_height > 0 && (line->line == line->nlines-1)) + { + int sep_height = MIN(line->separator_height, height); + display->set_drawmode(DRMODE_FG); +#if LCD_DEPTH > 1 + display->set_foreground(global_settings.list_separator_color); +#endif + display->fillrect(x, y + height - sep_height, width, sep_height); + bar_height -= sep_height; +#if LCD_DEPTH > 1 + display->set_foreground(global_settings.fg_color); +#endif + } /* mask out gradient and colorbar styles for non-color displays */ if (display->depth < 16) @@ -322,7 +344,7 @@ static void style_line(struct screen *display, #ifdef HAVE_LCD_COLOR case STYLE_GRADIENT: display->set_drawmode(DRMODE_FG); - display->gradient_fillrect_part(x, y, width, height, + display->gradient_fillrect_part(x, y, width, bar_height, line->line_color, line->line_end_color, height*line->nlines, @@ -331,16 +353,16 @@ static void style_line(struct screen *display, case STYLE_COLORBAR: display->set_drawmode(DRMODE_FG); display->set_foreground(line->line_color); - display->fillrect(x, y, width - x, height); + display->fillrect(x, y, width - x, bar_height); break; #endif case STYLE_INVERT: display->set_drawmode(DRMODE_FG); - display->fillrect(x, y, width - x, height); + display->fillrect(x, y, width - x, bar_height); break; case STYLE_DEFAULT: default: display->set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); - display->fillrect(x, y, width - x, height); + display->fillrect(x, y, width - x, bar_height); break; case STYLE_NONE: break; -- cgit v1.2.3