Object context menu wip / Removed links to settings dialog from user interface / Fixed and unified append_menu_item() function / Fixed File->Open menu item / Fixed Window menu items / Added Plater menu

This commit is contained in:
Enrico Turri 2018-10-17 12:17:25 +02:00
parent 3059438853
commit 7d1828df05
12 changed files with 109 additions and 86 deletions
src/slic3r/GUI

View file

@ -17,6 +17,7 @@
#include "Print.hpp"
#include "Polygon.hpp"
#include "AppConfig.hpp"
#include "wxExtensions.hpp"
#include <fstream>
#include "GUI_App.hpp"
@ -237,10 +238,8 @@ void MainFrame::init_menubar()
// File menu
wxMenu* fileMenu = new wxMenu;
{
wxGetApp().append_menu_item(fileMenu, wxID_ANY, _(L("Open STL/OBJ/AMF/3MF…\tCtrl+O")), _(L("Open a model")),
"", [](wxCommandEvent&){
// if (m_plater) m_plater->add();
}); //'brick_add.png');
append_menu_item(fileMenu, wxID_ANY, _(L("Open STL/OBJ/AMF/3MF…\tCtrl+O")), _(L("Open a model")),
[this](wxCommandEvent&) { if (m_plater) m_plater->add(); }, "brick_add.png");
append_menu_item(fileMenu, wxID_ANY, _(L("&Load Config…\tCtrl+L")), _(L("Load exported configuration file")),
[this](wxCommandEvent&){ load_config_file(); }, "plugin_add.png");
append_menu_item(fileMenu, wxID_ANY, _(L("&Export Config…\tCtrl+E")), _(L("Export current configuration to file")),
@ -285,19 +284,16 @@ void MainFrame::init_menubar()
}
// Plater menu
if(m_plater) {
auto plater_menu = new wxMenu();
append_menu_item(plater_menu, wxID_ANY, L("Export G-code..."), L("Export current plate as G-code"),
if (m_plater) {
m_plater_menu = new wxMenu();
append_menu_item(m_plater_menu, wxID_ANY, _(L("Export G-code...")), _(L("Export current plate as G-code")),
[this](wxCommandEvent&){ /*m_plater->export_gcode(); */}, "cog_go.png");
append_menu_item(plater_menu, wxID_ANY, L("Export plate as STL..."), L("Export current plate as STL"),
append_menu_item(m_plater_menu, wxID_ANY, _(L("Export plate as STL...")), _(L("Export current plate as STL")),
[this](wxCommandEvent&){ /*m_plater->export_stl(); */}, "brick_go.png");
append_menu_item(plater_menu, wxID_ANY, L("Export plate as AMF..."), L("Export current plate as AMF"),
append_menu_item(m_plater_menu, wxID_ANY, _(L("Export plate as AMF...")), _(L("Export current plate as AMF")),
[this](wxCommandEvent&){ /*m_plater->export_amf();*/ }, "brick_go.png");
append_menu_item(plater_menu, wxID_ANY, L("Export plate as 3MF..."), L("Export current plate as 3MF"),
append_menu_item(m_plater_menu, wxID_ANY, _(L("Export plate as 3MF...")), _(L("Export current plate as 3MF")),
[this](wxCommandEvent&){ /*m_plater->export_3mf(); */}, "brick_go.png");
// m_object_menu = m_plater->object_menu;
on_plater_selection_changed(false);
}
// Window menu
@ -375,7 +371,6 @@ void MainFrame::init_menubar()
auto menubar = new wxMenuBar();
menubar->Append(fileMenu, L("&File"));
if (m_plater_menu) menubar->Append(m_plater_menu, L("&Plater")) ;
if (m_object_menu) menubar->Append(m_object_menu, L("&Object")) ;
menubar->Append(windowMenu, L("&Window"));
if (m_viewMenu) menubar->Append(m_viewMenu, L("&View"));
// Add additional menus from C++
@ -385,15 +380,6 @@ void MainFrame::init_menubar()
}
}
// Selection of a 3D object changed on the platter.
void MainFrame::on_plater_selection_changed(const bool have_selection)
{
if (!m_object_menu) return;
for (auto item : m_object_menu->GetMenuItems())
m_object_menu->Enable(item->GetId(), have_selection);
}
void MainFrame::slice_to_png(){
// m_plater->stop_background_process();
// m_plater->async_apply_config();
@ -702,22 +688,6 @@ void MainFrame::select_view(const std::string& direction){
// m_plater->select_view(direction);
}
wxMenuItem* MainFrame::append_menu_item(wxMenu* menu,
int id,
const wxString& string,
const wxString& description,
std::function<void(wxCommandEvent& event)> cb,
const std::string& icon /*= ""*/)
{
if (id == wxID_ANY)
id = wxNewId();
auto item = menu->Append(id, string, description);
if (!icon.empty())
item->SetBitmap(wxBitmap(Slic3r::var(icon), wxBITMAP_TYPE_PNG));
menu->Bind(wxEVT_MENU, /*[cb](wxCommandEvent& event){cb; }*/cb);
return item;
}
void MainFrame::on_presets_changed(SimpleEvent &event)
{
auto *tab = dynamic_cast<Tab*>(event.GetEventObject());