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.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) | |||
78 | add_event(GUI_EVENT_THEME_CHANGED, false, list_force_reinit); | 78 | add_event(GUI_EVENT_THEME_CHANGED, false, list_force_reinit); |
79 | } | 79 | } |
80 | 80 | ||
81 | #ifdef HAVE_TOUCHSCREEN | ||
82 | static int line_height_from_lcd_dpi(const struct viewport *vp) | ||
83 | { | ||
84 | /* the 4/12 factor is designed for reasonable item size on a 160dpi screen */ | ||
85 | return MAX(lcd_get_dpi()*4/12, (int)font_get(vp->font)->height); | ||
86 | } | ||
87 | |||
88 | static int list_line_height(const struct viewport *vp) | ||
89 | { | ||
90 | if (global_settings.list_line_padding == -1) | ||
91 | return line_height_from_lcd_dpi(vp); | ||
92 | return font_get(vp->font)->height + global_settings.list_line_padding; | ||
93 | } | ||
94 | #endif | ||
95 | |||
81 | static void list_init_viewports(struct gui_synclist *list) | 96 | static void list_init_viewports(struct gui_synclist *list) |
82 | { | 97 | { |
83 | int parent_used; | 98 | int parent_used; |
@@ -90,6 +105,9 @@ static void list_init_viewports(struct gui_synclist *list) | |||
90 | { | 105 | { |
91 | list->parent[i] = &parent[i]; | 106 | list->parent[i] = &parent[i]; |
92 | viewport_set_defaults(&parent[i], i); | 107 | viewport_set_defaults(&parent[i], i); |
108 | #ifdef HAVE_TOUCHSCREEN | ||
109 | parent[i].line_height = list_line_height(list->parent[i]); | ||
110 | #endif | ||
93 | #ifdef HAVE_BUTTONBAR | 111 | #ifdef HAVE_BUTTONBAR |
94 | if (screens[i].has_buttonbar) | 112 | if (screens[i].has_buttonbar) |
95 | list->parent[i]->height -= BUTTONBAR_HEIGHT; | 113 | list->parent[i]->height -= BUTTONBAR_HEIGHT; |
@@ -124,13 +142,15 @@ bool list_display_title(struct gui_synclist *list, enum screen_type screen) | |||
124 | 142 | ||
125 | static int list_get_nb_lines(struct gui_synclist *list, enum screen_type screen) | 143 | static int list_get_nb_lines(struct gui_synclist *list, enum screen_type screen) |
126 | { | 144 | { |
127 | struct viewport vp = *list->parent[screen]; | 145 | struct viewport *vp = list->parent[screen]; |
128 | int skin_count = skinlist_get_line_count(screen, list); | 146 | int lines = skinlist_get_line_count(screen, list); |
129 | if (skin_count >= 0) | 147 | if (lines < 0) |
130 | return skin_count; | 148 | { |
131 | if (list_display_title(list, screen)) | 149 | lines = viewport_get_nb_lines(vp); |
132 | vp.height -= font_get(list->parent[screen]->font)->height; | 150 | if (list_display_title(list, screen)) |
133 | return viewport_get_nb_lines(&vp); | 151 | lines -= 1; |
152 | } | ||
153 | return lines; | ||
134 | } | 154 | } |
135 | #else | 155 | #else |
136 | #define list_display_title(l, i) false | 156 | #define list_display_title(l, i) false |