unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Retain image properties after image-mode commands
@ 2024-03-04  6:07 Joseph Turner
  2024-03-05 16:34 ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Joseph Turner @ 2024-03-04  6:07 UTC (permalink / raw)
  To: Emacs Devel Mailing List

Hello!

I would like to use `image-mode' commands such as
`image-transform-set-scale' on non-file-backed images which have image
properties.  That command internally calls `image-toggle-display-image',
which recontructs the image with `create-image', throwing away any
existing image properties.

A concrete example:

Evalute the following form to render an SVG image in an Emacs buffer:

(with-current-buffer (get-buffer-create "*image-properties-test*")
  (let ((svg-string "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.43.0 (0)\n -->\n<!-- Title: orggraphview Pages: 1 -->\n<svg width=\"128pt\" height=\"128pt\"\n viewBox=\"0.00 0.00 127.59 127.59\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 123.59)\">\n<title>orggraphview</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-123.59 123.59,-123.59 123.59,4 -4,4\"/>\n<!-- a -->\n<g id=\"node1\" class=\"node\">\n<title>a</title>\n<g id=\"a_node1\"><a xlink:href=\"1\" xlink:title=\"Hover me!\">\n<ellipse fill=\"none\" stroke=\"black\" cx=\"59.79\" cy=\"-59.79\" rx=\"59.59\" ry=\"59.59\"/>\n<text text-anchor=\"middle\" x=\"59.79\" y=\"-56.09\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">Hover me!</text>\n</a>\n</g>\n</g>\n</g>\n</svg>\n")
        (map '(((circle (85 . 85) . 80) "1" (help-echo "Surprise!"))))
        (inhibit-read-only t))
    (fundamental-mode)
    (erase-buffer)
    (insert-image (create-image svg-string 'svg t :map map) svg-string)
    (image-mode)
    (pop-to-buffer (current-buffer))))

Mouse over the circle in the center of the SVG to see the tooltip.

Then zoom in on the image: Interactively run `image-transform-set-scale'
by pressing "s s" then type the number 2 and press RET.

The image gets bigger, but now mousing over the circle has no effect.

How can I keep the mouse-over effect (the image :map property) after
running `image-mode' commands which reconstruct the image?

Thank you!!

Joseph



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-08  7:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-04  6:07 Retain image properties after image-mode commands Joseph Turner
2024-03-05 16:34 ` Juri Linkov
2024-03-05 17:10   ` Stephen Berman
2024-03-06  7:51     ` Joseph Turner
2024-03-08  7:33       ` Joseph Turner

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).