From 93477bc2ecb7fe3ea12b47905b225d38743071ff Mon Sep 17 00:00:00 2001 From: yw4z Date: Sun, 2 Feb 2025 15:59:44 +0300 Subject: [PATCH] Hide delete filament button while only 1 filament exist (#8240) Update Plater.cpp --- src/slic3r/GUI/Plater.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 3a57ead3a3..2fc5e9d26a 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -852,7 +852,7 @@ Sidebar::Sidebar(Plater *parent) p->m_panel_filament_title->SetBackgroundColor2(0xF1F1F1); p->m_panel_filament_title->Bind(wxEVT_LEFT_UP, [this](wxMouseEvent &e) { if (e.GetPosition().x > (p->m_flushing_volume_btn->IsShown() - ? p->m_flushing_volume_btn->GetPosition().x : p->m_bpButton_add_filament->GetPosition().x)) + ? p->m_flushing_volume_btn->GetPosition().x : (p->m_bpButton_add_filament->GetPosition().x - FromDIP(30)))) // ORCA exclude area of del button from titlebar collapse/expand feature to fix undesired collapse when user spams del filament button return; if (p->m_panel_filament_content->GetMaxHeight() == 0) p->m_panel_filament_content->SetMaxSize({-1, -1}); @@ -957,8 +957,7 @@ Sidebar::Sidebar(Plater *parent) }); p->m_bpButton_add_filament = add_btn; - bSizer39->Add(add_btn, 0, wxALIGN_CENTER|wxALL, FromDIP(5)); - bSizer39->Add(FromDIP(10), 0, 0, 0, 0 ); + // ORCA Moved add button after delete button to prevent add button position change when remove icon automatically hidden ScalableButton* del_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "delete_filament"); del_btn->SetToolTip(_L("Remove last filament")); @@ -983,8 +982,15 @@ Sidebar::Sidebar(Plater *parent) p->m_bpButton_del_filament = del_btn; bSizer39->Add(del_btn, 0, wxALIGN_CENTER_VERTICAL, FromDIP(5)); + bSizer39->Add(FromDIP(10), 0, 0, 0, 0); + bSizer39->Add(add_btn, 0, wxALIGN_CENTER | wxALL, FromDIP(5)); // ORCA Moved add button after delete button to prevent add button position change when remove icon automatically hidden bSizer39->Add(FromDIP(20), 0, 0, 0, 0); + if (p->combos_filament.size() <= 1) { // ORCA Fix Flushing button and Delete filament button not hidden on launch while only 1 filament exist + bSizer39->Hide(p->m_flushing_volume_btn); + bSizer39->Hide(p->m_bpButton_del_filament); // ORCA: Hide delete filament button if there is only one filament + } + ams_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition, wxBU_EXACTFIT | wxNO_BORDER, false, 18); ams_btn->SetToolTip(_L("Synchronize filament list from AMS")); @@ -1632,10 +1638,13 @@ void Sidebar::on_filaments_change(size_t num_filaments) auto sizer = p->m_panel_filament_title->GetSizer(); if (p->m_flushing_volume_btn != nullptr && sizer != nullptr) { - if (num_filaments > 1) + if (num_filaments > 1) { sizer->Show(p->m_flushing_volume_btn); - else + 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 + } } Layout(); @@ -1856,9 +1865,9 @@ void Sidebar::show_SEMM_buttons(bool bshow) { if(p->m_bpButton_add_filament) p->m_bpButton_add_filament->Show(bshow); - if(p->m_bpButton_del_filament) + 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) + 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); Layout(); }