diff options
author | Glenn Morris <rgm@gnu.org> | 2013-02-16 11:56:50 -0800 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2013-02-16 11:56:50 -0800 |
commit | ed8d7fcaa2965216d44388fd00a757c8d55e7395 (patch) | |
tree | 8e04c2457944d8e829c1eacd5eadcf68d0ad0ba6 /lisp/image.el | |
parent | 783b7b7551b197fdcfd384ac4a3d93302a073eaf (diff) | |
download | emacs-ed8d7fcaa2965216d44388fd00a757c8d55e7395.tar.gz |
Generalize "animated" images to "multi-frame" images
* lisp/image.el (image-animated-types): Remove.
(image-multi-frame-p): Rename from image-animated-p, and generalize.
(image-animated-p): Make obsolete alias.
(image-animate, image-nth-frame, image-animate-timeout):
Use image-multi-frame-p.
(image-animate-timeout): If no delay, use image-default-frame-delay.
* lisp/image-mode.el (image-mode, image-toggle-animation):
Use image-multi-frame-p.
(image-mode): Adjust startup message for a multi-frame image.
* lisp/gnus/shr.el (shr-put-image): Only animate images that specify a delay.
This is consistent with the old image-animated-p behavior.
* etc/NEWS: Add placeholder for this.
Fixes: debbugs:10739
Diffstat (limited to 'lisp/image.el')
-rw-r--r-- | lisp/image.el | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/lisp/image.el b/lisp/image.el index 22c6bdf4207..b91d136443d 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -606,29 +606,25 @@ Example: ;;; Animated image API -(defconst image-animated-types '(gif) - "List of supported animated image types.") - (defvar image-default-frame-delay 0.1 "Default interval in seconds between frames of a multi-frame image. Only used if the image does not specify a value.") -(defun image-animated-p (image) - "Return non-nil if IMAGE can be animated. -To be capable of being animated, an image must be of a type -listed in `image-animated-types', and contain more than one -sub-image, with a specified animation delay. The actual return -value is a cons (NIMAGES . DELAY), where NIMAGES is the number -of sub-images in the animated image and DELAY is the delay in -seconds until the next sub-image should be displayed." - (cond - ((memq (plist-get (cdr image) :type) image-animated-types) - (let* ((metadata (image-metadata image)) - (images (plist-get metadata 'count)) - (delay (plist-get metadata 'delay))) - (when (and images (> images 1) (numberp delay)) - (if (< delay 0) (setq delay image-default-frame-delay)) - (cons images delay)))))) +(defun image-multi-frame-p (image) + "Return non-nil if IMAGE contains more than one frame. +The actual return value is a cons (NIMAGES . DELAY), where NIMAGES is +the number of frames (or sub-images) in the image and DELAY is the delay +in seconds that the image specifies between each frame. DELAY may be nil, +in which case you might want to use `image-default-frame-delay'." + (let* ((metadata (image-metadata image)) + (images (plist-get metadata 'count)) + (delay (plist-get metadata 'delay))) + (when (and images (> images 1)) + (if (or (not (numberp delay)) (< delay 0)) + (setq delay image-default-frame-delay)) + (cons images delay)))) + +(define-obsolete-function-alias 'image-animated-p 'image-multi-frame-p "24.4") ;; "Destructively"? (defun image-animate (image &optional index limit) @@ -639,7 +635,7 @@ With optional INDEX, begin animating from that animation frame. LIMIT specifies how long to animate the image. If omitted or nil, play the animation until the end. If t, loop forever. If a number, play until that number of seconds has elapsed." - (let ((animation (image-animated-p image)) + (let ((animation (image-multi-frame-p image)) timer) (when animation (if (setq timer (image-animate-timer image)) @@ -673,13 +669,13 @@ Frames are indexed from 0. Optional argument NOCHECK non-nil means do not check N is within the range of frames present in the image." (unless nocheck (if (< n 0) (setq n 0) - (setq n (min n (1- (car (image-animated-p image))))))) + (setq n (min n (1- (car (image-multi-frame-p image))))))) (plist-put (cdr image) :index n) (setq image-current-frame n) (force-window-update)) ;; FIXME? The delay may not be the same for different sub-images, -;; hence we need to call image-animated-p to return it. +;; hence we need to call image-multi-frame-p to return it. ;; But it also returns count, so why do we bother passing that as an ;; argument? (defun image-animate-timeout (image n count time-elapsed limit) @@ -695,10 +691,11 @@ The minimum delay between successive frames is `image-minimum-frame-delay'." (image-nth-frame image n t) (setq n (1+ n)) (let* ((time (float-time)) - (animation (image-animated-p image)) + (animation (image-multi-frame-p image)) ;; Subtract off the time we took to load the image from the ;; stated delay time. - (delay (max (+ (cdr animation) time (- (float-time))) + (delay (max (+ (or (cdr animation) image-default-frame-delay) + time (- (float-time))) image-minimum-frame-delay)) done) (if (>= n count) |