diff options
| author | Glenn Morris | 2013-02-15 19:39:12 -0800 |
|---|---|---|
| committer | Glenn Morris | 2013-02-15 19:39:12 -0800 |
| commit | 99e619b61769c2cd226777a1352e27463d75bc07 (patch) | |
| tree | 3582f624ce9dfd47b9e5e8baf3335868fb8ed1c8 | |
| parent | c0211c4e370ec5fb46b90764235282d098ca21c1 (diff) | |
| download | emacs-99e619b61769c2cd226777a1352e27463d75bc07.tar.gz emacs-99e619b61769c2cd226777a1352e27463d75bc07.zip | |
Add variables for default/minimum animated image frame delay
* lisp/image.el (image-default-frame-delay): New variable.
(image-animated-p): Use image-default-frame-delay.
(image-minimum-frame-delay): New constant.
(image-animate-timeout): Use image-minimum-frame-delay.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/image.el | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e71e3d6752e..072521f1b44 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2013-02-16 Glenn Morris <rgm@gnu.org> | 1 | 2013-02-16 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * image.el (image-default-frame-delay): New variable. | ||
| 4 | (image-animated-p): Use image-default-frame-delay. | ||
| 5 | (image-minimum-frame-delay): New constant. | ||
| 6 | (image-animate-timeout): Use image-minimum-frame-delay. | ||
| 7 | |||
| 3 | * image.el (image-nth-frame): New, split from image-animate-timeout. | 8 | * image.el (image-nth-frame): New, split from image-animate-timeout. |
| 4 | (image-animate-timeout): Use image-nth-frame. | 9 | (image-animate-timeout): Use image-nth-frame. |
| 5 | * image-mode.el (image-goto-frame, image-next-frame) | 10 | * image-mode.el (image-goto-frame, image-next-frame) |
diff --git a/lisp/image.el b/lisp/image.el index b03a634d060..22c6bdf4207 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -609,6 +609,10 @@ Example: | |||
| 609 | (defconst image-animated-types '(gif) | 609 | (defconst image-animated-types '(gif) |
| 610 | "List of supported animated image types.") | 610 | "List of supported animated image types.") |
| 611 | 611 | ||
| 612 | (defvar image-default-frame-delay 0.1 | ||
| 613 | "Default interval in seconds between frames of a multi-frame image. | ||
| 614 | Only used if the image does not specify a value.") | ||
| 615 | |||
| 612 | (defun image-animated-p (image) | 616 | (defun image-animated-p (image) |
| 613 | "Return non-nil if IMAGE can be animated. | 617 | "Return non-nil if IMAGE can be animated. |
| 614 | To be capable of being animated, an image must be of a type | 618 | To be capable of being animated, an image must be of a type |
| @@ -623,7 +627,7 @@ seconds until the next sub-image should be displayed." | |||
| 623 | (images (plist-get metadata 'count)) | 627 | (images (plist-get metadata 'count)) |
| 624 | (delay (plist-get metadata 'delay))) | 628 | (delay (plist-get metadata 'delay))) |
| 625 | (when (and images (> images 1) (numberp delay)) | 629 | (when (and images (> images 1) (numberp delay)) |
| 626 | (if (< delay 0) (setq delay 0.1)) | 630 | (if (< delay 0) (setq delay image-default-frame-delay)) |
| 627 | (cons images delay)))))) | 631 | (cons images delay)))))) |
| 628 | 632 | ||
| 629 | ;; "Destructively"? | 633 | ;; "Destructively"? |
| @@ -657,6 +661,9 @@ number, play until that number of seconds has elapsed." | |||
| 657 | (setq timer nil))) | 661 | (setq timer nil))) |
| 658 | timer)) | 662 | timer)) |
| 659 | 663 | ||
| 664 | (defconst image-minimum-frame-delay 0.01 | ||
| 665 | "Minimum interval in seconds between frames of an animated image.") | ||
| 666 | |||
| 660 | (defvar-local image-current-frame nil | 667 | (defvar-local image-current-frame nil |
| 661 | "The frame index of the current animated image.") | 668 | "The frame index of the current animated image.") |
| 662 | 669 | ||
| @@ -684,7 +691,7 @@ TIME-ELAPSED is the total time that has elapsed since | |||
| 684 | LIMIT determines when to stop. If t, loop forever. If nil, stop | 691 | LIMIT determines when to stop. If t, loop forever. If nil, stop |
| 685 | after displaying the last animation frame. Otherwise, stop | 692 | after displaying the last animation frame. Otherwise, stop |
| 686 | after LIMIT seconds have elapsed. | 693 | after LIMIT seconds have elapsed. |
| 687 | The minimum delay between successive frames is 0.01s." | 694 | The minimum delay between successive frames is `image-minimum-frame-delay'." |
| 688 | (image-nth-frame image n t) | 695 | (image-nth-frame image n t) |
| 689 | (setq n (1+ n)) | 696 | (setq n (1+ n)) |
| 690 | (let* ((time (float-time)) | 697 | (let* ((time (float-time)) |
| @@ -692,7 +699,7 @@ The minimum delay between successive frames is 0.01s." | |||
| 692 | ;; Subtract off the time we took to load the image from the | 699 | ;; Subtract off the time we took to load the image from the |
| 693 | ;; stated delay time. | 700 | ;; stated delay time. |
| 694 | (delay (max (+ (cdr animation) time (- (float-time))) | 701 | (delay (max (+ (cdr animation) time (- (float-time))) |
| 695 | 0.01)) | 702 | image-minimum-frame-delay)) |
| 696 | done) | 703 | done) |
| 697 | (if (>= n count) | 704 | (if (>= n count) |
| 698 | (if limit | 705 | (if limit |