diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/bitmap/list.c | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index dacf65adbd..ee9cab2da7 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c | |||
@@ -278,13 +278,15 @@ void list_draw(struct screen *display, struct viewport *parent, | |||
278 | 278 | ||
279 | 279 | ||
280 | #if defined(HAVE_TOUCHPAD) | 280 | #if defined(HAVE_TOUCHPAD) |
281 | /* 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 assumption but | ||
283 | * fine until customizable lists comes in... | ||
284 | */ | ||
281 | static unsigned int prev_line=0; | 285 | static unsigned int prev_line=0; |
282 | /* this needs to be fixed if we ever get more than 1 touchscreen on a target */ | 286 | |
283 | /* this also assumes the whole screen is used, which is a bad asusmption but | ||
284 | fine untill customizable lists comes in... */ | ||
285 | unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewport *parent) | 287 | unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewport *parent) |
286 | { | 288 | { |
287 | short x,y; | 289 | short x, y; |
288 | unsigned button = action_get_touchpad_press(&x, &y); | 290 | unsigned button = action_get_touchpad_press(&x, &y); |
289 | int line; | 291 | int line; |
290 | struct screen *display = &screens[SCREEN_MAIN]; | 292 | struct screen *display = &screens[SCREEN_MAIN]; |
@@ -292,7 +294,7 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor | |||
292 | return ACTION_NONE; | 294 | return ACTION_NONE; |
293 | if (x<list_text[SCREEN_MAIN].x) | 295 | if (x<list_text[SCREEN_MAIN].x) |
294 | { | 296 | { |
295 | /* top left corner is hopefully GO_TO_ROOT */ | 297 | /* Top left corner is hopefully GO_TO_ROOT */ |
296 | if (y<list_text[SCREEN_MAIN].y) | 298 | if (y<list_text[SCREEN_MAIN].y) |
297 | { | 299 | { |
298 | if (button == BUTTON_REL) | 300 | if (button == BUTTON_REL) |
@@ -302,7 +304,7 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor | |||
302 | else | 304 | else |
303 | return ACTION_NONE; | 305 | return ACTION_NONE; |
304 | } | 306 | } |
305 | /* scroll bar */ | 307 | /* Scroll bar */ |
306 | else | 308 | else |
307 | { | 309 | { |
308 | int new_selection, nb_lines; | 310 | int new_selection, nb_lines; |
@@ -327,8 +329,18 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor | |||
327 | } | 329 | } |
328 | else | 330 | else |
329 | { | 331 | { |
330 | /* pressing an item will select it. | 332 | /* |--------------------------------------------------------| |
331 | pressing the selected item will "enter" it */ | 333 | * | Description of the touchscreen list interface: | |
334 | * |--------------------------------------------------------| | ||
335 | * | Pressing an item will select it and "enter" it. | | ||
336 | * | | | ||
337 | * | Pressing and holding your pen down will scroll through | | ||
338 | * | the list of items, releasing your pen will "enter" it. | | ||
339 | * | | | ||
340 | * | Pressing and holding your pen down on a single item | | ||
341 | * | will bring up the context menu of it. | | ||
342 | * |--------------------------------------------------------| | ||
343 | */ | ||
332 | if (y > list_text[SCREEN_MAIN].y) | 344 | if (y > list_text[SCREEN_MAIN].y) |
333 | { | 345 | { |
334 | int i, line_height, actual_y; | 346 | int i, line_height, actual_y; |
@@ -343,11 +355,13 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor | |||
343 | break; | 355 | break; |
344 | } | 356 | } |
345 | } | 357 | } |
358 | |||
359 | /* Something went wrong during line detection... */ | ||
346 | if(line == -1) | 360 | if(line == -1) |
347 | return ACTION_NONE; | 361 | return ACTION_NONE; |
348 | 362 | ||
349 | /* BUTTON_TOUCHPAD represents a button press*/ | 363 | /* BUTTON_TOUCHPAD represents a button press*/ |
350 | if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN] && button == BUTTON_TOUCHPAD) | 364 | if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN] && button ^ BUTTON_REL) |
351 | { | 365 | { |
352 | if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) | 366 | if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) |
353 | return ACTION_NONE; | 367 | return ACTION_NONE; |
@@ -356,27 +370,39 @@ unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewpor | |||
356 | } | 370 | } |
357 | 371 | ||
358 | if (button == (BUTTON_REPEAT|BUTTON_REL)) | 372 | if (button == (BUTTON_REPEAT|BUTTON_REL)) |
359 | return ACTION_STD_CONTEXT; | ||
360 | else if(button == BUTTON_REL) | ||
361 | { | 373 | { |
362 | if((signed)prev_line == line) | 374 | if(prev_line == (unsigned)line) |
363 | { | 375 | { |
376 | /* Pen was hold on the same line as the previously selected one | ||
377 | * => simulate long button press | ||
378 | */ | ||
364 | prev_line = -1; | 379 | prev_line = -1; |
365 | return ACTION_STD_OK; | 380 | return ACTION_STD_CONTEXT; |
366 | } | 381 | } |
367 | else | 382 | else |
368 | { | 383 | { |
384 | /* Pen was moved across several lines and then released on this one | ||
385 | * => simulate short button press | ||
386 | */ | ||
369 | prev_line = line; | 387 | prev_line = line; |
370 | return ACTION_NONE; | 388 | return ACTION_STD_OK; |
371 | } | 389 | } |
372 | } | 390 | } |
391 | else if(button == BUTTON_REL) | ||
392 | { | ||
393 | /* Pen was released on either the same line as the previously selected one | ||
394 | * or an other one | ||
395 | * => simulate short press | ||
396 | */ | ||
397 | return ACTION_STD_OK; | ||
398 | } | ||
373 | else | 399 | else |
374 | return ACTION_NONE; | 400 | return ACTION_NONE; |
375 | } | 401 | } |
376 | /* title goes up one level */ | 402 | /* Title goes up one level (only on BUTTON_REL&~BUTTON_REPEAT) */ |
377 | else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list) && button == BUTTON_REL) | 403 | else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list) && button == BUTTON_REL) |
378 | return ACTION_STD_CANCEL; | 404 | return ACTION_STD_CANCEL; |
379 | /* title or statusbar is cancel */ | 405 | /* Title or statusbar is cancel (only on BUTTON_REL&~BUTTON_REPEAT) */ |
380 | else if (global_settings.statusbar && button == BUTTON_REL) | 406 | else if (global_settings.statusbar && button == BUTTON_REL) |
381 | return ACTION_STD_CANCEL; | 407 | return ACTION_STD_CANCEL; |
382 | } | 408 | } |