Simplified img_frame_animate

This commit is contained in:
Bert Münnich 2014-09-01 20:41:27 +02:00
parent 95a7496edc
commit 2fbc21a205
4 changed files with 8 additions and 13 deletions

View file

@ -293,7 +293,7 @@ bool ci_toggle_animation(arg_t a)
if (img.multi.cnt > 0) { if (img.multi.cnt > 0) {
img.multi.animate = !img.multi.animate; img.multi.animate = !img.multi.animate;
if (img.multi.animate) { if (img.multi.animate) {
dirty = img_frame_animate(&img, true); dirty = img_frame_animate(&img);
set_timeout(animate, img.multi.frames[img.multi.sel].delay, true); set_timeout(animate, img.multi.frames[img.multi.sel].delay, true);
} else { } else {
reset_timeout(animate); reset_timeout(animate);

11
image.c
View file

@ -824,21 +824,16 @@ bool img_frame_navigate(img_t *img, int d)
return img_frame_goto(img, d); return img_frame_goto(img, d);
} }
bool img_frame_animate(img_t *img, bool restart) bool img_frame_animate(img_t *img)
{ {
if (img == NULL || img->im == NULL || img->multi.cnt == 0) if (img == NULL || img->im == NULL || img->multi.cnt == 0)
return false; return false;
if (img->multi.sel + 1 >= img->multi.cnt) { if (img->multi.sel + 1 >= img->multi.cnt)
img_frame_goto(img, 0); img_frame_goto(img, 0);
img->dirty = true; else
return true;
} else if (!restart) {
img_frame_goto(img, img->multi.sel + 1); img_frame_goto(img, img->multi.sel + 1);
img->dirty = true; img->dirty = true;
return true; return true;
} else {
return false;
}
} }

View file

@ -91,6 +91,6 @@ void img_toggle_antialias(img_t*);
bool img_change_gamma(img_t*, int); bool img_change_gamma(img_t*, int);
bool img_frame_navigate(img_t*, int); bool img_frame_navigate(img_t*, int);
bool img_frame_animate(img_t*, bool); bool img_frame_animate(img_t*);
#endif /* IMAGE_H */ #endif /* IMAGE_H */

2
main.c
View file

@ -449,7 +449,7 @@ void reset_cursor(void)
void animate(void) void animate(void)
{ {
if (img_frame_animate(&img, false)) { if (img_frame_animate(&img)) {
redraw(); redraw();
set_timeout(animate, img.multi.frames[img.multi.sel].delay, true); set_timeout(animate, img.multi.frames[img.multi.sel].delay, true);
} }