sghpjuikit / player

Audio player and management application.
22 stars 2 forks source link

DirViewer - preview icons for directories #122

Closed xeruf closed 5 years ago

xeruf commented 5 years ago

It would be nice if folders also had preview icons. On Windows it could be determined using a ".desktop"-file if it exists, otherwise look through the content and grab up to 4 icons of files in it and display them in a mini grid, that is how it is often done. There should probably be an option to disable it though due to the high I/O involved. One should also consider caching icons.

sghpjuikit commented 5 years ago

Feature has been implemented. Put an image cover.* file in a directory. Supported are all the formats imageio supports, so all basic formats, including stuff like animated gifs, psd or even krita files.

I will improve the documentation.

Closing as delivered.

xeruf commented 5 years ago

This is not what I am talking about. The feature you mentioned does make sense for a player, but this is a multiapplication and thus should also support other cases. For example if you have a gallery, there is no "cover"-image. Instead, if that does not exist, I would like it to take the first 4 icons it can get from files in the folder and show them, sort of how my file browser does it: image

sghpjuikit commented 5 years ago

Thats quite a request and it involves several nasty problems, from top of my head:

And worst of all: the code for displaying items in that grid is very complicated, particularly the image stuff. It's also old, its Java, its immensely fragile, it has some bugs/misbehavior. So I will need to do some research on how to approach this.

sghpjuikit commented 5 years ago

Im more interested in you 'use case'. What are you trying to accomplish?

xeruf commented 5 years ago

Use-case: If I am to use this application for day-to-day stuff, I want it to be useful for file navigation, and that involves identifying directories at a glance without reading the text.

xeruf commented 5 years ago

1) Cache it in tmp, if you do it. Don't pollute directories. But it was merely an idea 2) manipulation? 3) Doesn't the way my file explorer (Dolphin) does it give you an idea? It looks nice imo. Displaying just one image often does not give you a sufficient overview of the content. 4) Yes, I mean you just take the existing icon from file extraction algorithm, apply it to some files in the directory and take the first few you get, regardless of the file type. 5) Ooof. Nobody complains about it in Dolphin either. The only reason to have customization here is performance imho.

sghpjuikit commented 5 years ago

0 Would displaying first image file as the directory's cover help your use case? 1 Yes slightly better. Still, caching is... one of the sacred rules of programming is to not code your own caching... I found that the hard way (in this project). 2 Yes you need to compose a final image out of multiple images. Lots of buffers, since Java has I think 3 buffers for image or something. Add to that scaling and conversion from swing to fx image and you are looking at a disaster. The memory goes poof. 3 It looks okey, but I'm looking at an implementation complexity trade off.

xeruf commented 5 years ago

0) It would be a start 2) I was thinking about the directories simply having a mini-grid in them, that displays up to 4 images. That way there is no composing or conversion.

sghpjuikit commented 5 years ago

0 Ok I will play around with the code 1 Composition doesnt mean the images must overlap, but that there are source images and another result image and an algorithm for composing them into one must be devised. The swing->javafx conversion is always necessary as javafx has nothing to do with java image facilities that image.io uses. Very unfortunate. Needless to say the loading code is already complicated, due to attempting to produce great scaling result and fast/efficient image reading.

xeruf commented 5 years ago

an algorithm for composing them into one must be devised

No! As I said, just display a mini-grid of individual images within the directory preview thingy.

sghpjuikit commented 5 years ago

I see.

sghpjuikit commented 5 years ago

I realized this has additional complication. Because the files in the directory may inherit its parent's cover, they must be prevented from inheriting a 'composite' cover. This really is going in a direction of customization being very necessary.

sghpjuikit commented 5 years ago

I'll start looking into this soon. No promises if the feature will make it.

sghpjuikit commented 5 years ago

I have came up with an idea how to implement this. Detail at the bottom.

displaying first image file...

As mentioned, images should not be treated special, say you have a directory of video files. It would be reasonable to expect the video file thumbnails to be used as the directory thumbnail.

just display a mini-grid...

You are suggesting the directory thumbnail to not be an image but JavaFX layout. That requires having separate thumbnail graphics implementations based on some properties of the file resource. Not good.

files in the directory may inherit its parent's cover, they must be prevented from inheriting a 'composite' cover

Not a problem. Multi-file thumbnail of a directory would not have a cover file, only cover image (or something else). Child items only inherit parent cover file.

The only reason to have customization here is performance imho.

I disagree. For example in my uses, I need/want thumbnail for directories with no explicit cover.image empty.

Implementation notes:

sghpjuikit commented 5 years ago

I implemented a working prototype.

sghpjuikit commented 5 years ago

Implemented in b14361b.

New features: