From 5e6a8e4daf76d0cd63ee012eff2a66555ceeb1bb Mon Sep 17 00:00:00 2001 From: yw4z Date: Mon, 23 Feb 2026 07:56:09 +0300 Subject: [PATCH] Add preference for filament area height to reduce scrolling while using 16+ filaments (#12317) Fixes https://github.com/OrcaSlicer/OrcaSlicer/issues/12284 Adds a preference for filaments area height since every user has different amount of MM units and external filaments so users can set a value that fits their setups this way we might see 3 or 6 filaments for each unit on future. thats why i set value as int used 10 as default value. its good for 2 multimaterial units ( 8 filaments ) and 1 external filament min value is 8. might be good when no external filaments in use max value is 99. UI works same as 2.3.1 version Screenshot-20260215194149 **BEFORE** Scrollable area fixed for 10 items. that causes a lot of scrolling whe user has 3 or 4 ams units Screenshot-20260215194816 **AFTER** value 10. - 2 multimaterial units ( 8 filaments ) and 1 external filament Screenshot-20260215195243 value 18 - 4 multimaterial units ( 16 filaments ) and 1 external filament Screenshot-20260215195127 --- src/libslic3r/AppConfig.cpp | 3 +++ src/slic3r/GUI/Plater.cpp | 9 +++++-- src/slic3r/GUI/Preferences.cpp | 47 ++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 64d4bbc89e..46facd18de 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -196,6 +196,9 @@ void AppConfig::set_defaults() if (get("seq_top_layer_only").empty()) set("seq_top_layer_only", "1"); + if (get("filaments_area_preferred_count").empty()) + set("filaments_area_preferred_count", "10"); + if (get("use_perspective_camera").empty()) set_bool("use_perspective_camera", true); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 4ceca9a260..e4c6ddc516 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -469,6 +469,7 @@ struct Sidebar::priv ScalableButton * m_bpButton_ams_filament; ScalableButton * m_bpButton_set_filament; int m_menu_filament_id = -1; + int filament_area_height; wxScrolledWindow* m_panel_filament_content; wxScrolledWindow* m_scrolledWindow_filament_content; wxStaticLine* m_staticline2; @@ -2105,10 +2106,14 @@ Sidebar::Sidebar(Plater *parent) bSizer39->AddSpacer(FromDIP(SidebarProps::TitlebarMargin())); // add filament content + // ORCA use a height with user preference + int filament_count_user = std::stoi(wxGetApp().app_config->get("filaments_area_preferred_count")); + p->filament_area_height = std::ceil(filament_count_user * 0.5) * (30 + SidebarProps::ElementSpacing()) - SidebarProps::ElementSpacing(); + p->m_panel_filament_content = new wxScrolledWindow( p->scrolled, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); p->m_panel_filament_content->SetScrollbars(0, 100, 1, 2); p->m_panel_filament_content->SetScrollRate(0, 5); - p->m_panel_filament_content->SetMaxSize(wxSize{-1, FromDIP(174)}); + p->m_panel_filament_content->SetMaxSize(wxSize{-1, FromDIP(p->filament_area_height)}); // ORCA p->m_panel_filament_content->SetBackgroundColour(wxColour(255, 255, 255)); //wxBoxSizer* bSizer_filament_content; @@ -3519,7 +3524,7 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn) for (auto& c : p->combos_filament) c->update(); // Expand filament list - p->m_panel_filament_content->SetMaxSize({-1, FromDIP(174)}); + p->m_panel_filament_content->SetMaxSize({-1, FromDIP(p->filament_area_height)}); // ORCA auto min_size = p->m_panel_filament_content->GetSizer()->GetMinSize(); if (min_size.y > p->m_panel_filament_content->GetMaxHeight()) min_size.y = p->m_panel_filament_content->GetMaxHeight(); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 98ec6e0707..30cff2490f 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -558,6 +558,50 @@ wxBoxSizer *PreferencesDialog::create_item_input(wxString title, wxString title2 return sizer_input; } +wxBoxSizer *PreferencesDialog::create_item_spinctrl(wxString title, wxString title2, wxString side_label, wxString tooltip, std::string param, int min, int max, std::function onchange) +{ + wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); + + auto label = new wxStaticText(m_parent, wxID_ANY, title, wxDefaultPosition, DESIGN_TITLE_SIZE, wxST_NO_AUTORESIZE); + label->SetForegroundColour(DESIGN_GRAY900_COLOR); + label->SetFont(::Label::Body_14); + label->SetToolTip(tooltip); + label->Wrap(DESIGN_TITLE_SIZE.x); + label->Wrap(DESIGN_TITLE_SIZE.x); + + auto input = new SpinInput(m_parent, wxEmptyString, side_label, wxDefaultPosition, DESIGN_INPUT_SIZE, wxSP_ARROW_KEYS, min, max, stoi(app_config->get(param))); + input->SetToolTip(tooltip); + + sizer->AddSpacer(FromDIP(DESIGN_LEFT_MARGIN)); + sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL); + sizer->Add(input, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(5)); + + if(!title2.empty()){ + auto second_title = new wxStaticText(m_parent, wxID_ANY, title2, wxDefaultPosition, wxDefaultSize, 0); + second_title->SetForegroundColour(DESIGN_GRAY900_COLOR); + second_title->SetFont(::Label::Body_14); + second_title->SetToolTip(tooltip); + sizer->Add(second_title, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(5)); + } + + input->Bind(wxEVT_TEXT_ENTER, [this, param, input, onchange](wxCommandEvent& e) { + auto value = input->GetValue(); + app_config->set(param, std::to_string(value)); + app_config->save(); + if (onchange != nullptr) onchange(value); + e.Skip(); + }); + + input->Bind(wxEVT_KILL_FOCUS, [this, param, input, onchange](wxFocusEvent &e) { + auto value = input->GetValue(); + app_config->set(param, std::to_string(value)); + if (onchange != nullptr) onchange(value); + e.Skip(); + }); + + return sizer; +} + wxBoxSizer *PreferencesDialog::create_camera_orbit_mult_input(wxString title, wxString tooltip) { wxBoxSizer *sizer_input = new wxBoxSizer(wxHORIZONTAL); @@ -1354,6 +1398,9 @@ void PreferencesDialog::create_items() "group_filament_presets", {_L("All"), _L("None"), _L("By type"), _L("By vendor")}, [](wxString value) {wxGetApp().plater()->sidebar().update_presets(Preset::TYPE_FILAMENT);}); g_sizer->Add(item_filament_preset_grouping); + auto item_filament_area_height = create_item_spinctrl(_L("Optimize filaments area height for..."), _L("(Requires restart)"), _L("filaments"), _L("Optimizes filament area maximum height by chosen filament count"), "filaments_area_preferred_count", 8, 99); + g_sizer->Add(item_filament_area_height); + //// GENERAL > Features g_sizer->Add(create_item_title(_L("Features")), 1, wxEXPAND);