diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/bitmap/list.c | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index a1b0c79eaa..578c9ced72 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c | |||
@@ -130,10 +130,13 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
130 | vp = list_text[screen]; | 130 | vp = list_text[screen]; |
131 | vp.width = SCROLLBAR_WIDTH; | 131 | vp.width = SCROLLBAR_WIDTH; |
132 | list_text[screen].width -= SCROLLBAR_WIDTH; | 132 | list_text[screen].width -= SCROLLBAR_WIDTH; |
133 | list_text[screen].x += SCROLLBAR_WIDTH; | 133 | if(global_settings.scrollbar_position) /* left */ |
134 | list_text[screen].x += SCROLLBAR_WIDTH; | ||
134 | vp.height = line_height * | 135 | vp.height = line_height * |
135 | viewport_get_nb_lines(&list_text[screen]); | 136 | viewport_get_nb_lines(&list_text[screen]); |
136 | vp.x = parent->x; | 137 | vp.x = parent->x; |
138 | if(!global_settings.scrollbar_position) /* right */ | ||
139 | vp.x += list_text[screen].width; | ||
137 | display->set_viewport(&vp); | 140 | display->set_viewport(&vp); |
138 | gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1, | 141 | gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1, |
139 | vp.height, list->nb_items, | 142 | vp.height, list->nb_items, |
@@ -144,8 +147,11 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
144 | else if (show_title) | 147 | else if (show_title) |
145 | { | 148 | { |
146 | /* shift everything right a bit... */ | 149 | /* shift everything right a bit... */ |
147 | list_text[screen].width -= SCROLLBAR_WIDTH; | 150 | if(global_settings.scrollbar_position) /* left */ |
148 | list_text[screen].x += SCROLLBAR_WIDTH; | 151 | { |
152 | list_text[screen].width -= SCROLLBAR_WIDTH; | ||
153 | list_text[screen].x += SCROLLBAR_WIDTH; | ||
154 | } | ||
149 | } | 155 | } |
150 | 156 | ||
151 | /* setup icon placement */ | 157 | /* setup icon placement */ |
@@ -284,6 +290,35 @@ void list_draw(struct screen *display, struct gui_synclist *list) | |||
284 | */ | 290 | */ |
285 | static bool scrolling=false; | 291 | static bool scrolling=false; |
286 | 292 | ||
293 | static int gui_synclist_touchscreen_scrollbar(struct gui_synclist * gui_list, | ||
294 | int y) | ||
295 | { | ||
296 | int screen = screens[SCREEN_MAIN].screen_type; | ||
297 | int nb_lines = viewport_get_nb_lines(&list_text[screen]); | ||
298 | if (nb_lines < gui_list->nb_items) | ||
299 | { | ||
300 | int scrollbar_size = nb_lines* | ||
301 | font_get(gui_list->parent[screen]->font)->height; | ||
302 | int actual_y = y - list_text[screen].y; | ||
303 | |||
304 | int new_selection = (actual_y * gui_list->nb_items) | ||
305 | / scrollbar_size; | ||
306 | |||
307 | int start_item = new_selection - nb_lines/2; | ||
308 | if(start_item < 0) | ||
309 | start_item = 0; | ||
310 | else if(start_item > gui_list->nb_items - nb_lines) | ||
311 | start_item = gui_list->nb_items - nb_lines; | ||
312 | |||
313 | gui_list->start_item[screen] = start_item; | ||
314 | gui_synclist_select_item(gui_list, new_selection); | ||
315 | |||
316 | return ACTION_REDRAW; | ||
317 | } | ||
318 | |||
319 | return ACTION_NONE; | ||
320 | } | ||
321 | |||
287 | unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list) | 322 | unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list) |
288 | { | 323 | { |
289 | short x, y; | 324 | short x, y; |
@@ -306,33 +341,15 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list) | |||
306 | return ACTION_NONE; | 341 | return ACTION_NONE; |
307 | } | 342 | } |
308 | /* Scroll bar */ | 343 | /* Scroll bar */ |
309 | else | 344 | else if(global_settings.scrollbar_position) /* left */ |
310 | { | 345 | return gui_synclist_touchscreen_scrollbar(gui_list, y); |
311 | int nb_lines = viewport_get_nb_lines(&list_text[screen]); | ||
312 | if (nb_lines < gui_list->nb_items) | ||
313 | { | ||
314 | int scrollbar_size = nb_lines* | ||
315 | font_get(gui_list->parent[screen]->font)->height; | ||
316 | int actual_y = y - list_text[screen].y; | ||
317 | |||
318 | int new_selection = (actual_y * gui_list->nb_items) | ||
319 | / scrollbar_size; | ||
320 | |||
321 | int start_item = new_selection - nb_lines/2; | ||
322 | if(start_item < 0) | ||
323 | start_item = 0; | ||
324 | else if(start_item > gui_list->nb_items - nb_lines) | ||
325 | start_item = gui_list->nb_items - nb_lines; | ||
326 | |||
327 | gui_list->start_item[screen] = start_item; | ||
328 | gui_synclist_select_item(gui_list, new_selection); | ||
329 | |||
330 | return ACTION_REDRAW; | ||
331 | } | ||
332 | } | ||
333 | } | 346 | } |
334 | else | 347 | else |
335 | { | 348 | { |
349 | if(x>list_text[screen].x+list_text[screen].width && | ||
350 | !global_settings.scrollbar_position) /* right*/ | ||
351 | return gui_synclist_touchscreen_scrollbar(gui_list, y); | ||
352 | |||
336 | /* |--------------------------------------------------------| | 353 | /* |--------------------------------------------------------| |
337 | * | Description of the touchscreen list interface: | | 354 | * | Description of the touchscreen list interface: | |
338 | * |--------------------------------------------------------| | 355 | * |--------------------------------------------------------| |