From 0a3c0c6882db2976c2b6fdbebbc127747ed63703 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 19 Jan 2024 18:16:41 -0500 Subject: Area popups are now painted Instead of being a bunch of controls. This fixes the problem with the window being slow to drag around, and with items in lists disappearing. Overall W for me. --- src/eye_indicator.cpp | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/eye_indicator.cpp (limited to 'src/eye_indicator.cpp') 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 @@ -#include "eye_indicator.h" - -#include "global.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( - GetAbsolutePath("assets/unchecked.png").c_str(), wxBITMAP_TYPE_PNG); - return *unchecked_image; -} - -const wxImage& EyeIndicator::GetCheckedImage() { - static wxImage* checked_image = new wxImage( - GetAbsolutePath("assets/checked.png").c_str(), 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