diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-10-17 17:38:10 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-10-17 17:38:10 +0000 |
commit | 3b12634e6bc966cb2b2e7f21e9a435cdd20f0bc4 (patch) | |
tree | 2f103d5b58b4a22f65e9fd02de4a720022034121 /apps/gui/list.c | |
parent | 859cd4b627a48cab8273d8f4d04e2afeb0ee7c87 (diff) | |
download | rockbox-3b12634e6bc966cb2b2e7f21e9a435cdd20f0bc4.tar.gz rockbox-3b12634e6bc966cb2b2e7f21e9a435cdd20f0bc4.tar.bz2 rockbox-3b12634e6bc966cb2b2e7f21e9a435cdd20f0bc4.zip |
Commit FS#12321 - Touchscreen: List line padding, to more easily select lines
This adds line padding to lists on touchscreens,
in order to make lists reasonably useful without huge fonts.
It's configurable:
* Automatic (default, line height calculated using a lcd dpi aware function)
* Off (status quo, line height = font height)
* X pixels (from 2 to 50 in even steps)
The automatic setting should/aims to Just Work Out Of The Box on all targets
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30773 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/list.c')
-rw-r--r-- | apps/gui/list.c | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c index 1a90ff9e40..66c3438574 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -78,6 +78,21 @@ void list_init(void) add_event(GUI_EVENT_THEME_CHANGED, false, list_force_reinit); } +#ifdef HAVE_TOUCHSCREEN +static int line_height_from_lcd_dpi(const struct viewport *vp) +{ + /* the 4/12 factor is designed for reasonable item size on a 160dpi screen */ + return MAX(lcd_get_dpi()*4/12, (int)font_get(vp->font)->height); +} + +static int list_line_height(const struct viewport *vp) +{ + if (global_settings.list_line_padding == -1) + return line_height_from_lcd_dpi(vp); + return font_get(vp->font)->height + global_settings.list_line_padding; +} +#endif + static void list_init_viewports(struct gui_synclist *list) { int parent_used; @@ -90,6 +105,9 @@ static void list_init_viewports(struct gui_synclist *list) { list->parent[i] = &parent[i]; viewport_set_defaults(&parent[i], i); +#ifdef HAVE_TOUCHSCREEN + parent[i].line_height = list_line_height(list->parent[i]); +#endif #ifdef HAVE_BUTTONBAR if (screens[i].has_buttonbar) list->parent[i]->height -= BUTTONBAR_HEIGHT; @@ -124,13 +142,15 @@ bool list_display_title(struct gui_synclist *list, enum screen_type screen) static int list_get_nb_lines(struct gui_synclist *list, enum screen_type screen) { - struct viewport vp = *list->parent[screen]; - int skin_count = skinlist_get_line_count(screen, list); - if (skin_count >= 0) - return skin_count; - if (list_display_title(list, screen)) - vp.height -= font_get(list->parent[screen]->font)->height; - return viewport_get_nb_lines(&vp); + struct viewport *vp = list->parent[screen]; + int lines = skinlist_get_line_count(screen, list); + if (lines < 0) + { + lines = viewport_get_nb_lines(vp); + if (list_display_title(list, screen)) + lines -= 1; + } + return lines; } #else #define list_display_title(l, i) false |