|
TachyonUI 0.1.0
High-performance UI for building tools.
|
A file's thumbnail, registered with a text system as a picture icon (ITextSystem::RegisterIconFromPixels). More...
#include <gui_controls/gui_file_thumbnails.h>
Classes | |
| struct | Picture |
| RGBA pixels, rows from the top, straight alpha. More... | |
Public Types | |
| using | Reader = std::function<bool(const std::filesystem::path& file, uint32_t pixels, Picture& picture)> |
| Reads file's thumbnail, at most pixels square, keeping its shape. | |
Public Member Functions | |
| FileThumbnails (ITextSystem &textSystem, size_t capacity=512, Reader reader=ShellReader(), std::chrono::milliseconds inUse=std::chrono::milliseconds(500)) | |
| ~FileThumbnails () | |
| FileThumbnails (const FileThumbnails &)=delete | |
| FileThumbnails & | operator= (const FileThumbnails &)=delete |
| IconID | Get (const std::filesystem::path &file, std::filesystem::file_time_type modified, uint32_t pixels) |
| The thumbnail of the file file on the disk, last written at modified, at most pixels square (the icon's size on screen, in pixels). | |
| size_t | Count () const |
| How many are kept, read or still being read. | |
| size_t | Reading () |
| How many of those are still being read. | |
Static Public Member Functions | |
| static std::string | Key (const std::filesystem::path &file, std::filesystem::file_time_type modified, uint32_t pixels) |
| What a thumbnail is kept by: the same for the same file, time and size. | |
| static Reader | ShellReader () |
| The Windows shell's thumbnails (IShellItemImageFactory, thumbnails only, never the type's icon); an empty Reader elsewhere. | |
A file's thumbnail, registered with a text system as a picture icon (ITextSystem::RegisterIconFromPixels).
Thumbnails are read on a thread of their own, so Get gives IconID::Invalid until one is ready, and for a file without one: a view shows the file's type icon (FileIcons) meanwhile. Read from the Windows shell (what Explorer shows); elsewhere there are none.
Kept by path, modification time and size, so a file that changed is read again. At most capacity are kept: past that, the one asked for longest ago is let go, and its icon unregistered (ITextSystem::UnregisterIcon). One asked for within inUse (on screen still) isn't let go: a file past those gets no thumbnail until one is, rather than all of them being read over and over. Destroy it before the text system.
| using tachyon::FileThumbnails::Reader = std::function<bool(const std::filesystem::path& file, uint32_t pixels, Picture& picture)> |
Reads file's thumbnail, at most pixels square, keeping its shape.
False when it has none. Called on the reading thread.
|
explicit |
| tachyon::FileThumbnails::~FileThumbnails | ( | ) |
|
delete |
|
delete |
| IconID tachyon::FileThumbnails::Get | ( | const std::filesystem::path & | file, |
| std::filesystem::file_time_type | modified, | ||
| uint32_t | pixels ) |
The thumbnail of the file file on the disk, last written at modified, at most pixels square (the icon's size on screen, in pixels).
Starts reading it the first time; IconID::Invalid until it's ready, for a file without one, and for an empty path (a file that's only in memory).
|
inline |
How many are kept, read or still being read.
| size_t tachyon::FileThumbnails::Reading | ( | ) |
How many of those are still being read.
|
static |
What a thumbnail is kept by: the same for the same file, time and size.
|
static |
The Windows shell's thumbnails (IShellItemImageFactory, thumbnails only, never the type's icon); an empty Reader elsewhere.