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

<img width="562" height="122" alt="Screenshot-20260215194149" src="https://github.com/user-attachments/assets/309cec36-8b83-48f3-875f-d5f22a9631e7" />

**BEFORE**
Scrollable area fixed for 10 items. that causes a lot of scrolling whe user has 3 or 4 ams units

<img width="411" height="237" alt="Screenshot-20260215194816" src="https://github.com/user-attachments/assets/fc7823c0-d82a-4d1f-bb5b-56e8dd47abd2" />

**AFTER**
value 10. - 2 multimaterial units ( 8 filaments ) and 1 external filament
<img width="1002" height="250" alt="Screenshot-20260215195243" src="https://github.com/user-attachments/assets/e3238cd1-788e-4ed2-b048-89c63bd323db" />

value 18  - 4 multimaterial units ( 16 filaments ) and 1 external filament
<img width="1001" height="355" alt="Screenshot-20260215195127" src="https://github.com/user-attachments/assets/afe0305e-fcb4-4a51-b8dc-e70a063aa391" />
This commit is contained in:
yw4z 2026-02-23 07:56:09 +03:00 committed by GitHub
parent 386aab9f94
commit 5e6a8e4daf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 57 additions and 2 deletions

View file

@ -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);

View file

@ -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();

View file

@ -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<void(int)> 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);