diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-05 15:46:58 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-05 15:46:58 -0400 |
commit | 149e7c0836927e14a926a952bd1a7f0d1b49e779 (patch) | |
tree | 2c7ac89387eb890d3d345217b79929e9a23f4ecf /eye_indicator.cpp | |
parent | 0dace7831673170bd31eefa6bbe6e705211d3061 (diff) | |
download | lingo-ap-tracker-149e7c0836927e14a926a952bd1a7f0d1b49e779.tar.gz lingo-ap-tracker-149e7c0836927e14a926a952bd1a7f0d1b49e779.tar.bz2 lingo-ap-tracker-149e7c0836927e14a926a952bd1a7f0d1b49e779.zip |
Organised repo
Diffstat (limited to 'eye_indicator.cpp')
-rw-r--r-- | eye_indicator.cpp | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/eye_indicator.cpp b/eye_indicator.cpp deleted file mode 100644 index 03e234e..0000000 --- a/eye_indicator.cpp +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | #include "eye_indicator.h" | ||
2 | |||
3 | EyeIndicator::EyeIndicator(wxWindow* parent) : wxWindow(parent, wxID_ANY) { | ||
4 | SetMinSize({32, 32}); | ||
5 | |||
6 | Redraw(); | ||
7 | |||
8 | Bind(wxEVT_PAINT, &EyeIndicator::OnPaint, this); | ||
9 | } | ||
10 | |||
11 | void EyeIndicator::SetChecked(bool checked) { | ||
12 | if (intended_checked_ != checked) { | ||
13 | intended_checked_ = checked; | ||
14 | |||
15 | Redraw(); | ||
16 | } | ||
17 | } | ||
18 | |||
19 | const wxImage& EyeIndicator::GetUncheckedImage() { | ||
20 | static wxImage* unchecked_image = | ||
21 | new wxImage("assets/unchecked.png", wxBITMAP_TYPE_PNG); | ||
22 | return *unchecked_image; | ||
23 | } | ||
24 | |||
25 | const wxImage& EyeIndicator::GetCheckedImage() { | ||
26 | static wxImage* checked_image = | ||
27 | new wxImage("assets/checked.png", wxBITMAP_TYPE_PNG); | ||
28 | return *checked_image; | ||
29 | } | ||
30 | |||
31 | void EyeIndicator::OnPaint(wxPaintEvent& event) { | ||
32 | if (GetSize() != rendered_.GetSize() || | ||
33 | intended_checked_ != rendered_checked_) { | ||
34 | Redraw(); | ||
35 | } | ||
36 | |||
37 | wxPaintDC dc(this); | ||
38 | dc.DrawBitmap(rendered_, 0, 0); | ||
39 | |||
40 | event.Skip(); | ||
41 | } | ||
42 | |||
43 | void EyeIndicator::Redraw() { | ||
44 | rendered_ = | ||
45 | wxBitmap((intended_checked_ ? GetCheckedImage() : GetUncheckedImage()) | ||
46 | .Scale(GetSize().GetWidth(), GetSize().GetHeight(), | ||
47 | wxIMAGE_QUALITY_NORMAL)); | ||
48 | rendered_checked_ = intended_checked_; | ||
49 | } | ||