Index: apps/plugins/pictureflow.c =================================================================== --- apps/plugins/pictureflow.c (Revision 19419) +++ apps/plugins/pictureflow.c (Arbeitskopie) @@ -80,7 +80,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 @@ -88,6 +88,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 @@ -229,6 +232,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; @@ -249,6 +253,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; @@ -498,11 +504,10 @@ if ( rb->tagcache_get_next(&tcs) ) { struct mp3entry id3; - char size[9]; + char size[16]; int fd; rb->snprintf(size, sizeof(size), ".%dx%d", PREFERRED_IMG_WIDTH, PREFERRED_IMG_HEIGHT); - fd = rb->open(tcs.result, O_RDONLY); rb->get_metadata(&id3, fd, tcs.result); rb->close(fd); @@ -643,7 +648,7 @@ /* delete existing cache, so it's a true rebuild */ if(rb->file_exists(tmp_path_name)) rb->remove(tmp_path_name); - if (!create_bmp(&input_bmp, tmp_path_name, false)) { + 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 +920,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; @@ -1556,22 +1565,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 +1611,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 +1630,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 +1695,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; } /** @@ -1762,21 +1800,45 @@ } +static inline void track_list_yh(int 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 ); + int 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); + } } /** @@ -1789,23 +1851,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 ) { @@ -1855,6 +1907,9 @@ */ void draw_album_text(void) { + if (0 == config.show_album_name) + return; + int albumtxt_w, albumtxt_h; int albumtxt_y = 0; @@ -1885,8 +1940,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 ) { @@ -1992,6 +2051,7 @@ long current_update; long update_interval = 100; int fps = 0; + int fpstxt_y; bool instant_update; old_drawmode = rb->lcd_get_drawmode(); @@ -2036,10 +2096,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();