mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-19 08:52:09 +00:00
Since the wxWidgets 3.3 upgrade the Slice/Print split-button's transient popup was dismissed the moment the cursor entered the gap between the button and the menu, making "Print -> Export" impossible to select. Anchor the menu flush against the button (with a 2 px overlap) instead of 6 px below it, removing the dead-zone the cursor had to cross. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
121 lines
2.8 KiB
C++
121 lines
2.8 KiB
C++
#include "SideMenuPopup.hpp"
|
|
#include "Label.hpp"
|
|
|
|
#include <wx/display.h>
|
|
#include <wx/dcgraph.h>
|
|
#include "../GUI_App.hpp"
|
|
|
|
|
|
|
|
wxBEGIN_EVENT_TABLE(SidePopup,PopupWindow)
|
|
EVT_PAINT(SidePopup::paintEvent)
|
|
wxEND_EVENT_TABLE()
|
|
|
|
SidePopup::SidePopup(wxWindow* parent)
|
|
:PopupWindow(parent,
|
|
wxBORDER_NONE |
|
|
wxPU_CONTAINS_CONTROLS)
|
|
{
|
|
#ifdef __WINDOWS__
|
|
SetDoubleBuffered(true);
|
|
#endif //__WINDOWS__
|
|
}
|
|
|
|
SidePopup::~SidePopup()
|
|
{
|
|
;
|
|
}
|
|
|
|
void SidePopup::OnDismiss()
|
|
{
|
|
Slic3r::GUI::wxGetApp().set_side_menu_popup_status(false);
|
|
PopupWindow::OnDismiss();
|
|
}
|
|
|
|
bool SidePopup::ProcessLeftDown(wxMouseEvent& event)
|
|
{
|
|
return PopupWindow::ProcessLeftDown(event);
|
|
}
|
|
bool SidePopup::Show( bool show )
|
|
{
|
|
return PopupWindow::Show(show);
|
|
}
|
|
|
|
void SidePopup::Popup(wxWindow* focus)
|
|
{
|
|
Create();
|
|
auto drect = wxDisplay(GetParent()).GetGeometry();
|
|
int screenwidth = drect.x + drect.width;
|
|
//int screenwidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X,NULL);
|
|
|
|
int max_width = 0;
|
|
|
|
for (auto btn : btn_list)
|
|
{
|
|
max_width = std::max(btn->GetMinSize().x, max_width);
|
|
}
|
|
if (focus) {
|
|
wxPoint pos = focus->ClientToScreen(wxPoint(0, -6));
|
|
int anchor_h = focus->GetSize().y + 12;
|
|
|
|
#ifdef __APPLE__
|
|
pos.x = pos.x - FromDIP(20);
|
|
// Orca #12936: since the wxWidgets 3.3 upgrade the transient popup is dismissed the
|
|
// instant the cursor enters the gap between the button and the menu, making
|
|
// "Print -> Export" unselectable. Anchor the menu flush against the button (slight
|
|
// overlap) so there is no dead-zone for the cursor to cross.
|
|
pos.y = focus->ClientToScreen(wxPoint(0, 0)).y;
|
|
anchor_h = focus->GetSize().y - 2;
|
|
#endif // __APPLE__
|
|
|
|
if (pos.x + max_width > screenwidth)
|
|
Position({pos.x - (pos.x + max_width - screenwidth), pos.y}, {0, anchor_h});
|
|
else
|
|
Position(pos, {0, anchor_h});
|
|
}
|
|
Slic3r::GUI::wxGetApp().set_side_menu_popup_status(true);
|
|
PopupWindow::Popup();
|
|
}
|
|
|
|
void SidePopup::Create()
|
|
{
|
|
wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
int max_width = 0;
|
|
int height = 0;
|
|
for (auto btn : btn_list)
|
|
{
|
|
max_width = std::max(btn->GetMinSize().x, max_width);
|
|
}
|
|
|
|
for (auto btn : btn_list)
|
|
{
|
|
wxSize size = btn->GetMinSize();
|
|
height += size.y;
|
|
size.x = max_width;
|
|
btn->SetMinSize(size);
|
|
btn->SetSize(size);
|
|
sizer->Add(btn, 0, 0, 0);
|
|
}
|
|
|
|
SetSize(wxSize(max_width, height));
|
|
|
|
SetSizer(sizer, true);
|
|
|
|
Layout();
|
|
Refresh();
|
|
}
|
|
|
|
void SidePopup::paintEvent(wxPaintEvent& evt)
|
|
{
|
|
wxPaintDC dc(this);
|
|
wxSize size = GetSize();
|
|
dc.SetBrush(wxTransparentColour);
|
|
dc.DrawRectangle(0, 0, size.x, size.y);
|
|
}
|
|
|
|
void SidePopup::append_button(SideButton* btn)
|
|
{
|
|
btn_list.push_back(btn);
|
|
}
|