TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::FileThumbnails Class Reference

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.

Detailed Description

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.

Member Typedef Documentation

◆ Reader

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.

Constructor & Destructor Documentation

◆ FileThumbnails() [1/2]

tachyon::FileThumbnails::FileThumbnails ( ITextSystem & textSystem,
size_t capacity = 512,
Reader reader = ShellReader(),
std::chrono::milliseconds inUse = std::chrono::milliseconds(500) )
explicit

◆ ~FileThumbnails()

tachyon::FileThumbnails::~FileThumbnails ( )

◆ FileThumbnails() [2/2]

tachyon::FileThumbnails::FileThumbnails ( const FileThumbnails & )
delete

Member Function Documentation

◆ operator=()

FileThumbnails & tachyon::FileThumbnails::operator= ( const FileThumbnails & )
delete

◆ Get()

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).

◆ Count()

size_t tachyon::FileThumbnails::Count ( ) const
inline

How many are kept, read or still being read.

◆ Reading()

size_t tachyon::FileThumbnails::Reading ( )

How many of those are still being read.

◆ Key()

std::string tachyon::FileThumbnails::Key ( const std::filesystem::path & file,
std::filesystem::file_time_type modified,
uint32_t pixels )
static

What a thumbnail is kept by: the same for the same file, time and size.

◆ ShellReader()

Reader tachyon::FileThumbnails::ShellReader ( )
static

The Windows shell's thumbnails (IShellItemImageFactory, thumbnails only, never the type's icon); an empty Reader elsewhere.


The documentation for this class was generated from the following file: