From f2ade4c627cd8347b11c7909f3ba9e9da82ed6c8 Mon Sep 17 00:00:00 2001 From: vindarel Date: Fri, 21 Jul 2023 23:58:31 +0200 Subject: [PATCH 1/4] image-buffer: add help on ? and C-h --- frontends/sdl2/image-buffer.lisp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontends/sdl2/image-buffer.lisp b/frontends/sdl2/image-buffer.lisp index e1b512276..53a7e66f4 100644 --- a/frontends/sdl2/image-buffer.lisp +++ b/frontends/sdl2/image-buffer.lisp @@ -33,6 +33,8 @@ (define-key *image-viewer-keymap* "C-+" 'image-zoom-in) (define-key *image-viewer-keymap* "C--" 'image-zoom-out) (define-key *image-viewer-keymap* "C-0" 'image-zoom-reset) +(define-key *image-viewer-keymap* "?" 'image-zoom-help) +(define-key *image-viewer-keymap* "C-h" 'image-zoom-help) (defmethod render :before (texture window (buffer image-buffer)) (sdl2:set-render-target (current-renderer) texture) @@ -76,6 +78,13 @@ (define-command image-zoom-reset () () (reset-buffer-scale (current-buffer))) +(define-command image-zoom-help () () + (with-pop-up-typeout-window (s (make-buffer "*image-zoom-help*") :erase t) + (format s "Open an image file in Lem and use these keys to zoom in and out:~&") + (format s "Zoom in: C - + (M-x image-zoom-in)~&") + (format s "Zoom out: C - - (M-x image-zoom-out)~&") + (format s "Zoom reset: C - 0 (M-x image-zoom-reset)~&"))) + (defclass sdl2-find-file-executor (lem:find-file-executor) ()) (defmethod lem:execute-find-file ((executor sdl2-find-file-executor) mode pathname) From 78f998dfadf7ef687b86820a2dfa0bee973f031d Mon Sep 17 00:00:00 2001 From: vindarel Date: Sat, 22 Jul 2023 00:17:20 +0200 Subject: [PATCH 2/4] image-buffer: add +, - and 0 keys --- frontends/sdl2/image-buffer.lisp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontends/sdl2/image-buffer.lisp b/frontends/sdl2/image-buffer.lisp index 53a7e66f4..78fc107f5 100644 --- a/frontends/sdl2/image-buffer.lisp +++ b/frontends/sdl2/image-buffer.lisp @@ -31,8 +31,11 @@ (lem-sdl2::image-height image)))) (define-key *image-viewer-keymap* "C-+" 'image-zoom-in) +(define-key *image-viewer-keymap* "+" 'image-zoom-in) (define-key *image-viewer-keymap* "C--" 'image-zoom-out) +(define-key *image-viewer-keymap* "-" 'image-zoom-out) (define-key *image-viewer-keymap* "C-0" 'image-zoom-reset) +(define-key *image-viewer-keymap* "0" 'image-zoom-reset) (define-key *image-viewer-keymap* "?" 'image-zoom-help) (define-key *image-viewer-keymap* "C-h" 'image-zoom-help) @@ -81,9 +84,9 @@ (define-command image-zoom-help () () (with-pop-up-typeout-window (s (make-buffer "*image-zoom-help*") :erase t) (format s "Open an image file in Lem and use these keys to zoom in and out:~&") - (format s "Zoom in: C - + (M-x image-zoom-in)~&") - (format s "Zoom out: C - - (M-x image-zoom-out)~&") - (format s "Zoom reset: C - 0 (M-x image-zoom-reset)~&"))) + (format s "Zoom in: + or C - + (M-x image-zoom-in)~&") + (format s "Zoom out: - or C - - (M-x image-zoom-out)~&") + (format s "Zoom reset: 0 or C - 0 (M-x image-zoom-reset)~&"))) (defclass sdl2-find-file-executor (lem:find-file-executor) ()) From 0978bef72560ef8c9f4833b82ca3d6df2181a16a Mon Sep 17 00:00:00 2001 From: vindarel Date: Sat, 22 Jul 2023 01:02:58 +0200 Subject: [PATCH 3/4] image: show scaling indicator next to dimensions as in 2000x1200 (x1.00) --- frontends/sdl2/image-buffer.lisp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontends/sdl2/image-buffer.lisp b/frontends/sdl2/image-buffer.lisp index 78fc107f5..b5b4d4c94 100644 --- a/frontends/sdl2/image-buffer.lisp +++ b/frontends/sdl2/image-buffer.lisp @@ -26,9 +26,10 @@ (defun image-information (window) (let ((image (buffer-image (window-buffer window)))) - (format nil " ~Dx~D" + (format nil " ~Dx~D (x~,2F)" (lem-sdl2::image-width image) - (lem-sdl2::image-height image)))) + (lem-sdl2::image-height image) + (buffer-scaling (window-buffer window))))) (define-key *image-viewer-keymap* "C-+" 'image-zoom-in) (define-key *image-viewer-keymap* "+" 'image-zoom-in) From e7f7cc541fa93984cc919a139ccebe46e6c43f19 Mon Sep 17 00:00:00 2001 From: vindarel Date: Sat, 22 Jul 2023 03:12:24 +0200 Subject: [PATCH 4/4] image viewer: set the image directory --- frontends/sdl2/image-buffer.lisp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontends/sdl2/image-buffer.lisp b/frontends/sdl2/image-buffer.lisp index b5b4d4c94..1f8d68ea6 100644 --- a/frontends/sdl2/image-buffer.lisp +++ b/frontends/sdl2/image-buffer.lisp @@ -101,7 +101,9 @@ (defun open-image-buffer (pathname) (let ((image (load-image pathname)) - (buffer (lem:make-buffer (file-namestring pathname)))) + (buffer (lem:make-buffer (file-namestring pathname) + :directory (expand-file-name + (namestring (uiop:pathname-directory-pathname pathname)))))) (change-class buffer 'image-buffer) (setf (buffer-image buffer) image) (setf (buffer-scaling buffer) 1)