Updated settings menu according to the view mode

+ Created new class PrusaMenu, derived from wxMenu and contains pointers to the separators.
This commit is contained in:
YuSanka 2019-01-25 13:16:32 +01:00
parent 9f734a073f
commit 5a7061a7fb
6 changed files with 99 additions and 35 deletions

View File

@ -711,7 +711,7 @@ void ObjectList::append_menu_item_add_generic(wxMenuItem* menu, const int type)
menu->SetSubMenu(sub_menu);
}
void ObjectList::append_menu_items_add_volume(wxMenu* menu, wxMenuItem* *item_separator)
void ObjectList::append_menu_items_add_volume(wxMenu* menu)
{
// Note: id accords to type of the sub-object, so sequence of the menu items is important
std::vector<std::string> menu_object_types_items = {L("Add part"), // ~ModelVolume::MODEL_PART
@ -725,8 +725,6 @@ void ObjectList::append_menu_items_add_volume(wxMenu* menu, wxMenuItem* *item_se
if (settings_id != wxNOT_FOUND)
menu->Destroy(settings_id);
}
if (*item_separator)
menu->Destroy(*item_separator);
const ConfigOptionMode mode = wxGetApp().get_mode();
@ -743,8 +741,6 @@ void ObjectList::append_menu_items_add_volume(wxMenu* menu, wxMenuItem* *item_se
[this](wxCommandEvent&) { load_generic_subobject(_(L("Box")).ToUTF8().data(), ModelVolume::SUPPORT_BLOCKER); },
*m_bmp_vector[ModelVolume::SUPPORT_BLOCKER]);
*item_separator = nullptr;
return;
}
@ -758,8 +754,6 @@ void ObjectList::append_menu_items_add_volume(wxMenu* menu, wxMenuItem* *item_se
menu->Append(menu_item);
}
*item_separator = menu->AppendSeparator();
}
wxMenuItem* ObjectList::append_menu_item_split(wxMenu* menu)
@ -768,23 +762,41 @@ wxMenuItem* ObjectList::append_menu_item_split(wxMenu* menu)
[this](wxCommandEvent&) { split(); }, m_bmp_split, menu);
}
wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu)
wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_)
{
PrusaMenu* menu = dynamic_cast<PrusaMenu*>(menu_);
// Update (delete old & create new) settings popupmenu
const auto settings_id = menu->FindItem(_("Add settings"));
if (settings_id != wxNOT_FOUND)
menu->Destroy(settings_id);
if (wxGetApp().get_mode() == comSimple)
return nullptr;
auto menu_item = new wxMenuItem(menu, wxID_ANY, _(L("Add settings")));
menu_item->SetBitmap(m_bmp_cog);
menu->DestroySeparators(); // delete old separators
const auto sel_vol = get_selected_model_volume();
if (sel_vol && sel_vol->type() >= ModelVolume::SUPPORT_ENFORCER)
menu_item->Enable(false);
else
return nullptr;
const ConfigOptionMode mode = wxGetApp().get_mode();
if (mode == comSimple)
return nullptr;
menu->m_separator_frst = menu->AppendSeparator();
// Add frequently settings
create_freq_settings_popupmenu(menu);
if (mode == comAdvanced)
return nullptr;
menu->m_separator_scnd = menu->AppendSeparator();
// Add full settings list
auto menu_item = new wxMenuItem(menu, wxID_ANY, _(L("Add settings")));
menu_item->SetBitmap(m_bmp_cog);
// const auto sel_vol = get_selected_model_volume();
// if (sel_vol && sel_vol->type() >= ModelVolume::SUPPORT_ENFORCER)
// menu_item->Enable(false);
// else
menu_item->SetSubMenu(create_settings_popupmenu(menu));
return menu->Append(menu_item);
@ -828,8 +840,8 @@ void ObjectList::create_part_popupmenu(wxMenu *menu)
menu->AppendSeparator();
append_menu_item_change_type(menu);
// Append settings popupmenu
menu->AppendSeparator();
// rest of a object_sla_menu will be added later in:
// - append_menu_item_settings() -> for "Add (settings)"
}
void ObjectList::create_instance_popupmenu(wxMenu*menu)
@ -854,6 +866,11 @@ wxMenu* ObjectList::create_settings_popupmenu(wxMenu *parent_menu)
return menu;
}
void ObjectList::create_freq_settings_popupmenu(wxMenu *parent_menu)
{
}
void ObjectList::update_opt_keys(t_config_option_keys& opt_keys)
{
auto full_current_opts = get_options(false);
@ -1824,7 +1841,7 @@ void ObjectList::update_settings_items()
void ObjectList::update_object_menu()
{
append_menu_items_add_volume(&m_menu_object, &m_mi_volumes_settings_separator);
append_menu_items_add_volume(&m_menu_object);
}
void ObjectList::instances_to_separated_object(const int obj_idx, const std::set<int>& inst_idxs)

View File

@ -14,6 +14,7 @@
class wxBoxSizer;
class wxMenuItem;
class PrusaObjectDataViewModel;
class PrusaMenu;
namespace Slic3r {
class ConfigOptionsGroup;
@ -104,15 +105,14 @@ class ObjectList : public wxDataViewCtrl
wxBitmap m_bmp_cog;
wxBitmap m_bmp_split;
wxMenu m_menu_object;
wxMenu m_menu_part;
wxMenu m_menu_sla_object;
wxMenu m_menu_instance;
PrusaMenu m_menu_object;
PrusaMenu m_menu_part;
PrusaMenu m_menu_sla_object;
PrusaMenu m_menu_instance;
wxMenuItem* m_menu_item_split { nullptr };
wxMenuItem* m_menu_item_split_part { nullptr };
wxMenuItem* m_menu_item_settings { nullptr };
wxMenuItem* m_menu_item_split_instances { nullptr };
wxMenuItem* m_mi_volumes_settings_separator { nullptr };
std::vector<wxBitmap*> m_bmp_vector;
@ -163,7 +163,7 @@ public:
void get_settings_choice(const wxString& category_name);
void append_menu_item_add_generic(wxMenuItem* menu, const int type);
void append_menu_items_add_volume(wxMenu* menu, wxMenuItem* *item_separator);
void append_menu_items_add_volume(wxMenu* menu);
wxMenuItem* append_menu_item_split(wxMenu* menu);
wxMenuItem* append_menu_item_settings(wxMenu* menu);
wxMenuItem* append_menu_item_change_type(wxMenu* menu);
@ -173,6 +173,7 @@ public:
void create_part_popupmenu(wxMenu*menu);
void create_instance_popupmenu(wxMenu*menu);
wxMenu* create_settings_popupmenu(wxMenu *parent_menu);
void create_freq_settings_popupmenu(wxMenu *parent_menu);
void update_opt_keys(t_config_option_keys& t_optopt_keys);

View File

@ -94,6 +94,16 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
// m_plater->print = undef;
_3DScene::remove_all_canvases();
// Slic3r::GUI::deregister_on_request_update_callback();
// destroy and set to null tabs and a platter
// to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing
wxGetApp().clear_tabs_list();
if (wxGetApp().plater_) {
// before creating a new plater let's delete old one
wxGetApp().plater_->Destroy();
wxGetApp().plater_ = nullptr;
}
// propagate event
event.Skip();
});

View File

@ -934,13 +934,11 @@ struct Plater::priv
MainFrame *main_frame;
// Object popup menu
wxMenu object_menu;
PrusaMenu object_menu;
// Part popup menu
wxMenu part_menu;
PrusaMenu part_menu;
// SLA-Object popup menu
wxMenu sla_object_menu;
wxMenuItem* separator_volumes_settings{ nullptr };
PrusaMenu sla_object_menu;
// Data
Slic3r::DynamicPrintConfig *config; // FIXME: leak?
@ -2472,8 +2470,6 @@ bool Plater::priv::complit_init_sla_object_menu()
append_menu_item(&sla_object_menu, wxID_ANY, _(L("Optimize orientation")), _(L("Optimize the rotation of the object for better print results.")),
[this](wxCommandEvent&) { sla_optimize_rotation(); });
sla_object_menu.AppendSeparator();
// ui updates needs to be binded to the parent panel
if (q != nullptr)
{
@ -2493,8 +2489,6 @@ bool Plater::priv::complit_init_part_menu()
auto obj_list = sidebar->obj_list();
obj_list->append_menu_item_change_type(&part_menu);
part_menu.AppendSeparator();
// ui updates needs to be binded to the parent panel
if (q != nullptr)
{
@ -2621,7 +2615,7 @@ bool Plater::priv::can_mirror() const
void Plater::priv::update_object_menu()
{
sidebar->obj_list()->append_menu_items_add_volume(&object_menu, &separator_volumes_settings);
sidebar->obj_list()->append_menu_items_add_volume(&object_menu);
}
// Plater / Public

View File

@ -2393,6 +2393,25 @@ void PrusaModeSizer::SetMode(const int mode)
mode_btns[m]->SetState(m == mode);
}
// ----------------------------------------------------------------------------
// PrusaMenu
// ----------------------------------------------------------------------------
void PrusaMenu::DestroySeparators()
{
if (m_separator_frst) {
Destroy(m_separator_frst);
m_separator_frst = nullptr;
}
if (m_separator_scnd) {
Destroy(m_separator_scnd);
m_separator_scnd = nullptr;
}
}
// ************************************** EXPERIMENTS ***************************************
// *****************************************************************************

View File

@ -920,6 +920,29 @@ private:
};
// ----------------------------------------------------------------------------
// PrusaMenu
// ----------------------------------------------------------------------------
class PrusaMenu : public wxMenu
{
public:
PrusaMenu(const wxString& title, long style = 0)
: wxMenu(title, style) {}
PrusaMenu(long style = 0)
: wxMenu(style) {}
~PrusaMenu() {}
void DestroySeparators();
wxMenuItem* m_separator_frst { nullptr }; // use like separator before settings item
wxMenuItem* m_separator_scnd { nullptr }; // use like separator between settings items
};
// ******************************* EXPERIMENTS **********************************************
// ******************************************************************************************