From 6a0fa2507cc933cfb54fdf4d80c094bfcdf782cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Sat, 4 Jan 2014 18:38:40 +0100 Subject: Slideshow mode is back, in a simplified version --- main.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 5789ff0..8094265 100644 --- a/main.c +++ b/main.c @@ -68,6 +68,7 @@ typedef struct { void redraw(void); void reset_cursor(void); void animate(void); +void slideshow(void); void clear_resize(void); appmode_t mode; @@ -96,9 +97,10 @@ struct { } info; timeout_t timeouts[] = { - { { 0, 0 }, false, redraw }, + { { 0, 0 }, false, redraw }, { { 0, 0 }, false, reset_cursor }, - { { 0, 0 }, false, animate }, + { { 0, 0 }, false, animate }, + { { 0, 0 }, false, slideshow }, { { 0, 0 }, false, clear_resize }, }; @@ -304,6 +306,7 @@ void load_image(int new) return; win_set_cursor(&win, CURSOR_WATCH); + reset_timeout(slideshow); if (new != fileidx) alternate = fileidx; @@ -363,6 +366,8 @@ void update_info(void) } } else { n = snprintf(rt, rlen, "%s", mark); + if (img.ss.on) + n += snprintf(rt + n, rlen - n, "%ds | ", img.ss.delay); if (img.gamma != 0) n += snprintf(rt + n, rlen - n, "G%+d | ", img.gamma); n += snprintf(rt + n, rlen - n, "%3d%% | ", (int) (img.zoom * 100.0)); @@ -389,10 +394,18 @@ void update_info(void) void redraw(void) { - if (mode == MODE_IMAGE) + int t; + + if (mode == MODE_IMAGE) { img_render(&img); - else + if (img.ss.on) { + t = img.ss.delay * 1000; + t = img.multi.animate ? MAX(t, img.multi.length) : t; + set_timeout(slideshow, t, false); + } + } else { tns_render(&tns); + } update_info(); win_draw(&win); reset_timeout(redraw); @@ -429,6 +442,12 @@ void animate(void) } } +void slideshow(void) +{ + load_image(fileidx + 1 < filecnt ? fileidx + 1 : 0); + redraw(); +} + void clear_resize(void) { resized = false; -- cgit v1.2.3