blob: 94870538d6113c75be9c48eb6d7b2765fd75d946 [file] [log] [blame]
Jonathan Gordon0e5cec22008-03-05 09:58:30 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Jonathan Gordon
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/* This file contains the code to draw the list widget on BITMAP LCDs. */
23
24#include "config.h"
25#include "lcd.h"
26#include "font.h"
27#include "button.h"
28#include "sprintf.h"
29#include "string.h"
30#include "settings.h"
31#include "kernel.h"
32#include "system.h"
Nils Wallménius4f879762009-08-19 21:48:17 +000033#include "file.h"
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000034
35#include "action.h"
36#include "screen_access.h"
37#include "list.h"
38#include "scrollbar.h"
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000039#include "lang.h"
40#include "sound.h"
41#include "misc.h"
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000042#include "viewport.h"
43
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000044#define ICON_PADDING 1
45
Jonathan Gordone385ee12008-12-31 05:59:26 +000046/* these are static to make scrolling work */
47static struct viewport list_text[NB_SCREENS], title_text[NB_SCREENS];
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000048
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000049int gui_list_get_item_offset(struct gui_synclist * gui_list, int item_width,
50 int text_pos, struct screen * display,
51 struct viewport *vp);
Jonathan Gordone385ee12008-12-31 05:59:26 +000052bool list_display_title(struct gui_synclist *list, enum screen_type screen);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000053
54/* Draw the list...
55 internal screen layout:
56 -----------------
57 |TI| title | TI is title icon
58 -----------------
59 | | | |
60 |S|I| | S - scrollbar
61 | | | items | I - icons
62 | | | |
63 ------------------
64*/
Jonathan Gordone385ee12008-12-31 05:59:26 +000065static bool draw_title(struct screen *display, struct gui_synclist *list)
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000066{
Jonathan Gordone385ee12008-12-31 05:59:26 +000067 const int screen = display->screen_type;
Jens Arnold3f69bb22009-03-08 12:42:33 +000068 int style = STYLE_DEFAULT;
Thomas Martitz3c47d942009-09-04 16:34:55 +000069 display->scroll_stop(&title_text[screen]);
Jonathan Gordone385ee12008-12-31 05:59:26 +000070 if (!list_display_title(list, screen))
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000071 return false;
Jonathan Gordone385ee12008-12-31 05:59:26 +000072 title_text[screen] = *(list->parent[screen]);
Thomas Martitz0dd66412009-01-28 18:06:58 +000073 title_text[screen].height = font_get(title_text[screen].font)->height;
74
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000075 if (list->title_icon != Icon_NOICON && global_settings.show_icons)
76 {
Thomas Martitz0dd66412009-01-28 18:06:58 +000077 struct viewport title_icon = title_text[screen];
Jonathan Gordone385ee12008-12-31 05:59:26 +000078 title_icon.width = get_icon_width(screen)
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000079 + ICON_PADDING*2;
Jonathan Gordone385ee12008-12-31 05:59:26 +000080 title_icon.x += ICON_PADDING;
81
Thomas Martitz0dd66412009-01-28 18:06:58 +000082 title_text[screen].width -= title_icon.width;
83 title_text[screen].x += title_icon.width;
Jonathan Gordone385ee12008-12-31 05:59:26 +000084
85 display->set_viewport(&title_icon);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000086 screen_put_icon(display, 0, 0, list->title_icon);
87 }
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000088#ifdef HAVE_LCD_COLOR
89 if (list->title_color >= 0)
90 {
Jens Arnold3f69bb22009-03-08 12:42:33 +000091 style |= (STYLE_COLORED|list->title_color);
Jonathan Gordone385ee12008-12-31 05:59:26 +000092 }
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000093#endif
Jonathan Gordone385ee12008-12-31 05:59:26 +000094 display->set_viewport(&title_text[screen]);
Jens Arnold3f69bb22009-03-08 12:42:33 +000095 display->puts_scroll_style(0, 0, list->title, style);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +000096 return true;
97}
Maurus Cuelenaere07b27082009-08-22 21:46:02 +000098
Jonathan Gordone385ee12008-12-31 05:59:26 +000099void list_draw(struct screen *display, struct gui_synclist *list)
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000100{
Jonathan Gordone385ee12008-12-31 05:59:26 +0000101 struct viewport list_icons;
Jens Arnold3f69bb22009-03-08 12:42:33 +0000102 int start, end, line_height, style, i;
Jonathan Gordone385ee12008-12-31 05:59:26 +0000103 const int screen = display->screen_type;
104 const int icon_width = get_icon_width(screen) + ICON_PADDING;
105 const bool show_cursor = !global_settings.cursor_style &&
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000106 list->show_selection_marker;
Jonathan Gordone385ee12008-12-31 05:59:26 +0000107 struct viewport *parent = (list->parent[screen]);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000108#ifdef HAVE_LCD_COLOR
109 unsigned char cur_line = 0;
110#endif
111 int item_offset;
112 bool show_title;
113 line_height = font_get(parent->font)->height;
114 display->set_viewport(parent);
115 display->clear_viewport();
Thomas Martitz3c47d942009-09-04 16:34:55 +0000116 display->scroll_stop(&list_text[screen]);
Jonathan Gordone385ee12008-12-31 05:59:26 +0000117 list_text[screen] = *parent;
118 if ((show_title = draw_title(display, list)))
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000119 {
Jonathan Gordone385ee12008-12-31 05:59:26 +0000120 list_text[screen].y += line_height;
121 list_text[screen].height -= line_height;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000122 }
Jonathan Gordone385ee12008-12-31 05:59:26 +0000123
124 start = list->start_item[screen];
125 end = start + viewport_get_nb_lines(&list_text[screen]);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000126
127 /* draw the scrollbar if its needed */
128 if (global_settings.scrollbar &&
Jonathan Gordone385ee12008-12-31 05:59:26 +0000129 viewport_get_nb_lines(&list_text[screen]) < list->nb_items)
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000130 {
131 struct viewport vp;
Jonathan Gordone385ee12008-12-31 05:59:26 +0000132 vp = list_text[screen];
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000133 vp.width = SCROLLBAR_WIDTH;
Jonathan Gordone385ee12008-12-31 05:59:26 +0000134 list_text[screen].width -= SCROLLBAR_WIDTH;
Alexander Levin07d0bfd2009-08-19 12:36:40 +0000135 if(global_settings.scrollbar == SCROLLBAR_LEFT)
Maurus Cuelenaeredaaecb92009-08-17 23:36:49 +0000136 list_text[screen].x += SCROLLBAR_WIDTH;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000137 vp.height = line_height *
Jonathan Gordone385ee12008-12-31 05:59:26 +0000138 viewport_get_nb_lines(&list_text[screen]);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000139 vp.x = parent->x;
Alexander Levin23e534d2009-08-19 12:38:16 +0000140 if(global_settings.scrollbar == SCROLLBAR_RIGHT)
Maurus Cuelenaeredaaecb92009-08-17 23:36:49 +0000141 vp.x += list_text[screen].width;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000142 display->set_viewport(&vp);
143 gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1,
144 vp.height, list->nb_items,
Jonathan Gordone385ee12008-12-31 05:59:26 +0000145 list->start_item[screen],
146 list->start_item[screen] + end-start,
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000147 VERTICAL);
148 }
149 else if (show_title)
150 {
151 /* shift everything right a bit... */
Alexander Levin07d0bfd2009-08-19 12:36:40 +0000152 if(global_settings.scrollbar == SCROLLBAR_LEFT)
Maurus Cuelenaeredaaecb92009-08-17 23:36:49 +0000153 {
154 list_text[screen].width -= SCROLLBAR_WIDTH;
155 list_text[screen].x += SCROLLBAR_WIDTH;
156 }
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000157 }
158
159 /* setup icon placement */
Jonathan Gordone385ee12008-12-31 05:59:26 +0000160 list_icons = list_text[screen];
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000161 int icon_count = global_settings.show_icons &&
162 (list->callback_get_item_icon != NULL) ? 1 : 0;
163 if (show_cursor)
164 icon_count++;
165 if (icon_count)
166 {
Jonathan Gordone385ee12008-12-31 05:59:26 +0000167 list_icons.width = icon_width * icon_count;
168 list_text[screen].width -=
169 list_icons.width + ICON_PADDING;
170 list_text[screen].x +=
171 list_icons.width + ICON_PADDING;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000172 }
173
174 for (i=start; i<end && i<list->nb_items; i++)
175 {
176 /* do the text */
Nils Wallménius3200d042009-08-20 16:47:44 +0000177 unsigned const char *s;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000178 char entry_buffer[MAX_PATH];
179 unsigned char *entry_name;
180 int text_pos = 0;
Nils Wallménius68489612008-04-09 15:25:17 +0000181 s = list->callback_get_item_name(i, list->data, entry_buffer,
182 sizeof(entry_buffer));
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000183 entry_name = P2STR(s);
Jonathan Gordone385ee12008-12-31 05:59:26 +0000184 display->set_viewport(&list_text[screen]);
Jens Arnold3f69bb22009-03-08 12:42:33 +0000185 style = STYLE_DEFAULT;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000186 /* position the string at the correct offset place */
187 int item_width,h;
188 display->getstringsize(entry_name, &item_width, &h);
189 item_offset = gui_list_get_item_offset(list, item_width,
190 text_pos, display,
Jonathan Gordone385ee12008-12-31 05:59:26 +0000191 &list_text[screen]);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000192
193#ifdef HAVE_LCD_COLOR
194 /* if the list has a color callback */
195 if (list->callback_get_item_color)
196 {
197 int color = list->callback_get_item_color(i, list->data);
198 /* if color selected */
199 if (color >= 0)
200 {
Jens Arnold3f69bb22009-03-08 12:42:33 +0000201 style |= STYLE_COLORED|color;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000202 }
203 }
204#endif
Jonathan Gordone385ee12008-12-31 05:59:26 +0000205 if(i >= list->selected_item && i < list->selected_item
206 + list->selected_size && list->show_selection_marker)
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000207 {/* The selected item must be displayed scrolling */
Jonathan Gordon34196ed2008-04-03 04:41:42 +0000208 if (global_settings.cursor_style == 1
209#ifdef HAVE_REMOTE_LCD
Jonathan Gordone385ee12008-12-31 05:59:26 +0000210 /* the global_settings.cursor_style check is here to make
211 * sure if they want the cursor instead of bar it will work
212 */
Jonathan Gordon34196ed2008-04-03 04:41:42 +0000213 || (display->depth < 16 && global_settings.cursor_style)
214#endif
215 )
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000216 {
217 /* Display inverted-line-style */
Jens Arnold3f69bb22009-03-08 12:42:33 +0000218 style = STYLE_INVERT;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000219 }
220#ifdef HAVE_LCD_COLOR
221 else if (global_settings.cursor_style == 2)
222 {
223 /* Display colour line selector */
Jens Arnold3f69bb22009-03-08 12:42:33 +0000224 style = STYLE_COLORBAR;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000225 }
226 else if (global_settings.cursor_style == 3)
227 {
228 /* Display gradient line selector */
Jens Arnold3f69bb22009-03-08 12:42:33 +0000229 style = STYLE_GRADIENT;
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000230
231 /* Make the lcd driver know how many lines the gradient should
232 cover and current line number */
233 /* number of selected lines */
Jens Arnold3f69bb22009-03-08 12:42:33 +0000234 style |= NUMLN_PACK(list->selected_size);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000235 /* current line number, zero based */
Jens Arnold3f69bb22009-03-08 12:42:33 +0000236 style |= CURLN_PACK(cur_line);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000237 cur_line++;
238 }
239#endif
240 /* if the text is smaller than the viewport size */
Jonathan Gordone385ee12008-12-31 05:59:26 +0000241 if (item_offset> item_width
242 - (list_text[screen].width - text_pos))
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000243 {
244 /* don't scroll */
245 display->puts_style_offset(0, i-start, entry_name,
Jens Arnold3f69bb22009-03-08 12:42:33 +0000246 style, item_offset);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000247 }
248 else
249 {
250 display->puts_scroll_style_offset(0, i-start, entry_name,
Jens Arnold3f69bb22009-03-08 12:42:33 +0000251 style, item_offset);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000252 }
253 }
254 else
Jonathan Gordon311d0482008-07-05 12:31:04 +0000255 {
256 if (list->scroll_all)
257 display->puts_scroll_style_offset(0, i-start, entry_name,
Jens Arnold3f69bb22009-03-08 12:42:33 +0000258 style, item_offset);
Jonathan Gordon311d0482008-07-05 12:31:04 +0000259 else
260 display->puts_style_offset(0, i-start, entry_name,
Jens Arnold3f69bb22009-03-08 12:42:33 +0000261 style, item_offset);
Jonathan Gordon311d0482008-07-05 12:31:04 +0000262 }
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000263 /* do the icon */
264 if (list->callback_get_item_icon && global_settings.show_icons)
265 {
Jonathan Gordone385ee12008-12-31 05:59:26 +0000266 display->set_viewport(&list_icons);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000267 screen_put_icon_with_offset(display, show_cursor?1:0,
Jonathan Gordone385ee12008-12-31 05:59:26 +0000268 (i-start),show_cursor?ICON_PADDING:0,0,
269 list->callback_get_item_icon(i, list->data));
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000270 if (show_cursor && i >= list->selected_item &&
271 i < list->selected_item + list->selected_size)
272 {
273 screen_put_icon(display, 0, i-start, Icon_Cursor);
274 }
275 }
276 else if (show_cursor && i >= list->selected_item &&
277 i < list->selected_item + list->selected_size)
278 {
Jonathan Gordone385ee12008-12-31 05:59:26 +0000279 display->set_viewport(&list_icons);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000280 screen_put_icon(display, 0, (i-start), Icon_Cursor);
281 }
282 }
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000283 display->set_viewport(parent);
284 display->update_viewport();
Jonathan Gordonf9329e42009-01-07 07:52:32 +0000285 display->set_viewport(NULL);
Jonathan Gordon0e5cec22008-03-05 09:58:30 +0000286}
287
Maurus Cuelenaere1392dc22008-08-23 09:46:38 +0000288#if defined(HAVE_TOUCHSCREEN)
Maurus Cuelenaere94419e92009-08-22 23:35:27 +0000289/* This needs to be fixed if we ever get more than 1 touchscreen on a target. */
Maurus Cuelenaere75cac2c2008-06-02 18:59:32 +0000290static bool scrolling=false;
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000291
Maurus Cuelenaeredaaecb92009-08-17 23:36:49 +0000292static int gui_synclist_touchscreen_scrollbar(struct gui_synclist * gui_list,
293 int y)
294{
295 int screen = screens[SCREEN_MAIN].screen_type;
296 int nb_lines = viewport_get_nb_lines(&list_text[screen]);
297 if (nb_lines < gui_list->nb_items)
298 {
Maurus Cuelenaere07b27082009-08-22 21:46:02 +0000299 scrolling = true;
300
Maurus Cuelenaeredaaecb92009-08-17 23:36:49 +0000301 int scrollbar_size = nb_lines*
302 font_get(gui_list->parent[screen]->font)->height;
303 int actual_y = y - list_text[screen].y;
304
305 int new_selection = (actual_y * gui_list->nb_items)
306 / scrollbar_size;
307
308 int start_item = new_selection - nb_lines/2;
309 if(start_item < 0)
310 start_item = 0;
311 else if(start_item > gui_list->nb_items - nb_lines)
312 start_item = gui_list->nb_items - nb_lines;
313
314 gui_list->start_item[screen] = start_item;
315 gui_synclist_select_item(gui_list, new_selection);
316
317 return ACTION_REDRAW;
318 }
319
320 return ACTION_NONE;
321}
322
Jonathan Gordone385ee12008-12-31 05:59:26 +0000323unsigned gui_synclist_do_touchscreen(struct gui_synclist * gui_list)
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000324{
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000325 short x, y;
Jonathan Gordone385ee12008-12-31 05:59:26 +0000326 int button = action_get_touchscreen_press(&x, &y);
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000327 int line;
328 struct screen *display = &screens[SCREEN_MAIN];
Jonathan Gordon79b3e872008-12-31 06:11:23 +0000329 int screen = display->screen_type;
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000330 if (button == BUTTON_NONE)
331 return ACTION_NONE;
Jonathan Gordon79b3e872008-12-31 06:11:23 +0000332 if (x<list_text[screen].x)
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000333 {
Maurus Cuelenaere39be5ff2009-02-12 15:58:55 +0000334 /* Top left corner is GO_TO_ROOT */
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000335 if (y<list_text[SCREEN_MAIN].y)
336 {
337 if (button == BUTTON_REL)
338 return ACTION_STD_MENU;
Maurus Cuelenaere5dca53e2008-06-01 13:56:34 +0000339 else if (button == (BUTTON_REPEAT|BUTTON_REL))
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000340 return ACTION_STD_CONTEXT;
341 else
342 return ACTION_NONE;
343 }
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000344 /* Scroll bar */
Alexander Levin07d0bfd2009-08-19 12:36:40 +0000345 else if(global_settings.scrollbar == SCROLLBAR_LEFT)
Maurus Cuelenaeredaaecb92009-08-17 23:36:49 +0000346 return gui_synclist_touchscreen_scrollbar(gui_list, y);
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000347 }
348 else
349 {
Maurus Cuelenaeredaaecb92009-08-17 23:36:49 +0000350 if(x>list_text[screen].x+list_text[screen].width &&
Alexander Levin07d0bfd2009-08-19 12:36:40 +0000351 global_settings.scrollbar == SCROLLBAR_RIGHT)
Maurus Cuelenaeredaaecb92009-08-17 23:36:49 +0000352 return gui_synclist_touchscreen_scrollbar(gui_list, y);
353
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000354 /* |--------------------------------------------------------|
355 * | Description of the touchscreen list interface: |
356 * |--------------------------------------------------------|
357 * | Pressing an item will select it and "enter" it. |
358 * | |
359 * | Pressing and holding your pen down will scroll through |
Maurus Cuelenaere75cac2c2008-06-02 18:59:32 +0000360 * | the list of items. |
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000361 * | |
362 * | Pressing and holding your pen down on a single item |
363 * | will bring up the context menu of it. |
364 * |--------------------------------------------------------|
365 */
Maurus Cuelenaere39be5ff2009-02-12 15:58:55 +0000366 if (y > list_text[screen].y || button & BUTTON_REPEAT)
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000367 {
Maurus Cuelenaere4bbdc5c2008-06-06 18:44:59 +0000368 int line_height, actual_y;
Maurus Cuelenaeree1753de2008-06-06 18:29:46 +0000369
Maurus Cuelenaere21ca8662009-02-19 16:16:22 +0000370 actual_y = y - list_text[screen].y;
Jonathan Gordone385ee12008-12-31 05:59:26 +0000371 line_height = font_get(gui_list->parent[screen]->font)->height;
Maurus Cuelenaeree1753de2008-06-06 18:29:46 +0000372 line = actual_y / line_height;
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000373
Maurus Cuelenaere21ca8662009-02-19 16:16:22 +0000374 /* Pressed below the list*/
375 if (gui_list->start_item[screen]+line >= gui_list->nb_items)
Maurus Cuelenaere944219b2008-05-30 22:55:24 +0000376 return ACTION_NONE;
Maurus Cuelenaere21ca8662009-02-19 16:16:22 +0000377
378 /* Pressed a border */
379 if(UNLIKELY(actual_y % line_height == 0))
Maurus Cuelenaere3d240f12008-06-28 20:11:51 +0000380 return ACTION_NONE;
Maurus Cuelenaere21ca8662009-02-19 16:16:22 +0000381
382 if (line != (gui_list->selected_item - gui_list->start_item[screen])
383 && button ^ BUTTON_REL)
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000384 {
Maurus Cuelenaere75cac2c2008-06-02 18:59:32 +0000385 if(button & BUTTON_REPEAT)
386 scrolling = true;
Maurus Cuelenaere21ca8662009-02-19 16:16:22 +0000387
Jonathan Gordone385ee12008-12-31 05:59:26 +0000388 gui_synclist_select_item(gui_list, gui_list->start_item[screen]
Maurus Cuelenaere21ca8662009-02-19 16:16:22 +0000389 + line);
390
Maurus Cuelenaere944219b2008-05-30 22:55:24 +0000391 return ACTION_REDRAW;
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000392 }
Maurus Cuelenaere944219b2008-05-30 22:55:24 +0000393
Maurus Cuelenaere4ce82b92009-08-22 22:48:03 +0000394 /* This has the same effect as the icons do when the scrollbar
395 is on the left (ie eliminate the chances an user enters/starts
396 an item when he wanted to use the scrollbar, due to touchscreen
397 dead zones)
398 */
399 if(global_settings.scrollbar == SCROLLBAR_RIGHT &&
400 x > list_text[screen].x + list_text[screen].width -
Maurus Cuelenaere94419e92009-08-22 23:35:27 +0000401 get_icon_width(SCREEN_MAIN))
Maurus Cuelenaere4ce82b92009-08-22 22:48:03 +0000402 return ACTION_NONE;
403
Maurus Cuelenaere5dca53e2008-06-01 13:56:34 +0000404 if (button == (BUTTON_REPEAT|BUTTON_REL))
Maurus Cuelenaere944219b2008-05-30 22:55:24 +0000405 {
Maurus Cuelenaere75cac2c2008-06-02 18:59:32 +0000406 if(!scrolling)
Maurus Cuelenaere944219b2008-05-30 22:55:24 +0000407 {
Jonathan Gordone385ee12008-12-31 05:59:26 +0000408 /* Pen was hold on the same line as the
409 * previously selected one
410 * => simulate long button press
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000411 */
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000412 return ACTION_STD_CONTEXT;
Maurus Cuelenaere944219b2008-05-30 22:55:24 +0000413 }
414 else
415 {
Jonathan Gordone385ee12008-12-31 05:59:26 +0000416 /* Pen was moved across several lines and then released on
417 * this one
418 * => do nothing
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000419 */
Maurus Cuelenaere75cac2c2008-06-02 18:59:32 +0000420 scrolling = false;
421 return ACTION_NONE;
Maurus Cuelenaere944219b2008-05-30 22:55:24 +0000422 }
423 }
Maurus Cuelenaere21ca8662009-02-19 16:16:22 +0000424 else if(button == BUTTON_REL &&
425 line == gui_list->selected_item - gui_list->start_item[screen])
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000426 {
Jonathan Gordone385ee12008-12-31 05:59:26 +0000427 /* Pen was released on either the same line as the previously
428 * selected one or an other one
Maurus Cuelenaerecad30d32008-06-02 16:08:01 +0000429 * => simulate short press
430 */
431 return ACTION_STD_OK;
432 }
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000433 else
Maurus Cuelenaere944219b2008-05-30 22:55:24 +0000434 return ACTION_NONE;
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000435 }
Maurus Cuelenaere21ca8662009-02-19 16:16:22 +0000436 /* Everything above the items is cancel */
437 else if (y < list_text[screen].y && button == BUTTON_REL)
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000438 return ACTION_STD_CANCEL;
Jonathan Gordonf444f1e2008-03-05 10:38:10 +0000439 }
440 return ACTION_NONE;
441}
442#endif