diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 17:26:46 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 17:26:46 -0400 |
| commit | 09d67fbad9df92caf2251d36b4abd7979fd27126 (patch) | |
| tree | 287be3da3588f1fb991ffd3212fdfd53a703d6ab /eye_indicator.cpp | |
| parent | 116ba412079ddf647d19a54d09eb61e67a2f9aac (diff) | |
| download | lingo-ap-tracker-09d67fbad9df92caf2251d36b4abd7979fd27126.tar.gz lingo-ap-tracker-09d67fbad9df92caf2251d36b4abd7979fd27126.tar.bz2 lingo-ap-tracker-09d67fbad9df92caf2251d36b4abd7979fd27126.zip | |
Map + popups reflect checked locations
Diffstat (limited to 'eye_indicator.cpp')
| -rw-r--r-- | eye_indicator.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
| diff --git a/eye_indicator.cpp b/eye_indicator.cpp new file mode 100644 index 0000000..c490589 --- /dev/null +++ b/eye_indicator.cpp | |||
| @@ -0,0 +1,47 @@ | |||
| 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 | |||
| 41 | void EyeIndicator::Redraw() { | ||
| 42 | rendered_ = | ||
| 43 | wxBitmap((intended_checked_ ? GetCheckedImage() : GetUncheckedImage()) | ||
| 44 | .Scale(GetSize().GetWidth(), GetSize().GetHeight(), | ||
| 45 | wxIMAGE_QUALITY_NORMAL)); | ||
| 46 | rendered_checked_ = intended_checked_; | ||
| 47 | } | ||
