summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorTomas Salfischberger <tomas@rockbox.org>2006-01-22 01:42:05 +0000
committerTomas Salfischberger <tomas@rockbox.org>2006-01-22 01:42:05 +0000
commit7fa39df4277fba4b567a57c79a8933afc96d9339 (patch)
tree89b5fcf1e0f6f80828e5ebe41531151b88de4b75 /apps/gui
parentee6a95a7d188e4d53f43e35713f0e1c9efe34236 (diff)
downloadrockbox-7fa39df4277fba4b567a57c79a8933afc96d9339.tar.gz
rockbox-7fa39df4277fba4b567a57c79a8933afc96d9339.zip
Horizontal scrolling patch by Shachar Liberman
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8412 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/list.c127
-rw-r--r--apps/gui/list.h37
2 files changed, 156 insertions, 8 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 83a1fbfb22..2ae5f995f4 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -37,7 +37,8 @@
37#define SCROLL_LIMIT 2 37#define SCROLL_LIMIT 2
38#endif 38#endif
39 39
40 40static int offset_step = 15;
41static bool offset_outof_view = false;
41 42
42void gui_list_init(struct gui_list * gui_list, 43void gui_list_init(struct gui_list * gui_list,
43 list_get_name callback_get_item_name, 44 list_get_name callback_get_item_name,
@@ -53,6 +54,7 @@ void gui_list_init(struct gui_list * gui_list,
53 gui_list->limit_scroll = false; 54 gui_list->limit_scroll = false;
54 gui_list->data=data; 55 gui_list->data=data;
55 gui_list->cursor_flash_state=false; 56 gui_list->cursor_flash_state=false;
57 gui_list->offsetval = 0;
56} 58}
57 59
58void gui_list_set_display(struct gui_list * gui_list, struct screen * display) 60void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
@@ -179,14 +181,47 @@ void gui_list_draw(struct gui_list * gui_list)
179 entry_name = gui_list->callback_get_item_name(current_item, 181 entry_name = gui_list->callback_get_item_name(current_item,
180 gui_list->data, 182 gui_list->data,
181 entry_buffer); 183 entry_buffer);
182 if(current_item == gui_list->selected_item) 184
183 {
184 /* The selected item must be displayed scrolling */
185#ifdef HAVE_LCD_BITMAP 185#ifdef HAVE_LCD_BITMAP
186 if (global_settings.invert_cursor)/* Display inverted-line-style*/ 186 /* position the string at the right offset place */
187 display->puts_scroll_style(0, i, entry_name, STYLE_INVERT); 187 int item_offset;
188 int str_width,h;
189 display->getstringsize(entry_name, &str_width, &h);
190
191 if (offset_outof_view)
192 item_offset = gui_list->offsetval;
193 else
194 /* if text is smaller then view */
195 if (str_width <= display->width - text_pos)
196 item_offset = 0;
197 else
198 /* if text got out of view */
199 if (gui_list->offsetval > str_width - (display->width - text_pos))
200 item_offset = str_width - (display->width - text_pos);
188 else 201 else
189 display->puts_scroll(0, i, entry_name); 202 item_offset = gui_list->offsetval;
203
204#endif
205
206 if(current_item == gui_list->selected_item) {
207 /* The selected item must be displayed scrolling */
208#ifdef HAVE_LCD_BITMAP
209 if (global_settings.invert_cursor) /* Display inverted-line-style*/
210
211 /* if text got out of view */
212 if (item_offset > str_width - (display->width - text_pos))
213 /* don't scroll */
214 display->puts_style_offset(0, i, entry_name, STYLE_INVERT,item_offset);
215 else
216 display->puts_scroll_style_offset(0, i, entry_name, STYLE_INVERT,item_offset);
217
218 else /* if (global_settings.invert_cursor) */
219
220 if (item_offset > str_width - (display->width - text_pos))
221 display->puts_offset(0, i, entry_name,item_offset);
222 else
223 display->puts_scroll_offset(0, i, entry_name,item_offset);
224
190#else 225#else
191 display->puts_scroll(text_pos, i, entry_name); 226 display->puts_scroll(text_pos, i, entry_name);
192#endif 227#endif
@@ -197,7 +232,7 @@ void gui_list_draw(struct gui_list * gui_list)
197 else 232 else
198 {/* normal item */ 233 {/* normal item */
199#ifdef HAVE_LCD_BITMAP 234#ifdef HAVE_LCD_BITMAP
200 display->puts(0, i, entry_name); 235 display->puts_offset(0, i, entry_name,item_offset);
201#else 236#else
202 display->puts(text_pos, i, entry_name); 237 display->puts(text_pos, i, entry_name);
203#endif 238#endif
@@ -229,6 +264,40 @@ void gui_list_draw(struct gui_list * gui_list)
229 gui_textarea_update(display); 264 gui_textarea_update(display);
230} 265}
231 266
267#ifdef HAVE_LCD_BITMAP
268void gui_list_screen_scroll_step(int ofs)
269{
270 offset_step = ofs;
271}
272
273void gui_list_screen_scroll_out_of_view(bool enable)
274{
275 if (enable)
276 offset_outof_view = true;
277 else
278 offset_outof_view = false;
279}
280
281void gui_list_offset_right(struct gui_list * gui_list)
282{
283 /* there should be a callback to find out what's the longest item on the list,
284 * and then, by finding out the width with get_stringsize, we would stop the
285 * list from scrolling at that point */
286
287 gui_list->offsetval+=offset_step;
288 if (gui_list->offsetval > 1000)
289 gui_list->offsetval = 1000;
290}
291
292void gui_list_offset_left(struct gui_list * gui_list)
293{
294 gui_list->offsetval-=offset_step;
295 if (gui_list->offsetval < 0)
296 gui_list->offsetval = 0;
297
298}
299#endif /* HAVE_LCD_BITMAP */
300
232void gui_list_select_item(struct gui_list * gui_list, int item_number) 301void gui_list_select_item(struct gui_list * gui_list, int item_number)
233{ 302{
234 if( item_number > gui_list->nb_items-1 || item_number < 0 ) 303 if( item_number > gui_list->nb_items-1 || item_number < 0 )
@@ -384,6 +453,7 @@ void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
384 FOR_NB_SCREENS(i) 453 FOR_NB_SCREENS(i)
385 { 454 {
386 gui_list_set_nb_items(&(lists->gui_list[i]), nb_items); 455 gui_list_set_nb_items(&(lists->gui_list[i]), nb_items);
456 lists->gui_list[i].offsetval = 0;
387 } 457 }
388} 458}
389void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback) 459void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback)
@@ -432,6 +502,22 @@ void gui_synclist_select_next_page(struct gui_synclist * lists,
432 screens[screen].nb_lines); 502 screens[screen].nb_lines);
433} 503}
434 504
505#ifdef HAVE_LCD_BITMAP
506void gui_synclist_offset_right(struct gui_synclist * lists)
507{
508 int i;
509 FOR_NB_SCREENS(i)
510 gui_list_offset_right(&(lists->gui_list[i]));
511}
512
513void gui_synclist_offset_left(struct gui_synclist * lists)
514{
515 int i;
516 FOR_NB_SCREENS(i)
517 gui_list_offset_left(&(lists->gui_list[i]));
518}
519#endif /* HAVE_LCD_BITMAP */
520
435void gui_synclist_select_previous_page(struct gui_synclist * lists, 521void gui_synclist_select_previous_page(struct gui_synclist * lists,
436 enum screen_type screen) 522 enum screen_type screen)
437{ 523{
@@ -502,6 +588,31 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
502 gui_synclist_select_next(lists); 588 gui_synclist_select_next(lists);
503 gui_synclist_draw(lists); 589 gui_synclist_draw(lists);
504 return LIST_NEXT; 590 return LIST_NEXT;
591
592#ifdef LIST_PGRIGHT
593 case LIST_PGRIGHT:
594 case LIST_PGRIGHT | BUTTON_REPEAT:
595#ifdef LIST_RC_PGRIGHT
596 case LIST_RC_PGRIGHT:
597 case LIST_RC_PGRIGHT | BUTTON_REPEAT:
598#endif
599 gui_synclist_offset_right(lists);
600 gui_synclist_draw(lists);
601 return true;
602#endif
603
604#ifdef LIST_PGLEFT
605 case LIST_PGLEFT:
606 case LIST_PGLEFT | BUTTON_REPEAT:
607#ifdef LIST_RC_PGLEFT
608 case LIST_RC_PGLEFT:
609 case LIST_RC_PGLEFT | BUTTON_REPEAT:
610#endif
611 gui_synclist_offset_left(lists);
612 gui_synclist_draw(lists);
613 return true;
614#endif
615
505/* for pgup / pgdown, we are obliged to have a different behaviour depending on the screen 616/* for pgup / pgdown, we are obliged to have a different behaviour depending on the screen
506 * for which the user pressed the key since for example, remote and main screen doesn't 617 * for which the user pressed the key since for example, remote and main screen doesn't
507 * have the same number of lines*/ 618 * have the same number of lines*/
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 25fb07d7c4..e177f5ef75 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -33,12 +33,16 @@
33#define LIST_PREV BUTTON_UP 33#define LIST_PREV BUTTON_UP
34#define LIST_PGUP (BUTTON_ON | BUTTON_UP) 34#define LIST_PGUP (BUTTON_ON | BUTTON_UP)
35#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN) 35#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN)
36#define LIST_PGRIGHT (BUTTON_ON | BUTTON_RIGHT)
37#define LIST_PGLEFT (BUTTON_ON | BUTTON_LEFT)
36 38
37#ifdef CONFIG_REMOTE_KEYPAD 39#ifdef CONFIG_REMOTE_KEYPAD
38#define LIST_RC_NEXT BUTTON_RC_FF 40#define LIST_RC_NEXT BUTTON_RC_FF
39#define LIST_RC_PREV BUTTON_RC_REW 41#define LIST_RC_PREV BUTTON_RC_REW
40#define LIST_RC_PGUP BUTTON_RC_SOURCE 42#define LIST_RC_PGUP BUTTON_RC_SOURCE
41#define LIST_RC_PGDN BUTTON_RC_BITRATE 43#define LIST_RC_PGDN BUTTON_RC_BITRATE
44#define LIST_RC_PGRIGHT (BUTTON_RC_VOL_UP)
45#define LIST_RC_PGLEFT (BUTTON_RC_VOL_DOWN)
42#endif /* CONFIG_REMOTE_KEYPAD */ 46#endif /* CONFIG_REMOTE_KEYPAD */
43 47
44#elif CONFIG_KEYPAD == RECORDER_PAD 48#elif CONFIG_KEYPAD == RECORDER_PAD
@@ -46,6 +50,8 @@
46#define LIST_PREV BUTTON_UP 50#define LIST_PREV BUTTON_UP
47#define LIST_PGUP (BUTTON_ON | BUTTON_UP) 51#define LIST_PGUP (BUTTON_ON | BUTTON_UP)
48#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN) 52#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN)
53#define LIST_PGRIGHT (BUTTON_ON | BUTTON_RIGHT)
54#define LIST_PGLEFT (BUTTON_ON | BUTTON_LEFT)
49 55
50#ifdef CONFIG_REMOTE_KEYPAD 56#ifdef CONFIG_REMOTE_KEYPAD
51#define LIST_RC_NEXT BUTTON_RC_RIGHT 57#define LIST_RC_NEXT BUTTON_RC_RIGHT
@@ -64,6 +70,8 @@
64#elif CONFIG_KEYPAD == ONDIO_PAD 70#elif CONFIG_KEYPAD == ONDIO_PAD
65#define LIST_NEXT BUTTON_DOWN 71#define LIST_NEXT BUTTON_DOWN
66#define LIST_PREV BUTTON_UP 72#define LIST_PREV BUTTON_UP
73#define LIST_PGRIGHT (BUTTON_MENU | BUTTON_RIGHT)
74#define LIST_PGLEFT (BUTTON_MENU | BUTTON_LEFT)
67 75
68#elif (CONFIG_KEYPAD == IPOD_4G_PAD) 76#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
69#define LIST_NEXT BUTTON_SCROLL_FWD 77#define LIST_NEXT BUTTON_SCROLL_FWD
@@ -78,6 +86,8 @@
78#define LIST_PREV BUTTON_UP 86#define LIST_PREV BUTTON_UP
79#define LIST_PGUP (BUTTON_ON | BUTTON_UP) 87#define LIST_PGUP (BUTTON_ON | BUTTON_UP)
80#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN) 88#define LIST_PGDN (BUTTON_ON | BUTTON_DOWN)
89#define LIST_PGRIGHT (BUTTON_ON | BUTTON_RIGHT)
90#define LIST_PGLEFT (BUTTON_ON | BUTTON_LEFT)
81 91
82#elif CONFIG_KEYPAD == IAUDIO_X5_PAD 92#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
83#define LIST_NEXT BUTTON_DOWN 93#define LIST_NEXT BUTTON_DOWN
@@ -116,12 +126,14 @@ typedef void list_get_icon(int selected_item,
116 * a buffer when it's not necessary) 126 * a buffer when it's not necessary)
117 * Returns a pointer to a string that contains the text to display 127 * Returns a pointer to a string that contains the text to display
118 */ 128 */
129
119typedef char * list_get_name(int selected_item, 130typedef char * list_get_name(int selected_item,
120 void * data, 131 void * data,
121 char *buffer); 132 char *buffer);
122 133
123struct gui_list 134struct gui_list
124{ 135{
136 int offsetval; /* value of screen offset */
125 int nb_items; 137 int nb_items;
126 int selected_item; 138 int selected_item;
127 bool cursor_flash_state; 139 bool cursor_flash_state;
@@ -222,6 +234,13 @@ extern void gui_list_draw(struct gui_list * gui_list);
222 * (Item 0 gets selected if the end of the list is reached) 234 * (Item 0 gets selected if the end of the list is reached)
223 * - gui_list : the list structure 235 * - gui_list : the list structure
224 */ 236 */
237
238extern void gui_list_screen_scroll_step(int ofs);
239/* parse global setting to static int */
240
241extern void gui_list_screen_scroll_out_of_view(bool enable);
242/* parse global setting to static bool */
243
225extern void gui_list_select_next(struct gui_list * gui_list); 244extern void gui_list_select_next(struct gui_list * gui_list);
226 245
227/* 246/*
@@ -236,6 +255,22 @@ extern void gui_list_select_previous(struct gui_list * gui_list);
236 * - gui_list : the list structure 255 * - gui_list : the list structure
237 * - nb_lines : the number of lines to try to move the cursor 256 * - nb_lines : the number of lines to try to move the cursor
238 */ 257 */
258
259extern void gui_list_offset_right(struct gui_list * gui_list);
260
261/*
262 * Makes all the item in the list scroll by one step to the right.
263 * Should stop increasing the value when reaching the widest item value
264 * in the list.
265 */
266
267extern void gui_list_offset_left(struct gui_list * gui_list);
268
269/*
270 * Makes all the item in the list scroll by one step to the left.
271 * stops at starting position.
272 */
273
239extern void gui_list_select_next_page(struct gui_list * gui_list, 274extern void gui_list_select_next_page(struct gui_list * gui_list,
240 int nb_lines); 275 int nb_lines);
241 276
@@ -312,6 +347,8 @@ extern void gui_synclist_select_item(struct gui_synclist * lists,
312 int item_number); 347 int item_number);
313extern void gui_synclist_select_next(struct gui_synclist * lists); 348extern void gui_synclist_select_next(struct gui_synclist * lists);
314extern void gui_synclist_select_previous(struct gui_synclist * lists); 349extern void gui_synclist_select_previous(struct gui_synclist * lists);
350extern void gui_synclist_offset_right(struct gui_synclist * lists);
351extern void gui_synclist_offset_left(struct gui_synclist * lists);
315extern void gui_synclist_select_next_page(struct gui_synclist * lists, 352extern void gui_synclist_select_next_page(struct gui_synclist * lists,
316 enum screen_type screen); 353 enum screen_type screen);
317extern void gui_synclist_select_previous_page(struct gui_synclist * lists, 354extern void gui_synclist_select_previous_page(struct gui_synclist * lists,