diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-01-30 16:38:08 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-01-30 16:38:08 -0500 |
commit | 19959f8479d1bb74f75890dcccbc038871771480 (patch) | |
tree | 56aab329819e56a7bcf405f08f2c0fbda9480270 /src/eye_indicator.cpp | |
parent | 90a208870cfe150f494e21b351152119f98633a2 (diff) | |
parent | 7cb55acb62c5a03df75edd0c3c8f228295c1bee8 (diff) | |
download | lingo-ap-tracker-19959f8479d1bb74f75890dcccbc038871771480.tar.gz lingo-ap-tracker-19959f8479d1bb74f75890dcccbc038871771480.tar.bz2 lingo-ap-tracker-19959f8479d1bb74f75890dcccbc038871771480.zip |
Merge branch 'main' into future
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 | } | ||