about summary refs log tree commit diff stats
path: root/src/eye_indicator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/eye_indicator.cpp')
-rw-r--r--src/eye_indicator.cpp51
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
5EyeIndicator::EyeIndicator(wxWindow* parent) : wxWindow(parent, wxID_ANY) {
6 SetMinSize({32, 32});
7
8 Redraw();
9
10 Bind(wxEVT_PAINT, &EyeIndicator::OnPaint, this);
11}
12
13void EyeIndicator::SetChecked(bool checked) {
14 if (intended_checked_ != checked) {
15 intended_checked_ = checked;
16
17 Redraw();
18 }
19}
20
21const 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
27const 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
33void 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
45void 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}