diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-01-19 18:16:41 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-01-19 18:16:41 -0500 |
commit | 0a3c0c6882db2976c2b6fdbebbc127747ed63703 (patch) | |
tree | 53d568418f3eb15c149bf7d60d93433e572fa7db /src/eye_indicator.cpp | |
parent | 402d559af2a727f106fa7fa59132b6710a5ae84e (diff) | |
download | lingo-ap-tracker-0a3c0c6882db2976c2b6fdbebbc127747ed63703.tar.gz lingo-ap-tracker-0a3c0c6882db2976c2b6fdbebbc127747ed63703.tar.bz2 lingo-ap-tracker-0a3c0c6882db2976c2b6fdbebbc127747ed63703.zip |
Area popups are now painted
Instead of being a bunch of controls. This fixes the problem with the window being slow to drag around, and with items in lists disappearing. Overall W for me.
Diffstat (limited to 'src/eye_indicator.cpp')
-rw-r--r-- | src/eye_indicator.cpp | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/eye_indicator.cpp b/src/eye_indicator.cpp deleted file mode 100644 index 61ad780..0000000 --- a/src/eye_indicator.cpp +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | #include "eye_indicator.h" | ||
2 | |||
3 | #include "global.h" | ||
4 | |||
5 | EyeIndicator::EyeIndicator(wxWindow* parent) : wxWindow(parent, wxID_ANY) { | ||
6 | SetMinSize({32, 32}); | ||
7 | |||
8 | Redraw(); | ||
9 | |||
10 | Bind(wxEVT_PAINT, &EyeIndicator::OnPaint, this); | ||
11 | } | ||
12 | |||
13 | void EyeIndicator::SetChecked(bool checked) { | ||
14 | if (intended_checked_ != checked) { | ||
15 | intended_checked_ = checked; | ||
16 | |||
17 | Redraw(); | ||
18 | } | ||
19 | } | ||
20 | |||
21 | const wxImage& EyeIndicator::GetUncheckedImage() { | ||
22 | static wxImage* unchecked_image = new wxImage( | ||
23 | GetAbsolutePath("assets/unchecked.png").c_str(), wxBITMAP_TYPE_PNG); | ||
24 | return *unchecked_image; | ||
25 | } | ||
26 | |||
27 | const wxImage& EyeIndicator::GetCheckedImage() { | ||
28 | static wxImage* checked_image = new wxImage( | ||
29 | GetAbsolutePath("assets/checked.png").c_str(), wxBITMAP_TYPE_PNG); | ||
30 | return *checked_image; | ||
31 | } | ||
32 | |||
33 | void EyeIndicator::OnPaint(wxPaintEvent& event) { | ||
34 | if (GetSize() != rendered_.GetSize() || | ||
35 | intended_checked_ != rendered_checked_) { | ||
36 | Redraw(); | ||
37 | } | ||
38 | |||
39 | wxPaintDC dc(this); | ||
40 | dc.DrawBitmap(rendered_, 0, 0); | ||
41 | |||
42 | event.Skip(); | ||
43 | } | ||
44 | |||
45 | void EyeIndicator::Redraw() { | ||
46 | rendered_ = | ||
47 | wxBitmap((intended_checked_ ? GetCheckedImage() : GetUncheckedImage()) | ||
48 | .Scale(GetSize().GetWidth(), GetSize().GetHeight(), | ||
49 | wxIMAGE_QUALITY_NORMAL)); | ||
50 | rendered_checked_ = intended_checked_; | ||
51 | } | ||