Skip to content

Commit 05a67d0

Browse files
committed
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
1 parent 20e114c commit 05a67d0

File tree

10 files changed

+116
-14
lines changed

10 files changed

+116
-14
lines changed

apps/gui/bitmap/list.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ static bool draw_title(struct screen *display, struct gui_synclist *list)
106106
line.height = list->line_height[screen];
107107
title_text_vp->height = line.height;
108108

109+
#if LCD_DEPTH > 1
110+
/* XXX: Do we want to support the separator on remote displays? */
111+
if (display->screen_type == SCREEN_MAIN && global_settings.list_separator_height != 0)
112+
line.separator_height = abs(global_settings.list_separator_height)
113+
+ (lcd_get_dpi() > 200 ? 2 : 1);
114+
#endif
115+
109116
#ifdef HAVE_LCD_COLOR
110117
if (list->title_color >= 0)
111118
line.style |= (STYLE_COLORED|list->title_color);
@@ -154,7 +161,11 @@ void list_draw(struct screen *display, struct gui_synclist *list)
154161

155162
linedes.height = list->line_height[screen];
156163
linedes.nlines = list->selected_size;
157-
164+
#if LCD_DEPTH > 1
165+
/* XXX: Do we want to support the separator on remote displays? */
166+
if (display->screen_type == SCREEN_MAIN)
167+
linedes.separator_height = abs(global_settings.list_separator_height);
168+
#endif
158169
start = list_start_item;
159170
end = start + nb_lines;
160171

apps/gui/line.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,28 @@ static void style_line(struct screen *display,
305305
int style = line->style;
306306
int width = display->getwidth();
307307
int height = line->height == -1 ? display->getcharheight() : line->height;
308+
int bar_height = height;
309+
310+
/* mask out gradient and colorbar styles for non-color displays */
311+
if (display->depth < 16 && (style & (STYLE_COLORBAR|STYLE_GRADIENT)))
312+
{
313+
style &= ~(STYLE_COLORBAR|STYLE_GRADIENT);
314+
style |= STYLE_INVERT;
315+
}
316+
317+
if (line->separator_height > 0 && (line->line == line->nlines-1))
318+
{
319+
int sep_height = MIN(line->separator_height, height);
320+
display->set_drawmode(DRMODE_FG);
321+
#if LCD_DEPTH > 1
322+
display->set_foreground(global_settings.list_separator_color);
323+
#endif
324+
display->fillrect(x, y + height - sep_height, width, sep_height);
325+
bar_height -= sep_height;
326+
#if LCD_DEPTH > 1
327+
display->set_foreground(global_settings.fg_color);
328+
#endif
329+
}
308330

309331
/* mask out gradient and colorbar styles for non-color displays */
310332
if (display->depth < 16)
@@ -322,7 +344,7 @@ static void style_line(struct screen *display,
322344
#ifdef HAVE_LCD_COLOR
323345
case STYLE_GRADIENT:
324346
display->set_drawmode(DRMODE_FG);
325-
display->gradient_fillrect_part(x, y, width, height,
347+
display->gradient_fillrect_part(x, y, width, bar_height,
326348
line->line_color,
327349
line->line_end_color,
328350
height*line->nlines,
@@ -331,16 +353,16 @@ static void style_line(struct screen *display,
331353
case STYLE_COLORBAR:
332354
display->set_drawmode(DRMODE_FG);
333355
display->set_foreground(line->line_color);
334-
display->fillrect(x, y, width - x, height);
356+
display->fillrect(x, y, width - x, bar_height);
335357
break;
336358
#endif
337359
case STYLE_INVERT:
338360
display->set_drawmode(DRMODE_FG);
339-
display->fillrect(x, y, width - x, height);
361+
display->fillrect(x, y, width - x, bar_height);
340362
break;
341363
case STYLE_DEFAULT: default:
342364
display->set_drawmode(DRMODE_BG | DRMODE_INVERSEVID);
343-
display->fillrect(x, y, width - x, height);
365+
display->fillrect(x, y, width - x, bar_height);
344366
break;
345367
case STYLE_NONE:
346368
break;

apps/gui/line.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,14 @@ struct line_desc {
7474
enum line_styles style;
7575
/* whether the line can scroll */
7676
bool scroll;
77+
/* height of the line separator (in pixels). 0 to disable drawing
78+
* of the separator */
79+
int8_t separator_height;
7780
};
7881

7982
/* default initializer, can be used for static initialitation also.
8083
* This initializer will result in single lines without style that don't scroll */
81-
#define LINE_DESC_DEFINIT { .style = STYLE_DEFAULT, .height = -1, .line = 0, .nlines = 1, .scroll = false }
84+
#define LINE_DESC_DEFINIT { .style = STYLE_DEFAULT, .height = -1, .separator_height = 0, .line = 0, .nlines = 1, .scroll = false }
8285

8386
/**
8487
* Print a line at a given pixel postion, using decoration information from

apps/lang/english.lang

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12925,6 +12925,34 @@
1292512925
*: "Cancel Sleep Timer"
1292612926
</voice>
1292712927
</phrase>
12928+
<phrase>
12929+
id: LANG_LIST_SEPARATOR
12930+
desc: line between lines in lists
12931+
user: core
12932+
<source>
12933+
*: "Line Separator"
12934+
</source>
12935+
<dest>
12936+
*: "Line Separator"
12937+
</dest>
12938+
<voice>
12939+
*: "Line Separator"
12940+
</voice>
12941+
</phrase>
12942+
<phrase>
12943+
id: LANG_LIST_SEPARATOR_COLOR
12944+
desc: line between lines in lists
12945+
user: core
12946+
<source>
12947+
*: "Line Separator Colour"
12948+
</source>
12949+
<dest>
12950+
*: "Line Separator Colour"
12951+
</dest>
12952+
<voice>
12953+
*: "Line Separator Colour"
12954+
</voice>
12955+
</phrase>
1292812956
<phrase>
1292912957
id: LANG_SHORTCUTS
1293012958
desc: Title in the shortcuts menu

apps/menus/theme_menu.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ enum Colors {
6868
COLOR_LSS,
6969
COLOR_LSE,
7070
COLOR_LST,
71+
COLOR_SEP,
7172
COLOR_COUNT
7273
};
7374
static struct colour_info
@@ -80,6 +81,7 @@ static struct colour_info
8081
[COLOR_LSS] = {&global_settings.lss_color, LANG_SELECTOR_START_COLOR},
8182
[COLOR_LSE] = {&global_settings.lse_color, LANG_SELECTOR_END_COLOR},
8283
[COLOR_LST] = {&global_settings.lst_color, LANG_SELECTOR_TEXT_COLOR},
84+
[COLOR_SEP] = {&global_settings.list_separator_color, LANG_LIST_SEPARATOR_COLOR},
8385
};
8486

8587
/**
@@ -91,7 +93,7 @@ static int set_color_func(void* color)
9193
/* Don't let foreground be set the same as background and vice-versa */
9294
if (c == COLOR_BG)
9395
banned_color = *colors[COLOR_FG].setting;
94-
else if (c == COLOR_FG)
96+
else if (c == COLOR_FG || c == COLOR_SEP)
9597
banned_color = *colors[COLOR_BG].setting;
9698

9799
old_color = *colors[c].setting;
@@ -113,6 +115,7 @@ static int reset_color(void)
113115
global_settings.lss_color = LCD_DEFAULT_LS;
114116
global_settings.lse_color = LCD_DEFAULT_BG;
115117
global_settings.lst_color = LCD_DEFAULT_FG;
118+
global_settings.list_separator_color = LCD_DARKGRAY;
116119

117120
settings_save();
118121
settings_apply(false);
@@ -129,6 +132,8 @@ MENUITEM_FUNCTION(set_lse_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_END_COLOR)
129132
set_color_func, (void*)COLOR_LSE, NULL, Icon_NOICON);
130133
MENUITEM_FUNCTION(set_lst_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_TEXT_COLOR),
131134
set_color_func, (void*)COLOR_LST, NULL, Icon_NOICON);
135+
MENUITEM_FUNCTION(set_sep_col, MENU_FUNC_USEPARAM, ID2P(LANG_LIST_SEPARATOR_COLOR),
136+
set_color_func, (void*)COLOR_SEP, NULL, Icon_NOICON);
132137
MENUITEM_FUNCTION(reset_colors, 0, ID2P(LANG_RESET_COLORS),
133138
reset_color, NULL, NULL, Icon_NOICON);
134139

@@ -140,7 +145,7 @@ MAKE_MENU(lss_settings, ID2P(LANG_SELECTOR_COLOR_MENU),
140145
/* now the actual menu */
141146
MAKE_MENU(colors_settings, ID2P(LANG_COLORS_MENU),
142147
NULL, Icon_Display_menu,
143-
&lss_settings,
148+
&lss_settings, &set_sep_col,
144149
&set_bg_col, &set_fg_col, &reset_colors
145150
);
146151

@@ -388,6 +393,9 @@ MENUITEM_FUNCTION(browse_themes, MENU_FUNC_USEPARAM,
388393
#ifdef HAVE_LCD_BITMAP
389394
MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, NULL);
390395
#endif
396+
#if LCD_DEPTH > 1
397+
MENUITEM_SETTING(sep_menu, &global_settings.list_separator_height, NULL);
398+
#endif
391399

392400
MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
393401
NULL, Icon_Wps,
@@ -418,8 +426,11 @@ MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
418426
#ifdef HAVE_LCD_BITMAP
419427
&bars_menu,
420428
&cursor_style,
429+
#if LCD_DEPTH > 1
430+
&sep_menu,
421431
#endif
422432
#ifdef HAVE_LCD_COLOR
423433
&colors_settings,
424434
#endif
425-
);
435+
#endif /* HAVE_LCD_BITMAP */
436+
);

apps/settings.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,15 @@ struct user_settings
531531
#ifdef HAVE_LCD_BITMAP
532532
int scrollbar; /* SCROLLBAR_* enum values */
533533
int scrollbar_width;
534-
#endif
535534

536535
#ifdef HAVE_TOUCHSCREEN
537536
int list_line_padding;
538537
#endif
539-
538+
#if LCD_DEPTH > 1
539+
int list_separator_height; /* -1=auto (== 1 currently), 0=disabled, X=height in pixels */
540+
int list_separator_color;
541+
#endif
542+
#endif
540543
/* goto current song when exiting WPS */
541544
bool browse_current; /* 1=goto current song,
542545
0=goto previous location */

apps/settings_list.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static const char graphic_numeric[] = "graphic,numeric";
282282
#define DEFAULT_THEME_SELECTOR_START LCD_RGBPACK(0xff, 0xeb, 0x9c)
283283
#define DEFAULT_THEME_SELECTOR_END LCD_RGBPACK(0xb5, 0x8e, 0x00)
284284
#define DEFAULT_THEME_SELECTOR_TEXT LCD_RGBPACK(0x00, 0x00, 0x00)
285+
#define DEFAULT_THEME_SEPARATOR LCD_RGBPACK(0x80, 0x80, 0x80)
285286

286287
#define DEFAULT_BACKDROP BACKDROP_DIR "/cabbiev2.bmp"
287288

@@ -323,7 +324,6 @@ static const char graphic_numeric[] = "graphic,numeric";
323324
#define DEFAULT_TAGCACHE_SCAN_PATHS "/"
324325
#endif
325326

326-
#ifdef HAVE_TOUCHSCREEN
327327

328328
static const char* list_pad_formatter(char *buffer, size_t buffer_size,
329329
int val, const char *unit)
@@ -348,7 +348,6 @@ static int32_t list_pad_getlang(int value, int unit)
348348
}
349349
}
350350

351-
#endif /* HAVE_TOUCHSCREEN */
352351
static const char* formatter_unit_0_is_off(char *buffer, size_t buffer_size,
353352
int val, const char *unit)
354353
{
@@ -910,6 +909,14 @@ const struct settings_list settings[] = {
910909
list_pad_getlang, NULL, 16,
911910
-1,0,2,4,6,8,10,12,16,20,24,28,32,38,44,50),
912911
#endif
912+
#if LCD_DEPTH > 1
913+
TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, list_separator_height, LANG_LIST_SEPARATOR,
914+
0, "list separator height", "auto,off", UNIT_PIXEL,
915+
list_pad_formatter, list_pad_getlang, NULL, 15,
916+
-1,0,1,2,3,4,5,7,9,11,13,16,20,25,30),
917+
{F_T_INT|F_RGB|F_THEMESETTING ,&global_settings.list_separator_color,-1,
918+
INT(DEFAULT_THEME_SEPARATOR),"list separator color",NULL,UNUSED},
919+
#endif
913920
#if CONFIG_KEYPAD == RECORDER_PAD
914921
OFFON_SETTING(F_THEMESETTING,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL),
915922
#endif

firmware/export/lcd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ struct scrollinfo;
114114
#define STRIDE(screen, w, h) (screen==SCREEN_MAIN?STRIDE_MAIN((w), \
115115
(h)):STRIDE_REMOTE((w),(h)))
116116

117-
118117
#ifdef HAVE_LCD_BITMAP
119118
#if LCD_DEPTH <=8
120119
#if (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED) \

wps/WPSLIST

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ viewers iconset..+x2: icons/tango_small_viewers_mono.bmp
202202
show icons: on
203203
statusbar: top
204204
ui viewport: -
205+
# Touchscreen: whether to show line separators or not. Default to yes only on touchscreen targets.
206+
list separator height: 0
207+
list separator height..+&touchscreen: auto
208+
list separator color: 808080
209+
205210
</main>
206211

207212
<remote>

wps/wpsbuild.pl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
my $remotefont;
5656
my $fgcolor;
5757
my $bgcolor;
58+
my $sepcolor;
59+
my $sep;
5860
my $statusbar;
5961
my $remotestatusbar;
6062
my $author;
@@ -291,6 +293,9 @@ sub buildcfg {
291293
push @out, "line selector start color: $lineselectstart\n" if($lineselectstart);
292294
push @out, "line selector end color: $lineselectend\n" if($lineselectend);;
293295
push @out, "line selector text color: $lineselecttextcolor\n" if($lineselecttextcolor);
296+
# list separator actually depends on HAVE_TOUCSCREEN
297+
push @out, "list separator height: $sep\n" if($sep);
298+
push @out, "list separator color: $sepcolor\n" if($sepcolor);
294299
}
295300

296301
push @out, "font: $font\n" if (defined($font));
@@ -430,6 +435,8 @@ sub check_skinfile {
430435
undef $remotefont;
431436
undef $fgcolor;
432437
undef $bgcolor;
438+
undef $sepcolor;
439+
undef $sep;
433440
undef $statusbar;
434441
undef $remotestatusbar;
435442
undef $author;
@@ -502,6 +509,12 @@ sub check_skinfile {
502509
elsif($l =~ /^Background Color: *(.*)/i) {
503510
$bgcolor = $1;
504511
}
512+
elsif($_ = check_res_feature($l, "list separator color")) {
513+
$sepcolor = $_;
514+
}
515+
elsif($_ = check_res_feature($l, "list separator height")) {
516+
$sep = $_;
517+
}
505518
elsif($l =~ /^line selector start color: *(.*)/i) {
506519
$lineselectstart = $1;
507520
}

0 commit comments

Comments
 (0)