From 7fa39df4277fba4b567a57c79a8933afc96d9339 Mon Sep 17 00:00:00 2001 From: Tomas Salfischberger Date: Sun, 22 Jan 2006 01:42:05 +0000 Subject: Horizontal scrolling patch by Shachar Liberman git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8412 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/list.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 119 insertions(+), 8 deletions(-) (limited to 'apps/gui/list.c') 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 @@ #define SCROLL_LIMIT 2 #endif - +static int offset_step = 15; +static bool offset_outof_view = false; void gui_list_init(struct gui_list * gui_list, list_get_name callback_get_item_name, @@ -53,6 +54,7 @@ void gui_list_init(struct gui_list * gui_list, gui_list->limit_scroll = false; gui_list->data=data; gui_list->cursor_flash_state=false; + gui_list->offsetval = 0; } void 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) entry_name = gui_list->callback_get_item_name(current_item, gui_list->data, entry_buffer); - if(current_item == gui_list->selected_item) - { - /* The selected item must be displayed scrolling */ + #ifdef HAVE_LCD_BITMAP - if (global_settings.invert_cursor)/* Display inverted-line-style*/ - display->puts_scroll_style(0, i, entry_name, STYLE_INVERT); + /* position the string at the right offset place */ + int item_offset; + int str_width,h; + display->getstringsize(entry_name, &str_width, &h); + + if (offset_outof_view) + item_offset = gui_list->offsetval; + else + /* if text is smaller then view */ + if (str_width <= display->width - text_pos) + item_offset = 0; + else + /* if text got out of view */ + if (gui_list->offsetval > str_width - (display->width - text_pos)) + item_offset = str_width - (display->width - text_pos); else - display->puts_scroll(0, i, entry_name); + item_offset = gui_list->offsetval; + +#endif + + if(current_item == gui_list->selected_item) { + /* The selected item must be displayed scrolling */ +#ifdef HAVE_LCD_BITMAP + if (global_settings.invert_cursor) /* Display inverted-line-style*/ + + /* if text got out of view */ + if (item_offset > str_width - (display->width - text_pos)) + /* don't scroll */ + display->puts_style_offset(0, i, entry_name, STYLE_INVERT,item_offset); + else + display->puts_scroll_style_offset(0, i, entry_name, STYLE_INVERT,item_offset); + + else /* if (global_settings.invert_cursor) */ + + if (item_offset > str_width - (display->width - text_pos)) + display->puts_offset(0, i, entry_name,item_offset); + else + display->puts_scroll_offset(0, i, entry_name,item_offset); + #else display->puts_scroll(text_pos, i, entry_name); #endif @@ -197,7 +232,7 @@ void gui_list_draw(struct gui_list * gui_list) else {/* normal item */ #ifdef HAVE_LCD_BITMAP - display->puts(0, i, entry_name); + display->puts_offset(0, i, entry_name,item_offset); #else display->puts(text_pos, i, entry_name); #endif @@ -229,6 +264,40 @@ void gui_list_draw(struct gui_list * gui_list) gui_textarea_update(display); } +#ifdef HAVE_LCD_BITMAP +void gui_list_screen_scroll_step(int ofs) +{ + offset_step = ofs; +} + +void gui_list_screen_scroll_out_of_view(bool enable) +{ + if (enable) + offset_outof_view = true; + else + offset_outof_view = false; +} + +void gui_list_offset_right(struct gui_list * gui_list) +{ + /* there should be a callback to find out what's the longest item on the list, + * and then, by finding out the width with get_stringsize, we would stop the + * list from scrolling at that point */ + + gui_list->offsetval+=offset_step; + if (gui_list->offsetval > 1000) + gui_list->offsetval = 1000; +} + +void gui_list_offset_left(struct gui_list * gui_list) +{ + gui_list->offsetval-=offset_step; + if (gui_list->offsetval < 0) + gui_list->offsetval = 0; + +} +#endif /* HAVE_LCD_BITMAP */ + void gui_list_select_item(struct gui_list * gui_list, int item_number) { 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) FOR_NB_SCREENS(i) { gui_list_set_nb_items(&(lists->gui_list[i]), nb_items); + lists->gui_list[i].offsetval = 0; } } void 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, screens[screen].nb_lines); } +#ifdef HAVE_LCD_BITMAP +void gui_synclist_offset_right(struct gui_synclist * lists) +{ + int i; + FOR_NB_SCREENS(i) + gui_list_offset_right(&(lists->gui_list[i])); +} + +void gui_synclist_offset_left(struct gui_synclist * lists) +{ + int i; + FOR_NB_SCREENS(i) + gui_list_offset_left(&(lists->gui_list[i])); +} +#endif /* HAVE_LCD_BITMAP */ + void gui_synclist_select_previous_page(struct gui_synclist * lists, enum screen_type screen) { @@ -502,6 +588,31 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button) gui_synclist_select_next(lists); gui_synclist_draw(lists); return LIST_NEXT; + +#ifdef LIST_PGRIGHT + case LIST_PGRIGHT: + case LIST_PGRIGHT | BUTTON_REPEAT: +#ifdef LIST_RC_PGRIGHT + case LIST_RC_PGRIGHT: + case LIST_RC_PGRIGHT | BUTTON_REPEAT: +#endif + gui_synclist_offset_right(lists); + gui_synclist_draw(lists); + return true; +#endif + +#ifdef LIST_PGLEFT + case LIST_PGLEFT: + case LIST_PGLEFT | BUTTON_REPEAT: +#ifdef LIST_RC_PGLEFT + case LIST_RC_PGLEFT: + case LIST_RC_PGLEFT | BUTTON_REPEAT: +#endif + gui_synclist_offset_left(lists); + gui_synclist_draw(lists); + return true; +#endif + /* for pgup / pgdown, we are obliged to have a different behaviour depending on the screen * for which the user pressed the key since for example, remote and main screen doesn't * have the same number of lines*/ -- cgit v1.2.3