Show filament edit button or action menu dynamically depends on single / multi materilal usage (#12651)
* init * fix build error * add guards * Update Plater.cpp
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user