FIX: speed switch popup window display bug

Jira: [STUDIO-14642]
Change-Id: If95ca1b448b2d3a03c2f6d6c0b5faad4a3c04e8c
(cherry picked from commit 08943207564c0256d5a5efea9440e55efb7ccea0)
This commit is contained in:
hemai 2025-09-17 20:22:13 +08:00 committed by Noisyfox
parent ada573a1fd
commit 32af91cf61
3 changed files with 48 additions and 3 deletions

View file

@ -4662,6 +4662,9 @@ void StatusPanel::on_switch_speed(wxCommandEvent &event)
PopupWindow *popUp = new PopupWindow(nullptr);
#else
PopupWindow *popUp = new PopupWindow(m_switch_speed);
#endif
#ifdef __WXMSW__
popUp->BindUnfocusEvent();
#endif
popUp->SetBackgroundColour(StateColor::darkModeColorFor(0xeeeeee));
StepCtrl *step = new StepCtrl(popUp, wxID_ANY);

View file

@ -31,6 +31,11 @@ PopupWindow::~PopupWindow()
#ifdef __WXGTK__
GetTopParent(this)->Unbind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
#endif
#ifdef __WXMSW__
GetTopParent(this)->Unbind(wxEVT_ACTIVATE, &PopupWindow::topWindowActivate, this);
GetTopParent(this)->Unbind(wxEVT_ICONIZE, &PopupWindow::topWindowIconize, this);
GetTopParent(this)->Unbind(wxEVT_SHOW, &PopupWindow::topWindowShow, this);
#endif
}
#ifdef __WXOSX__
@ -84,3 +89,32 @@ void PopupWindow::topWindowActiavate(wxActivateEvent &event)
if (!event.GetActive() && IsShown()) DismissAndNotify();
}
#endif
#ifdef __WXMSW__
void PopupWindow::BindUnfocusEvent()
{
GetTopParent(this)->Bind(wxEVT_ACTIVATE, &PopupWindow::topWindowActivate, this);
GetTopParent(this)->Bind(wxEVT_ICONIZE, &PopupWindow::topWindowIconize, this);
GetTopParent(this)->Bind(wxEVT_SHOW, &PopupWindow::topWindowShow, this);
}
void PopupWindow::topWindowActivate(wxActivateEvent &event)
{
if (!event.GetActive())
Dismiss();
}
void PopupWindow::topWindowIconize(wxIconizeEvent &event)
{
event.Skip();
if (event.IsIconized())
Dismiss();
}
void PopupWindow::topWindowShow(wxShowEvent &event)
{
event.Skip();
if (!event.IsShown())
Dismiss();
}
#endif

View file

@ -2,6 +2,7 @@
#define slic3r_GUI_PopupWindow_hpp_
#include <wx/popupwin.h>
#include <wx/event.h>
class PopupWindow : public wxPopupTransientWindow
{
@ -10,11 +11,12 @@ public:
~PopupWindow();
PopupWindow(wxWindow *parent, int style = wxBORDER_NONE)
{ Create(parent, style); }
PopupWindow(wxWindow *parent, int style = wxBORDER_NONE) { Create(parent, style); }
bool Create(wxWindow *parent, int flags = wxBORDER_NONE);
#ifdef __WXMSW__
void BindUnfocusEvent();
#endif
private:
#ifdef __WXOSX__
void OnMouseEvent2(wxMouseEvent &evt);
@ -24,6 +26,12 @@ private:
#ifdef __WXGTK__
void topWindowActiavate(wxActivateEvent &event);
#endif
#ifdef __WXMSW__
void topWindowActivate(wxActivateEvent &event);
void topWindowIconize(wxIconizeEvent &event);
void topWindowShow(wxShowEvent &event);
#endif
};
#endif // !slic3r_GUI_PopupWindow_hpp_