ENH: optimize object list display

1. add filament title
2. adjust the layout propotion of object list and per-object
   parameter setting panel
3. replace wxScrollWindow with wxPanel for the Sidebar to avoid ugly
   double scrollbars
4. remove the auto height logic in object list to avoid it occupies too much
   height, causing no enough space for per-object setting panel

Signed-off-by: yifan.wu <yifan.wu@bambulab.com>
Change-Id: I2201b61e5a654e86427ce7f377d0e4c4ef593748
(cherry picked from commit dd0413d6c22a20059e9042b88a15391518fb54c7)
This commit is contained in:
yifan.wu 2022-07-27 11:51:22 +08:00 committed by Lane.Wei
parent 3d80bb52dc
commit 21d41bbbec
3 changed files with 12 additions and 8 deletions

View File

@ -289,10 +289,14 @@ void ObjectList::update_min_height()
wxDataViewItemArray all_items; wxDataViewItemArray all_items;
m_objects_model->GetAllChildren(wxDataViewItem(nullptr), all_items); m_objects_model->GetAllChildren(wxDataViewItem(nullptr), all_items);
size_t items_cnt = all_items.Count(); size_t items_cnt = all_items.Count();
#if 0
if (items_cnt < 7) if (items_cnt < 7)
items_cnt = 7; items_cnt = 7;
else if (items_cnt >= 15) else if (items_cnt >= 15)
items_cnt = 15; items_cnt = 15;
#else
items_cnt = 8;
#endif
if (m_items_count == items_cnt) if (m_items_count == items_cnt)
return; return;
@ -356,7 +360,7 @@ void ObjectList::create_objects_ctrl()
bmp_choice_renderer->set_default_extruder_idx([this]() { bmp_choice_renderer->set_default_extruder_idx([this]() {
return m_objects_model->GetDefaultExtruderIdx(GetSelection()); return m_objects_model->GetDefaultExtruderIdx(GetSelection());
}); });
AppendColumn(new wxDataViewColumn(_L(""), bmp_choice_renderer, AppendColumn(new wxDataViewColumn(_L("Fila."), bmp_choice_renderer,
colFilament, m_columns_width[colFilament] * em, wxALIGN_CENTER_HORIZONTAL, 0)); colFilament, m_columns_width[colFilament] * em, wxALIGN_CENTER_HORIZONTAL, 0));
// BBS // BBS

View File

@ -268,7 +268,7 @@ struct Sidebar::priv
{ {
Plater *plater; Plater *plater;
wxScrolledWindow *scrolled; wxPanel *scrolled;
PlaterPresetComboBox *combo_print; PlaterPresetComboBox *combo_print;
std::vector<PlaterPresetComboBox*> combos_filament; std::vector<PlaterPresetComboBox*> combos_filament;
int editing_filament = -1; int editing_filament = -1;
@ -407,12 +407,12 @@ void Sidebar::priv::hide_rich_tip(wxButton* btn)
Sidebar::Sidebar(Plater *parent) Sidebar::Sidebar(Plater *parent)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(42 * wxGetApp().em_unit(), -1)), p(new priv(parent)) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(42 * wxGetApp().em_unit(), -1)), p(new priv(parent))
{ {
p->scrolled = new wxScrolledWindow(this); p->scrolled = new wxPanel(this);
// p->scrolled->SetScrollbars(0, 100, 1, 2); // ys_DELETE_after_testing. pixelsPerUnitY = 100 // p->scrolled->SetScrollbars(0, 100, 1, 2); // ys_DELETE_after_testing. pixelsPerUnitY = 100
// but this cause the bad layout of the sidebar, when all infoboxes appear. // but this cause the bad layout of the sidebar, when all infoboxes appear.
// As a result we can see the empty block at the bottom of the sidebar // As a result we can see the empty block at the bottom of the sidebar
// But if we set this value to 5, layout will be better // But if we set this value to 5, layout will be better
p->scrolled->SetScrollRate(0, 5); //p->scrolled->SetScrollRate(0, 5);
p->scrolled->SetBackgroundColour(*wxWHITE); p->scrolled->SetBackgroundColour(*wxWHITE);
@ -724,7 +724,7 @@ Sidebar::Sidebar(Plater *parent)
p->sizer_params = new wxBoxSizer(wxVERTICAL); p->sizer_params = new wxBoxSizer(wxVERTICAL);
p->m_object_list = new ObjectList(p->scrolled); p->m_object_list = new ObjectList(p->scrolled);
p->sizer_params->Add(p->m_object_list, 1, wxEXPAND | wxTOP, 0); p->sizer_params->Add(p->m_object_list, 1, wxEXPAND | wxTOP, 0);
scrolled_sizer->Add(p->sizer_params, 3, wxEXPAND | wxLEFT, 0); scrolled_sizer->Add(p->sizer_params, 2, wxEXPAND | wxLEFT, 0);
p->m_object_list->Hide(); p->m_object_list->Hide();
p->m_auxiliary_dialog = new AuxiliaryDialog(this); p->m_auxiliary_dialog = new AuxiliaryDialog(this);
@ -737,7 +737,7 @@ Sidebar::Sidebar(Plater *parent)
#else #else
if (params_panel) { if (params_panel) {
params_panel->Reparent(p->scrolled); params_panel->Reparent(p->scrolled);
scrolled_sizer->Add(params_panel, 2, wxEXPAND); scrolled_sizer->Add(params_panel, 3, wxEXPAND);
} }
#endif #endif
@ -1202,7 +1202,7 @@ ObjectSettings* Sidebar::obj_settings()
return p->object_settings; return p->object_settings;
} }
wxScrolledWindow* Sidebar::scrolled_panel() wxPanel* Sidebar::scrolled_panel()
{ {
return p->scrolled; return p->scrolled;
} }

View File

@ -122,7 +122,7 @@ public:
ObjectList* obj_list(); ObjectList* obj_list();
ObjectSettings* obj_settings(); ObjectSettings* obj_settings();
wxScrolledWindow* scrolled_panel(); wxPanel* scrolled_panel();
wxPanel* print_panel(); wxPanel* print_panel();
wxPanel* filament_panel(); wxPanel* filament_panel();