Index: apps/plugins/pictureflow.c =================================================================== --- apps/plugins/pictureflow.c (Revision 17451) +++ apps/plugins/pictureflow.c (Arbeitskopie) @@ -85,13 +85,9 @@ #define MAX_IMG_WIDTH LCD_WIDTH #define MAX_IMG_HEIGHT LCD_HEIGHT -#if (LCD_HEIGHT < 100) -#define PREFERRED_IMG_WIDTH 50 -#define PREFERRED_IMG_HEIGHT 50 -#else -#define PREFERRED_IMG_WIDTH 100 -#define PREFERRED_IMG_HEIGHT 100 -#endif +/* album art takes upto the half of the screen height */ +#define PREFERRED_IMG_HEIGHT ((LCD_HEIGHT -(LCD_HEIGHT % 100)) / 2 ) +#define PREFERRED_IMG_WIDTH PREFERRED_IMG_HEIGHT #define BUFFER_WIDTH LCD_WIDTH #define BUFFER_HEIGHT LCD_HEIGHT @@ -175,12 +171,17 @@ {pictureflow_logo, BMPWIDTH_pictureflow_logo, BMPHEIGHT_pictureflow_logo}, }; +enum show_album_name_values { album_name_hide = 0, album_name_bottom , album_name_top }; + struct config_data { + bool show_fps; long avg_album_width; int spacing_between_slides; int extra_spacing_for_center_slide; int show_slides; int zoom; + bool resize; + enum show_album_name_values show_album_name; }; /** below we allocate the memory we want to use **/ @@ -198,7 +199,6 @@ static int itilt; static PFreal offsetX; static PFreal offsetY; -static bool show_fps; /* show fps in the main screen */ static int number_of_slides; static struct slide_cache cache[SLIDE_CACHE_SIZE]; @@ -614,7 +617,7 @@ rb->snprintf(tmp_path_name, sizeof(tmp_path_name), CACHE_PREFIX "/%d.pfraw", i); - 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; @@ -879,23 +882,33 @@ bool create_bmp(struct bitmap *input_bmp, char *target_path, bool resize) { struct bitmap output_bmp; - output_bmp.format = input_bmp->format; output_bmp.data = (char *)output_bmp_buffer; if ( resize ) { /* resize image */ - output_bmp.width = config.avg_album_width; - output_bmp.height = config.avg_album_width; - simple_resize_bitmap(input_bmp, &output_bmp); + output_bmp.width = PREFERRED_IMG_WIDTH; + output_bmp.height = PREFERRED_IMG_HEIGHT; + config.avg_album_width = PREFERRED_IMG_WIDTH; - /* 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))) + { +#ifdef HAVE_LCD_COLOR + smooth_resize_bitmap(input_bmp, &output_bmp); +#else + simple_resize_bitmap(input_bmp, &output_bmp); +#endif + + /* 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; + } } output_bmp.width = input_bmp->width * 2; @@ -1526,22 +1539,34 @@ 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 selection = 0; - + bool old; MENUITEM_STRINGLIST(settings_menu, "PictureFlow Settings", NULL, "Show FPS", "Spacing", "Center margin", "Number of slides", "Zoom", - "Rebuild cache"); + "Show album titles", "Resize Covers", "Rebuild cache"); do { selection=rb->do_menu(&settings_menu,&selection, NULL, false); switch(selection) { case 0: - rb->set_bool("Show FPS", &show_fps); + rb->set_bool("Show FPS", &(config.show_fps)); break; case 1: @@ -1568,13 +1593,23 @@ break; case 4: - rb->set_int("Number of slides", "", 1, &(config.zoom), + rb->set_int("Zoom", "", 1, &(config.zoom), NULL, 1, 10, 300, NULL ); recalc_table(); reset_slides(); break; - case 5: + album_name_menu(); + recalc_table(); + reset_slides(); + break; + case 6: + old = config.resize; + rb->set_bool("Resize Cover", &(config.resize)); + if (old != config.resize) + rb->splash(HZ, "Please rebuild cache to apply the change"); + break; + case 7: rb->remove(CACHE_PREFIX "/ready"); rb->remove(EMPTY_SLIDE); rb->splash(HZ, "Cache will be rebuilt on next restart"); @@ -1627,11 +1662,14 @@ */ void set_default_config(void) { + config.show_fps = false; config.spacing_between_slides = 40; config.extra_spacing_for_center_slide = 0; config.show_slides = 3; config.avg_album_width = 0; config.zoom = 100; + config.resize = true; + config.show_album_name = album_name_bottom; } /** @@ -1739,8 +1777,19 @@ 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; - track_list_visible_entries = fmin( height/albumtxt_h , track_count ); + const int height = LCD_HEIGHT-albumtxt_h-8; + switch (config.show_album_name) + { + case album_name_hide: + track_list_visible_entries = fmin((LCD_HEIGHT-(config.show_fps ? + albumtxt_h * 2 : 0))/albumtxt_h, track_count); + break; + case album_name_bottom: + case album_name_top: + track_list_visible_entries = fmin((height-(config.show_fps ? + albumtxt_h * 2 : 0))/albumtxt_h, track_count); + break; + } start_index_track_list = 0; track_scroll_index = 0; track_scroll_dir = 1; @@ -1758,14 +1807,19 @@ reset_track_list(); } static int titletxt_w, titletxt_h, titletxt_y, titletxt_x, i, color; - titletxt_y = 0; int track_i; for (i=0; i < track_list_visible_entries; i++) { track_i = i+start_index_track_list; rb->lcd_getstringsize(get_track_name(track_i), &titletxt_w, &titletxt_h); + /* adjust track list a bit downwards if album title is set to + * be shown at the top OR fps show fps is enabled, but only once */ + if (i == 0) + titletxt_y = ((config.show_album_name == album_name_top || + config.show_fps) ? titletxt_h * 2 : 0); titletxt_x = (LCD_WIDTH-titletxt_w)/2; if ( track_i == selected_track ) { draw_gradient(titletxt_y, titletxt_h); + rb->lcd_set_foreground(LCD_RGBPACK(255,255,255)); if (titletxt_w > LCD_WIDTH ) { if ( titletxt_w + track_scroll_index <= LCD_WIDTH ) @@ -1841,8 +1895,8 @@ albumtxt_dir = -1; prev_center_index = center_index; } - albumtxt_y = LCD_HEIGHT-albumtxt_h-10; - + albumtxt_y = ((config.show_album_name == album_name_bottom) ? + (LCD_HEIGHT-albumtxt_h-10) : 10); if (albumtxt_w > LCD_WIDTH ) { rb->lcd_putsxy(albumtxt_x, albumtxt_y , albumtxt); if ( pf_state == pf_idle || pf_state == pf_show_tracks ) { @@ -1936,12 +1990,12 @@ step = 0; target = 0; fade = 256; - show_fps = false; recalc_table(); reset_slides(); char fpstxt[10]; + int fpstxt_w, fpstxt_h; int button; int frames = 0; @@ -1985,6 +2039,7 @@ break; } + rb->lcd_getstringsize(fpstxt, &fpstxt_w, &fpstxt_h); /* Calculate FPS */ if (current_update - last_update > update_interval) { fps = frames * HZ / (current_update - last_update); @@ -1993,13 +2048,17 @@ } /* Draw FPS */ - if (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); + /* move fps text to the bottom, when the album + titles are set to be shown at the top */ + rb->lcd_putsxy(0, (config.show_album_name == album_name_top ? + (LCD_HEIGHT-fpstxt_h) : 0), fpstxt); } - draw_album_text(); + if (config.show_album_name) /* Don't draw when album names are hidden */ + draw_album_text(); /* Copy offscreen buffer to LCD and give time to other threads */ @@ -2062,7 +2121,10 @@ case PICTUREFLOW_SELECT_ALBUM: if ( pf_state == pf_idle ) + { + reset_track_list(); pf_state = pf_cover_in; + } if ( pf_state == pf_show_tracks ) pf_state = pf_cover_out; break;