Index: apps/plugins/pictureflow.c =================================================================== --- apps/plugins/pictureflow.c (Revision 19403) +++ apps/plugins/pictureflow.c (Arbeitskopie) @@ -43,15 +43,7 @@ #define NB_ACTION_CONTEXTS sizeof(plugin_contexts)/sizeof(plugin_contexts[0]) -/* Key assignement */ -#if (CONFIG_KEYPAD == IPOD_1G2G_PAD) \ - || (CONFIG_KEYPAD == IPOD_3G_PAD) \ - || (CONFIG_KEYPAD == IPOD_4G_PAD) \ - || (CONFIG_KEYPAD == SANSA_E200_PAD) -#define SCROLLWHEEL -#endif - -#ifdef SCROLLWHEEL +#ifdef HAVE_SCROLLWHEEL #define PICTUREFLOW_NEXT_ALBUM PLA_DOWN #define PICTUREFLOW_NEXT_ALBUM_REPEAT PLA_DOWN_REPEAT #define PICTUREFLOW_PREV_ALBUM PLA_UP @@ -87,7 +79,7 @@ #define MAX_IMG_WIDTH LCD_WIDTH #define MAX_IMG_HEIGHT LCD_HEIGHT -#if (LCD_HEIGHT < 100) +#if (LCD_HEIGHT < 120) #define PREFERRED_IMG_WIDTH 50 #define PREFERRED_IMG_HEIGHT 50 #else @@ -95,6 +87,9 @@ #define PREFERRED_IMG_HEIGHT 100 #endif +#define RESIZE_HEIGHT LCD_HEIGHT/2 +#define RESIZE_WIDTH RESIZE_HEIGHT + #define BUFFER_WIDTH LCD_WIDTH #define BUFFER_HEIGHT LCD_HEIGHT @@ -221,7 +216,7 @@ unsigned int thread_id; struct event_queue thread_q; -static char tmp_path_name[MAX_PATH]; +static char tmp_path_name[MAX_PATH+1]; static long uniqbuf[UNIQBUF_SIZE]; static struct tagcache_search tcs; @@ -236,6 +231,7 @@ static int track_index; static int selected_track; static int selected_track_pulse; +void reset_track_list(void); static fb_data *input_bmp_buffer; static fb_data *output_bmp_buffer; @@ -256,6 +252,8 @@ static int start_index_track_list = 0; static int track_list_visible_entries = 0; +static int track_list_y; +static int track_list_h; static int track_scroll_index = 0; static int track_scroll_dir = 1; @@ -505,7 +503,7 @@ if ( rb->tagcache_get_next(&tcs) ) { struct mp3entry id3; - char size[9]; + char size[16]; rb->snprintf(size, sizeof(size), ".%dx%d", PREFERRED_IMG_WIDTH, PREFERRED_IMG_HEIGHT); rb->strncpy( (char*)&id3.path, tcs.result, MAX_PATH ); @@ -625,11 +623,11 @@ int i, slides = 0; struct bitmap input_bmp; - config.avg_album_width = 0; for (i=0; i < album_count; i++) { draw_progressbar(i); + if (!get_albumart_for_index_from_db(i, tmp_path_name, MAX_PATH)) continue; @@ -644,7 +642,10 @@ rb->snprintf(tmp_path_name, sizeof(tmp_path_name), CACHE_PREFIX "/%d.pfraw", i); - if (!create_bmp(&input_bmp, tmp_path_name, false)) { + /* delete old cache, so that rebuild is a true rebuild */ + if (rb->file_exists(tmp_path_name)) + rb->remove(tmp_path_name); + if (!create_bmp(&input_bmp, tmp_path_name, config.resize)) { rb->splash(HZ, "Could not write bmp"); } config.avg_album_width += input_bmp.width; @@ -915,17 +916,23 @@ if ( resize ) { /* resize image */ - output_bmp.width = config.avg_album_width; - output_bmp.height = config.avg_album_width; - smooth_resize_bitmap(input_bmp, &output_bmp); + output_bmp.width = RESIZE_WIDTH; + output_bmp.height = RESIZE_HEIGHT; - /* Resized bitmap is now in the output buffer, - copy it back to the input buffer */ - rb->memcpy(input_bmp_buffer, output_bmp_buffer, - config.avg_album_width * config.avg_album_width * sizeof(fb_data)); - input_bmp->data = (char *)input_bmp_buffer; - input_bmp->width = output_bmp.width; - input_bmp->height = output_bmp.height; + /* Only resize if it's really needed */ + if (!((input_bmp->height == output_bmp.height) && + (input_bmp->width == output_bmp.width))) + { + smooth_resize_bitmap(input_bmp, &output_bmp); + + /* Resized bitmap is now in the output buffer, + copy it back to the input buffer */ + rb->memcpy(input_bmp_buffer, output_bmp_buffer, + output_bmp.width * output_bmp.height * sizeof(fb_data)); + input_bmp->data = (char *)input_bmp_buffer; + input_bmp->width = output_bmp.width; + input_bmp->height = output_bmp.height; + } } output_bmp.width = input_bmp->width * 2; @@ -1025,11 +1032,9 @@ return NULL; struct bitmap *bmp; - ssize_t ret = rb->bufgetdata(hid, 0, (void *)&bmp); if (ret < 0) return NULL; - return bmp; } @@ -1556,22 +1561,39 @@ return true; } +/** + Shows the album name setting menu +*/ +int album_name_menu(void) +{ + int selection = config.show_album_name; + MENUITEM_STRINGLIST(album_name_menu,"Show album title",NULL, + "Hide album title", "Show at the bottom", "Show at the top"); + rb->do_menu(&album_name_menu, &selection, NULL, false); + + config.show_album_name = selection; + return GO_TO_PREVIOUS; +} + /** Shows the settings menu */ -int settings_menu(void) { +int settings_menu(void) +{ int selection = 0; + bool old_val; MENUITEM_STRINGLIST(settings_menu, "PictureFlow Settings", NULL, "Show FPS", "Spacing", "Center margin", "Number of slides", "Zoom", - "Rebuild cache"); + "Show album title", "Resize Covers", "Rebuild cache"); do { selection=rb->do_menu(&settings_menu,&selection, NULL, false); switch(selection) { case 0: rb->set_bool("Show FPS", &(config.show_fps)); + reset_track_list(); break; case 1: @@ -1585,7 +1607,7 @@ case 2: rb->set_int("Center margin", "", 1, &(config.extra_spacing_for_center_slide), - NULL, 1, -50, 50, NULL ); + NULL, 1, -70, 70, NULL ); recalc_table(); reset_slides(); break; @@ -1604,6 +1626,18 @@ reset_slides(); break; case 5: + album_name_menu(); + reset_track_list(); + recalc_table(); + reset_slides(); + break; + case 6: + old_val = config.resize; + rb->set_bool("Resize Covers", &(config.resize)); + if (old_val == config.resize) /* changed? */ + break; + /* fallthrough if changed, since cache needs to be rebuilt */ + case 7: rb->remove(CACHE_PREFIX "/ready"); rb->remove(EMPTY_SLIDE); rb->splash(HZ, "Cache will be rebuilt on next restart"); @@ -1657,13 +1691,13 @@ void set_default_config(void) { config.spacing_between_slides = 40; - config.extra_spacing_for_center_slide = 0; + config.extra_spacing_for_center_slide = (-40); config.show_slides = 3; config.avg_album_width = 0; config.zoom = 100; config.show_fps = false; config.resize = true; - config.show_album_name = album_name_bottom; + config.show_album_name = album_name_top; } /** @@ -1716,7 +1750,6 @@ } else { cover_animation_keyframe = 0; - selected_track = 0; pf_state = pf_show_tracks; } } @@ -1763,21 +1796,45 @@ } +static inline void track_list_yh(short char_height) +{ + switch (config.show_album_name) + { + case album_name_hide: + track_list_y = (config.show_fps ? char_height : 0); + track_list_h = LCD_HEIGHT - track_list_y; + break; + case album_name_bottom: + track_list_y = (config.show_fps ? char_height : 0); + track_list_h = LCD_HEIGHT - track_list_y - char_height * 2; + break; + default: /* case album_name_top */ + track_list_y = char_height * 2; + track_list_h = LCD_HEIGHT - track_list_y - (config.show_fps ? char_height : 0); + break; + } +} + /** Reset the track list after a album change */ void reset_track_list(void) { - int albumtxt_w, albumtxt_h; - const char* albumtxt = get_album_name(center_index); - rb->lcd_getstringsize(albumtxt, &albumtxt_w, &albumtxt_h); - const int height = - LCD_HEIGHT-albumtxt_h-10 - (config.show_fps?(albumtxt_h + 5):0); - track_list_visible_entries = fmin( height/albumtxt_h , track_count ); + short albumtxt_h = rb->screens[SCREEN_MAIN]->getcharheight(); + track_list_yh(albumtxt_h); + track_list_visible_entries = fmin( track_list_h/albumtxt_h , track_count ); start_index_track_list = 0; track_scroll_index = 0; track_scroll_dir = 1; selected_track = 0; + + /* let the tracklist start more centered + * if the screen isn't filled with tracks */ + if (track_count*albumtxt_h < track_list_h) + { + track_list_h = track_count * albumtxt_h; + track_list_y = LCD_HEIGHT / 2 - (track_list_h / 2); + } } /** @@ -1790,23 +1847,13 @@ create_track_index(center_slide.slide_index); reset_track_list(); } - static int titletxt_w, titletxt_h, titletxt_y, titletxt_x, i, color; - rb->lcd_getstringsize("W", NULL, &titletxt_h); - if (track_list_visible_entries >= track_count) - { - int albumtxt_h; - const char* albumtxt = get_album_name(center_index); - rb->lcd_getstringsize(albumtxt, NULL, &albumtxt_h); - titletxt_y = ((LCD_HEIGHT-albumtxt_h-10)-(track_count*albumtxt_h))/2; - } - else if (config.show_fps) - titletxt_y = titletxt_h + 5; - else - titletxt_y = 0; + static int titletxt_w, titletxt_x, color, titletxt_h; + titletxt_h = rb->screens[SCREEN_MAIN]->getcharheight(); + int titletxt_y = track_list_y; int track_i; - for (i=0; i < track_list_visible_entries; i++) { - track_i = i+start_index_track_list; + track_i = start_index_track_list; + for (;track_i < track_list_visible_entries+start_index_track_list; track_i++) { rb->lcd_getstringsize(get_track_name(track_i), &titletxt_w, NULL); titletxt_x = (LCD_WIDTH-titletxt_w)/2; if ( track_i == selected_track ) { @@ -1856,6 +1903,9 @@ */ void draw_album_text(void) { + if (0 == config.show_album_name) + return; + int albumtxt_w, albumtxt_h; int albumtxt_y = 0; @@ -1886,8 +1936,12 @@ albumtxt_dir = -1; prev_center_index = center_index; } - albumtxt_y = LCD_HEIGHT-albumtxt_h-10; + if (config.show_album_name == album_name_top) + albumtxt_y = albumtxt_h / 2; + else + albumtxt_y = LCD_HEIGHT - albumtxt_h - albumtxt_h/2; + if (albumtxt_w > LCD_WIDTH ) { rb->lcd_putsxy(albumtxt_x, albumtxt_y , albumtxt); if ( pf_state == pf_idle || pf_state == pf_show_tracks ) { @@ -1993,6 +2047,7 @@ long current_update; long update_interval = 100; int fps = 0; + short fpstxt_y; bool instant_update; old_drawmode = rb->lcd_get_drawmode(); @@ -2037,10 +2092,15 @@ } /* Draw FPS */ - if (config.show_fps) { + if (config.show_fps) + { rb->lcd_set_foreground(LCD_RGBPACK(255, 0, 0)); rb->snprintf(fpstxt, sizeof(fpstxt), "FPS: %d", fps); - rb->lcd_putsxy(0, 0, fpstxt); + if (config.show_album_name == album_name_top) + fpstxt_y = LCD_HEIGHT - rb->screens[SCREEN_MAIN]->getcharheight(); + else + fpstxt_y = 0; + rb->lcd_putsxy(0, fpstxt_y, fpstxt); } draw_album_text(); @@ -2072,7 +2132,7 @@ case PICTUREFLOW_NEXT_ALBUM: case PICTUREFLOW_NEXT_ALBUM_REPEAT: -#ifdef SCROLLWHEEL +#ifdef HAVE_SCROLLWHEEL if ( pf_state == pf_show_tracks ) select_next_track(); #endif @@ -2082,7 +2142,7 @@ case PICTUREFLOW_PREV_ALBUM: case PICTUREFLOW_PREV_ALBUM_REPEAT: -#ifdef SCROLLWHEEL +#ifdef HAVE_SCROLLWHEEL if ( pf_state == pf_show_tracks ) select_prev_track(); #endif @@ -2090,7 +2150,7 @@ show_previous_slide(); break; -#ifndef SCROLLWHEEL +#ifndef HAVE_SCROLLWHEEL case PICTUREFLOW_NEXT_TRACK: case PICTUREFLOW_NEXT_TRACK_REPEAT: if ( pf_state == pf_show_tracks ) @@ -2106,7 +2166,6 @@ case PICTUREFLOW_SELECT_ALBUM: if ( pf_state == pf_idle ) { - reset_track_list(); pf_state = pf_cover_in; } if ( pf_state == pf_show_tracks )