mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 06:57:36 -06:00
ENH: use system menu on mac platform
Change-Id: Ia0e0bf42232d51cd08216811fdc6633527b3eb97 Signed-off-by: chunmao.guo <chunmao.guo@bambulab.com>
This commit is contained in:
parent
099e72b885
commit
39f9c23b89
4 changed files with 88 additions and 13 deletions
|
@ -142,7 +142,7 @@ static wxIcon main_frame_icon(GUI_App::EAppMode app_mode)
|
|||
#ifdef __WINDOWS__
|
||||
#define BORDERLESS_FRAME_STYLE (wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxCLOSE_BOX)
|
||||
#else
|
||||
#define BORDERLESS_FRAME_STYLE (wxRESIZE_BORDER)
|
||||
#define BORDERLESS_FRAME_STYLE (wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxCLOSE_BOX)
|
||||
#endif
|
||||
|
||||
wxDEFINE_EVENT(EVT_SYNC_CLOUD_PRESET, SimpleEvent);
|
||||
|
@ -184,8 +184,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
|||
auto panel_topbar = new wxPanel(this, wxID_ANY);
|
||||
panel_topbar->SetBackgroundColour(wxColour(38, 46, 48));
|
||||
auto sizer_tobar = new wxBoxSizer(wxVERTICAL);
|
||||
m_topbar = new BBLTopbar(this);
|
||||
sizer_tobar->Add(m_topbar, 0, wxEXPAND);
|
||||
panel_topbar->SetSizer(sizer_tobar);
|
||||
panel_topbar->Layout();
|
||||
#endif
|
||||
|
@ -286,13 +284,15 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
|
|||
//Bind(wxEVT_MENU, [this](wxCommandEvent&) { m_plater->cut_selection_to_clipboard(); }, wxID_HIGHEST + wxID_CUT);
|
||||
Bind(wxEVT_SIZE, [this](wxSizeEvent&) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "mainframe: size changed, is maximized = " << this->IsMaximized();
|
||||
#ifdef __WINDOWS__
|
||||
if (this->IsMaximized()) {
|
||||
m_topbar->SetWindowSize();
|
||||
} else {
|
||||
m_topbar->SetMaximizedSize();
|
||||
}
|
||||
Refresh();
|
||||
Layout();
|
||||
#endif
|
||||
Refresh();
|
||||
Layout();
|
||||
});
|
||||
|
||||
//BBS
|
||||
|
@ -828,13 +828,14 @@ void MainFrame::init_tabpanel()
|
|||
//monitor
|
||||
}
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
if (sel == tp3DEditor) {
|
||||
m_topbar->EnableUndoRedoItems();
|
||||
}
|
||||
else {
|
||||
m_topbar->DisableUndoRedoItems();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*switch (sel) {
|
||||
case TabPosition::tpHome:
|
||||
|
@ -1475,8 +1476,10 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
|
|||
dynamic_cast<Notebook*>(m_tabpanel)->Rescale();
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
// BBS
|
||||
m_topbar->Rescale();
|
||||
#endif
|
||||
|
||||
m_tabpanel->Rescale();
|
||||
|
||||
|
@ -1596,9 +1599,11 @@ static wxMenu* generate_help_menu()
|
|||
return true;
|
||||
});
|
||||
// About
|
||||
#ifdef __WINDOWS__
|
||||
wxString about_title = wxString::Format(_L("&About %s"), SLIC3R_APP_FULL_NAME);
|
||||
append_menu_item(helpMenu, wxID_ANY, about_title, about_title,
|
||||
[](wxCommandEvent&) { Slic3r::GUI::about(); });
|
||||
#endif
|
||||
return helpMenu;
|
||||
}
|
||||
|
||||
|
@ -1628,6 +1633,7 @@ void MainFrame::init_menubar_as_editor()
|
|||
{
|
||||
#ifdef __APPLE__
|
||||
wxMenuBar::SetAutoWindowMenu(false);
|
||||
m_menubar = new wxMenuBar();
|
||||
#endif
|
||||
|
||||
// File menu
|
||||
|
@ -1890,10 +1896,18 @@ void MainFrame::init_menubar_as_editor()
|
|||
//auto config_wizard_name = _(ConfigWizard::name(true) + "(Debug)");
|
||||
//const auto config_wizard_tooltip = from_u8((boost::format(_utf8(L("Run %s"))) % config_wizard_name).str());
|
||||
//auto config_item = new wxMenuItem(m_topbar->GetTopMenu(), ConfigMenuWizard + config_id_base, config_wizard_name, config_wizard_tooltip);
|
||||
auto preference_item = new wxMenuItem(m_topbar->GetTopMenu(), ConfigMenuPreferences + config_id_base, _L("Preferences") + "\tCtrl+P", "");
|
||||
//auto printer_item = new wxMenuItem(m_topbar->GetTopMenu(), ConfigMenuPrinter + config_id_base, _L("Printer"), "");
|
||||
//auto language_item = new wxMenuItem(m_topbar->GetTopMenu(), ConfigMenuLanguage + config_id_base, _L("Switch Language"), "");
|
||||
m_topbar->GetTopMenu()->Bind(wxEVT_MENU, [this, config_id_base](wxEvent& event) {
|
||||
#ifdef __APPLE__
|
||||
wxWindowID bambu_studio_id_base = wxWindow::NewControlId(int(2));
|
||||
wxMenu* parent_menu = m_menubar->OSXGetAppleMenu();
|
||||
auto preference_item = new wxMenuItem(parent_menu, BambuStudioMenuPreferences + bambu_studio_id_base, _L("Preferences") + "\tCtrl+P", "");
|
||||
#else
|
||||
wxMenu* parent_menu = m_topbar->GetTopMenu();
|
||||
auto preference_item = new wxMenuItem(parent_menu, ConfigMenuPreferences + config_id_base, _L("Preferences") + "\tCtrl+P", "");
|
||||
#endif
|
||||
|
||||
//auto printer_item = new wxMenuItem(parent_menu, ConfigMenuPrinter + config_id_base, _L("Printer"), "");
|
||||
//auto language_item = new wxMenuItem(parent_menu, ConfigMenuLanguage + config_id_base, _L("Switch Language"), "");
|
||||
parent_menu->Bind(wxEVT_MENU, [this, config_id_base](wxEvent& event) {
|
||||
switch (event.GetId() - config_id_base) {
|
||||
//case ConfigMenuLanguage:
|
||||
//{
|
||||
|
@ -1958,10 +1972,50 @@ void MainFrame::init_menubar_as_editor()
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
wxString about_title = wxString::Format(_L("&About %s"), SLIC3R_APP_FULL_NAME);
|
||||
auto about_item = new wxMenuItem(parent_menu, BambuStudioMenuAbout + bambu_studio_id_base, about_title, "");
|
||||
parent_menu->Bind(wxEVT_MENU, [this, bambu_studio_id_base](wxEvent& event) {
|
||||
switch (event.GetId() - bambu_studio_id_base) {
|
||||
case BambuStudioMenuAbout:
|
||||
Slic3r::GUI::about();
|
||||
break;
|
||||
case BambuStudioMenuPreferences:
|
||||
wxGetApp().CallAfter([this] {
|
||||
PreferencesDialog dlg(this);
|
||||
dlg.ShowModal();
|
||||
#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
if (dlg.seq_top_layer_only_changed() || dlg.seq_seq_top_gcode_indices_changed())
|
||||
#else
|
||||
if (dlg.seq_top_layer_only_changed())
|
||||
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
plater()->refresh_print();
|
||||
#if ENABLE_CUSTOMIZABLE_FILES_ASSOCIATION_ON_WIN
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
if (wxGetApp().app_config()->get("associate_3mf") == "true")
|
||||
wxGetApp().associate_3mf_files();
|
||||
if (wxGetApp().app_config()->get("associate_stl") == "true")
|
||||
wxGetApp().associate_stl_files();
|
||||
/*if (wxGetApp().app_config()->get("associate_step") == "true")
|
||||
wxGetApp().associate_step_files();*/
|
||||
#endif // _WIN32
|
||||
#endif
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
parent_menu->Insert(0, about_item);
|
||||
parent_menu->Insert(1, preference_item);
|
||||
#endif
|
||||
// Help menu
|
||||
auto helpMenu = generate_help_menu();
|
||||
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
m_topbar->SetFileMenu(fileMenu);
|
||||
if (editMenu)
|
||||
m_topbar->AddDropDownSubMenu(editMenu, _L("Edit"));
|
||||
|
@ -1973,6 +2027,16 @@ void MainFrame::init_menubar_as_editor()
|
|||
//m_topbar->AddDropDownMenuItem(language_item);
|
||||
//m_topbar->AddDropDownMenuItem(config_item);
|
||||
m_topbar->AddDropDownSubMenu(helpMenu, _L("Help"));
|
||||
#else
|
||||
m_menubar->Append(fileMenu, _L("&File"));
|
||||
if (editMenu)
|
||||
m_menubar->Append(editMenu, _L("&Edit"));
|
||||
if (viewMenu)
|
||||
m_menubar->Append(viewMenu, _L("&View"));
|
||||
if (helpMenu)
|
||||
m_menubar->Append(helpMenu, _L("&Help"));
|
||||
SetMenuBar(m_menubar);
|
||||
#endif
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (wxGetApp().tabs_as_menu())
|
||||
|
@ -1982,12 +2046,12 @@ void MainFrame::init_menubar_as_editor()
|
|||
#ifdef __APPLE__
|
||||
// This fixes a bug on Mac OS where the quit command doesn't emit window close events
|
||||
// wx bug: https://trac.wxwidgets.org/ticket/18328
|
||||
/* wxMenu* apple_menu = m_menubar->OSXGetAppleMenu();
|
||||
wxMenu* apple_menu = m_menubar->OSXGetAppleMenu();
|
||||
if (apple_menu != nullptr) {
|
||||
apple_menu->Bind(wxEVT_MENU, [this](wxCommandEvent &) {
|
||||
Close();
|
||||
}, wxID_EXIT);
|
||||
}*/
|
||||
}
|
||||
#endif // __APPLE__
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue