ConfigWizard: Wrap printer model titles
This commit is contained in:
parent
a0096cf563
commit
abe7a71f85
2 changed files with 24 additions and 14 deletions
|
@ -65,22 +65,27 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, cons
|
||||||
auto namefont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
auto namefont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
namefont.SetWeight(wxFONTWEIGHT_BOLD);
|
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<wxStaticText*> titles;
|
||||||
|
std::vector<wxStaticBitmap*> bitmaps;
|
||||||
|
std::vector<wxPanel*> variants_panels;
|
||||||
|
|
||||||
for (const auto &model : models) {
|
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);
|
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);
|
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;
|
const auto model_id = model.id;
|
||||||
|
|
||||||
bool default_variant = true; // Mark the first variant as default in the GUI
|
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")),
|
const auto label = wxString::Format("%s %s %s %s", variant.name, _(L("mm")), _(L("nozzle")),
|
||||||
(default_variant ? _(L("(default)")) : wxString()));
|
(default_variant ? _(L("(default)")) : wxString()));
|
||||||
default_variant = false;
|
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();
|
const size_t idx = cboxes.size();
|
||||||
cboxes.push_back(cbox);
|
cboxes.push_back(cbox);
|
||||||
bool enabled = appconfig_vendors.get_variant("PrusaResearch", model_id, variant.name);
|
bool enabled = appconfig_vendors.get_variant("PrusaResearch", model_id, variant.name);
|
||||||
variants_checked += enabled;
|
variants_checked += enabled;
|
||||||
cbox->SetValue(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) {
|
cbox->Bind(wxEVT_CHECKBOX, [this, idx](wxCommandEvent &event) {
|
||||||
if (idx >= this->cboxes.size()) { return; }
|
if (idx >= this->cboxes.size()) { return; }
|
||||||
this->on_checkbox(this->cboxes[idx], event.IsChecked());
|
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 *all_none_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
auto *sel_all = new wxButton(this, wxID_ANY, _(L("Select all")));
|
auto *sel_all = new wxButton(this, wxID_ANY, _(L("Select all")));
|
||||||
auto *sel_none = new wxButton(this, wxID_ANY, _(L("Select none")));
|
auto *sel_none = new wxButton(this, wxID_ANY, _(L("Select none")));
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace GUI {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
WRAP_WIDTH = 500,
|
WRAP_WIDTH = 500,
|
||||||
|
MODEL_MIN_WRAP = 150,
|
||||||
|
|
||||||
DIALOG_MARGIN = 15,
|
DIALOG_MARGIN = 15,
|
||||||
INDEX_MARGIN = 40,
|
INDEX_MARGIN = 40,
|
||||||
|
|
Loading…
Reference in a new issue