summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2012-06-13 23:07:49 +0200
committerFrank Gevaerts <frank@gevaerts.be>2012-06-19 22:02:59 +0200
commit715111122837440d3a1463d0d6932c469418dcbb (patch)
treedeb2c8485c4f0aed36659b26f80313b8a8fbb507
parent1a665aab1e1e32e7355bc390fe4b09ff26d59082 (diff)
downloadrockbox-715111122837440d3a1463d0d6932c469418dcbb.tar.gz
rockbox-715111122837440d3a1463d0d6932c469418dcbb.zip
Make touchscreen handling work with skinned lists.
Change-Id: I7df93319c8f16f05e840d74b022aab4803bb8f80
-rw-r--r--apps/gui/bitmap/list-skinned.c14
-rw-r--r--apps/gui/bitmap/list.c15
-rw-r--r--apps/gui/list.h2
3 files changed, 26 insertions, 5 deletions
diff --git a/apps/gui/bitmap/list-skinned.c b/apps/gui/bitmap/list-skinned.c
index 81ef6fc18f..d0803b5dc8 100644
--- a/apps/gui/bitmap/list-skinned.c
+++ b/apps/gui/bitmap/list-skinned.c
@@ -167,6 +167,20 @@ void skinlist_get_scrollbar(int* nb_item, int* first_shown, int* last_shown)
167 } 167 }
168} 168}
169 169
170bool skinlist_get_item(struct screen *display, struct gui_synclist *list, int x, int y, int *item)
171{
172 const int screen = display->screen_type;
173 if (!skinlist_is_configured(screen, list))
174 return false;
175
176 int row = y / listcfg[screen]->height;
177 int column = x / listcfg[screen]->width;
178 struct viewport *parent = (list->parent[screen]);
179 int cols = (parent->width / listcfg[screen]->width);
180 *item = row * cols+ column;
181 return true;
182}
183
170bool skinlist_draw(struct screen *display, struct gui_synclist *list) 184bool skinlist_draw(struct screen *display, struct gui_synclist *list)
171{ 185{
172 int cur_line, display_lines; 186 int cur_line, display_lines;
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 3a45a8124c..aad3eda98f 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -704,7 +704,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
704 enum screen_type screen; 704 enum screen_type screen;
705 struct viewport *parent; 705 struct viewport *parent;
706 short x, y; 706 short x, y;
707 int action, adj_y, line, line_height, list_start_item; 707 int action, adj_x, adj_y, line, line_height, list_start_item;
708 bool recurse; 708 bool recurse;
709 static int last_y = -1; 709 static int last_y = -1;
710 710
@@ -714,6 +714,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
714 list_start_item = list->start_item[screen]; 714 list_start_item = list->start_item[screen];
715 /* start with getting the action code and finding the click location */ 715 /* start with getting the action code and finding the click location */
716 action = action_get_touchscreen_press(&x, &y); 716 action = action_get_touchscreen_press(&x, &y);
717 adj_x = x - parent->x;
717 adj_y = y - parent->y; 718 adj_y = y - parent->y;
718 719
719 720
@@ -736,13 +737,17 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
736 line = 0; /* silence gcc 'used uninitialized' warning */ 737 line = 0; /* silence gcc 'used uninitialized' warning */
737 if (click_loc & LIST) 738 if (click_loc & LIST)
738 { 739 {
739 /* selection needs to be corrected if items are only partially visible */ 740 if(!skinlist_get_item(&screens[screen], list, adj_x, adj_y, &line))
740 line = (adj_y - y_offset) / line_height; 741 {
741 if (list_display_title(list, screen)) 742 /* selection needs to be corrected if items are only partially visible */
742 line -= 1; /* adjust for the list title */ 743 line = (adj_y - y_offset) / line_height;
744 if (list_display_title(list, screen))
745 line -= 1; /* adjust for the list title */
746 }
743 if (line >= list->nb_items) 747 if (line >= list->nb_items)
744 return ACTION_NONE; 748 return ACTION_NONE;
745 list->selected_item = list_start_item+line; 749 list->selected_item = list_start_item+line;
750
746 gui_synclist_speak_item(list); 751 gui_synclist_speak_item(list);
747 } 752 }
748 if (action == BUTTON_TOUCHSCREEN) 753 if (action == BUTTON_TOUCHSCREEN)
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 647b4ea20e..162bb38e1a 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -188,6 +188,8 @@ struct listitem_viewport_cfg {
188 bool tile; 188 bool tile;
189 struct skin_viewport selected_item_vp; 189 struct skin_viewport selected_item_vp;
190}; 190};
191
192bool skinlist_get_item(struct screen *display, struct gui_synclist *list, int x, int y, int *item);
191bool skinlist_draw(struct screen *display, struct gui_synclist *list); 193bool skinlist_draw(struct screen *display, struct gui_synclist *list);
192bool skinlist_is_selected_item(void); 194bool skinlist_is_selected_item(void);
193void skinlist_set_cfg(enum screen_type screen, 195void skinlist_set_cfg(enum screen_type screen,