From 149e7c0836927e14a926a952bd1a7f0d1b49e779 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 5 May 2023 15:46:58 -0400 Subject: Organised repo --- eye_indicator.cpp | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 eye_indicator.cpp (limited to 'eye_indicator.cpp') 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 @@ -#include "eye_indicator.h" - -EyeIndicator::EyeIndicator(wxWindow* parent) : wxWindow(parent, wxID_ANY) { - SetMinSize({32, 32}); - - Redraw(); - - Bind(wxEVT_PAINT, &EyeIndicator::OnPaint, this); -} - -void EyeIndicator::SetChecked(bool checked) { - if (intended_checked_ != checked) { - intended_checked_ = checked; - - Redraw(); - } -} - -const wxImage& EyeIndicator::GetUncheckedImage() { - static wxImage* unchecked_image = - new wxImage("assets/unchecked.png", wxBITMAP_TYPE_PNG); - return *unchecked_image; -} - -const wxImage& EyeIndicator::GetCheckedImage() { - static wxImage* checked_image = - new wxImage("assets/checked.png", wxBITMAP_TYPE_PNG); - return *checked_image; -} - -void EyeIndicator::OnPaint(wxPaintEvent& event) { - if (GetSize() != rendered_.GetSize() || - intended_checked_ != rendered_checked_) { - Redraw(); - } - - wxPaintDC dc(this); - dc.DrawBitmap(rendered_, 0, 0); - - event.Skip(); -} - -void EyeIndicator::Redraw() { - rendered_ = - wxBitmap((intended_checked_ ? GetCheckedImage() : GetUncheckedImage()) - .Scale(GetSize().GetWidth(), GetSize().GetHeight(), - wxIMAGE_QUALITY_NORMAL)); - rendered_checked_ = intended_checked_; -} -- cgit 1.4.1