Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
aurore::ThemeImages Class Reference

#include <aurore/core/theme_image.hpp>

Static Public Member Functions

static std::shared_ptr< ThemeImage > load (const std::string &path, int flags=0)
 
static std::shared_ptr< ThemeImage > load (const std::string &path, const ThemeImageOptions &options)
 
static Event< const ThemeImage * > * getLoadedEvent ()
 
static bool meanColor (const std::string &path, NVGcolor *color)
 
static bool knownMeanColor (const std::string &path, NVGcolor *color)
 
static bool exists (const std::string &path)
 
static int decoding ()
 
static void releaseAll ()
 

Static Public Attributes

static constexpr int MAX_WIDTH = 1920
 
static constexpr int MAX_HEIGHT = 1080
 
static constexpr int LOGO_SIZE = 256
 
static constexpr int ICON_SIZE = 128
 
static constexpr int PREVIEW_SIZE = 128
 

Detailed Description

The one loader of theme pictures. load() hands back the image at once, still loading: it is decoded on the decode thread (Threading::asyncDecode), made smaller when larger than MAX_WIDTH x MAX_HEIGHT (its ratio kept), and its texture is made on the UI thread (aurore::sync), which draws again. A file that cannot be read is logged once and stays FAILED.

The images are shared by path and flags while someone holds them, and freed when the last holder lets go: whoever draws a theme's picture keeps the shared_ptr while that theme is in use (Application does for the background), and drops it when the theme changes.

PNG and JPEG (what stb_image decodes; not WebP). Paths are files, resources ("@res/...") or romfs files.

Member Function Documentation

◆ decoding()

static int aurore::ThemeImages::decoding ( )
static

How many pictures the decode thread is decoding now. A test waits for none, in real time, before it counts frames: the frames drawn while a picture decodes then do not depend on the machine's speed.

◆ exists()

static bool aurore::ThemeImages::exists ( const std::string &  path)
static

Whether there is a file at path (a resource, or a file on disk), without reading it.

◆ getLoadedEvent()

static Event< const ThemeImage * > * aurore::ThemeImages::getLoadedEvent ( )
static

Fired on the UI thread when an image loaded with load() is ready or failed (its texture made), before the frame that can draw it.

◆ knownMeanColor()

static bool aurore::ThemeImages::knownMeanColor ( const std::string &  path,
NVGcolor *  color 
)
static

The same, only when already known: never decodes.

◆ load() [1/2]

static std::shared_ptr< ThemeImage > aurore::ThemeImages::load ( const std::string &  path,
const ThemeImageOptions &  options 
)
static

The same, with its size cap and mask (ThemeImageOptions): shared by path and options.

◆ load() [2/2]

static std::shared_ptr< ThemeImage > aurore::ThemeImages::load ( const std::string &  path,
int  flags = 0 
)
static

The image at path, made with flags (NVG_IMAGE_REPEATX...): loading, or ready when someone holds it already. From the UI thread.

◆ meanColor()

static bool aurore::ThemeImages::meanColor ( const std::string &  path,
NVGcolor *  color 
)
static

The average colour of the picture at path (opaque), for the contrast checks: remembered once known (a load() computes it on the decode thread); else decoded here, on the calling thread: not from the UI thread (a check, a test). False when the file cannot be read.

◆ releaseAll()

static void aurore::ThemeImages::releaseAll ( )
static

Deletes every texture still held, before the NVG context goes away (Application::exit): an image held afterwards is FAILED, empty.

Member Data Documentation

◆ ICON_SIZE

constexpr int aurore::ThemeImages::ICON_SIZE = 128
staticconstexpr

◆ LOGO_SIZE

constexpr int aurore::ThemeImages::LOGO_SIZE = 256
staticconstexpr

◆ MAX_HEIGHT

constexpr int aurore::ThemeImages::MAX_HEIGHT = 1080
staticconstexpr

◆ MAX_WIDTH

constexpr int aurore::ThemeImages::MAX_WIDTH = 1920
staticconstexpr

◆ PREVIEW_SIZE

constexpr int aurore::ThemeImages::PREVIEW_SIZE = 128
staticconstexpr

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