summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/gui/bitmap/list.c85
-rw-r--r--apps/gui/list.c90
2 files changed, 87 insertions, 88 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 63f24dd456..4bffca84bc 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -274,3 +274,88 @@ void list_draw(struct screen *display, struct viewport *parent,
274} 274}
275 275
276 276
277#if defined(HAVE_TOUCHPAD)
278/* this needs to be fixed if we ever get more than 1 touchscreen on a target */
279/* this also assumes the whole screen is used, which is a bad asusmption but
280 fine untill customizable lists comes in... */
281unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewport *parent)
282{
283 short x,y;
284 unsigned button = action_get_touchpad_press(&x, &y);
285 int line;
286 struct screen *display = &screens[SCREEN_MAIN];
287 if (button == BUTTON_NONE)
288 return ACTION_NONE;
289 if (x<list_text[SCREEN_MAIN].x)
290 {
291 /* top left corner is hopefully GO_TO_ROOT */
292 if (y<list_text[SCREEN_MAIN].y)
293 {
294 if (button == BUTTON_REL)
295 return ACTION_STD_MENU;
296 else if (button == BUTTON_REPEAT)
297 return ACTION_STD_CONTEXT;
298 else
299 return ACTION_NONE;
300 }
301 /* scroll bar */
302 else
303 {
304 int new_selection, nb_lines;
305 int height, size;
306 nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]);
307 if (nb_lines < gui_list->nb_items)
308 {
309 height = nb_lines * display->char_height;
310 size = height*nb_lines / gui_list->nb_items;
311 new_selection = ((y-list_text[SCREEN_MAIN].y)*(gui_list->nb_items-nb_lines))/(height-size);
312 gui_synclist_select_item(gui_list, new_selection);
313 nb_lines /= 2;
314 if (new_selection - gui_list->start_item[SCREEN_MAIN] > nb_lines)
315 {
316 new_selection = gui_list->start_item[SCREEN_MAIN]+nb_lines;
317 }
318 gui_list->start_item[SCREEN_MAIN] = new_selection;
319 return ACTION_REDRAW;
320 }
321 }
322 }
323 else
324 {
325 /* pressing an item will select it.
326 pressing the selected item will "enter" it */
327 if (y > list_text[SCREEN_MAIN].y)
328 {
329 line = (y-list_text[SCREEN_MAIN].y) / display->char_height;
330 if (button != BUTTON_REL && button != BUTTON_REPEAT)
331 {
332 if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN])
333 gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line);
334 return ACTION_REDRAW;
335 }
336 if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN])
337 {
338 if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items)
339 return ACTION_NONE;
340 gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line);
341 }
342
343 if (button == BUTTON_REPEAT)
344 return ACTION_STD_CONTEXT;
345 else
346 return ACTION_STD_OK;
347 }
348 /* title goes up one level */
349 else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list))
350 {
351 return ACTION_STD_CANCEL;
352 }
353 /* title or statusbar is cancel */
354 else if (global_settings.statusbar)
355 {
356 return ACTION_STD_CANCEL;
357 }
358 }
359 return ACTION_NONE;
360}
361#endif
diff --git a/apps/gui/list.c b/apps/gui/list.c
index fbc417edee..9aafece04e 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -528,95 +528,9 @@ void gui_synclist_speak_item(struct gui_synclist * lists)
528} 528}
529 529
530extern intptr_t get_action_data(void); 530extern intptr_t get_action_data(void);
531
532#if defined(HAVE_TOUCHPAD) 531#if defined(HAVE_TOUCHPAD)
533/* this needs to be fixed if we ever get more than 1 touchscreen on a target */ 532/* this needs to be fixed if we ever get more than 1 touchscreen on a target */
534unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list) 533unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewport *parent);
535{
536 short x,y;
537 unsigned button = action_get_touchpad_press(&x, &y);
538 int line;
539 struct screen *display = &screens[SCREEN_MAIN];
540 if (button == BUTTON_NONE)
541 return ACTION_NONE;
542 if (x<SCROLLBAR_WIDTH)
543 {
544 /* top left corner is hopefully GO_TO_ROOT */
545 if (y<STATUSBAR_HEIGHT)
546 {
547 if (button == BUTTON_REL)
548 return ACTION_STD_MENU;
549 else if (button == BUTTON_REPEAT)
550 return ACTION_STD_CONTEXT;
551 else
552 return ACTION_NONE;
553 }
554 /* scroll bar */
555 else
556 {
557 int new_selection, nb_lines;
558 int height, size;
559 nb_lines = display->nb_lines - SHOW_LIST_TITLE;
560 if (nb_lines < gui_list->nb_items)
561 {
562 height = nb_lines * display->char_height;
563 size = height*nb_lines / gui_list->nb_items;
564 new_selection = (y*(gui_list->nb_items-nb_lines))/(height-size);
565 gui_synclist_select_item(gui_list, new_selection);
566 nb_lines /= 2;
567 if (new_selection - gui_list->start_item[SCREEN_MAIN] > nb_lines)
568 {
569 new_selection = gui_list->start_item[SCREEN_MAIN]+nb_lines;
570 }
571 gui_list->start_item[SCREEN_MAIN] = new_selection;
572 return ACTION_REDRAW;
573 }
574 }
575 }
576 else
577 {
578 if (button != BUTTON_REL && button != BUTTON_REPEAT)
579 {
580 if (global_settings.statusbar)
581 y -= STATUSBAR_HEIGHT;
582 if (SHOW_LIST_TITLE)
583 y -= display->char_height;
584 line = y / display->char_height;
585 if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN])
586 gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line);
587 return ACTION_REDRAW;
588 }
589 /* title or statusbar is cancel */
590 if (global_settings.statusbar)
591 {
592 if (y < STATUSBAR_HEIGHT && !SHOW_LIST_TITLE )
593 return ACTION_STD_CANCEL;
594 y -= STATUSBAR_HEIGHT;
595 }
596 /* title goes up one level */
597 if (SHOW_LIST_TITLE)
598 {
599 if (y < display->char_height)
600 return ACTION_STD_CANCEL;
601 y -= display->char_height;
602 }
603 /* pressing an item will select it.
604 pressing the selected item will "enter" it */
605 line = y / display->char_height;
606 if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN])
607 {
608 if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items)
609 return ACTION_NONE;
610 gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line);
611 }
612
613 if (button == BUTTON_REPEAT)
614 return ACTION_STD_CONTEXT;
615 else
616 return ACTION_STD_OK;
617 }
618 return ACTION_NONE;
619}
620#endif 534#endif
621 535
622bool gui_synclist_do_button(struct gui_synclist * lists, 536bool gui_synclist_do_button(struct gui_synclist * lists,
@@ -659,7 +573,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists,
659 573
660#if defined(HAVE_TOUCHPAD) 574#if defined(HAVE_TOUCHPAD)
661 if (action == ACTION_TOUCHPAD) 575 if (action == ACTION_TOUCHPAD)
662 action = *actionptr = gui_synclist_do_touchpad(lists); 576 action = *actionptr = gui_synclist_do_touchpad(lists, &parent[SCREEN_MAIN]);
663#endif 577#endif
664 578
665 switch (wrap) 579 switch (wrap)