summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2009-02-19 16:16:22 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2009-02-19 16:16:22 +0000
commit21ca86646f0e3303f80cb1139d178eea28692c14 (patch)
tree38c646bbb4e3ff6939585892431fbddea5fb647a
parent856fda013ebf6cdbd5b0305fe73b8ad33b93472f (diff)
downloadrockbox-21ca86646f0e3303f80cb1139d178eea28692c14.tar.gz
rockbox-21ca86646f0e3303f80cb1139d178eea28692c14.zip
Touchscreen fixes:
* better handling of clicks/taps above the list itself (which results in exiting the current menu) * fix 'entering the first item when clicking on the empty space below a list which has less items than a full screen can handle' git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20046 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/bitmap/list.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 231c990bab..ff95f6b2f7 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -282,7 +282,6 @@ void list_draw(struct screen *display, struct gui_synclist *list)
282 display->set_viewport(NULL); 282 display->set_viewport(NULL);
283} 283}
284 284
285
286#if defined(HAVE_TOUCHSCREEN) 285#if defined(HAVE_TOUCHSCREEN)
287/* This needs to be fixed if we ever get more than 1 touchscreen on a target. 286/* This needs to be fixed if we ever get more than 1 touchscreen on a target.
288 * This also assumes the whole screen is used, which is a bad assumption but 287 * This also assumes the whole screen is used, which is a bad assumption but
@@ -354,28 +353,28 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list)
354 if (y > list_text[screen].y || button & BUTTON_REPEAT) 353 if (y > list_text[screen].y || button & BUTTON_REPEAT)
355 { 354 {
356 int line_height, actual_y; 355 int line_height, actual_y;
357 static int last_y = 0;
358 356
359 actual_y = y - list_text[screen].y; 357 actual_y = y - list_text[screen].y;
360 line_height = font_get(gui_list->parent[screen]->font)->height; 358 line_height = font_get(gui_list->parent[screen]->font)->height;
361 line = actual_y / line_height; 359 line = actual_y / line_height;
362 360
363 if(actual_y%line_height == 0) /* Pressed a border */ 361 /* Pressed below the list*/
362 if (gui_list->start_item[screen]+line >= gui_list->nb_items)
364 return ACTION_NONE; 363 return ACTION_NONE;
365 364
366 if (gui_list->start_item[screen]+line > gui_list->nb_items) 365 /* Pressed a border */
367 { 366 if(UNLIKELY(actual_y % line_height == 0))
368 /* Pressed below the list*/
369 return ACTION_NONE; 367 return ACTION_NONE;
370 } 368
371 last_y = actual_y; 369 if (line != (gui_list->selected_item - gui_list->start_item[screen])
372 if (line != gui_list->selected_item 370 && button ^ BUTTON_REL)
373 - gui_list->start_item[screen] && button ^ BUTTON_REL)
374 { 371 {
375 if(button & BUTTON_REPEAT) 372 if(button & BUTTON_REPEAT)
376 scrolling = true; 373 scrolling = true;
374
377 gui_synclist_select_item(gui_list, gui_list->start_item[screen] 375 gui_synclist_select_item(gui_list, gui_list->start_item[screen]
378 + line); 376 + line);
377
379 return ACTION_REDRAW; 378 return ACTION_REDRAW;
380 } 379 }
381 380
@@ -399,7 +398,8 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list)
399 return ACTION_NONE; 398 return ACTION_NONE;
400 } 399 }
401 } 400 }
402 else if(button == BUTTON_REL) 401 else if(button == BUTTON_REL &&
402 line == gui_list->selected_item - gui_list->start_item[screen])
403 { 403 {
404 /* Pen was released on either the same line as the previously 404 /* Pen was released on either the same line as the previously
405 * selected one or an other one 405 * selected one or an other one
@@ -410,17 +410,9 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list)
410 else 410 else
411 return ACTION_NONE; 411 return ACTION_NONE;
412 } 412 }
413 /* Title goes up one level (only on BUTTON_REL&~BUTTON_REPEAT) */ 413 /* Everything above the items is cancel */
414 else if (y > title_text[screen].y && draw_title(display, gui_list) 414 else if (y < list_text[screen].y && button == BUTTON_REL)
415 && button == BUTTON_REL)
416 {
417 return ACTION_STD_CANCEL;
418 }
419 /* Title or statusbar is cancel (only on BUTTON_REL&~BUTTON_REPEAT) */
420 else if (global_settings.statusbar && button == BUTTON_REL)
421 {
422 return ACTION_STD_CANCEL; 415 return ACTION_STD_CANCEL;
423 }
424 } 416 }
425 return ACTION_NONE; 417 return ACTION_NONE;
426} 418}