summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2013-05-06 07:20:40 +0200
committerThomas Martitz <kugel@rockbox.org>2014-03-03 15:14:16 +0100
commit05a67d021c8fbb10b2654f8378b549901dd4c520 (patch)
tree23d0fa787d7373bf2ea08d1678cff47306a1a55d
parent20e114c1a0f086e432f374fe0ecebf014a571448 (diff)
downloadrockbox-05a67d0.tar.gz
rockbox-05a67d0.tar.bz2
rockbox-05a67d0.zip
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
-rw-r--r--apps/gui/bitmap/list.c13
-rw-r--r--apps/gui/line.c30
-rw-r--r--apps/gui/line.h5
-rw-r--r--apps/lang/english.lang28
-rw-r--r--apps/menus/theme_menu.c17
-rw-r--r--apps/settings.h7
-rw-r--r--apps/settings_list.c11
-rw-r--r--firmware/export/lcd.h1
-rw-r--r--wps/WPSLIST5
-rwxr-xr-xwps/wpsbuild.pl13
10 files changed, 116 insertions, 14 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index f1def9007d..97eefce9db 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -106,6 +106,13 @@ static bool draw_title(struct screen *display, struct gui_synclist *list)
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 @@ void list_draw(struct screen *display, struct gui_synclist *list)
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 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;
diff --git a/apps/gui/line.h b/apps/gui/line.h
index 9a0769de35..c14f04d9a2 100644
--- a/apps/gui/line.h
+++ b/apps/gui/line.h
@@ -74,11 +74,14 @@ struct line_desc {
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 0778ab74d3..9914b160f1 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 93511f8197..f64ded1615 100644
--- a/apps/menus/theme_menu.c
+++ b/apps/menus/theme_menu.c
@@ -68,6 +68,7 @@ enum Colors {
COLOR_LSS,
COLOR_LSE,
COLOR_LST,
+ COLOR_SEP,
COLOR_COUNT
};
static struct colour_info
@@ -80,6 +81,7 @@ static struct colour_info
[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 @@ static int set_color_func(void* color)
/* 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 @@ static int reset_color(void)
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 @@ MENUITEM_FUNCTION(set_lse_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_END_COLOR)
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 @@ MAKE_MENU(lss_settings, ID2P(LANG_SELECTOR_COLOR_MENU),
/* 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 @@ MENUITEM_FUNCTION(browse_themes, MENU_FUNC_USEPARAM,
#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 @@ MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
#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 62ae038385..5b876d3e67 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -531,12 +531,15 @@ struct user_settings
#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 9b1ec4427f..681a3ab05b 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -282,6 +282,7 @@ static const char graphic_numeric[] = "graphic,numeric";
#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 @@ static const char graphic_numeric[] = "graphic,numeric";
#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 @@ static int32_t list_pad_getlang(int value, int unit)
}
}
-#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 @@ const struct settings_list settings[] = {
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 b72989fdb5..673ce069af 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -114,7 +114,6 @@ struct scrollinfo;
#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 3b10c3002b..3286b1eb8b 100644
--- a/wps/WPSLIST
+++ b/wps/WPSLIST
@@ -202,6 +202,11 @@ viewers iconset..+x2: icons/tango_small_viewers_mono.bmp
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 d6d8085449..52492f6b71 100755
--- a/wps/wpsbuild.pl
+++ b/wps/wpsbuild.pl
@@ -55,6 +55,8 @@ my $font;
my $remotefont;
my $fgcolor;
my $bgcolor;
+my $sepcolor;
+my $sep;
my $statusbar;
my $remotestatusbar;
my $author;
@@ -291,6 +293,9 @@ MOO
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 @@ while(<WPS>) {
undef $remotefont;
undef $fgcolor;
undef $bgcolor;
+ undef $sepcolor;
+ undef $sep;
undef $statusbar;
undef $remotestatusbar;
undef $author;
@@ -502,6 +509,12 @@ while(<WPS>) {
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;
}