summaryrefslogtreecommitdiff
path: root/apps/gui/bitmap/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/bitmap/list.c')
-rw-r--r--apps/gui/bitmap/list.c85
1 files changed, 85 insertions, 0 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