Unified append_submenu() function and modified append_menu_item() function
This commit is contained in:
parent
7dea8b1c47
commit
ea7216c019
5 changed files with 39 additions and 27 deletions
|
@ -327,24 +327,6 @@ void GUI_App::CallAfter(std::function<void()> cb)
|
|||
callback_register.unlock();
|
||||
}
|
||||
|
||||
wxMenuItem* GUI_App::append_submenu(wxMenu* menu,
|
||||
wxMenu* sub_menu,
|
||||
int id,
|
||||
const wxString& string,
|
||||
const wxString& description,
|
||||
const std::string& icon)
|
||||
{
|
||||
if (id == wxID_ANY)
|
||||
id = wxNewId();
|
||||
auto item = new wxMenuItem(menu, id, string, description);
|
||||
if (!icon.empty())
|
||||
item->SetBitmap(wxBitmap(Slic3r::var(icon), wxBITMAP_TYPE_PNG));
|
||||
item->SetSubMenu(sub_menu);
|
||||
menu->Append(item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void GUI_App::window_pos_save(wxTopLevelWindow* window, const std::string &name)
|
||||
{
|
||||
if (name.empty()) { return; }
|
||||
|
|
|
@ -107,12 +107,6 @@ public:
|
|||
// void notify(/*message*/);
|
||||
void update_ui_from_settings();
|
||||
void CallAfter(std::function<void()> cb);
|
||||
wxMenuItem* append_submenu(wxMenu* menu,
|
||||
wxMenu* sub_menu,
|
||||
int id,
|
||||
const wxString& string,
|
||||
const wxString& description,
|
||||
const std::string& icon);
|
||||
|
||||
void window_pos_save(wxTopLevelWindow* window, const std::string &name);
|
||||
void window_pos_restore(wxTopLevelWindow* window, const std::string &name);
|
||||
|
|
|
@ -1829,6 +1829,21 @@ bool Plater::priv::init_object_menu()
|
|||
wxMenuItem* item_decrease = append_menu_item(&object_menu, wxID_ANY, _(L("Decrease copies\t-")), _(L("Remove one copy of the selected object")),
|
||||
[this](wxCommandEvent&){ q->decrease(); }, "delete.png");
|
||||
|
||||
object_menu.AppendSeparator();
|
||||
|
||||
wxMenu* mirror_menu = new wxMenu();
|
||||
if (mirror_menu == nullptr)
|
||||
return false;
|
||||
|
||||
append_menu_item(mirror_menu, wxID_ANY, _(L("Along X axis")), _(L("Mirror the selected object along the X axis")),
|
||||
[this](wxCommandEvent&){ mirror(X); }, "bullet_red.png", &object_menu);
|
||||
append_menu_item(mirror_menu, wxID_ANY, _(L("Along Y axis")), _(L("Mirror the selected object along the Y axis")),
|
||||
[this](wxCommandEvent&){ mirror(Y); }, "bullet_green.png", &object_menu);
|
||||
append_menu_item(mirror_menu, wxID_ANY, _(L("Along Z axis")), _(L("Mirror the selected object along the Z axis")),
|
||||
[this](wxCommandEvent&){ mirror(Z); }, "bullet_blue.png", &object_menu);
|
||||
|
||||
wxMenuItem* item_mirror = append_submenu(&object_menu, mirror_menu, wxID_ANY, _(L("Mirror")), _(L("Mirror the selected object")));
|
||||
|
||||
#if ENABLE_EXTENDED_SELECTION
|
||||
// ui updates needs to be binded to the parent panel
|
||||
if (q != nullptr)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "GUI_ObjectList.hpp"
|
||||
|
||||
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
||||
std::function<void(wxCommandEvent& event)> cb, const std::string& icon)
|
||||
std::function<void(wxCommandEvent& event)> cb, const std::string& icon, wxEvtHandler* event_handler)
|
||||
{
|
||||
if (id == wxID_ANY)
|
||||
id = wxNewId();
|
||||
|
@ -20,7 +20,26 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const
|
|||
if (!icon.empty())
|
||||
item->SetBitmap(wxBitmap(Slic3r::var(icon), wxBITMAP_TYPE_PNG));
|
||||
|
||||
menu->Bind(wxEVT_MENU, cb, id);
|
||||
if (event_handler != nullptr)
|
||||
event_handler->Bind(wxEVT_MENU, cb, id);
|
||||
else
|
||||
menu->Bind(wxEVT_MENU, cb, id);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxString& string, const wxString& description, const std::string& icon)
|
||||
{
|
||||
if (id == wxID_ANY)
|
||||
id = wxNewId();
|
||||
|
||||
wxMenuItem* item = new wxMenuItem(menu, id, string, description);
|
||||
if (!icon.empty())
|
||||
item->SetBitmap(wxBitmap(Slic3r::var(icon), wxBITMAP_TYPE_PNG));
|
||||
|
||||
item->SetSubMenu(sub_menu);
|
||||
menu->Append(item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
#include <set>
|
||||
|
||||
wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
||||
std::function<void(wxCommandEvent& event)> cb, const std::string& icon = "");
|
||||
std::function<void(wxCommandEvent& event)> cb, const std::string& icon = "", wxEvtHandler* event_handler = nullptr);
|
||||
|
||||
wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxString& string, const wxString& description, const std::string& icon = "");
|
||||
|
||||
class wxCheckListBoxComboPopup : public wxCheckListBox, public wxComboPopup
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue