From cfe0bd6ce1ae1089f718ac61a5a0824bb021d10c Mon Sep 17 00:00:00 2001
From: Vojtech Kral <vojtech@kral.hk>
Date: Tue, 12 Feb 2019 11:01:15 +0100
Subject: [PATCH] ConfigWizard: Cap width, clarify select buttons

---
 src/slic3r/GUI/ConfigWizard.cpp         | 32 ++++++++++++++-----------
 src/slic3r/GUI/ConfigWizard_private.hpp |  4 ++--
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp
index 2ddbea164..8159eff0b 100644
--- a/src/slic3r/GUI/ConfigWizard.cpp
+++ b/src/slic3r/GUI/ConfigWizard.cpp
@@ -178,10 +178,13 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
     if (titles.size() > 1) {
         // It only makes sense to add the All / None buttons if there's multiple printers
 
+        auto *sel_all_std = new wxButton(this, wxID_ANY, _(L("All standard")));
         auto *sel_all = new wxButton(this, wxID_ANY, _(L("All")));
         auto *sel_none = new wxButton(this, wxID_ANY, _(L("None")));
-        sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(true); });
+        sel_all_std->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(true, false); });
+        sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(true, true); });
         sel_none->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &event) { this->select_all(false); });
+        title_sizer->Add(sel_all_std, 0, wxRIGHT, BTN_SPACING);
         title_sizer->Add(sel_all, 0, wxRIGHT, BTN_SPACING);
         title_sizer->Add(sel_none);
     }
@@ -196,7 +199,7 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
     : PrinterPicker(parent, vendor, std::move(title), max_cols, appconfig_vendors, [](const VendorProfile::PrinterModel&) { return true; })
 {}
 
-void PrinterPicker::select_all(bool select)
+void PrinterPicker::select_all(bool select, bool alternates)
 {
     for (const auto &cb : cboxes) {
         if (cb->GetValue() != select) {
@@ -205,13 +208,12 @@ void PrinterPicker::select_all(bool select)
         }
     }
 
-    // Alt nozzles are de-selected if this is an all-deselect, left intact otherwise
-    if (! select) {
-        for (const auto &cb : cboxes_alt) {
-            if (cb->GetValue()) {
-                cb->SetValue(false);
-                on_checkbox(cb, false);
-            }
+    if (! select) { alternates = false; }
+
+    for (const auto &cb : cboxes_alt) {
+        if (cb->GetValue() != alternates) {
+            cb->SetValue(alternates);
+            on_checkbox(cb, alternates);
         }
     }
 }
@@ -340,10 +342,10 @@ PagePrinters::PagePrinters(ConfigWizard *parent, wxString title, wxString shortn
     }
 }
 
-void PagePrinters::select_all(bool select)
+void PagePrinters::select_all(bool select, bool alternates)
 {
     for (auto picker : printer_pickers) {
-        picker->select_all(select);
+        picker->select_all(select, alternates);
     }
 }
 
@@ -363,6 +365,7 @@ PageCustom::PageCustom(ConfigWizard *parent)
     tc_profile_name = new wxTextCtrl(this, wxID_ANY, default_profile_name);
     auto *label = new wxStaticText(this, wxID_ANY, _(L("Custom profile name:")));
 
+    tc_profile_name->Enable(false);
     tc_profile_name->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent &evt) {
         if (tc_profile_name->GetValue().IsEmpty()) {
             if (profile_name_prev.IsEmpty()) { tc_profile_name->SetValue(default_profile_name); }
@@ -374,6 +377,7 @@ PageCustom::PageCustom(ConfigWizard *parent)
     });
 
     cb_custom->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) {
+        tc_profile_name->Enable(custom_wanted());
         wizard_p()->on_custom_setup(custom_wanted());
     });
 
@@ -994,7 +998,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
     topsizer->AddSpacer(INDEX_MARGIN);
     topsizer->Add(p->hscroll, 1, wxEXPAND);
 
-    auto *btn_sel_all = new wxButton(this, wxID_ANY, _(L("Select all printers")));
+    auto *btn_sel_all = new wxButton(this, wxID_ANY, _(L("Select all standard printers")));
     p->btnsizer->Add(btn_sel_all);
 
     p->btn_prev = new wxButton(this, wxID_ANY, _(L("< &Back")));
@@ -1068,8 +1072,8 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
     p->btn_finish->Hide();
 
     btn_sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) {
-        p->page_fff->select_all(true);
-        p->page_msla->select_all(true);
+        p->page_fff->select_all(true, false);
+        p->page_msla->select_all(true, false);
         p->index->go_to(p->page_update);
     });
 
diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp
index 4cbe2199f..df7602adf 100644
--- a/src/slic3r/GUI/ConfigWizard_private.hpp
+++ b/src/slic3r/GUI/ConfigWizard_private.hpp
@@ -64,7 +64,7 @@ struct PrinterPicker: wxPanel
     PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxString title, size_t max_cols, const AppConfig &appconfig_vendors, const ModelFilter &filter);
     PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxString title, size_t max_cols, const AppConfig &appconfig_vendors);
 
-    void select_all(bool select);
+    void select_all(bool select, bool alternates = false);
     void select_one(size_t i, bool select);
     void on_checkbox(const Checkbox *cbox, bool checked);
 
@@ -119,7 +119,7 @@ struct PagePrinters: ConfigWizardPage
 
     PagePrinters(ConfigWizard *parent, wxString title, wxString shortname, const VendorProfile &vendor, unsigned indent, Technology technology);
 
-    void select_all(bool select);
+    void select_all(bool select, bool alternates = false);
     int get_width() const;
 };