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. | |
wxBitmapBundle | GetBitmapBundle (BITMAPS aBitmapId) |
Constructs and returns a bitmap bundle containing all available sizes of the given ID. | |
wxBitmapBundle | GetDisabledBitmapBundle (BITMAPS aBitmapId) |
Constructs and returns a bitmap bundle for the given icon ID, with the bitmaps converted to disabled state according to the current UI theme. | |
wxBitmap | GetBitmapScaled (BITMAPS aBitmapId, int aScaleFactor, int aHeight=-1) |
Retrieves a bitmap from the given bitmap id, scaled to a given factor. | |
void | ThemeChanged () |
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated. | |
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 46 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 231 of file bitmap_store.cpp.
References computeBitmapName(), and m_bitmapNameCache.
Referenced by getImage().
|
private |
Definition at line 275 of file bitmap_store.cpp.
References BuildBitmapInfo(), and m_bitmapInfoCache.
Referenced by BITMAP_STORE().
|
private |
Definition at line 242 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().
wxBitmapBundle BITMAP_STORE::GetBitmapBundle | ( | BITMAPS | aBitmapId | ) |
Constructs and returns a bitmap bundle containing all available sizes of the given ID.
aBitmapId | is from the BITMAPS enum in bitmaps_list.h |
Definition at line 124 of file bitmap_store.cpp.
References getImage(), info, m_bitmapInfoCache, and m_theme.
Referenced by KiBitmapBundle().
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 158 of file bitmap_store.cpp.
References getImage(), and image.
Referenced by KiScaledBitmap().
wxBitmapBundle BITMAP_STORE::GetDisabledBitmapBundle | ( | BITMAPS | aBitmapId | ) |
Constructs and returns a bitmap bundle for the given icon ID, with the bitmaps converted to disabled state according to the current UI theme.
aBitmapId | is from the BITMAPS enum in bitmaps_list.h |
Definition at line 140 of file bitmap_store.cpp.
References getImage(), info, KIPLATFORM::UI::IsDarkTheme(), m_bitmapInfoCache, and m_theme.
Referenced by KiDisabledBitmapBundle().
|
private |
Definition at line 173 of file bitmap_store.cpp.
References bitmapName(), image, m_archive, m_theme, s_dummyItem, s_imageNotFound, and traceBitmaps.
Referenced by GetBitmap(), GetBitmapBundle(), GetBitmapScaled(), and GetDisabledBitmapBundle().
|
inline |
Definition at line 95 of file bitmap_store.h.
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 205 of file bitmap_store.cpp.
References PGM_BASE::GetCommonSettings(), 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 107 of file bitmap_store.h.
Referenced by BITMAP_STORE(), and getImage().
|
private |
Definition at line 111 of file bitmap_store.h.
Referenced by buildBitmapInfoCache(), computeBitmapName(), GetBitmapBundle(), and GetDisabledBitmapBundle().
|
private |
Definition at line 109 of file bitmap_store.h.
Referenced by bitmapName(), and ThemeChanged().
|
private |
Definition at line 113 of file bitmap_store.h.
Referenced by computeBitmapName(), GetBitmapBundle(), GetDisabledBitmapBundle(), getImage(), and ThemeChanged().