summaryrefslogtreecommitdiff
path: root/apps/plugins/imageviewer/imageviewer.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/imageviewer/imageviewer.c')
-rw-r--r--apps/plugins/imageviewer/imageviewer.c64
1 files changed, 55 insertions, 9 deletions
diff --git a/apps/plugins/imageviewer/imageviewer.c b/apps/plugins/imageviewer/imageviewer.c
index 044c835d00..39507a1fcf 100644
--- a/apps/plugins/imageviewer/imageviewer.c
+++ b/apps/plugins/imageviewer/imageviewer.c
@@ -550,17 +550,38 @@ static void pan_view_down(struct image_info *info)
550/* interactively scroll around the image */ 550/* interactively scroll around the image */
551static int scroll_bmp(struct image_info *info) 551static int scroll_bmp(struct image_info *info)
552{ 552{
553 static long ss_timeout = 0;
554
553 int button; 555 int button;
554#if defined(IMGVIEW_ZOOM_PRE) || defined(IMGVIEW_MENU_PRE) 556#if defined(IMGVIEW_ZOOM_PRE) || defined(IMGVIEW_MENU_PRE)
555 int lastbutton = BUTTON_NONE; 557 int lastbutton = BUTTON_NONE;
556#endif 558#endif
557 559
560 if (!ss_timeout && iv_api.slideshow_enabled)
561 ss_timeout = *rb->current_tick + settings.ss_timeout * HZ;
562
558 while (true) 563 while (true)
559 { 564 {
560 if (iv_api.slideshow_enabled) 565 if (iv_api.slideshow_enabled)
561 button = rb->button_get_w_tmo(settings.ss_timeout * HZ); 566 {
567 if (info->frames_count > 1 && info->delay &&
568 settings.ss_timeout * HZ > info->delay)
569 {
570 /* animated content and delay between subsequent frames
571 * is shorter then slideshow delay
572 */
573 button = rb->button_get_w_tmo(info->delay);
574 }
575 else
576 button = rb->button_get_w_tmo(settings.ss_timeout * HZ);
577 }
562 else 578 else
563 button = rb->button_get(true); 579 {
580 if (info->frames_count > 1 && info->delay)
581 button = rb->button_get_w_tmo(info->delay);
582 else
583 button = rb->button_get(true);
584 }
564 585
565 iv_api.running_slideshow = false; 586 iv_api.running_slideshow = false;
566 587
@@ -595,9 +616,28 @@ static int scroll_bmp(struct image_info *info)
595 case BUTTON_NONE: 616 case BUTTON_NONE:
596 if (iv_api.slideshow_enabled && entries > 1) 617 if (iv_api.slideshow_enabled && entries > 1)
597 { 618 {
598 iv_api.running_slideshow = true; 619 if (info->frames_count > 1)
599 return change_filename(DIR_NEXT); 620 {
621 /* animations */
622 if (TIME_AFTER(*rb->current_tick, ss_timeout))
623 {
624 iv_api.running_slideshow = true;
625 ss_timeout = 0;
626 return change_filename(DIR_NEXT);
627 }
628 else
629 return NEXT_FRAME;
630 }
631 else
632 {
633 /* still picture */
634 iv_api.running_slideshow = true;
635 return change_filename(DIR_NEXT);
636 }
600 } 637 }
638 else
639 return NEXT_FRAME;
640
601 break; 641 break;
602 642
603#ifdef IMGVIEW_SLIDE_SHOW 643#ifdef IMGVIEW_SLIDE_SHOW
@@ -838,9 +878,11 @@ static int load_and_show(char* filename, struct image_info *info)
838 cx = info->x_size/ds/2; /* center the view */ 878 cx = info->x_size/ds/2; /* center the view */
839 cy = info->y_size/ds/2; 879 cy = info->y_size/ds/2;
840 880
881 /* used to loop through subimages in animated gifs */
882 int frame = 0;
841 do /* loop the image prepare and decoding when zoomed */ 883 do /* loop the image prepare and decoding when zoomed */
842 { 884 {
843 status = imgdec->get_image(info, ds); /* decode or fetch from cache */ 885 status = imgdec->get_image(info, frame, ds); /* decode or fetch from cache */
844 if (status == PLUGIN_ERROR) 886 if (status == PLUGIN_ERROR)
845 { 887 {
846 file_pt[curfile] = NULL; 888 file_pt[curfile] = NULL;
@@ -849,7 +891,7 @@ static int load_and_show(char* filename, struct image_info *info)
849 891
850 set_view(info, cx, cy); 892 set_view(info, cx, cy);
851 893
852 if(!iv_api.running_slideshow) 894 if(!iv_api.running_slideshow && (info->frames_count == 1))
853 { 895 {
854 rb->lcd_putsf(0, 3, "showing %dx%d", info->width, info->height); 896 rb->lcd_putsf(0, 3, "showing %dx%d", info->width, info->height);
855 rb->lcd_update(); 897 rb->lcd_update();
@@ -870,6 +912,7 @@ static int load_and_show(char* filename, struct image_info *info)
870 while (1) 912 while (1)
871 { 913 {
872 status = scroll_bmp(info); 914 status = scroll_bmp(info);
915
873 if (status == ZOOM_IN) 916 if (status == ZOOM_IN)
874 { 917 {
875 if (ds > ds_min || (imgdec->unscaled_avail && ds > 1)) 918 if (ds > ds_min || (imgdec->unscaled_avail && ds > 1))
@@ -899,16 +942,19 @@ static int load_and_show(char* filename, struct image_info *info)
899 else 942 else
900 continue; 943 continue;
901 } 944 }
945
946 /* next frame in animated content */
947 if (status == NEXT_FRAME)
948 frame = (frame + 1)%info->frames_count;
949
902 break; 950 break;
903 } 951 }
904 952
905#ifdef USEGSLIB
906 grey_show(false); /* switch off overlay */
907#endif
908 rb->lcd_clear_display(); 953 rb->lcd_clear_display();
909 } 954 }
910 while (status > PLUGIN_OTHER); 955 while (status > PLUGIN_OTHER);
911#ifdef USEGSLIB 956#ifdef USEGSLIB
957 grey_show(false); /* switch off overlay */
912 rb->lcd_update(); 958 rb->lcd_update();
913#endif 959#endif
914 return status; 960 return status;