From 9b04886c3a9e1c8b825a03befcc6e1ed7d8a90e0 Mon Sep 17 00:00:00 2001 From: sunsets <845944018@qq.com> Date: Mon, 1 Apr 2024 15:16:47 +0800 Subject: [PATCH] Fixed a bug where the device interface failed to render by pressing alt button --- src/slic3r/GUI/MainFrame.cpp | 2 ++ src/slic3r/GUI/PrinterWebView.cpp | 48 ++++++++++++++++++++++++------- src/slic3r/GUI/PrinterWebView.hpp | 20 +++++++++++-- 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 41313c9..8e240e1 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -2178,6 +2178,8 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/) #if defined(__WIN32__) || defined(__WXMAC__) m_printer_view->ResumeButton(); + //B63 + m_printer_view->SetFocus(); #endif diff --git a/src/slic3r/GUI/PrinterWebView.cpp b/src/slic3r/GUI/PrinterWebView.cpp index 01d7546..2542f15 100644 --- a/src/slic3r/GUI/PrinterWebView.cpp +++ b/src/slic3r/GUI/PrinterWebView.cpp @@ -25,13 +25,12 @@ namespace Slic3r { namespace GUI { -wxBEGIN_EVENT_TABLE(MachineListButton, wxButton) EVT_PAINT(MachineListButton::OnPaint) EVT_ENTER_WINDOW(MachineListButton::OnMouseEnter) - EVT_LEAVE_WINDOW(MachineListButton::OnMouseLeave) - //EVT_LEFT_DOWN(MachineListButton::OnMouseLeftDown) - // EVT_LEFT_UP(MachineListButton::OnMouseLeftUp) - EVT_SET_FOCUS(MachineListButton::OnSetFocus) - EVT_KILL_FOCUS(MachineListButton::OnKillFocus) EVT_KEY_DOWN(MachineListButton::OnKeyDown) EVT_KEY_UP(MachineListButton::OnKeyUp) - wxEND_EVENT_TABLE() +//wxBEGIN_EVENT_TABLE(MachineListButton, wxButton) EVT_PAINT(MachineListButton::OnPaint) EVT_ENTER_WINDOW(MachineListButton::OnMouseEnter) +// EVT_LEAVE_WINDOW(MachineListButton::OnMouseLeave) +// // EVT_LEFT_DOWN(MachineListButton::OnMouseLeftDown) +// // EVT_LEFT_UP(MachineListButton::OnMouseLeftUp) +// EVT_SET_FOCUS(MachineListButton::OnSetFocus) EVT_KILL_FOCUS(MachineListButton::OnKillFocus) EVT_KEY_DOWN(MachineListButton::OnKeyDown) +// EVT_KEY_UP(MachineListButton::OnKeyUp) wxEND_EVENT_TABLE() //B45 @@ -196,7 +195,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent) //MachineListButton *add_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, // wxDefaultValidator, wxButtonNameStr); //wxButton *add_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE); - MachineListButton *add_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, + //B63 + add_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, wxDefaultValidator, wxButtonNameStr); #if defined(__WIN32__) || defined(__WXMAC__) add_button->SetBackgroundColour(wxColour(30, 30, 21)); @@ -211,7 +211,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent) //wxButton *delete_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE); - MachineListButton *delete_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, + //B63 + delete_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, wxDefaultValidator, wxButtonNameStr); #if defined(__WIN32__) || defined(__WXMAC__) delete_button->SetBackgroundColour(wxColour(30, 30, 21)); @@ -224,7 +225,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent) buttonsizer->Add(delete_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2)); delete_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnDeleteButtonClick, this); - MachineListButton *edit_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, + //B63 + edit_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, wxDefaultValidator, wxButtonNameStr); //wxButton *edit_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE); #if defined(__WIN32__) || defined(__WXMAC__) @@ -238,7 +240,7 @@ PrinterWebView::PrinterWebView(wxWindow *parent) buttonsizer->Add(edit_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2)); edit_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnEditButtonClick, this); - MachineListButton *refresh_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, + refresh_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT, wxDefaultValidator, wxButtonNameStr); //wxButton *refresh_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE); #if defined(__WIN32__) || defined(__WXMAC__) @@ -387,11 +389,28 @@ void PrinterWebView::AddButton(const wxString & devi #else customButton->SetSize(wxSize(200, -1)); #endif + //B63 + customButton->Bind(wxEVT_KEY_UP, &PrinterWebView::OnKeyUp, this); leftsizer->Add(customButton, wxSizerFlags().Border(wxALL, 1).Expand()); leftsizer->Layout(); m_buttons.push_back(customButton); } +//B63 + void PrinterWebView::RefreshButton() + { + if (m_buttons.empty()) { + BOOST_LOG_TRIVIAL(info) << " empty"; + } else { + for (MachineListButton *button : m_buttons) { + button->Refresh(); + } + add_button->Refresh(); + delete_button->Refresh(); + edit_button->Refresh(); + refresh_button->Refresh(); + } + } //B45 void PrinterWebView::PauseButton() @@ -781,6 +800,13 @@ void PrinterWebView::OnScroll(wxScrollWinEvent &event) event.Skip(); } +//B63 +void PrinterWebView::OnKeyUp(wxKeyEvent &event) +{ + + event.Skip(); + RefreshButton(); +} //B45 void PrinterWebView::load_url(wxString& url) { diff --git a/src/slic3r/GUI/PrinterWebView.hpp b/src/slic3r/GUI/PrinterWebView.hpp index 6dd40ae..c21904f 100644 --- a/src/slic3r/GUI/PrinterWebView.hpp +++ b/src/slic3r/GUI/PrinterWebView.hpp @@ -71,6 +71,13 @@ public: else SetBackgroundColour(wxColour(67, 67, 71)); #endif + Bind(wxEVT_PAINT, &MachineListButton::OnPaint, this); + Bind(wxEVT_ENTER_WINDOW, &MachineListButton::OnMouseEnter, this); + Bind(wxEVT_LEAVE_WINDOW, &MachineListButton::OnMouseLeave, this); + Bind(wxEVT_SET_FOCUS, &MachineListButton::OnSetFocus, this); + Bind(wxEVT_KILL_FOCUS, &MachineListButton::OnKillFocus, this); + Bind(wxEVT_KEY_DOWN, &MachineListButton::OnKeyDown, this); + //Bind(wxEVT_KEY_UP, &MachineListButton::OnKeyUp, this); } void SetLabel(const wxString &fullname) { full_label = fullname; } @@ -159,7 +166,7 @@ public: void OnKeyUp(wxKeyEvent &event); void OnMouseEnter(wxMouseEvent &event); void OnMouseLeave(wxMouseEvent &event); - void OnMouseLeftDown(wxMouseEvent &event); + //void OnMouseLeftDown(wxMouseEvent &event); //void OnMouseLeftUp(wxMouseEvent &event); //void OnClickHandler(wxCommandEvent &event); void SetStatusThread(std::thread thread) { m_statusThread = std::move(thread); } @@ -228,7 +235,7 @@ private: std::function m_handlerl; //B59 bool m_is_QIDI; - wxDECLARE_EVENT_TABLE(); + //wxDECLARE_EVENT_TABLE(); }; @@ -258,6 +265,8 @@ public: void OnScroll(wxScrollWinEvent &event); void OnScrollup(wxScrollWinEvent &event); void OnScrolldown(wxScrollWinEvent &event); + //B63 + void OnKeyUp(wxKeyEvent &event); void SetUpdateHandler(const std::function &handler) { m_handlerl = handler; } void SetDeleteHandler(const std::function &handler) { m_delete_handlerl = handler; } @@ -280,6 +289,8 @@ public: void StopAllThread(); void UnSelectedButton(); + //B63 + void RefreshButton(); std::vector GetButton() { return m_buttons; }; private: @@ -306,6 +317,11 @@ private: wxWebView* m_browser; long m_zoomFactor; + //B63 + MachineListButton *add_button; + MachineListButton *delete_button; + MachineListButton *edit_button; + MachineListButton *refresh_button; // DECLARE_EVENT_TABLE() };