KiCad PCB EDA Suite
|
Helper to retrieve bitmaps while handling icon themes and scaling. More...
#include <bitmap_store.h>
Public Member Functions | |
BITMAP_STORE () | |
~BITMAP_STORE ()=default | |
wxBitmap | GetBitmap (BITMAPS aBitmapId, int aHeight=-1) |
Retrieves a bitmap from the given bitmap id. More... | |
wxBitmap | GetBitmapScaled (BITMAPS aBitmapId, int aScaleFactor, int aHeight=-1) |
Retrieves a bitmap from the given bitmap id, scaled to a given factor. More... | |
void | ThemeChanged () |
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated. More... | |
bool | IsDarkTheme () const |
Private Member Functions | |
wxImage | getImage (BITMAPS aBitmapId, int aHeight=-1) |
const wxString & | bitmapName (BITMAPS aBitmapId, int aHeight=-1) |
wxString | computeBitmapName (BITMAPS aBitmapId, int aHeight=-1) |
void | buildBitmapInfoCache () |
Private Attributes | |
std::unique_ptr< ASSET_ARCHIVE > | m_archive |
std::unordered_map< std::pair< BITMAPS, int >, wxString > | m_bitmapNameCache |
std::unordered_map< BITMAPS, std::vector< BITMAP_INFO > > | m_bitmapInfoCache |
wxString | m_theme |
Helper to retrieve bitmaps while handling icon themes and scaling.
Definition at line 43 of file bitmap_store.h.
BITMAP_STORE::BITMAP_STORE | ( | ) |
Definition at line 104 of file bitmap_store.cpp.
References buildBitmapInfoCache(), PATHS::GetStockDataPath(), IMAGE_ARCHIVE, m_archive, path, ThemeChanged(), and traceBitmaps.
|
default |
|
private |
Definition at line 196 of file bitmap_store.cpp.
References computeBitmapName(), and m_bitmapNameCache.
Referenced by getImage().
|
private |
Definition at line 240 of file bitmap_store.cpp.
References BuildBitmapInfo(), and m_bitmapInfoCache.
Referenced by BITMAP_STORE().
|
private |
Definition at line 207 of file bitmap_store.cpp.
References info, m_bitmapInfoCache, m_theme, and traceBitmaps.
Referenced by bitmapName().
wxBitmap BITMAP_STORE::GetBitmap | ( | BITMAPS | aBitmapId, |
int | aHeight = -1 |
||
) |
Retrieves a bitmap from the given bitmap id.
aBitmapId | is from the BITMAPS enum in bitmaps_list.h |
aHeight | is the requested height in pixels of the source image, or -1 for any height |
Definition at line 118 of file bitmap_store.cpp.
References getImage().
Referenced by KiBitmap().
wxBitmap BITMAP_STORE::GetBitmapScaled | ( | BITMAPS | aBitmapId, |
int | aScaleFactor, | ||
int | aHeight = -1 |
||
) |
Retrieves a bitmap from the given bitmap id, scaled to a given factor.
This factor is for legacy reasons divided by 4, so a scale factor of 4 will return the original image.
aBitmapId | is from the BITMAPS enum in bitmaps_list.h |
aScaleFactor | is used to scale the bitmap uniformly |
aHeight | is the requested height in pixels of the source image to scale from |
Definition at line 124 of file bitmap_store.cpp.
References getImage(), and image.
Referenced by KiScaledBitmap().
|
private |
Definition at line 139 of file bitmap_store.cpp.
References bitmapName(), image, m_archive, m_theme, s_dummyItem, s_imageNotFound, and traceBitmaps.
Referenced by GetBitmap(), and GetBitmapScaled().
|
inline |
Definition at line 79 of file bitmap_store.h.
References m_theme.
void BITMAP_STORE::ThemeChanged | ( | ) |
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated.
Definition at line 170 of file bitmap_store.cpp.
References COMMON_SETTINGS::APPEARANCE::icon_theme, KIPLATFORM::UI::IsDarkTheme(), COMMON_SETTINGS::m_Appearance, m_bitmapNameCache, m_theme, and Pgm().
Referenced by BITMAP_STORE(), EDA_BASE_FRAME::CommonSettingsChanged(), EDA_BASE_FRAME::HandleSystemColorChange(), ACTION_TOOLBAR::onThemeChanged(), PANEL_KICAD_LAUNCHER::onThemeChanged(), PROJECT_TREE_PANE::onThemeChanged(), and PCB_CALCULATOR_FRAME::onThemeChanged().
|
private |
Definition at line 91 of file bitmap_store.h.
Referenced by BITMAP_STORE(), and getImage().
|
private |
Definition at line 95 of file bitmap_store.h.
Referenced by buildBitmapInfoCache(), and computeBitmapName().
|
private |
Definition at line 93 of file bitmap_store.h.
Referenced by bitmapName(), and ThemeChanged().
|
private |
Definition at line 97 of file bitmap_store.h.
Referenced by computeBitmapName(), getImage(), IsDarkTheme(), and ThemeChanged().