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/report_popup.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/report_popup.cpp') diff --git a/src/report_popup.cpp b/src/report_popup.cpp index 74216c3..cf5b086 100644 --- a/src/report_popup.cpp +++ b/src/report_popup.cpp @@ -6,6 +6,7 @@ #include #include "global.h" +#include "icons.h" #include "tracker_state.h" ReportPopup::ReportPopup(wxWindow* parent) @@ -73,7 +74,7 @@ void ReportPopup::UpdateIndicators() { int cur_height = FromDIP(10); for (const auto& [text, obtained] : report) { - wxBitmap* eye_ptr = obtained ? &checked_eye_ : &unchecked_eye_; + const wxBitmap* eye_ptr = obtained ? checked_eye_ : unchecked_eye_; mem_dc.DrawBitmap(*eye_ptr, wxPoint{FromDIP(10), cur_height}); @@ -104,13 +105,8 @@ void ReportPopup::OnDPIChanged(wxDPIChangedEvent& event) { } void ReportPopup::LoadIcons() { - // TODO: We do not have to read these in and scale them for every single - // popup. - unchecked_eye_ = - wxBitmap(wxImage(GetAbsolutePath("assets/unchecked.png").c_str(), - wxBITMAP_TYPE_PNG) - .Scale(FromDIP(32), FromDIP(32))); - checked_eye_ = wxBitmap( - wxImage(GetAbsolutePath("assets/checked.png").c_str(), wxBITMAP_TYPE_PNG) - .Scale(FromDIP(32), FromDIP(32))); + unchecked_eye_ = GetTheIconCache().GetIcon("assets/unchecked.png", + FromDIP(wxSize{32, 32})); + checked_eye_ = + GetTheIconCache().GetIcon("assets/checked.png", FromDIP(wxSize{32, 32})); } -- cgit 1.4.1