Filament list improvements (Filament counter & Auto unfold & Scroll to end of list on changes) (#14158)

* Update Plater.cpp

* filament counter
This commit is contained in:
yw4z
2026-06-14 07:04:34 +03:00
committed by GitHub
parent 0c4c04bcaf
commit 9bcee518f8
2 changed files with 46 additions and 3 deletions

View File

@@ -524,6 +524,7 @@ struct Sidebar::priv
wxStaticLine * m_staticline1;
StaticBox* m_panel_filament_title;
wxStaticText* m_staticText_filament_settings;
wxStaticText* m_staticText_filament_count;
ScalableButton * m_bpButton_add_filament;
ScalableButton * m_bpButton_del_filament;
ScalableButton * m_bpButton_ams_filament;
@@ -2073,6 +2074,8 @@ Sidebar::Sidebar(Plater *parent)
return;
p->m_panel_filament_content->Show(!p->m_panel_filament_content->IsShown());
m_scrolled_sizer->Layout();
CallAfter([this]{update_filaments_counter(true);}); // call after all UI processing done
});
wxBoxSizer* bSizer39;
@@ -2080,11 +2083,13 @@ Sidebar::Sidebar(Plater *parent)
p->m_filament_icon = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "filament");
p->m_staticText_filament_settings = new Label(p->m_panel_filament_title, _L("Project Filaments"), LB_PROPAGATE_MOUSE_EVENT);
bSizer39->Add(p->m_filament_icon, 0, wxALIGN_CENTER | wxLEFT, FromDIP(SidebarProps::TitlebarMargin()));
bSizer39->AddSpacer(FromDIP(SidebarProps::ElementSpacing()));
bSizer39->Add( p->m_staticText_filament_settings, 0, wxALIGN_CENTER );
bSizer39->Add(FromDIP(10), 0, 0, 0, 0);
bSizer39->Add(p->m_staticText_filament_settings, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(SidebarProps::ElementSpacing()));
bSizer39->SetMinSize(-1, FromDIP(30));
p->m_staticText_filament_count = new Label(p->m_panel_filament_title, "(0)", LB_PROPAGATE_MOUSE_EVENT);
bSizer39->Add(p->m_staticText_filament_count, 0, wxALIGN_CENTER );
bSizer39->Add(FromDIP(10), 0, 0, 0, 0);
p->m_panel_filament_title->SetSizer( bSizer39 );
p->m_panel_filament_title->Layout();
auto spliter_1 = new ::StaticLine(p->scrolled);
@@ -2119,6 +2124,7 @@ Sidebar::Sidebar(Plater *parent)
add_btn->SetToolTip(_L("Add one filament"));
add_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e){
add_filament();
update_filaments_counter();
});
p->m_bpButton_add_filament = add_btn;
@@ -2128,6 +2134,7 @@ Sidebar::Sidebar(Plater *parent)
del_btn->SetToolTip(_L("Remove last filament"));
del_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent &e) {
delete_filament();
update_filaments_counter();
});
p->m_bpButton_del_filament = del_btn;
@@ -2854,6 +2861,26 @@ void Sidebar::update_filaments_area_height()
if (min_size.y > p->m_panel_filament_content->GetMaxHeight())
min_size.y = p->m_panel_filament_content->GetMaxHeight();
p->m_panel_filament_content->SetMinSize({-1, min_size.y});
update_filaments_counter();
}
void Sidebar::update_filaments_counter(bool force_layout)
// ORCA
{
int current_count = p->combos_filament.size();
int preferred_count = std::stoi(wxGetApp().app_config->get("filaments_area_preferred_count"));
bool isShown = p->m_panel_filament_content->IsShown();
auto counter = p->m_staticText_filament_count;
counter->SetLabel("(" + std::to_string(current_count) + ")"); // update counter on every change
if(current_count > preferred_count || !isShown)
counter->Show();
else if (isShown) // hide when list is visible and short enough
counter->Hide();
if(force_layout)
m_scrolled_sizer->Layout();
}
void Sidebar::msw_rescale()
@@ -3161,6 +3188,13 @@ void Sidebar::add_filament() {
if (p->combos_filament.size() >= MAXIMUM_EXTRUDER_NUMBER) return;
wxColour new_col = Plater::get_next_color_for_filament();
add_custom_filament(new_col);
auto filament_list = p->m_panel_filament_content;
if(!filament_list->IsShown()){
filament_list->Show(); // ORCA show list if its folded
m_scrolled_sizer->Layout();
}
filament_list->Scroll(-1, INT_MAX); // ORCA scroll to end of list on changes to inform user about filament count
}
void Sidebar::delete_filament(size_t filament_id, int replace_filament_id) {
@@ -3193,6 +3227,14 @@ void Sidebar::delete_filament(size_t filament_id, int replace_filament_id) {
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
wxGetApp().plater()->update();
auto filament_list = p->m_panel_filament_content;
if(!filament_list->IsShown()){
filament_list->Show(); // ORCA show list if its folded
m_scrolled_sizer->Layout();
}
filament_list->Scroll(-1, INT_MAX); // ORCA scroll to end of list on changes to inform user about filament count
}
void Sidebar::change_filament(size_t from_id, size_t to_id)

View File

@@ -173,6 +173,7 @@ public:
bool reset_bed_type_combox_choices(bool is_sidebar_init = false);
void change_top_border_for_mode_sizer(bool increase_border);
void update_filaments_area_height();
void update_filaments_counter(bool force_layout = false);
void msw_rescale();
void sys_color_changed();
void search();