KiCad PCB EDA Suite
Loading...
Searching...
No Matches
bitmap_store.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef KICAD_BITMAP_STORE_H
21#define KICAD_BITMAP_STORE_H
22
23#include <memory>
24#include <unordered_map>
25
26#include <wx/bmpbndl.h>
27
28#include <bitmaps/bitmap_info.h>
29#include <kicommon.h>
30
31class ASSET_ARCHIVE;
32class wxImage;
33
34
35namespace std
36{
37 template<> struct KICOMMON_API hash<std::pair<BITMAPS, int>>
38 {
39 size_t operator()( const std::pair<BITMAPS, int>& aPair ) const;
40 };
41}
42
47{
48public:
50
51 // Out of line, since MSVC builds an exported class's destructor wherever the header is included
53
59 wxBitmap GetBitmap( BITMAPS aBitmapId, int aHeight = -1 );
60
69 wxBitmapBundle GetBitmapBundle( BITMAPS aBitmapId, int aMinHeight = -1 );
70
78 wxBitmapBundle GetBitmapBundleDef( BITMAPS aBitmapId, int aDefHeight );
79
86 wxBitmapBundle GetDisabledBitmapBundle( BITMAPS aBitmapId, int aMinHeight = -1 );
87
96 wxBitmapBundle GetDisabledBitmapBundleDef( BITMAPS aBitmapId, int aDefHeight );
97
103 static wxBitmapBundle MakeBitmapBundleDef( const wxVector<wxBitmap>& aBitmaps, int aDefHeight );
104
119 wxBitmap GetBitmapScaled( BITMAPS aBitmapId, int aScaleFactor, int aHeight = -1 );
120
125 void ThemeChanged();
126
127 bool IsDarkTheme() const { return m_theme == BITMAP_INFO::THEME::DARK; }
128
129private:
130
131 wxImage getImage( BITMAPS aBitmapId, int aHeight = -1 );
132
133 const wxString& bitmapName( BITMAPS aBitmapId, int aHeight = -1 );
134
135 wxString computeBitmapName( BITMAPS aBitmapId, int aHeight = -1 );
136
137 void buildBitmapInfoCache();
138
139 std::unique_ptr<ASSET_ARCHIVE> m_archive;
140
141 std::unordered_map<std::pair<BITMAPS, int>, wxString> m_bitmapNameCache;
142
143 std::unordered_map<BITMAPS, std::vector<BITMAP_INFO>> m_bitmapInfoCache;
144
146};
147
148#endif // KICAD_BITMAP_STORE_H
BITMAPS
A list of all bitmap identifiers.
An asset archive represents a file containing data assets that are loaded from disk and then cached i...
wxBitmapBundle GetBitmapBundleDef(BITMAPS aBitmapId, int aDefHeight)
Constructs and returns a bitmap bundle for the given icon ID, with the default bitmap size being aDef...
BITMAP_INFO::THEME m_theme
wxBitmapBundle GetBitmapBundle(BITMAPS aBitmapId, int aMinHeight=-1)
Constructs and returns a bitmap bundle containing all available sizes of the given ID.
wxBitmapBundle GetDisabledBitmapBundleDef(BITMAPS aBitmapId, int aDefHeight)
Constructs and returns a bitmap bundle for the given icon ID, with the bitmaps converted to disabled ...
bool IsDarkTheme() const
std::unordered_map< BITMAPS, std::vector< BITMAP_INFO > > m_bitmapInfoCache
void ThemeChanged()
Notifies the store that the icon theme has been changed by the user, so caches must be invalidated.
wxBitmapBundle GetDisabledBitmapBundle(BITMAPS aBitmapId, int aMinHeight=-1)
Constructs and returns a bitmap bundle for the given icon ID, with the bitmaps converted to disabled ...
std::unique_ptr< ASSET_ARCHIVE > m_archive
std::unordered_map< std::pair< BITMAPS, int >, wxString > m_bitmapNameCache
static wxBitmapBundle MakeBitmapBundleDef(const wxVector< wxBitmap > &aBitmaps, int aDefHeight)
Constructs a bitmap bundle from the given bitmaps.
wxBitmap GetBitmap(BITMAPS aBitmapId, int aHeight=-1)
Retrieves a bitmap from the given bitmap id.
wxBitmap GetBitmapScaled(BITMAPS aBitmapId, int aScaleFactor, int aHeight=-1)
Retrieves a bitmap from the given bitmap id, scaled to a given factor.
#define KICOMMON_API
Definition kicommon.h:27
STL namespace.
size_t operator()(const std::pair< BITMAPS, int > &aPair) const