From 6e0f691a96fb54d99cc265088d2d8f389519af0a Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 7 Mar 2025 14:52:13 -0500 Subject: Share icons across popups --- src/icons.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/icons.cpp (limited to 'src/icons.cpp') diff --git a/src/icons.cpp b/src/icons.cpp new file mode 100644 index 0000000..87ba037 --- /dev/null +++ b/src/icons.cpp @@ -0,0 +1,22 @@ +#include "icons.h" + +#include "global.h" + +const wxBitmap* IconCache::GetIcon(const std::string& filename, wxSize size) { + std::tuple key = {filename, size.x, size.y}; + + if (!icons_.count(key)) { + icons_[key] = + wxBitmap(wxImage(GetAbsolutePath(filename).c_str(), + wxBITMAP_TYPE_PNG) + .Scale(size.x, size.y)); + } + + return &icons_.at(key); +} + +static IconCache* ICON_CACHE_INSTANCE = nullptr; + +void SetTheIconCache(IconCache* instance) { ICON_CACHE_INSTANCE = instance; } + +IconCache& GetTheIconCache() { return *ICON_CACHE_INSTANCE; } -- cgit 1.4.1