diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-05-30 22:55:24 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-05-30 22:55:24 +0000 |
commit | 944219bb7764206b59a5ea6e44ec52db39793161 (patch) | |
tree | 2de70412d29edff70d7cf68c2c9722195f581536 /apps/gui | |
parent | 48b47801e737202b575aeadb39b8bb99942f85a2 (diff) | |
download | rockbox-944219bb7764206b59a5ea6e44ec52db39793161.tar.gz rockbox-944219bb7764206b59a5ea6e44ec52db39793161.zip |
(Simulator) Touchscreen improvements.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17662 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/bitmap/list.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index ed257155bd..fa41daeb01 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c | |||
@@ -278,6 +278,7 @@ void list_draw(struct screen *display, struct viewport *parent, | |||
278 | 278 | ||
279 | 279 | ||
280 | #if defined(HAVE_TOUCHPAD) | 280 | #if defined(HAVE_TOUCHPAD) |
281 | static int prev_line=0; | ||
281 | /* this needs to be fixed if we ever get more than 1 touchscreen on a target */ | 282 | /* this needs to be fixed if we ever get more than 1 touchscreen on a target */ |
282 | /* this also assumes the whole screen is used, which is a bad asusmption but | 283 | /* this also assumes the whole screen is used, which is a bad asusmption but |
283 | fine untill customizable lists comes in... */ | 284 | fine untill customizable lists comes in... */ |
@@ -309,15 +310,15 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor | |||
309 | nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]); | 310 | nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]); |
310 | if (nb_lines < gui_list->nb_items) | 311 | if (nb_lines < gui_list->nb_items) |
311 | { | 312 | { |
312 | height = nb_lines * display->char_height; | 313 | height = nb_lines * font_get(parent->font)->height; |
313 | size = height*nb_lines / gui_list->nb_items; | 314 | size = height*nb_lines / gui_list->nb_items; |
314 | new_selection = ((y-list_text[SCREEN_MAIN].y)*(gui_list->nb_items-nb_lines))/(height-size); | 315 | new_selection = ((y-list_text[SCREEN_MAIN].y)*(gui_list->nb_items-nb_lines))/(height-size); |
315 | gui_synclist_select_item(gui_list, new_selection); | ||
316 | nb_lines /= 2; | 316 | nb_lines /= 2; |
317 | |||
317 | if (new_selection - gui_list->start_item[SCREEN_MAIN] > nb_lines) | 318 | if (new_selection - gui_list->start_item[SCREEN_MAIN] > nb_lines) |
318 | { | ||
319 | new_selection = gui_list->start_item[SCREEN_MAIN]+nb_lines; | 319 | new_selection = gui_list->start_item[SCREEN_MAIN]+nb_lines; |
320 | } | 320 | |
321 | gui_synclist_select_item(gui_list, new_selection); | ||
321 | gui_list->start_item[SCREEN_MAIN] = new_selection; | 322 | gui_list->start_item[SCREEN_MAIN] = new_selection; |
322 | return ACTION_REDRAW; | 323 | return ACTION_REDRAW; |
323 | } | 324 | } |
@@ -329,32 +330,52 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor | |||
329 | pressing the selected item will "enter" it */ | 330 | pressing the selected item will "enter" it */ |
330 | if (y > list_text[SCREEN_MAIN].y) | 331 | if (y > list_text[SCREEN_MAIN].y) |
331 | { | 332 | { |
332 | line = (y-list_text[SCREEN_MAIN].y) / display->char_height; | 333 | int i, line_height, actual_y; |
333 | if (button != BUTTON_REL && button != BUTTON_REPEAT) | 334 | actual_y = y - list_text[SCREEN_MAIN].y; |
335 | line_height = font_get(parent->font)->height; | ||
336 | line = -1; | ||
337 | for(i=0; i<gui_list->nb_items; i++) | ||
334 | { | 338 | { |
335 | if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN]) | 339 | if(actual_y > line_height*i && actual_y < line_height*(i+1)) |
336 | gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); | 340 | line = i; |
337 | return ACTION_REDRAW; | ||
338 | } | 341 | } |
339 | if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN]) | 342 | if(line == -1) |
343 | return ACTION_NONE; | ||
344 | |||
345 | /* BUTTON_TOUCHPAD represents a button press*/ | ||
346 | if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN] && button == BUTTON_TOUCHPAD) | ||
340 | { | 347 | { |
341 | if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) | 348 | if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) |
342 | return ACTION_NONE; | 349 | return ACTION_NONE; |
343 | gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); | 350 | gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); |
351 | return ACTION_REDRAW; | ||
344 | } | 352 | } |
345 | 353 | ||
346 | if (button == BUTTON_REPEAT) | 354 | if (button == BUTTON_REPEAT) |
347 | return ACTION_STD_CONTEXT; | 355 | return ACTION_STD_CONTEXT; |
356 | else if(button == BUTTON_REL) | ||
357 | { | ||
358 | if(prev_line == line) | ||
359 | { | ||
360 | prev_line = 0; | ||
361 | return ACTION_STD_OK; | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | prev_line = line; | ||
366 | return ACTION_NONE; | ||
367 | } | ||
368 | } | ||
348 | else | 369 | else |
349 | return ACTION_STD_OK; | 370 | return ACTION_NONE; |
350 | } | 371 | } |
351 | /* title goes up one level */ | 372 | /* title goes up one level */ |
352 | else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list)) | 373 | else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list) && button == BUTTON_REL) |
353 | { | 374 | { |
354 | return ACTION_STD_CANCEL; | 375 | return ACTION_STD_CANCEL; |
355 | } | 376 | } |
356 | /* title or statusbar is cancel */ | 377 | /* title or statusbar is cancel */ |
357 | else if (global_settings.statusbar) | 378 | else if (global_settings.statusbar && button == BUTTON_REL) |
358 | { | 379 | { |
359 | return ACTION_STD_CANCEL; | 380 | return ACTION_STD_CANCEL; |
360 | } | 381 | } |