KiCad PCB EDA Suite
Loading...
Searching...
No Matches
BITMAP_STORE Class Reference

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_ARCHIVEm_archive
 
std::unordered_map< std::pair< BITMAPS, int >, wxString > m_bitmapNameCache
 
std::unordered_map< BITMAPS, std::vector< BITMAP_INFO > > m_bitmapInfoCache
 
wxString m_theme
 

Detailed Description

Helper to retrieve bitmaps while handling icon themes and scaling.

Definition at line 46 of file bitmap_store.h.

Constructor & Destructor Documentation

◆ BITMAP_STORE()

BITMAP_STORE::BITMAP_STORE ( )

◆ ~BITMAP_STORE()

BITMAP_STORE::~BITMAP_STORE ( )
default

Member Function Documentation

◆ bitmapName()

const wxString & BITMAP_STORE::bitmapName ( BITMAPS  aBitmapId,
int  aHeight = -1 
)
private

Definition at line 231 of file bitmap_store.cpp.

References computeBitmapName(), and m_bitmapNameCache.

Referenced by getImage().

◆ buildBitmapInfoCache()

void BITMAP_STORE::buildBitmapInfoCache ( )
private

Definition at line 275 of file bitmap_store.cpp.

References BuildBitmapInfo(), and m_bitmapInfoCache.

Referenced by BITMAP_STORE().

◆ computeBitmapName()

wxString BITMAP_STORE::computeBitmapName ( BITMAPS  aBitmapId,
int  aHeight = -1 
)
private

Definition at line 242 of file bitmap_store.cpp.

References info, m_bitmapInfoCache, m_theme, and traceBitmaps.

Referenced by bitmapName().

◆ GetBitmap()

wxBitmap BITMAP_STORE::GetBitmap ( BITMAPS  aBitmapId,
int  aHeight = -1 
)

Retrieves a bitmap from the given bitmap id.

Parameters
aBitmapIdis from the BITMAPS enum in bitmaps_list.h
aHeightis 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().

◆ GetBitmapBundle()

wxBitmapBundle BITMAP_STORE::GetBitmapBundle ( BITMAPS  aBitmapId)

Constructs and returns a bitmap bundle containing all available sizes of the given ID.

Parameters
aBitmapIdis 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().

◆ GetBitmapScaled()

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.

Todo:
this should be improved to take advantage of a number of different resolution PNGs stored in the asset archive, so we take the closest PNG and scale it rather than always starting with a low-resolution version.
Parameters
aBitmapIdis from the BITMAPS enum in bitmaps_list.h
aScaleFactoris used to scale the bitmap uniformly
aHeightis 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().

◆ GetDisabledBitmapBundle()

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.

Parameters
aBitmapIdis 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().

◆ getImage()

wxImage BITMAP_STORE::getImage ( BITMAPS  aBitmapId,
int  aHeight = -1 
)
private

◆ IsDarkTheme()

bool BITMAP_STORE::IsDarkTheme ( ) const
inline

Definition at line 95 of file bitmap_store.h.

◆ ThemeChanged()

Member Data Documentation

◆ m_archive

std::unique_ptr<ASSET_ARCHIVE> BITMAP_STORE::m_archive
private

Definition at line 107 of file bitmap_store.h.

Referenced by BITMAP_STORE(), and getImage().

◆ m_bitmapInfoCache

std::unordered_map<BITMAPS, std::vector<BITMAP_INFO> > BITMAP_STORE::m_bitmapInfoCache
private

◆ m_bitmapNameCache

std::unordered_map<std::pair<BITMAPS, int>, wxString> BITMAP_STORE::m_bitmapNameCache
private

Definition at line 109 of file bitmap_store.h.

Referenced by bitmapName(), and ThemeChanged().

◆ m_theme

wxString BITMAP_STORE::m_theme
private

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