From f77ac7a6a7e19aa20bdeb10bd006ad1a8c147f76 Mon Sep 17 00:00:00 2001 From: Kevin Ferrare Date: Sun, 2 Jul 2006 12:28:27 +0000 Subject: added support remote support for the id3 infos screen (had to slightly change the list engine to use it here as well), corrected a mistake in the french translation git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10175 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/list.c | 85 ++++++++------ apps/gui/list.h | 13 ++- apps/lang/francais.lang | 4 +- apps/menu.c | 2 +- apps/playlist_viewer.c | 4 +- apps/plugin.h | 5 +- apps/plugins/text_editor.c | 2 +- apps/screens.c | 277 +++++++++++++++++---------------------------- apps/tree.c | 2 +- 9 files changed, 176 insertions(+), 218 deletions(-) diff --git a/apps/gui/list.c b/apps/gui/list.c index ebc8115be0..5dff8dc1b2 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -47,7 +47,9 @@ static bool offset_out_of_view = false; void gui_list_init(struct gui_list * gui_list, list_get_name callback_get_item_name, - void * data + void * data, + bool scroll_all, + int selected_size ) { gui_list->callback_get_item_icon = NULL; @@ -62,6 +64,8 @@ void gui_list_init(struct gui_list * gui_list, #ifdef HAVE_LCD_BITMAP gui_list->offset_position = 0; #endif + gui_list->scroll_all=scroll_all; + gui_list->selected_size=selected_size; } void gui_list_set_display(struct gui_list * gui_list, struct screen * display) @@ -212,8 +216,8 @@ void gui_list_draw(struct gui_list * gui_list) item_offset = gui_list->offset_position; #endif - if(current_item == gui_list->selected_item) { - /* The selected item must be displayed scrolling */ + if(current_item >= gui_list->selected_item && current_item < gui_list->selected_item+gui_list->selected_size) + {/* 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 */ @@ -237,11 +241,22 @@ void gui_list_draw(struct gui_list * gui_list) } else {/* normal item */ + if(gui_list->scroll_all) + { +#ifdef HAVE_LCD_BITMAP + display->puts_scroll_offset(0, i, entry_name,item_offset); +#else + display->puts_scroll(text_pos, i, entry_name); +#endif + } + else + { #ifdef HAVE_LCD_BITMAP - display->puts_offset(0, i, entry_name,item_offset); + display->puts_offset(0, i, entry_name,item_offset); #else - display->puts(text_pos, i, entry_name); + display->puts(text_pos, i, entry_name); #endif + } } /* Icons display */ if(draw_icons) @@ -280,29 +295,26 @@ void gui_list_select_item(struct gui_list * gui_list, int item_number) void gui_list_select_next(struct gui_list * gui_list) { - int item_pos; - int end_item; - - if( gui_list->selected_item == gui_list->nb_items-1 ) + if( gui_list->selected_item+gui_list->selected_size >= gui_list->nb_items ) { if(gui_list->limit_scroll) return; - gui_list->selected_item++; /* we have already reached the bottom of the list */ gui_list->selected_item = 0; gui_list->start_item = 0; } else { + gui_list->selected_item+=gui_list->selected_size; int nb_lines = gui_list->display->nb_lines; - gui_list->selected_item++; - item_pos = gui_list->selected_item - gui_list->start_item; - end_item = gui_list->start_item + nb_lines; + int item_pos = gui_list->selected_item - gui_list->start_item; + int end_item = gui_list->start_item + nb_lines; + if (global_settings.scroll_paginated) { /* When we reach the bottom of the list * we jump to a new page if there are more items*/ - if( item_pos > nb_lines-1 && end_item < gui_list->nb_items ) + if( item_pos > nb_lines-gui_list->selected_size && end_item < gui_list->nb_items ) { gui_list->start_item = gui_list->selected_item; if ( gui_list->start_item > gui_list->nb_items-nb_lines ) @@ -315,22 +327,21 @@ void gui_list_select_next(struct gui_list * gui_list) * (nb_lines-SCROLL_LIMIT) * and when we are not in the last part of the list*/ if( item_pos > nb_lines-SCROLL_LIMIT && end_item < gui_list->nb_items ) - gui_list->start_item++; + gui_list->start_item+=gui_list->selected_size; } } } void gui_list_select_previous(struct gui_list * gui_list) { - if( gui_list->selected_item == 0 ) + if( gui_list->selected_item-gui_list->selected_size < 0 ) { int nb_lines = gui_list->display->nb_lines; if(gui_list->limit_scroll) return; - gui_list->selected_item--; /* we have aleady reached the top of the list */ int start; - gui_list->selected_item = gui_list->nb_items-1; + gui_list->selected_item = gui_list->nb_items-gui_list->selected_size; start = gui_list->nb_items-nb_lines; if( start < 0 ) gui_list->start_item = 0; @@ -341,31 +352,31 @@ void gui_list_select_previous(struct gui_list * gui_list) { int item_pos; int nb_lines = gui_list->display->nb_lines; - gui_list->selected_item--; + gui_list->selected_item-=gui_list->selected_size; item_pos = gui_list->selected_item - gui_list->start_item; if (global_settings.scroll_paginated) { /* When we reach the top of the list * we jump to a new page if there are more items*/ - if( item_pos < 0 && gui_list->start_item > 0 ) - gui_list->start_item = gui_list->selected_item-nb_lines+1; - if( gui_list->start_item < 0 ) - gui_list->start_item = 0; + if( item_pos < 0) + gui_list->start_item = gui_list->selected_item-nb_lines+gui_list->selected_size; } else { /* we start scrolling vertically when reaching the line * (nb_lines-SCROLL_LIMIT) * and when we are not in the last part of the list*/ - if( item_pos < SCROLL_LIMIT-1 && gui_list->start_item > 0 ) - gui_list->start_item--; + if( item_pos < SCROLL_LIMIT-1) + gui_list->start_item-=gui_list->selected_size; } + if( gui_list->start_item < 0 ) + gui_list->start_item = 0; } } void gui_list_select_next_page(struct gui_list * gui_list, int nb_lines) { - if(gui_list->selected_item == gui_list->nb_items-1) + if(gui_list->selected_item == gui_list->nb_items-gui_list->selected_size) { if(gui_list->limit_scroll) return; @@ -373,6 +384,7 @@ void gui_list_select_next_page(struct gui_list * gui_list, int nb_lines) } else { + nb_lines-=nb_lines%gui_list->selected_size; gui_list->selected_item += nb_lines; if(gui_list->selected_item > gui_list->nb_items-1) gui_list->selected_item = gui_list->nb_items-1; @@ -386,10 +398,11 @@ void gui_list_select_previous_page(struct gui_list * gui_list, int nb_lines) { if(gui_list->limit_scroll) return; - gui_list->selected_item = gui_list->nb_items - 1; + gui_list->selected_item = gui_list->nb_items - gui_list->selected_size; } else { + nb_lines-=nb_lines%gui_list->selected_size; gui_list->selected_item -= nb_lines; if(gui_list->selected_item < 0) gui_list->selected_item = 0; @@ -467,7 +480,9 @@ void gui_list_screen_scroll_out_of_view(bool enable) void gui_synclist_init( struct gui_synclist * lists, list_get_name callback_get_item_name, - void * data + void * data, + bool scroll_all, + int selected_size ) { int i; @@ -475,7 +490,7 @@ void gui_synclist_init( { gui_list_init(&(lists->gui_list[i]), callback_get_item_name, - data); + data, scroll_all, selected_size); gui_list_set_display(&(lists->gui_list[i]), &(screens[i])); } } @@ -641,9 +656,9 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button) case LIST_RC_PGRIGHT: case LIST_RC_PGRIGHT | BUTTON_REPEAT: #endif - gui_synclist_scroll_right(lists); - gui_synclist_draw(lists); - return true; + gui_synclist_scroll_right(lists); + gui_synclist_draw(lists); + return true; #endif #ifdef LIST_PGLEFT @@ -653,9 +668,9 @@ unsigned gui_synclist_do_button(struct gui_synclist * lists, unsigned button) case LIST_RC_PGLEFT: case LIST_RC_PGLEFT | BUTTON_REPEAT: #endif - gui_synclist_scroll_left(lists); - gui_synclist_draw(lists); - return true; + gui_synclist_scroll_left(lists); + gui_synclist_draw(lists); + return true; #endif /* for pgup / pgdown, we are obliged to have a different behaviour depending on the screen diff --git a/apps/gui/list.h b/apps/gui/list.h index 5658a1cd62..60a3651259 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h @@ -147,6 +147,11 @@ struct gui_list /* defines wether the list should stop when reaching the top/bottom * or should continue (by going to bottom/top) */ bool limit_scroll; + /* wether the text of the whole items of the list have to be + * scrolled or only for the selected item */ + bool scroll_all; + /* the number of lines that are selected at the same time */ + int selected_size; /* The data that will be passed to the callback function YOU implement */ void * data; }; @@ -162,7 +167,9 @@ struct gui_list */ extern void gui_list_init(struct gui_list * gui_list, list_get_name callback_get_item_name, - void * data + void * data, + bool scroll_all, + int selected_size ); /* @@ -329,7 +336,9 @@ struct gui_synclist extern void gui_synclist_init( struct gui_synclist * lists, list_get_name callback_get_item_name, - void * data + void * data, + bool scroll_all, + int selected_size ); extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items); extern void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback); diff --git a/apps/lang/francais.lang b/apps/lang/francais.lang index 17f6354501..22391f0858 100644 --- a/apps/lang/francais.lang +++ b/apps/lang/francais.lang @@ -5469,7 +5469,7 @@ *: "[Bitrate]" - *: "[Fréquence]" + *: "[Débit binaire]" *: "" @@ -5511,7 +5511,7 @@ *: "[Frequency]" - *: "[Fréquence]" + *: "[Échantillonnage]" *: "" diff --git a/apps/menu.c b/apps/menu.c index 26df94b5a7..f67c0633c6 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -96,7 +96,7 @@ int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, in return -1; menus[menu].items = (struct menu_item*)mitems; /* de-const */ gui_synclist_init(&(menus[menu].synclist), - &menu_get_itemname, &menus[menu]); + &menu_get_itemname, &menus[menu], false, 1); gui_synclist_set_icon_callback(&(menus[menu].synclist), NULL); gui_synclist_set_nb_items(&(menus[menu].synclist), count); menus[menu].callback = callback; diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 640063bb64..087bdd1583 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -621,7 +621,7 @@ bool playlist_viewer_ex(char* filename) if (!playlist_viewer_init(&viewer, filename, false)) goto exit; - gui_synclist_init(&playlist_lists, playlist_callback_name, &viewer); + gui_synclist_init(&playlist_lists, playlist_callback_name, &viewer, false, 1); gui_synclist_set_icon_callback(&playlist_lists, global_settings.playlist_viewer_icons? &playlist_callback_icons:NULL); @@ -873,7 +873,7 @@ bool search_playlist(void) } backlight_on(); gui_synclist_init(&playlist_lists, playlist_search_callback_name, - found_indicies); + found_indicies, false, 1); gui_synclist_set_icon_callback(&playlist_lists, global_settings.playlist_viewer_icons? &playlist_search_callback_icons:NULL); diff --git a/apps/plugin.h b/apps/plugin.h index f27654049b..1429e83847 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -7,7 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright (C) 2002 Bj�n Stenberg + * Copyright (C) 2002 Björn Stenberg * * All files in this archive are subject to the GNU General Public License. * See the file COPYING in the source tree root for full license agreement. @@ -488,7 +488,8 @@ struct plugin_api { /* list */ void (*gui_synclist_init)(struct gui_synclist * lists, - list_get_name callback_get_item_name,void * data); + list_get_name callback_get_item_name,void * data, + bool scroll_all,int selected_size); void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items); void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, list_get_icon icon_callback); int (*gui_synclist_get_nb_items)(struct gui_synclist * lists); diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index 5abd48485f..01af458654 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c @@ -245,7 +245,7 @@ void save_changes(int overwrite) void setup_lists(struct gui_synclist *lists, int sel) { - rb->gui_synclist_init(lists,list_get_name_cb,0); + rb->gui_synclist_init(lists,list_get_name_cb,0, false, 1); rb->gui_synclist_set_icon_callback(lists,NULL); rb->gui_synclist_set_nb_items(lists,line_count); rb->gui_synclist_limit_scroll(lists,true); diff --git a/apps/screens.c b/apps/screens.c index 51201525d4..99f23c55af 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -53,6 +53,7 @@ #include "quickscreen.h" #include "logo.h" #include "pcmbuf.h" +#include "list.h" #if defined(HAVE_LCD_BITMAP) #include "widgets.h" @@ -1006,189 +1007,127 @@ bool shutdown_screen(void) } #endif -int draw_id3_item(int line, int top, int header, const char* body) -{ - if (line >= top) - { -#if defined(HAVE_LCD_BITMAP) - const int rows = LCD_HEIGHT / font_get(FONT_UI)->height; -#else - const int rows = 2; -#endif - int y = line - top; - - if (y < rows) - { - lcd_puts(0, y, str(header)); - } - - if (++y < rows) - { - lcd_puts_scroll(0, y, - body ? (const unsigned char*) body : str(LANG_ID3_NO_INFO)); - } - } - - return line + 2; -} - #if CONFIG_CODEC == SWCODEC #define ID3_ITEMS 13 #else #define ID3_ITEMS 11 #endif -bool browse_id3(void) +char * id3_get_info(int selected_item, void* data, char *buffer) { - char buf[64]; - const struct mp3entry* id3 = audio_current_track(); -#if defined(HAVE_LCD_BITMAP) - const int y_margin = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; - const int line_height = font_get(FONT_UI)->height; - const int rows = (LCD_HEIGHT - y_margin) / line_height; - const bool show_scrollbar = global_settings.scrollbar - && (ID3_ITEMS * 2 > rows); -#else - const int rows = 2; -#endif - const int top_max = (ID3_ITEMS * 2) - (rows & ~1); - int top = 0; - int button; - bool exit = false; - - if (!id3 || (!(audio_status() & AUDIO_STATUS_PLAY))) - { - return false; - } - -#if defined(HAVE_LCD_BITMAP) - lcd_setmargins(show_scrollbar ? SCROLLBAR_WIDTH : 0, y_margin); -#endif - - while (!exit) - { - int line = 0; - int old_top = top; - char* body; - - lcd_clear_display(); - gui_syncstatusbar_draw(&statusbars, true); - line = draw_id3_item(line, top, LANG_ID3_TITLE, id3->title); - line = draw_id3_item(line, top, LANG_ID3_ARTIST, id3->artist); - line = draw_id3_item(line, top, LANG_ID3_ALBUM, id3->album); - - if (id3->track_string) - { - body = id3->track_string; - } - else if (id3->tracknum) + struct mp3entry* id3 =(struct mp3entry*)data; + int info_no=selected_item/2; + DEBUGF("%d : %d\n",info_no, selected_item); + if(!(selected_item%2)) + {/* header */ + int headers[]= { - snprintf(buf, sizeof(buf), "%d", id3->tracknum); - body = buf; - } - else - { - body = NULL; - } - - line = draw_id3_item(line, top, LANG_ID3_TRACKNUM, body); - - body = id3->genre_string ? id3->genre_string : id3_get_genre(id3); - line = draw_id3_item(line, top, LANG_ID3_GENRE, body); - - if (id3->year_string) - { - body = id3->year_string; - } - else if (id3->year) - { - snprintf(buf, sizeof(buf), "%d", id3->year); - body = buf; - } - else - { - body = NULL; - } - - line = draw_id3_item(line, top, LANG_ID3_YEAR, body); - - gui_wps_format_time(buf, sizeof(buf), id3->length); - line = draw_id3_item(line, top, LANG_ID3_LENGTH, buf); - - snprintf(buf, sizeof(buf), "%d/%d", playlist_get_display_index(), - playlist_amount()); - line = draw_id3_item(line, top, LANG_ID3_PLAYLIST, buf); - - snprintf(buf, sizeof(buf), "%d kbps%s", id3->bitrate, - id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) ""); - line = draw_id3_item(line, top, LANG_ID3_BITRATE, buf); - - snprintf(buf, sizeof(buf), "%ld Hz", id3->frequency); - line = draw_id3_item(line, top, LANG_ID3_FRECUENCY, buf); - + LANG_ID3_TITLE, + LANG_ID3_ARTIST, + LANG_ID3_ALBUM, + LANG_ID3_TRACKNUM, + LANG_ID3_GENRE, + LANG_ID3_YEAR, + LANG_ID3_LENGTH, + LANG_ID3_PLAYLIST, + LANG_ID3_BITRATE, + LANG_ID3_FRECUENCY, #if CONFIG_CODEC == SWCODEC - line = draw_id3_item(line, top, LANG_ID3_TRACK_GAIN, - id3->track_gain_string); - - line = draw_id3_item(line, top, LANG_ID3_ALBUM_GAIN, - id3->album_gain_string); -#endif - - line = draw_id3_item(line, top, LANG_ID3_PATH, id3->path); - -#if defined(HAVE_LCD_BITMAP) - if (show_scrollbar) - { - scrollbar(0, y_margin, SCROLLBAR_WIDTH - 1, rows * line_height, - ID3_ITEMS * 2 + (rows & 1), top, top + rows, VERTICAL); - } + LANG_ID3_TRACK_GAIN, + LANG_ID3_ALBUM_GAIN, #endif + LANG_ID3_PATH, + }; + return( str(headers[info_no])); + } + else + {/* data */ - while (!exit && (top == old_top)) + char * info=NULL; + switch(info_no) { - gui_syncstatusbar_draw(&statusbars, false); - lcd_update(); - button = button_get_w_tmo(HZ / 2); - - switch(button) - { - /* It makes more sense to have the keys mapped "backwards" when - * scrolling a list on the archos studios/players and the ipod. - */ -#if defined(HAVE_LCD_BITMAP) && !(CONFIG_KEYPAD == IPOD_4G_PAD) - case SETTINGS_INC: - case SETTINGS_INC | BUTTON_REPEAT: -#else - case SETTINGS_DEC: -#endif - if (top > 0) + case 0:/*LANG_ID3_TITLE*/ + info=id3->title; + break; + case 1:/*LANG_ID3_ARTIST*/ + info=id3->artist; + break; + case 2:/*LANG_ID3_ALBUM*/ + info=id3->album; + break; + case 3:/*LANG_ID3_TRACKNUM*/ + if (id3->track_string) + info = id3->track_string; + else if (id3->tracknum) { - top -= 2; + snprintf(buffer, MAX_PATH, "%d", id3->tracknum); + info = buffer; } - else if (!(button & BUTTON_REPEAT)) + break; + case 4:/*LANG_ID3_GENRE*/ + info = id3_get_genre(id3); + break; + case 5:/*LANG_ID3_YEAR*/ + if (id3->year_string) + info = id3->year_string; + else if (id3->year) { - top = top_max; + snprintf(buffer, MAX_PATH, "%d", id3->year); + info = buffer; } - break; - -#if defined(HAVE_LCD_BITMAP) && !(CONFIG_KEYPAD == IPOD_4G_PAD) - case SETTINGS_DEC: - case SETTINGS_DEC | BUTTON_REPEAT: + case 6:/*LANG_ID3_LENGTH*/ + gui_wps_format_time(buffer, MAX_PATH, id3->length); + info=buffer; + break; + case 7:/*LANG_ID3_PLAYLIST*/ + snprintf(buffer, MAX_PATH, "%d/%d", playlist_get_display_index(), + playlist_amount()); + info=buffer; + break; + case 8:/*LANG_ID3_BITRATE*/ + snprintf(buffer, MAX_PATH, "%d kbps%s", id3->bitrate, + id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) ""); + info=buffer; + break; + case 9:/*LANG_ID3_FRECUENCY*/ + snprintf(buffer, MAX_PATH, "%ld Hz", id3->frequency); + info=buffer; + break; +#if CONFIG_CODEC == SWCODEC + case 10:/*LANG_ID3_TRACK_GAIN*/ + info=id3->track_gain_string; + break; + case 11:/*LANG_ID3_ALBUM_GAIN*/ + info=id3->album_gain_string; + break; + case 12:/*LANG_ID3_PATH*/ #else - case SETTINGS_INC: + case 10:/*LANG_ID3_PATH*/ #endif - if (top < top_max) - { - top += 2; - } - else if (!(button & BUTTON_REPEAT)) - { - top = 0; - } - + info=id3->path; break; + } + if(info==NULL) + return(str(LANG_ID3_NO_INFO)); + return(info); + } +} +bool browse_id3(void) +{ + struct gui_synclist id3_lists; + struct mp3entry* id3 = audio_current_track(); + int key; + + gui_synclist_init(&id3_lists, &id3_get_info, id3, true, 2); + gui_synclist_set_nb_items(&id3_lists, ID3_ITEMS*2); + gui_synclist_draw(&id3_lists); + while (true) { + key = button_get_w_tmo(HZ/2); + /* If moved, "say" the entry under the cursor */ + gui_synclist_do_button(&id3_lists, key); + switch( key ) { #ifdef SETTINGS_OK2 case SETTINGS_OK2: #endif @@ -1196,23 +1135,17 @@ bool browse_id3(void) lcd_stop_scroll(); /* Eat release event */ button_get(true); - exit = true; - break; + return(false); default: - if (default_event_handler(button) == SYS_USB_CONNECTED) - { + if (default_event_handler(key) == SYS_USB_CONNECTED) return true; - } - - break; - } } + gui_syncstatusbar_draw(&statusbars, false); } - - return false; } + bool set_rating(void) { struct mp3entry* id3 = audio_current_track(); diff --git a/apps/tree.c b/apps/tree.c index 4556d86c53..0322c3933a 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -248,7 +248,7 @@ void browse_root(void) /* since archos only have one screen, no need to create more than that */ gui_buttonbar_set_display(&tree_buttonbar, &(screens[SCREEN_MAIN]) ); #endif - gui_synclist_init(&tree_lists, &tree_get_filename, &tc); + gui_synclist_init(&tree_lists, &tree_get_filename, &tc, false, 1); gui_synclist_set_icon_callback(&tree_lists, global_settings.show_icons?&tree_get_fileicon:NULL); #ifndef SIMULATOR -- cgit v1.2.3