about summary refs log tree commit diff stats
path: root/eye_indicator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'eye_indicator.cpp')
-rw-r--r--eye_indicator.cpp49
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
3EyeIndicator::EyeIndicator(wxWindow* parent) : wxWindow(parent, wxID_ANY) {
4 SetMinSize({32, 32});
5
6 Redraw();
7
8 Bind(wxEVT_PAINT, &EyeIndicator::OnPaint, this);
9}
10
11void EyeIndicator::SetChecked(bool checked) {
12 if (intended_checked_ != checked) {
13 intended_checked_ = checked;
14
15 Redraw();
16 }
17}
18
19const wxImage& EyeIndicator::GetUncheckedImage() {
20 static wxImage* unchecked_image =
21 new wxImage("assets/unchecked.png", wxBITMAP_TYPE_PNG);
22 return *unchecked_image;
23}
24
25const wxImage& EyeIndicator::GetCheckedImage() {
26 static wxImage* checked_image =
27 new wxImage("assets/checked.png", wxBITMAP_TYPE_PNG);
28 return *checked_image;
29}
30
31void 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
43void 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}