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
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index f1def90..97eefce 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -106,6 +106,13 @@
line.height = list->line_height[screen];
title_text_vp->height = line.height;
+#if LCD_DEPTH > 1
+ /* XXX: Do we want to support the separator on remote displays? */
+ if (display->screen_type == SCREEN_MAIN && global_settings.list_separator_height != 0)
+ line.separator_height = abs(global_settings.list_separator_height)
+ + (lcd_get_dpi() > 200 ? 2 : 1);
+#endif
+
#ifdef HAVE_LCD_COLOR
if (list->title_color >= 0)
line.style |= (STYLE_COLORED|list->title_color);
@@ -154,7 +161,11 @@
linedes.height = list->line_height[screen];
linedes.nlines = list->selected_size;
-
+#if LCD_DEPTH > 1
+ /* XXX: Do we want to support the separator on remote displays? */
+ if (display->screen_type == SCREEN_MAIN)
+ linedes.separator_height = abs(global_settings.list_separator_height);
+#endif
start = list_start_item;
end = start + nb_lines;
diff --git a/apps/gui/line.c b/apps/gui/line.c
index 55100f7..4a51c6e 100644
--- a/apps/gui/line.c
+++ b/apps/gui/line.c
@@ -305,6 +305,28 @@
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 @@
#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 @@
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;
diff --git a/apps/gui/line.h b/apps/gui/line.h
index 9a0769d..c14f04d 100644
--- a/apps/gui/line.h
+++ b/apps/gui/line.h
@@ -74,11 +74,14 @@
enum line_styles style;
/* whether the line can scroll */
bool scroll;
+ /* height of the line separator (in pixels). 0 to disable drawing
+ * of the separator */
+ int8_t separator_height;
};
/* default initializer, can be used for static initialitation also.
* This initializer will result in single lines without style that don't scroll */
-#define LINE_DESC_DEFINIT { .style = STYLE_DEFAULT, .height = -1, .line = 0, .nlines = 1, .scroll = false }
+#define LINE_DESC_DEFINIT { .style = STYLE_DEFAULT, .height = -1, .separator_height = 0, .line = 0, .nlines = 1, .scroll = false }
/**
* Print a line at a given pixel postion, using decoration information from
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 0778ab7..9914b16 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -12926,6 +12926,34 @@
</voice>
</phrase>
<phrase>
+ id: LANG_LIST_SEPARATOR
+ desc: line between lines in lists
+ user: core
+ <source>
+ *: "Line Separator"
+ </source>
+ <dest>
+ *: "Line Separator"
+ </dest>
+ <voice>
+ *: "Line Separator"
+ </voice>
+</phrase>
+<phrase>
+ id: LANG_LIST_SEPARATOR_COLOR
+ desc: line between lines in lists
+ user: core
+ <source>
+ *: "Line Separator Colour"
+ </source>
+ <dest>
+ *: "Line Separator Colour"
+ </dest>
+ <voice>
+ *: "Line Separator Colour"
+ </voice>
+</phrase>
+<phrase>
id: LANG_SHORTCUTS
desc: Title in the shortcuts menu
user: core
diff --git a/apps/menus/theme_menu.c b/apps/menus/theme_menu.c
index 93511f8..f64ded1 100644
--- a/apps/menus/theme_menu.c
+++ b/apps/menus/theme_menu.c
@@ -68,6 +68,7 @@
COLOR_LSS,
COLOR_LSE,
COLOR_LST,
+ COLOR_SEP,
COLOR_COUNT
};
static struct colour_info
@@ -80,6 +81,7 @@
[COLOR_LSS] = {&global_settings.lss_color, LANG_SELECTOR_START_COLOR},
[COLOR_LSE] = {&global_settings.lse_color, LANG_SELECTOR_END_COLOR},
[COLOR_LST] = {&global_settings.lst_color, LANG_SELECTOR_TEXT_COLOR},
+ [COLOR_SEP] = {&global_settings.list_separator_color, LANG_LIST_SEPARATOR_COLOR},
};
/**
@@ -91,7 +93,7 @@
/* Don't let foreground be set the same as background and vice-versa */
if (c == COLOR_BG)
banned_color = *colors[COLOR_FG].setting;
- else if (c == COLOR_FG)
+ else if (c == COLOR_FG || c == COLOR_SEP)
banned_color = *colors[COLOR_BG].setting;
old_color = *colors[c].setting;
@@ -113,6 +115,7 @@
global_settings.lss_color = LCD_DEFAULT_LS;
global_settings.lse_color = LCD_DEFAULT_BG;
global_settings.lst_color = LCD_DEFAULT_FG;
+ global_settings.list_separator_color = LCD_DARKGRAY;
settings_save();
settings_apply(false);
@@ -129,6 +132,8 @@
set_color_func, (void*)COLOR_LSE, NULL, Icon_NOICON);
MENUITEM_FUNCTION(set_lst_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_TEXT_COLOR),
set_color_func, (void*)COLOR_LST, NULL, Icon_NOICON);
+MENUITEM_FUNCTION(set_sep_col, MENU_FUNC_USEPARAM, ID2P(LANG_LIST_SEPARATOR_COLOR),
+ set_color_func, (void*)COLOR_SEP, NULL, Icon_NOICON);
MENUITEM_FUNCTION(reset_colors, 0, ID2P(LANG_RESET_COLORS),
reset_color, NULL, NULL, Icon_NOICON);
@@ -140,7 +145,7 @@
/* now the actual menu */
MAKE_MENU(colors_settings, ID2P(LANG_COLORS_MENU),
NULL, Icon_Display_menu,
- &lss_settings,
+ &lss_settings, &set_sep_col,
&set_bg_col, &set_fg_col, &reset_colors
);
@@ -388,6 +393,9 @@
#ifdef HAVE_LCD_BITMAP
MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, NULL);
#endif
+#if LCD_DEPTH > 1
+MENUITEM_SETTING(sep_menu, &global_settings.list_separator_height, NULL);
+#endif
MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
NULL, Icon_Wps,
@@ -418,8 +426,11 @@
#ifdef HAVE_LCD_BITMAP
&bars_menu,
&cursor_style,
+#if LCD_DEPTH > 1
+ &sep_menu,
#endif
#ifdef HAVE_LCD_COLOR
&colors_settings,
#endif
- );
+#endif /* HAVE_LCD_BITMAP */
+);
diff --git a/apps/settings.h b/apps/settings.h
index 62ae038..5b876d3 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -531,12 +531,15 @@
#ifdef HAVE_LCD_BITMAP
int scrollbar; /* SCROLLBAR_* enum values */
int scrollbar_width;
-#endif
#ifdef HAVE_TOUCHSCREEN
int list_line_padding;
#endif
-
+#if LCD_DEPTH > 1
+ int list_separator_height; /* -1=auto (== 1 currently), 0=disabled, X=height in pixels */
+ int list_separator_color;
+#endif
+#endif
/* goto current song when exiting WPS */
bool browse_current; /* 1=goto current song,
0=goto previous location */
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 9b1ec44..681a3ab 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -282,6 +282,7 @@
#define DEFAULT_THEME_SELECTOR_START LCD_RGBPACK(0xff, 0xeb, 0x9c)
#define DEFAULT_THEME_SELECTOR_END LCD_RGBPACK(0xb5, 0x8e, 0x00)
#define DEFAULT_THEME_SELECTOR_TEXT LCD_RGBPACK(0x00, 0x00, 0x00)
+#define DEFAULT_THEME_SEPARATOR LCD_RGBPACK(0x80, 0x80, 0x80)
#define DEFAULT_BACKDROP BACKDROP_DIR "/cabbiev2.bmp"
@@ -323,7 +324,6 @@
#define DEFAULT_TAGCACHE_SCAN_PATHS "/"
#endif
-#ifdef HAVE_TOUCHSCREEN
static const char* list_pad_formatter(char *buffer, size_t buffer_size,
int val, const char *unit)
@@ -348,7 +348,6 @@
}
}
-#endif /* HAVE_TOUCHSCREEN */
static const char* formatter_unit_0_is_off(char *buffer, size_t buffer_size,
int val, const char *unit)
{
@@ -910,6 +909,14 @@
list_pad_getlang, NULL, 16,
-1,0,2,4,6,8,10,12,16,20,24,28,32,38,44,50),
#endif
+#if LCD_DEPTH > 1
+ TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, list_separator_height, LANG_LIST_SEPARATOR,
+ 0, "list separator height", "auto,off", UNIT_PIXEL,
+ list_pad_formatter, list_pad_getlang, NULL, 15,
+ -1,0,1,2,3,4,5,7,9,11,13,16,20,25,30),
+ {F_T_INT|F_RGB|F_THEMESETTING ,&global_settings.list_separator_color,-1,
+ INT(DEFAULT_THEME_SEPARATOR),"list separator color",NULL,UNUSED},
+#endif
#if CONFIG_KEYPAD == RECORDER_PAD
OFFON_SETTING(F_THEMESETTING,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL),
#endif
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index b72989f..673ce06 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -114,7 +114,6 @@
#define STRIDE(screen, w, h) (screen==SCREEN_MAIN?STRIDE_MAIN((w), \
(h)):STRIDE_REMOTE((w),(h)))
-
#ifdef HAVE_LCD_BITMAP
#if LCD_DEPTH <=8
#if (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED) \
diff --git a/wps/WPSLIST b/wps/WPSLIST
index 3b10c300..3286b1e 100644
--- a/wps/WPSLIST
+++ b/wps/WPSLIST
@@ -202,6 +202,11 @@
show icons: on
statusbar: top
ui viewport: -
+# Touchscreen: whether to show line separators or not. Default to yes only on touchscreen targets.
+list separator height: 0
+list separator height..+&touchscreen: auto
+list separator color: 808080
+
</main>
<remote>
diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl
index d6d8085..52492f6 100755
--- a/wps/wpsbuild.pl
+++ b/wps/wpsbuild.pl
@@ -55,6 +55,8 @@
my $remotefont;
my $fgcolor;
my $bgcolor;
+my $sepcolor;
+my $sep;
my $statusbar;
my $remotestatusbar;
my $author;
@@ -291,6 +293,9 @@
push @out, "line selector start color: $lineselectstart\n" if($lineselectstart);
push @out, "line selector end color: $lineselectend\n" if($lineselectend);;
push @out, "line selector text color: $lineselecttextcolor\n" if($lineselecttextcolor);
+ # list separator actually depends on HAVE_TOUCSCREEN
+ push @out, "list separator height: $sep\n" if($sep);
+ push @out, "list separator color: $sepcolor\n" if($sepcolor);
}
push @out, "font: $font\n" if (defined($font));
@@ -430,6 +435,8 @@
undef $remotefont;
undef $fgcolor;
undef $bgcolor;
+ undef $sepcolor;
+ undef $sep;
undef $statusbar;
undef $remotestatusbar;
undef $author;
@@ -502,6 +509,12 @@
elsif($l =~ /^Background Color: *(.*)/i) {
$bgcolor = $1;
}
+ elsif($_ = check_res_feature($l, "list separator color")) {
+ $sepcolor = $_;
+ }
+ elsif($_ = check_res_feature($l, "list separator height")) {
+ $sep = $_;
+ }
elsif($l =~ /^line selector start color: *(.*)/i) {
$lineselectstart = $1;
}