diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 8aa227ebdc..2a47fe1aad 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -1644,17 +1644,6 @@ void MenuFactory::create_filament_action_menu(bool init, int active_filament_men []() { return true; }, m_parent); } - if (init) { - append_menu_item( - menu, wxID_ANY, _L("Delete"), _L("Delete this filament"), [](wxCommandEvent&) { - plater()->sidebar().delete_filament(-2); }, "", nullptr, - []() { - return plater()->sidebar().combos_filament().size() > 1 - // Orca: only show delete filament option for SEMM machines unless is BBL - && Sidebar::should_show_SEMM_buttons(); - }, m_parent); - } - const int item_id = menu->FindItem(_L("Merge with")); if (item_id != wxNOT_FOUND) menu->Destroy(item_id); @@ -1675,6 +1664,20 @@ void MenuFactory::create_filament_action_menu(bool init, int active_filament_men } append_submenu(menu, sub_menu, wxID_ANY, _L("Merge with"), "", "", [filaments_cnt]() { return filaments_cnt > 1; }, m_parent); + + // ORCA use delete item on end of menu to prevent accidental clicks. clicking to submenus(merge) already not allowed by OS + const int delete_id = menu->FindItem(_L("Delete")); + if (delete_id != wxNOT_FOUND) + menu->Destroy(delete_id); + + append_menu_item( + menu, wxID_ANY, _L("Delete"), _L("Delete this filament"), [](wxCommandEvent&) { + plater()->sidebar().delete_filament(-2); }, "", nullptr, + []() { + return plater()->sidebar().combos_filament().size() > 1 + // Orca: only show delete filament option for SEMM machines unless is BBL + && Sidebar::should_show_SEMM_buttons(); + }, m_parent); } //BBS: add part plate related logic diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 48d8c6c8c1..c3f62f90d4 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2403,13 +2403,23 @@ void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filame edit_btn->SetToolTip(_L("Click to edit preset")); PlaterPresetComboBox* combobox = (*combo); - edit_btn->Bind(wxEVT_BUTTON, [this, edit_btn, filament_idx](wxCommandEvent) { - auto menu = p->plater->filament_action_menu(filament_idx); - wxPoint pt { 0, edit_btn->GetSize().GetHeight() + 10 }; - pt = edit_btn->ClientToScreen(pt); - pt = wxGetApp().mainframe->ScreenToClient(pt); - p->m_menu_filament_id = filament_idx; - p->plater->PopupMenu(menu, (int) pt.x, pt.y); + edit_btn->Bind(wxEVT_BUTTON, [this, edit_btn, combobox, filament_idx](wxCommandEvent) { + bool single_or_bbl = should_show_SEMM_buttons(); + bool is_multi_material = p->combos_filament.size() > 1; + if(single_or_bbl && is_multi_material) { + // MULTI MATERIAL Show menu + auto menu = p->plater->filament_action_menu(filament_idx); + wxPoint pt { 0, edit_btn->GetSize().GetHeight() + FromDIP(2) }; + pt = edit_btn->ClientToScreen(pt); + pt = wxGetApp().mainframe->ScreenToClient(pt); + p->m_menu_filament_id = filament_idx; + p->plater->PopupMenu(menu, (int) pt.x, pt.y); + } + else { + // SINGLE MATERIAL / MULTI EXTRUDER / TOOLCHANGER / IDEX Opens Dialog directly + p->editing_filament = filament_idx; + combobox->switch_to_tab(); + } }); combobox->edit_btn = edit_btn; @@ -2510,7 +2520,7 @@ void Sidebar::update_all_preset_comboboxes() p->m_filament_icon->SetBitmap_("filament"); } - show_SEMM_buttons(should_show_SEMM_buttons()); + show_SEMM_buttons(); //p->m_staticText_filament_settings->Update(); @@ -3112,16 +3122,7 @@ void Sidebar::on_filament_count_change(size_t num_filaments) // remove unused choices if any remove_unused_filament_combos(num_filaments); - auto sizer = p->m_panel_filament_title->GetSizer(); - if (p->m_flushing_volume_btn != nullptr && sizer != nullptr) { - if (num_filaments > 1) { - sizer->Show(p->m_flushing_volume_btn); - sizer->Show(p->m_bpButton_del_filament); // ORCA: Show delete filament button if multiple filaments - } else { - sizer->Hide(p->m_flushing_volume_btn); - sizer->Hide(p->m_bpButton_del_filament); // ORCA: Hide delete filament button if there is only one filament - } - } + show_SEMM_buttons(); // ORCA update_filaments_area_height(); // ORCA @@ -3168,16 +3169,7 @@ void Sidebar::on_filaments_delete(size_t filament_id) } } - auto sizer = p->m_panel_filament_title->GetSizer(); - if (p->m_flushing_volume_btn != nullptr && sizer != nullptr) { - if (p->combos_filament.size() > 1) { - sizer->Show(p->m_flushing_volume_btn); - sizer->Show(p->m_bpButton_del_filament); // ORCA: Show delete filament button if multiple filaments - } else { - sizer->Hide(p->m_flushing_volume_btn); - sizer->Hide(p->m_bpButton_del_filament); // ORCA: Hide delete filament button if there is only one filament - } - } + show_SEMM_buttons(); // ORCA for (size_t idx = filament_id ; idx < p->combos_filament.size(); ++idx) { p->combos_filament[idx]->update(); @@ -3736,14 +3728,31 @@ bool Sidebar::should_show_SEMM_buttons() return cfg.opt_bool("single_extruder_multi_material") || is_bbl_vendor; } -void Sidebar::show_SEMM_buttons(bool bshow) +void Sidebar::show_SEMM_buttons() { - if(p->m_bpButton_add_filament) - p->m_bpButton_add_filament->Show(bshow); - if (p->m_bpButton_del_filament && p->combos_filament.size() > 1) // ORCA add filament count as condition to prevent showing Flushing volumes and Del Filament icon visible while only 1 filament exist - p->m_bpButton_del_filament->Show(bshow); - if (p->m_flushing_volume_btn && p->combos_filament.size() > 1) // ORCA add filament count as condition to prevent showing Flushing volumes and Del Filament icon visible while only 1 filament exist - p->m_flushing_volume_btn->Show(bshow); + // ORCA + if (!p || p->combos_filament.empty() || !p->m_bpButton_add_filament || !p->m_bpButton_del_filament || !p->m_flushing_volume_btn) + return; + + bool is_multi_material = p->combos_filament.size() > 1; + bool single_or_bbl = should_show_SEMM_buttons(); + bool is_single = single_or_bbl && !is_multi_material; // SINGLE EXTRUDER / BBL WITH 1 MATERIAL + bool is_multi = single_or_bbl && is_multi_material; // MULTI MATERIAL WITH SINGLE EXTRUDER + bool is_fixed = !is_single && !is_multi; // MULTI EXTRUDER / TOOLCHANGER / IDEX WITH FIXED MATERIAL + + p->m_bpButton_add_filament->Show(single_or_bbl); + p->m_bpButton_del_filament->Show(is_multi); + p->m_flushing_volume_btn->Show( is_multi); + + if (is_multi) { + for (auto &c : p->combos_filament) + c->edit_btn->SetBitmap_("menu_filament"); + } + else if (is_single || is_fixed) { + for (auto &c : p->combos_filament) + c->edit_btn->SetBitmap_("edit"); + } + Layout(); } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 31e0e2f0e1..f2089c1c4f 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -203,7 +203,7 @@ public: void get_small_btn_sync_pos_size(wxPoint &pt, wxSize &size); // Orca static bool should_show_SEMM_buttons(); - void show_SEMM_buttons(bool bshow); + void show_SEMM_buttons(); void update_dynamic_filament_list(); PlaterPresetComboBox * printer_combox(); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 9e58d7f9f5..ccf595b22a 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1554,8 +1554,7 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) if (opt_key == "single_extruder_multi_material" ){ - const auto bSEMM = m_config->opt_bool("single_extruder_multi_material"); - wxGetApp().sidebar().show_SEMM_buttons(bSEMM); + wxGetApp().sidebar().show_SEMM_buttons(); wxGetApp().get_tab(Preset::TYPE_PRINT)->update(); } @@ -1606,8 +1605,7 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) if (opt_key == "single_extruder_multi_material" ){ - const auto bSEMM = m_config->opt_bool("single_extruder_multi_material"); - wxGetApp().sidebar().show_SEMM_buttons(bSEMM); + wxGetApp().sidebar().show_SEMM_buttons(); wxGetApp().get_tab(Preset::TYPE_PRINT)->update(); }