|
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, int aMinHeight=-1) |
| Constructs and returns a bitmap bundle containing all available sizes of the given ID. | |
| wxBitmapBundle | GetBitmapBundleDef (BITMAPS aBitmapId, int aDefHeight) |
| Constructs and returns a bitmap bundle for the given icon ID, with the default bitmap size being aDefHeight. | |
| wxBitmapBundle | GetDisabledBitmapBundle (BITMAPS aBitmapId, int aMinHeight=-1) |
| Constructs and returns a bitmap bundle for the given icon ID, with the bitmaps converted to disabled state according to the current UI theme. | |
| wxBitmapBundle | GetDisabledBitmapBundleDef (BITMAPS aBitmapId, int aDefHeight) |
| Constructs and returns a bitmap bundle for the given icon ID, with the bitmaps converted to disabled state according to the current UI theme and the default bitmap size being aDefHeight. | |
| 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 348 of file bitmap_store.cpp.
References computeBitmapName(), and m_bitmapNameCache.
Referenced by getImage().
|
private |
Definition at line 392 of file bitmap_store.cpp.
References BuildBitmapInfo(), and m_bitmapInfoCache.
Referenced by BITMAP_STORE().
|
private |
Definition at line 359 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(), and ~BITMAP_STORE().
| wxBitmapBundle BITMAP_STORE::GetBitmapBundle | ( | BITMAPS | aBitmapId, |
| int | aMinHeight = -1 ) |
Constructs and returns a bitmap bundle containing all available sizes of the given ID.
| aBitmapId | is from the BITMAPS enum in bitmaps_list.h |
| aMinHeight | is the minimum height of the bitmaps to include in the bundle. This is important for uses of GetPreferredBitmap and more on wxBitmap bundles because wx assumes the smallest bitmap is the "original" intended size. This is a problem where some icons may be reused between controls at different intended sizes. |
Definition at line 124 of file bitmap_store.cpp.
References getImage(), info, m_bitmapInfoCache, and m_theme.
Referenced by KiBitmapBundle(), and ~BITMAP_STORE().
| wxBitmapBundle BITMAP_STORE::GetBitmapBundleDef | ( | BITMAPS | aBitmapId, |
| int | aDefHeight ) |
Constructs and returns a bitmap bundle for the given icon ID, with the default bitmap size being aDefHeight.
Rescaling is applied if no bitmap of that size is available.
| aBitmapId | is from the BITMAPS enum in bitmaps_list.h |
| aDefHeight | is the desired height of the default bitmap in the bundle. |
Definition at line 173 of file bitmap_store.cpp.
References getImage(), info, m_bitmapInfoCache, m_theme, and resampleImage().
Referenced by KiBitmapBundleDef(), and ~BITMAP_STORE().
| 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 278 of file bitmap_store.cpp.
References getImage(), and image.
Referenced by KiScaledBitmap(), and ~BITMAP_STORE().
| wxBitmapBundle BITMAP_STORE::GetDisabledBitmapBundle | ( | BITMAPS | aBitmapId, |
| int | aMinHeight = -1 ) |
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 |
| aMinHeight | is the minimum height of the bitmaps to include in the bundle. |
Definition at line 215 of file bitmap_store.cpp.
References getImage(), info, KIPLATFORM::UI::IsDarkTheme(), m_bitmapInfoCache, and m_theme.
Referenced by KiDisabledBitmapBundle(), and ~BITMAP_STORE().
| wxBitmapBundle BITMAP_STORE::GetDisabledBitmapBundleDef | ( | BITMAPS | aBitmapId, |
| int | aDefHeight ) |
Constructs and returns a bitmap bundle for the given icon ID, with the bitmaps converted to disabled state according to the current UI theme and the default bitmap size being aDefHeight.
Rescaling is applied if no bitmap of that size is available.
| aBitmapId | is from the BITMAPS enum in bitmaps_list.h |
| aDefHeight | is the desired height of the default bitmap in the bundle. |
Definition at line 236 of file bitmap_store.cpp.
References getImage(), info, KIPLATFORM::UI::IsDarkTheme(), m_bitmapInfoCache, m_theme, and resampleImage().
Referenced by KiDisabledBitmapBundleDef(), and ~BITMAP_STORE().
|
private |
Definition at line 293 of file bitmap_store.cpp.
References bitmapName(), dummy_item, image, m_archive, m_theme, s_dummyItem, s_imageNotFound, and traceBitmaps.
Referenced by GetBitmap(), GetBitmapBundle(), GetBitmapBundleDef(), GetBitmapScaled(), GetDisabledBitmapBundle(), and GetDisabledBitmapBundleDef().
|
inline |
Definition at line 119 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 325 of file bitmap_store.cpp.
References AUTO, DARK, KIPLATFORM::UI::IsDarkTheme(), LIGHT, 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(), PCB_CALCULATOR_FRAME::onThemeChanged(), PROJECT_TREE_PANE::onThemeChanged(), and ~BITMAP_STORE().
|
private |
Definition at line 131 of file bitmap_store.h.
Referenced by BITMAP_STORE(), and getImage().
|
private |
Definition at line 135 of file bitmap_store.h.
Referenced by buildBitmapInfoCache(), computeBitmapName(), GetBitmapBundle(), GetBitmapBundleDef(), GetDisabledBitmapBundle(), and GetDisabledBitmapBundleDef().
|
private |
Definition at line 133 of file bitmap_store.h.
Referenced by bitmapName(), and ThemeChanged().
|
private |
Definition at line 137 of file bitmap_store.h.
Referenced by computeBitmapName(), GetBitmapBundle(), GetBitmapBundleDef(), GetDisabledBitmapBundle(), GetDisabledBitmapBundleDef(), getImage(), IsDarkTheme(), and ThemeChanged().