diff options
| author | Jonathan Gordon <rockbox@jdgordon.info> | 2008-03-05 10:38:10 +0000 |
|---|---|---|
| committer | Jonathan Gordon <rockbox@jdgordon.info> | 2008-03-05 10:38:10 +0000 |
| commit | f444f1ecbe3d79a4c6b7b88a114e61da97f41bc7 (patch) | |
| tree | b557e0de1a9ba7f619c855a53eb5c6e2c6941d66 /apps | |
| parent | 0e5cec2d187dbded9b3c36dbcfd1469d00fe47af (diff) | |
| download | rockbox-f444f1ecbe3d79a4c6b7b88a114e61da97f41bc7.zip rockbox-f444f1ecbe3d79a4c6b7b88a114e61da97f41bc7.tar.gz rockbox-f444f1ecbe3d79a4c6b7b88a114e61da97f41bc7.tar.bz2 rockbox-f444f1ecbe3d79a4c6b7b88a114e61da97f41bc7.tar.xz | |
fix the touchpad list code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16528 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/gui/bitmap/list.c | 85 | ||||
| -rw-r--r-- | apps/gui/list.c | 90 |
2 files changed, 87 insertions, 88 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index 63f24dd..4bffca8 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, } +#if defined(HAVE_TOUCHPAD) +/* this needs to be fixed if we ever get more than 1 touchscreen on a target */ +/* this also assumes the whole screen is used, which is a bad asusmption but + fine untill customizable lists comes in... */ +unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewport *parent) +{ + short x,y; + unsigned button = action_get_touchpad_press(&x, &y); + int line; + struct screen *display = &screens[SCREEN_MAIN]; + if (button == BUTTON_NONE) + return ACTION_NONE; + if (x<list_text[SCREEN_MAIN].x) + { + /* top left corner is hopefully GO_TO_ROOT */ + if (y<list_text[SCREEN_MAIN].y) + { + if (button == BUTTON_REL) + return ACTION_STD_MENU; + else if (button == BUTTON_REPEAT) + return ACTION_STD_CONTEXT; + else + return ACTION_NONE; + } + /* scroll bar */ + else + { + int new_selection, nb_lines; + int height, size; + nb_lines = viewport_get_nb_lines(&list_text[SCREEN_MAIN]); + if (nb_lines < gui_list->nb_items) + { + height = nb_lines * display->char_height; + size = height*nb_lines / gui_list->nb_items; + new_selection = ((y-list_text[SCREEN_MAIN].y)*(gui_list->nb_items-nb_lines))/(height-size); + gui_synclist_select_item(gui_list, new_selection); + nb_lines /= 2; + if (new_selection - gui_list->start_item[SCREEN_MAIN] > nb_lines) + { + new_selection = gui_list->start_item[SCREEN_MAIN]+nb_lines; + } + gui_list->start_item[SCREEN_MAIN] = new_selection; + return ACTION_REDRAW; + } + } + } + else + { + /* pressing an item will select it. + pressing the selected item will "enter" it */ + if (y > list_text[SCREEN_MAIN].y) + { + line = (y-list_text[SCREEN_MAIN].y) / display->char_height; + if (button != BUTTON_REL && button != BUTTON_REPEAT) + { + if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN]) + gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); + return ACTION_REDRAW; + } + if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN]) + { + if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) + return ACTION_NONE; + gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); + } + + if (button == BUTTON_REPEAT) + return ACTION_STD_CONTEXT; + else + return ACTION_STD_OK; + } + /* title goes up one level */ + else if (y > title_text[SCREEN_MAIN].y && draw_title(display, parent, gui_list)) + { + return ACTION_STD_CANCEL; + } + /* title or statusbar is cancel */ + else if (global_settings.statusbar) + { + return ACTION_STD_CANCEL; + } + } + return ACTION_NONE; +} +#endif diff --git a/apps/gui/list.c b/apps/gui/list.c index fbc417e..9aafece 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -528,95 +528,9 @@ void gui_synclist_speak_item(struct gui_synclist * lists) } extern intptr_t get_action_data(void); - #if defined(HAVE_TOUCHPAD) /* this needs to be fixed if we ever get more than 1 touchscreen on a target */ -unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list) -{ - short x,y; - unsigned button = action_get_touchpad_press(&x, &y); - int line; - struct screen *display = &screens[SCREEN_MAIN]; - if (button == BUTTON_NONE) - return ACTION_NONE; - if (x<SCROLLBAR_WIDTH) - { - /* top left corner is hopefully GO_TO_ROOT */ - if (y<STATUSBAR_HEIGHT) - { - if (button == BUTTON_REL) - return ACTION_STD_MENU; - else if (button == BUTTON_REPEAT) - return ACTION_STD_CONTEXT; - else - return ACTION_NONE; - } - /* scroll bar */ - else - { - int new_selection, nb_lines; - int height, size; - nb_lines = display->nb_lines - SHOW_LIST_TITLE; - if (nb_lines < gui_list->nb_items) - { - height = nb_lines * display->char_height; - size = height*nb_lines / gui_list->nb_items; - new_selection = (y*(gui_list->nb_items-nb_lines))/(height-size); - gui_synclist_select_item(gui_list, new_selection); - nb_lines /= 2; - if (new_selection - gui_list->start_item[SCREEN_MAIN] > nb_lines) - { - new_selection = gui_list->start_item[SCREEN_MAIN]+nb_lines; - } - gui_list->start_item[SCREEN_MAIN] = new_selection; - return ACTION_REDRAW; - } - } - } - else - { - if (button != BUTTON_REL && button != BUTTON_REPEAT) - { - if (global_settings.statusbar) - y -= STATUSBAR_HEIGHT; - if (SHOW_LIST_TITLE) - y -= display->char_height; - line = y / display->char_height; - if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN]) - gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); - return ACTION_REDRAW; - } - /* title or statusbar is cancel */ - if (global_settings.statusbar) - { - if (y < STATUSBAR_HEIGHT && !SHOW_LIST_TITLE ) - return ACTION_STD_CANCEL; - y -= STATUSBAR_HEIGHT; - } - /* title goes up one level */ - if (SHOW_LIST_TITLE) - { - if (y < display->char_height) - return ACTION_STD_CANCEL; - y -= display->char_height; - } - /* pressing an item will select it. - pressing the selected item will "enter" it */ - line = y / display->char_height; - if (line != gui_list->selected_item - gui_list->start_item[SCREEN_MAIN]) - { - if (gui_list->start_item[SCREEN_MAIN]+line > gui_list->nb_items) - return ACTION_NONE; - gui_synclist_select_item(gui_list, gui_list->start_item[SCREEN_MAIN]+line); - } - - if (button == BUTTON_REPEAT) - return ACTION_STD_CONTEXT; - else - return ACTION_STD_OK; - } - return ACTION_NONE; -} +unsigned gui_synclist_do_touchpad(struct gui_synclist * gui_list, struct viewport *parent); #endif bool gui_synclist_do_button(struct gui_synclist * lists, @@ -659,7 +573,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, #if defined(HAVE_TOUCHPAD) if (action == ACTION_TOUCHPAD) - action = *actionptr = gui_synclist_do_touchpad(lists); + action = *actionptr = gui_synclist_do_touchpad(lists, &parent[SCREEN_MAIN]); #endif switch (wrap) |