[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ement f37423f6a0 3/5: Add: (ement-room-image-thumbnail-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ement f37423f6a0 3/5: Add: (ement-room-image-thumbnail-height, ement-room-image-thumbnail-height-min) |
Date: |
Mon, 4 Mar 2024 15:58:10 -0500 (EST) |
branch: externals/ement
commit f37423f6a093ec83cd4ccc2dfdfdea0a6c4ea114
Author: Phil Sainty <phil@catalyst.net.nz>
Commit: Phil Sainty <phil@catalyst.net.nz>
Add: (ement-room-image-thumbnail-height,
ement-room-image-thumbnail-height-min)
---
README.org | 2 ++
ement-room.el | 38 +++++++++++++++++++++++++++-----------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/README.org b/README.org
index 9b7e1f3d3e..037c9e04fa 100644
--- a/README.org
+++ b/README.org
@@ -326,6 +326,8 @@ Ement.el doesn't support encrypted rooms natively, but it
can be used transparen
+ Option ~ement-room-image-margin~ is the number of pixels of margin around
image thumbnails.
+ Option ~ement-room-image-relief~ is the number of pixels of shadow rectangle
around image thumbnails.
++ Option ~ement-room-image-thumbnail-height~ is the window body height
multiple to use when toggling full-sized images to thumbnails (by default, 0.2).
++ Option ~ement-room-image-thumbnail-height-min~ is the minimum pixel height
for thumbnail images (by default, 30 pixels).
*Changes*
+ Improve prompt used when viewing a room that is not joined.
([[https://github.com/alphapapa/ement.el/issues/241][#241]]. Thanks to
[[https://github.com/phil-s][Phil Sainty]].)
diff --git a/ement-room.el b/ement-room.el
index ab7764a00e..d2d742f64f 100644
--- a/ement-room.el
+++ b/ement-room.el
@@ -4907,12 +4907,23 @@ STRUCT should be an `ement-room-membership-events'
struct."
(when (and value (display-images-p))
(display-warning 'ement "This Emacs was not built with
ImageMagick support, nor does it support Cairo/XRender scaling, so images can't
be displayed in Ement")))))
-(defcustom ement-room-image-initial-height 0.2
+(defcustom ement-room-image-thumbnail-height 0.2
+ "Scale thumbnail images to this multiple of the window body height.
+Should be a number between 0 and 1.
+See also `ement-room-image-thumbnail-height-min'."
+ :type '(number :tag "Multiple of the window body height"))
+
+(defcustom ement-room-image-thumbnail-height-min 30
+ "Minimum height in pixels when scaling thumbnail images.
+See also `ement-room-image-thumbnail-height'."
+ :type 'natnum)
+
+(defcustom ement-room-image-initial-height ement-room-image-thumbnail-height
"Limit images' initial display height.
If a number, it should be no larger than 1 (because Emacs can't
display images larger than the window body height)."
- :type '(choice (const :tag "Use full window width" nil)
- (number :tag "Limit to this multiple of the window body
height")))
+ :type '(choice (const :tag "Use full window height (or width)" nil)
+ (number :tag "Multiple of the window body height")))
(defcustom ement-room-image-margin 5
"How many pixels to add as an extra margin around the image."
@@ -4937,9 +4948,10 @@ height."
(defun ement-room-image-scale (pos)
"Toggle scale of image at POS.
-Scale image to fit within the window's body. If image is already
-fit to the window, reduce its max-height to 10% of the window's
-height."
+Scale image to fit the window body. If the image already fits
+the window body, reduce its max-height in accordance with user
+options `ement-room-image-thumbnail-height' and
+`ement-room-image-thumbnail-height-min'."
(interactive "d")
(pcase-let* ((image (get-text-property pos 'display))
(max-height (image-property image :max-height))
@@ -4953,7 +4965,10 @@ height."
;; See <https://github.com/alphapapa/ement.el/issues/39>.
(new-height (if use-window-body-size
window-height
- (/ window-height 10))))
+ (max ement-room-image-thumbnail-height-min
+ ;; Emacs doesn't like floats as the
max-height.
+ (truncate (* window-height
+
ement-room-image-thumbnail-height))))))
(when (fboundp 'imagemagick-types)
;; Only do this when ImageMagick is supported.
;; FIXME: When requiring Emacs 27+, remove this (I guess?).
@@ -5034,10 +5049,11 @@ show it in the buffer."
;; Calculate max image display size.
(cond (ement-room-image-initial-height
;; Use configured value.
- (setf max-height (truncate
- ;; Emacs doesn't like floats as the
max-height.
- (* (window-body-height buffer-window t)
- ement-room-image-initial-height))
+ (setf max-height (max
ement-room-image-thumbnail-height-min
+ ;; Emacs doesn't like floats as the
max-height.
+ (truncate
+ (* (window-body-height
buffer-window t)
+
ement-room-image-initial-height)))
max-width (window-body-width buffer-window t)))
(buffer-window
;; Buffer displayed: use window size.
- [elpa] externals/ement updated (e25cab9625 -> e4512f410d), ELPA Syncer, 2024/03/04
- [elpa] externals/ement 15f7d3e2d9 1/5: Tidy: (ement-room-image-scale) Refactoring, ELPA Syncer, 2024/03/04
- [elpa] externals/ement ad0ba4d49d 2/5: Fix: (ement-room-image-scale) Prevent scrolling issues with images, ELPA Syncer, 2024/03/04
- [elpa] externals/ement f37423f6a0 3/5: Add: (ement-room-image-thumbnail-height, ement-room-image-thumbnail-height-min),
ELPA Syncer <=
- [elpa] externals/ement 325be47e50 4/5: Merge: Image scaling improvements, ELPA Syncer, 2024/03/04
- [elpa] externals/ement e4512f410d 5/5: Docs: Fix readme, ELPA Syncer, 2024/03/04