diff options
author | Bert <ber.t@gmx.com> | 2011-08-19 18:46:17 +0200 |
---|---|---|
committer | Bert <ber.t@gmx.com> | 2011-08-19 18:46:17 +0200 |
commit | bb577d274dbd9981a726092a504466bc9b5c9bdb (patch) | |
tree | f3bbf611ddd904f80dfe20bb4d1171d1dc45ed3d | |
parent | 8b3ae5027e9490bd7edfeea3d3cd2fbc5ec4beaf (diff) |
Added command to toggle gif animations
-rw-r--r-- | commands.c | 22 | ||||
-rw-r--r-- | commands.h | 1 | ||||
-rw-r--r-- | config.h | 7 | ||||
-rw-r--r-- | image.c | 18 | ||||
-rw-r--r-- | main.c | 8 |
5 files changed, 38 insertions, 18 deletions
@@ -41,7 +41,7 @@ extern int filecnt, fileidx; extern int timo_cursor; extern int timo_redraw; -extern int timo_delay; +extern int timo_adelay; int it_quit(arg_t a) { cleanup(); @@ -149,7 +149,24 @@ int it_last(arg_t a) { } int i_navigate_frame(arg_t a) { - return img_frame_navigate(&img, (int) a); + if (mode == MODE_IMAGE && !img.multi.animate) + return img_frame_navigate(&img, (int) a); + else + return 0; +} + +int i_toggle_animation(arg_t a) { + if (mode != MODE_IMAGE) + return 0; + + if (img.multi.animate) { + timo_adelay = 0; + img.multi.animate = 0; + return 0; + } else { + timo_adelay = img_frame_animate(&img, 1); + return 1; + } } int it_move(arg_t a) { @@ -239,6 +256,7 @@ int i_zoom(arg_t a) { if (mode != MODE_IMAGE) return 0; + if (scale > 0) return img_zoom_in(&img, &win); else if (scale < 0) @@ -48,6 +48,7 @@ int i_navigate(arg_t); int it_first(arg_t); int it_last(arg_t); int i_navigate_frame(arg_t); +int i_toggle_animation(arg_t); int it_move(arg_t); int i_pan_screen(arg_t); int i_pan_edge(arg_t); @@ -29,7 +29,7 @@ static const float zoom_levels[] = { 100.0, 150.0, 200.0, 400.0, 800.0 }; -/* default settings for gif images: */ +/* default settings for multi-frame gif images: */ enum { GIF_DELAY = 100, /* delay time (in ms) */ GIF_AUTOPLAY = 1, /* autoplay when loaded [0/1] */ @@ -64,8 +64,9 @@ static const keymap_t keys[] = { { False, XK_g, it_first, (arg_t) None }, { False, XK_G, it_last, (arg_t) None }, - { False, XK_N, i_navigate_frame, (arg_t) +1 }, - { False, XK_P, i_navigate_frame, (arg_t) -1 }, + { True, XK_n, i_navigate_frame, (arg_t) +1 }, + { True, XK_p, i_navigate_frame, (arg_t) -1 }, + { True, XK_space, i_toggle_animation, (arg_t) None }, { False, XK_h, it_move, (arg_t) DIR_LEFT }, { False, XK_Left, it_move, (arg_t) DIR_LEFT }, @@ -596,22 +596,18 @@ int img_frame_animate(img_t *img, int restart) { if (!img || !img->multi.cnt) return 0; - if (!img->multi.animate && !restart) - return 0; - - if (restart) { - img_frame_goto(img, 0); - img->multi.animate = 1; - } else if (img->multi.sel + 1 >= img->multi.cnt) { - if (!GIF_LOOP) { + if (img->multi.sel + 1 >= img->multi.cnt) { + if (restart || GIF_LOOP) { + img_frame_goto(img, 0); + } else { img->multi.animate = 0; return 0; - } else { - img_frame_goto(img, 0); } - } else { + } else if (!restart) { img_frame_goto(img, img->multi.sel + 1); } + img->multi.animate = 1; + return img->multi.frames[img->multi.sel].delay; } @@ -142,8 +142,12 @@ void load_image(int new) { else filesize = 0; - if (img.multi.cnt && img.multi.animate) - timo_adelay = img.multi.frames[img.multi.sel].delay; + if (img.multi.cnt) { + if (img.multi.animate) + timo_adelay = img.multi.frames[img.multi.sel].delay; + else + timo_adelay = 0; + } } void update_title() { |