summaryrefslogtreecommitdiff
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-05a67d021c8fbb10b2654f8378b549901dd4c520.tar.gz
rockbox-05a67d021c8fbb10b2654f8378b549901dd4c520.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)
106 line.height = list->line_height[screen]; 106 line.height = list->line_height[screen];
107 title_text_vp->height = line.height; 107 title_text_vp->height = line.height;
108 108
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
109#ifdef HAVE_LCD_COLOR 116#ifdef HAVE_LCD_COLOR
110 if (list->title_color >= 0) 117 if (list->title_color >= 0)
111 line.style |= (STYLE_COLORED|list->title_color); 118 line.style |= (STYLE_COLORED|list->title_color);
@@ -154,7 +161,11 @@ void list_draw(struct screen *display, struct gui_synclist *list)
154 161
155 linedes.height = list->line_height[screen]; 162 linedes.height = list->line_height[screen];
156 linedes.nlines = list->selected_size; 163 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
158 start = list_start_item; 169 start = list_start_item;
159 end = start + nb_lines; 170 end = start + nb_lines;
160 171
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,
305 int style = line->style; 305 int style = line->style;
306 int width = display->getwidth(); 306 int width = display->getwidth();
307 int height = line->height == -1 ? display->getcharheight() : line->height; 307 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 }
308 330
309 /* mask out gradient and colorbar styles for non-color displays */ 331 /* mask out gradient and colorbar styles for non-color displays */
310 if (display->depth < 16) 332 if (display->depth < 16)
@@ -322,7 +344,7 @@ static void style_line(struct screen *display,
322#ifdef HAVE_LCD_COLOR 344#ifdef HAVE_LCD_COLOR
323 case STYLE_GRADIENT: 345 case STYLE_GRADIENT:
324 display->set_drawmode(DRMODE_FG); 346 display->set_drawmode(DRMODE_FG);
325 display->gradient_fillrect_part(x, y, width, height, 347 display->gradient_fillrect_part(x, y, width, bar_height,
326 line->line_color, 348 line->line_color,
327 line->line_end_color, 349 line->line_end_color,
328 height*line->nlines, 350 height*line->nlines,
@@ -331,16 +353,16 @@ static void style_line(struct screen *display,
331 case STYLE_COLORBAR: 353 case STYLE_COLORBAR:
332 display->set_drawmode(DRMODE_FG); 354 display->set_drawmode(DRMODE_FG);
333 display->set_foreground(line->line_color); 355 display->set_foreground(line->line_color);
334 display->fillrect(x, y, width - x, height); 356 display->fillrect(x, y, width - x, bar_height);
335 break; 357 break;
336#endif 358#endif
337 case STYLE_INVERT: 359 case STYLE_INVERT:
338 display->set_drawmode(DRMODE_FG); 360 display->set_drawmode(DRMODE_FG);
339 display->fillrect(x, y, width - x, height); 361 display->fillrect(x, y, width - x, bar_height);
340 break; 362 break;
341 case STYLE_DEFAULT: default: 363 case STYLE_DEFAULT: default:
342 display->set_drawmode(DRMODE_BG | DRMODE_INVERSEVID); 364 display->set_drawmode(DRMODE_BG | DRMODE_INVERSEVID);
343 display->fillrect(x, y, width - x, height); 365 display->fillrect(x, y, width - x, bar_height);
344 break; 366 break;
345 case STYLE_NONE: 367 case STYLE_NONE:
346 break; 368 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 {
74 enum line_styles style; 74 enum line_styles style;
75 /* whether the line can scroll */ 75 /* whether the line can scroll */
76 bool scroll; 76 bool scroll;
77 /* height of the line separator (in pixels). 0 to disable drawing
78 * of the separator */
79 int8_t separator_height;
77}; 80};
78 81
79/* default initializer, can be used for static initialitation also. 82/* default initializer, can be used for static initialitation also.
80 * This initializer will result in single lines without style that don't scroll */ 83 * 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 }
82 85
83/** 86/**
84 * Print a line at a given pixel postion, using decoration information from 87 * 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 @@
12926 </voice> 12926 </voice>
12927</phrase> 12927</phrase>
12928<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>
12956<phrase>
12929 id: LANG_SHORTCUTS 12957 id: LANG_SHORTCUTS
12930 desc: Title in the shortcuts menu 12958 desc: Title in the shortcuts menu
12931 user: core 12959 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 {
68 COLOR_LSS, 68 COLOR_LSS,
69 COLOR_LSE, 69 COLOR_LSE,
70 COLOR_LST, 70 COLOR_LST,
71 COLOR_SEP,
71 COLOR_COUNT 72 COLOR_COUNT
72}; 73};
73static struct colour_info 74static struct colour_info
@@ -80,6 +81,7 @@ static struct colour_info
80 [COLOR_LSS] = {&global_settings.lss_color, LANG_SELECTOR_START_COLOR}, 81 [COLOR_LSS] = {&global_settings.lss_color, LANG_SELECTOR_START_COLOR},
81 [COLOR_LSE] = {&global_settings.lse_color, LANG_SELECTOR_END_COLOR}, 82 [COLOR_LSE] = {&global_settings.lse_color, LANG_SELECTOR_END_COLOR},
82 [COLOR_LST] = {&global_settings.lst_color, LANG_SELECTOR_TEXT_COLOR}, 83 [COLOR_LST] = {&global_settings.lst_color, LANG_SELECTOR_TEXT_COLOR},
84 [COLOR_SEP] = {&global_settings.list_separator_color, LANG_LIST_SEPARATOR_COLOR},
83}; 85};
84 86
85/** 87/**
@@ -91,7 +93,7 @@ static int set_color_func(void* color)
91 /* Don't let foreground be set the same as background and vice-versa */ 93 /* Don't let foreground be set the same as background and vice-versa */
92 if (c == COLOR_BG) 94 if (c == COLOR_BG)
93 banned_color = *colors[COLOR_FG].setting; 95 banned_color = *colors[COLOR_FG].setting;
94 else if (c == COLOR_FG) 96 else if (c == COLOR_FG || c == COLOR_SEP)
95 banned_color = *colors[COLOR_BG].setting; 97 banned_color = *colors[COLOR_BG].setting;
96 98
97 old_color = *colors[c].setting; 99 old_color = *colors[c].setting;
@@ -113,6 +115,7 @@ static int reset_color(void)
113 global_settings.lss_color = LCD_DEFAULT_LS; 115 global_settings.lss_color = LCD_DEFAULT_LS;
114 global_settings.lse_color = LCD_DEFAULT_BG; 116 global_settings.lse_color = LCD_DEFAULT_BG;
115 global_settings.lst_color = LCD_DEFAULT_FG; 117 global_settings.lst_color = LCD_DEFAULT_FG;
118 global_settings.list_separator_color = LCD_DARKGRAY;
116 119
117 settings_save(); 120 settings_save();
118 settings_apply(false); 121 settings_apply(false);
@@ -129,6 +132,8 @@ MENUITEM_FUNCTION(set_lse_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_END_COLOR)
129 set_color_func, (void*)COLOR_LSE, NULL, Icon_NOICON); 132 set_color_func, (void*)COLOR_LSE, NULL, Icon_NOICON);
130MENUITEM_FUNCTION(set_lst_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_TEXT_COLOR), 133MENUITEM_FUNCTION(set_lst_col, MENU_FUNC_USEPARAM, ID2P(LANG_SELECTOR_TEXT_COLOR),
131 set_color_func, (void*)COLOR_LST, NULL, Icon_NOICON); 134 set_color_func, (void*)COLOR_LST, NULL, Icon_NOICON);
135MENUITEM_FUNCTION(set_sep_col, MENU_FUNC_USEPARAM, ID2P(LANG_LIST_SEPARATOR_COLOR),
136 set_color_func, (void*)COLOR_SEP, NULL, Icon_NOICON);
132MENUITEM_FUNCTION(reset_colors, 0, ID2P(LANG_RESET_COLORS), 137MENUITEM_FUNCTION(reset_colors, 0, ID2P(LANG_RESET_COLORS),
133 reset_color, NULL, NULL, Icon_NOICON); 138 reset_color, NULL, NULL, Icon_NOICON);
134 139
@@ -140,7 +145,7 @@ MAKE_MENU(lss_settings, ID2P(LANG_SELECTOR_COLOR_MENU),
140/* now the actual menu */ 145/* now the actual menu */
141MAKE_MENU(colors_settings, ID2P(LANG_COLORS_MENU), 146MAKE_MENU(colors_settings, ID2P(LANG_COLORS_MENU),
142 NULL, Icon_Display_menu, 147 NULL, Icon_Display_menu,
143 &lss_settings, 148 &lss_settings, &set_sep_col,
144 &set_bg_col, &set_fg_col, &reset_colors 149 &set_bg_col, &set_fg_col, &reset_colors
145 ); 150 );
146 151
@@ -388,6 +393,9 @@ MENUITEM_FUNCTION(browse_themes, MENU_FUNC_USEPARAM,
388#ifdef HAVE_LCD_BITMAP 393#ifdef HAVE_LCD_BITMAP
389MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, NULL); 394MENUITEM_SETTING(cursor_style, &global_settings.cursor_style, NULL);
390#endif 395#endif
396#if LCD_DEPTH > 1
397MENUITEM_SETTING(sep_menu, &global_settings.list_separator_height, NULL);
398#endif
391 399
392MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU), 400MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
393 NULL, Icon_Wps, 401 NULL, Icon_Wps,
@@ -418,8 +426,11 @@ MAKE_MENU(theme_menu, ID2P(LANG_THEME_MENU),
418#ifdef HAVE_LCD_BITMAP 426#ifdef HAVE_LCD_BITMAP
419 &bars_menu, 427 &bars_menu,
420 &cursor_style, 428 &cursor_style,
429#if LCD_DEPTH > 1
430 &sep_menu,
421#endif 431#endif
422#ifdef HAVE_LCD_COLOR 432#ifdef HAVE_LCD_COLOR
423 &colors_settings, 433 &colors_settings,
424#endif 434#endif
425 ); 435#endif /* HAVE_LCD_BITMAP */
436);
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
531#ifdef HAVE_LCD_BITMAP 531#ifdef HAVE_LCD_BITMAP
532 int scrollbar; /* SCROLLBAR_* enum values */ 532 int scrollbar; /* SCROLLBAR_* enum values */
533 int scrollbar_width; 533 int scrollbar_width;
534#endif
535 534
536#ifdef HAVE_TOUCHSCREEN 535#ifdef HAVE_TOUCHSCREEN
537 int list_line_padding; 536 int list_line_padding;
538#endif 537#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
540 /* goto current song when exiting WPS */ 543 /* goto current song when exiting WPS */
541 bool browse_current; /* 1=goto current song, 544 bool browse_current; /* 1=goto current song,
542 0=goto previous location */ 545 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";
282#define DEFAULT_THEME_SELECTOR_START LCD_RGBPACK(0xff, 0xeb, 0x9c) 282#define DEFAULT_THEME_SELECTOR_START LCD_RGBPACK(0xff, 0xeb, 0x9c)
283#define DEFAULT_THEME_SELECTOR_END LCD_RGBPACK(0xb5, 0x8e, 0x00) 283#define DEFAULT_THEME_SELECTOR_END LCD_RGBPACK(0xb5, 0x8e, 0x00)
284#define DEFAULT_THEME_SELECTOR_TEXT LCD_RGBPACK(0x00, 0x00, 0x00) 284#define DEFAULT_THEME_SELECTOR_TEXT LCD_RGBPACK(0x00, 0x00, 0x00)
285#define DEFAULT_THEME_SEPARATOR LCD_RGBPACK(0x80, 0x80, 0x80)
285 286
286#define DEFAULT_BACKDROP BACKDROP_DIR "/cabbiev2.bmp" 287#define DEFAULT_BACKDROP BACKDROP_DIR "/cabbiev2.bmp"
287 288
@@ -323,7 +324,6 @@ static const char graphic_numeric[] = "graphic,numeric";
323#define DEFAULT_TAGCACHE_SCAN_PATHS "/" 324#define DEFAULT_TAGCACHE_SCAN_PATHS "/"
324#endif 325#endif
325 326
326#ifdef HAVE_TOUCHSCREEN
327 327
328static const char* list_pad_formatter(char *buffer, size_t buffer_size, 328static const char* list_pad_formatter(char *buffer, size_t buffer_size,
329 int val, const char *unit) 329 int val, const char *unit)
@@ -348,7 +348,6 @@ static int32_t list_pad_getlang(int value, int unit)
348 } 348 }
349} 349}
350 350
351#endif /* HAVE_TOUCHSCREEN */
352static const char* formatter_unit_0_is_off(char *buffer, size_t buffer_size, 351static const char* formatter_unit_0_is_off(char *buffer, size_t buffer_size,
353 int val, const char *unit) 352 int val, const char *unit)
354{ 353{
@@ -910,6 +909,14 @@ const struct settings_list settings[] = {
910 list_pad_getlang, NULL, 16, 909 list_pad_getlang, NULL, 16,
911 -1,0,2,4,6,8,10,12,16,20,24,28,32,38,44,50), 910 -1,0,2,4,6,8,10,12,16,20,24,28,32,38,44,50),
912#endif 911#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
913#if CONFIG_KEYPAD == RECORDER_PAD 920#if CONFIG_KEYPAD == RECORDER_PAD
914 OFFON_SETTING(F_THEMESETTING,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL), 921 OFFON_SETTING(F_THEMESETTING,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL),
915#endif 922#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;
114#define STRIDE(screen, w, h) (screen==SCREEN_MAIN?STRIDE_MAIN((w), \ 114#define STRIDE(screen, w, h) (screen==SCREEN_MAIN?STRIDE_MAIN((w), \
115 (h)):STRIDE_REMOTE((w),(h))) 115 (h)):STRIDE_REMOTE((w),(h)))
116 116
117
118#ifdef HAVE_LCD_BITMAP 117#ifdef HAVE_LCD_BITMAP
119#if LCD_DEPTH <=8 118#if LCD_DEPTH <=8
120#if (LCD_PIXELFORMAT == VERTICAL_INTERLEAVED) \ 119#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
202show icons: on 202show icons: on
203statusbar: top 203statusbar: top
204ui viewport: - 204ui viewport: -
205# Touchscreen: whether to show line separators or not. Default to yes only on touchscreen targets.
206list separator height: 0
207list separator height..+&touchscreen: auto
208list separator color: 808080
209
205</main> 210</main>
206 211
207<remote> 212<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;
55my $remotefont; 55my $remotefont;
56my $fgcolor; 56my $fgcolor;
57my $bgcolor; 57my $bgcolor;
58my $sepcolor;
59my $sep;
58my $statusbar; 60my $statusbar;
59my $remotestatusbar; 61my $remotestatusbar;
60my $author; 62my $author;
@@ -291,6 +293,9 @@ MOO
291 push @out, "line selector start color: $lineselectstart\n" if($lineselectstart); 293 push @out, "line selector start color: $lineselectstart\n" if($lineselectstart);
292 push @out, "line selector end color: $lineselectend\n" if($lineselectend);; 294 push @out, "line selector end color: $lineselectend\n" if($lineselectend);;
293 push @out, "line selector text color: $lineselecttextcolor\n" if($lineselecttextcolor); 295 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);
294 } 299 }
295 300
296 push @out, "font: $font\n" if (defined($font)); 301 push @out, "font: $font\n" if (defined($font));
@@ -430,6 +435,8 @@ while(<WPS>) {
430 undef $remotefont; 435 undef $remotefont;
431 undef $fgcolor; 436 undef $fgcolor;
432 undef $bgcolor; 437 undef $bgcolor;
438 undef $sepcolor;
439 undef $sep;
433 undef $statusbar; 440 undef $statusbar;
434 undef $remotestatusbar; 441 undef $remotestatusbar;
435 undef $author; 442 undef $author;
@@ -502,6 +509,12 @@ while(<WPS>) {
502 elsif($l =~ /^Background Color: *(.*)/i) { 509 elsif($l =~ /^Background Color: *(.*)/i) {
503 $bgcolor = $1; 510 $bgcolor = $1;
504 } 511 }
512 elsif($_ = check_res_feature($l, "list separator color")) {
513 $sepcolor = $_;
514 }
515 elsif($_ = check_res_feature($l, "list separator height")) {
516 $sep = $_;
517 }
505 elsif($l =~ /^line selector start color: *(.*)/i) { 518 elsif($l =~ /^line selector start color: *(.*)/i) {
506 $lineselectstart = $1; 519 $lineselectstart = $1;
507 } 520 }