emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Alignment and images


From: Lars Magne Ingebrigtsen
Subject: Alignment and images
Date: Tue, 28 Jun 2016 15:32:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

I wanted to implement a file browser for image files, and I wanted to
display them in a grid.

But images have different widths, so I need some magic to line them up
like this:

[ ] [  ] [ ]
[ ] [ ]  [ ]
[ ] [ ]  [ ]

I want the user to be able to use normal navigation commands to traverse
the grid, so no special commands.

My first attempt was a loop like this:

      (unless (bolp)
        (insert (propertize " " 'display
                            `(space :align-to (,(* (mod i width) pixels)))
                            'intangible t)))
      (insert-image (create-image file 'imagemagick nil
                                  :max-width pixels
                                  :max-height pixels)
                    " ")

This gives me a nice grid visually, but when moving around in the grid,
every other <right> lands me on the align-to space thing, which doesn't
feel very nice.  I thought that the 'intangible should make that effect
disappear, but it didn't.  Is that a bug?  Or am I doing something
wrong?

The second attempt was to add both the image and the align-to to the
same display property.  Kinda like this:

(insert (propertize " " 'display
                        `(,(create-image file 'imagemagick nil
                                  :max-width pixels
                                  :max-height pixels)
                          :align-to (,(* (mod i width) pixels)))))

That didn't work at all, but I didn't really expect it to.  :-)

Does anybody have any thoughts on this?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]