about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-03-10 13:05:10 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2025-03-10 13:05:10 -0400
commit30f9e78cb30178834c420106c9f515c8358c4dbf (patch)
treed50d3de81da8e018612675e751ef0408730a4df1 /src
parent79424e86dd7aa28c1b25868d86fa8ebffc801593 (diff)
downloadlingo-ap-tracker-30f9e78cb30178834c420106c9f515c8358c4dbf.tar.gz
lingo-ap-tracker-30f9e78cb30178834c420106c9f515c8358c4dbf.tar.bz2
lingo-ap-tracker-30f9e78cb30178834c420106c9f515c8358c4dbf.zip
Optimize ReportPopup refresh slightly
It no longer resizes the window or vanishes if it is open during a refresh, and instead just redraws the image.
Diffstat (limited to 'src')
-rw-r--r--src/report_popup.cpp31
-rw-r--r--src/report_popup.h4
2 files changed, 24 insertions, 11 deletions
diff --git a/src/report_popup.cpp b/src/report_popup.cpp index 674eea0..7ceef0d 100644 --- a/src/report_popup.cpp +++ b/src/report_popup.cpp
@@ -28,21 +28,20 @@ ReportPopup::ReportPopup(wxWindow* parent)
28void ReportPopup::SetDoorId(int door_id) { 28void ReportPopup::SetDoorId(int door_id) {
29 door_id_ = door_id; 29 door_id_ = door_id;
30 30
31 UpdateIndicators(); 31 ResetIndicators();
32} 32}
33 33
34void ReportPopup::Reset() { 34void ReportPopup::Reset() {
35 door_id_ = -1; 35 door_id_ = -1;
36} 36}
37 37
38void ReportPopup::UpdateIndicators() { 38void ReportPopup::ResetIndicators() {
39 wxMemoryDC mem_dc;
40
41 wxFont the_font = GetFont().Scale(GetDPIScaleFactor()); 39 wxFont the_font = GetFont().Scale(GetDPIScaleFactor());
42 mem_dc.SetFont(the_font);
43
44 const std::map<std::string, bool>& report = GetDoorRequirements(door_id_); 40 const std::map<std::string, bool>& report = GetDoorRequirements(door_id_);
45 41
42 wxMemoryDC mem_dc;
43 mem_dc.SetFont(the_font);
44
46 int acc_height = FromDIP(10); 45 int acc_height = FromDIP(10);
47 int col_width = 0; 46 int col_width = 0;
48 47
@@ -58,16 +57,26 @@ void ReportPopup::UpdateIndicators() {
58 } 57 }
59 58
60 int item_width = col_width + FromDIP(10 + 32); 59 int item_width = col_width + FromDIP(10 + 32);
61 int full_width = item_width + FromDIP(20); 60 full_width_ = item_width + FromDIP(20);
61 full_height_ = acc_height;
62 62
63 Fit(); 63 Fit();
64 SetVirtualSize(full_width, acc_height); 64 SetVirtualSize(full_width_, full_height_);
65 65
66 rendered_ = wxBitmap(full_width, acc_height); 66 UpdateIndicators();
67}
68
69void ReportPopup::UpdateIndicators() {
70 wxFont the_font = GetFont().Scale(GetDPIScaleFactor());
71 const std::map<std::string, bool>& report = GetDoorRequirements(door_id_);
72
73 rendered_ = wxBitmap(full_width_, full_height_);
74
75 wxMemoryDC mem_dc;
67 mem_dc.SelectObject(rendered_); 76 mem_dc.SelectObject(rendered_);
68 mem_dc.SetPen(*wxTRANSPARENT_PEN); 77 mem_dc.SetPen(*wxTRANSPARENT_PEN);
69 mem_dc.SetBrush(*wxBLACK_BRUSH); 78 mem_dc.SetBrush(*wxBLACK_BRUSH);
70 mem_dc.DrawRectangle({0, 0}, {full_width, acc_height}); 79 mem_dc.DrawRectangle({0, 0}, {full_width_, full_height_});
71 80
72 mem_dc.SetFont(the_font); 81 mem_dc.SetFont(the_font);
73 82
@@ -101,7 +110,7 @@ void ReportPopup::OnPaint(wxPaintEvent& event) {
101 110
102void ReportPopup::OnDPIChanged(wxDPIChangedEvent& event) { 111void ReportPopup::OnDPIChanged(wxDPIChangedEvent& event) {
103 LoadIcons(); 112 LoadIcons();
104 UpdateIndicators(); 113 ResetIndicators();
105 114
106 event.Skip(); 115 event.Skip();
107} 116}
diff --git a/src/report_popup.h b/src/report_popup.h index 2da9b73..bbb0bef 100644 --- a/src/report_popup.h +++ b/src/report_popup.h
@@ -15,6 +15,7 @@ class ReportPopup : public wxScrolledCanvas {
15 15
16 void Reset(); 16 void Reset();
17 17
18 void ResetIndicators();
18 void UpdateIndicators(); 19 void UpdateIndicators();
19 20
20 private: 21 private:
@@ -28,6 +29,9 @@ class ReportPopup : public wxScrolledCanvas {
28 const wxBitmap* unchecked_eye_; 29 const wxBitmap* unchecked_eye_;
29 const wxBitmap* checked_eye_; 30 const wxBitmap* checked_eye_;
30 31
32 int full_width_ = 0;
33 int full_height_ = 0;
34
31 wxBitmap rendered_; 35 wxBitmap rendered_;
32}; 36};
33 37