diff --git a/xs/src/slic3r/GUI/ConfigWizard.cpp b/xs/src/slic3r/GUI/ConfigWizard.cpp index 2e315a70b..0c42168bb 100644 --- a/xs/src/slic3r/GUI/ConfigWizard.cpp +++ b/xs/src/slic3r/GUI/ConfigWizard.cpp @@ -65,22 +65,27 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, cons auto namefont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); namefont.SetWeight(wxFONTWEIGHT_BOLD); + // wxGrid appends widgets by rows, but we need to construct them in columns. + // These vectors are used to hold the elements so that they can be appended in the right order. + std::vector titles; + std::vector bitmaps; + std::vector variants_panels; + for (const auto &model : models) { - auto *panel = new wxPanel(this); - auto *col_sizer = new wxBoxSizer(wxVERTICAL); - panel->SetSizer(col_sizer); - - auto *title = new wxStaticText(panel, wxID_ANY, model.name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); - title->SetFont(namefont); - col_sizer->Add(title, 0, wxBOTTOM, 3); - auto bitmap_file = wxString::Format("printers/%s_%s.png", vendor.id, model.id); wxBitmap bitmap(GUI::from_u8(Slic3r::var(bitmap_file.ToStdString())), wxBITMAP_TYPE_PNG); - auto *bitmap_widget = new wxStaticBitmap(panel, wxID_ANY, bitmap); - col_sizer->Add(bitmap_widget, 0, wxBOTTOM, 3); - col_sizer->AddSpacer(20); + auto *title = new wxStaticText(this, wxID_ANY, model.name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + title->SetFont(namefont); + title->Wrap(std::max((int)MODEL_MIN_WRAP, bitmap.GetWidth())); + titles.push_back(title); + auto *bitmap_widget = new wxStaticBitmap(this, wxID_ANY, bitmap); + bitmaps.push_back(bitmap_widget); + + auto *variants_panel = new wxPanel(this); + auto *variants_sizer = new wxBoxSizer(wxVERTICAL); + variants_panel->SetSizer(variants_sizer); const auto model_id = model.id; bool default_variant = true; // Mark the first variant as default in the GUI @@ -88,22 +93,26 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, cons const auto label = wxString::Format("%s %s %s %s", variant.name, _(L("mm")), _(L("nozzle")), (default_variant ? _(L("(default)")) : wxString())); default_variant = false; - auto *cbox = new Checkbox(panel, label, model_id, variant.name); + auto *cbox = new Checkbox(variants_panel, label, model_id, variant.name); const size_t idx = cboxes.size(); cboxes.push_back(cbox); bool enabled = appconfig_vendors.get_variant("PrusaResearch", model_id, variant.name); variants_checked += enabled; cbox->SetValue(enabled); - col_sizer->Add(cbox, 0, wxBOTTOM, 3); + variants_sizer->Add(cbox, 0, wxBOTTOM, 3); cbox->Bind(wxEVT_CHECKBOX, [this, idx](wxCommandEvent &event) { if (idx >= this->cboxes.size()) { return; } this->on_checkbox(this->cboxes[idx], event.IsChecked()); }); } - printer_grid->Add(panel); + variants_panels.push_back(variants_panel); } + for (auto title : titles) { printer_grid->Add(title, 0, wxBOTTOM, 3); } + for (auto bitmap : bitmaps) { printer_grid->Add(bitmap, 0, wxBOTTOM, 20); } + for (auto vp : variants_panels) { printer_grid->Add(vp); } + auto *all_none_sizer = new wxBoxSizer(wxHORIZONTAL); auto *sel_all = new wxButton(this, wxID_ANY, _(L("Select all"))); auto *sel_none = new wxButton(this, wxID_ANY, _(L("Select none"))); diff --git a/xs/src/slic3r/GUI/ConfigWizard_private.hpp b/xs/src/slic3r/GUI/ConfigWizard_private.hpp index 04319a1b4..c027f300d 100644 --- a/xs/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/xs/src/slic3r/GUI/ConfigWizard_private.hpp @@ -27,6 +27,7 @@ namespace GUI { enum { WRAP_WIDTH = 500, + MODEL_MIN_WRAP = 150, DIALOG_MARGIN = 15, INDEX_MARGIN = 40,