From 41ff632d28cef7cbd09ae7e5927476eb51ecfdcd Mon Sep 17 00:00:00 2001 From: yw4z Date: Sat, 10 May 2025 08:49:52 +0300 Subject: [PATCH] Improve UI of profile dependencies tab (#9553) * init * Update Tab.cpp * update labels * Update Tab.hpp * Fix checkbox label * Update Tab.cpp --------- Co-authored-by: Noisyfox --- .../images/param_dependencies_presets.svg | 1 + .../images/param_dependencies_printers.svg | 1 + .../images/param_profile_dependencies.svg | 1 - src/libslic3r/PrintConfig.cpp | 8 ++--- src/slic3r/GUI/Tab.cpp | 34 ++++++++++++++----- src/slic3r/GUI/Tab.hpp | 2 +- 6 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 resources/images/param_dependencies_presets.svg create mode 100644 resources/images/param_dependencies_printers.svg delete mode 100644 resources/images/param_profile_dependencies.svg diff --git a/resources/images/param_dependencies_presets.svg b/resources/images/param_dependencies_presets.svg new file mode 100644 index 0000000000..603c52b79f --- /dev/null +++ b/resources/images/param_dependencies_presets.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/images/param_dependencies_printers.svg b/resources/images/param_dependencies_printers.svg new file mode 100644 index 0000000000..0646f4730c --- /dev/null +++ b/resources/images/param_dependencies_printers.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/images/param_profile_dependencies.svg b/resources/images/param_profile_dependencies.svg deleted file mode 100644 index ceb305e081..0000000000 --- a/resources/images/param_profile_dependencies.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index c00c60d8e6..af56329930 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1318,7 +1318,7 @@ void PrintConfigDef::init_fff_params() def->set_default_value(new ConfigOptionFloat(1)); def = this->add("compatible_printers", coStrings); - def->label = L("Compatible machine"); + def->label = L("Select printers"); def->mode = comAdvanced; def->set_default_value(new ConfigOptionStrings()); def->cli = ConfigOptionDef::nocli; @@ -1331,7 +1331,7 @@ void PrintConfigDef::init_fff_params() def->cli = ConfigOptionDef::nocli; def = this->add("compatible_printers_condition", coString); - def->label = L("Compatible machine condition"); + def->label = L("Condition"); def->tooltip = L("A boolean expression using the configuration values of an active printer profile. " "If this expression evaluates to true, this profile is considered compatible " "with the active printer profile."); @@ -1340,13 +1340,13 @@ void PrintConfigDef::init_fff_params() def->cli = ConfigOptionDef::nocli; def = this->add("compatible_prints", coStrings); - def->label = L("Compatible process profiles"); + def->label = L("Select profiles"); def->mode = comAdvanced; def->set_default_value(new ConfigOptionStrings()); def->cli = ConfigOptionDef::nocli; def = this->add("compatible_prints_condition", coString); - def->label = L("Compatible process profiles condition"); + def->label = L("Condition"); def->tooltip = L("A boolean expression using the configuration values of an active print profile. " "If this expression evaluates to true, this profile is considered compatible " "with the active print profile."); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 14b890ff00..f21a0ab639 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3585,7 +3585,7 @@ void TabFilament::build() optgroup->append_single_option_line("filament_multitool_ramming_flow"); page = add_options_page(L("Dependencies"), "advanced"); - optgroup = page->new_optgroup(L("Profile dependencies"), "param_profile_dependencies"); + optgroup = page->new_optgroup(L("Compatible printers"), "param_dependencies_printers"); create_line_with_widget(optgroup.get(), "compatible_printers", "", [this](wxWindow* parent) { return compatible_widget_create(parent, m_compatible_printers); }); @@ -3594,6 +3594,7 @@ void TabFilament::build() option.opt.full_width = true; optgroup->append_single_option_line(option); + optgroup = page->new_optgroup(L("Compatible process profiles"), "param_dependencies_presets"); create_line_with_widget(optgroup.get(), "compatible_prints", "", [this](wxWindow* parent) { return compatible_widget_create(parent, m_compatible_prints); }); @@ -5921,8 +5922,14 @@ void Tab::create_line_with_widget(ConfigOptionsGroup* optgroup, const std::strin // Return a callback to create a Tab widget to mark the preferences as compatible / incompatible to the current printer. wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &deps) { - deps.checkbox = new wxCheckBox(parent, wxID_ANY, _(L("All"))); - deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font()); + auto cb_text = _L("All"); + deps.checkbox = new ::CheckBox(parent, wxID_ANY); + deps.checkbox->SetLabel(cb_text); + deps.checkbox->SetFont(Label::Body_14); + auto cb_size = wxSize(deps.checkbox->GetTextExtent(cb_text).x + deps.checkbox->GetBitmap().GetWidth() + FromDIP(6), -1); + deps.checkbox->SetSize( cb_size); + deps.checkbox->SetMinSize(cb_size); + deps.checkbox->SetForegroundColour(wxColour("#363636")); wxGetApp().UpdateDarkUI(deps.checkbox, false, true); // ORCA modernize button style @@ -5948,18 +5955,28 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add((deps.checkbox), 0, wxALIGN_CENTER_VERTICAL); + sizer->Add(new wxStaticText(parent, wxID_ANY, " ")); // weirdly didnt apply AddSpacer or wxRIGHT border sizer->Add((deps.btn), 0, wxALIGN_CENTER_VERTICAL); - deps.checkbox->Bind(wxEVT_CHECKBOX, ([this, &deps](wxCommandEvent e) + deps.checkbox->Bind(wxEVT_TOGGLEBUTTON, ([this, &deps](wxCommandEvent e) { - deps.btn->Enable(! deps.checkbox->GetValue()); + deps.checkbox->SetValue(e.IsChecked()); + deps.btn->Enable(!e.IsChecked()); // All printers have been made compatible with this preset. - if (deps.checkbox->GetValue()) + if (e.IsChecked()) this->load_key_value(deps.key_list, std::vector {}); - this->get_field(deps.key_condition)->toggle(deps.checkbox->GetValue()); + this->get_field(deps.key_condition)->toggle(e.IsChecked()); this->update_changed_ui(); - }) ); + e.Skip(); + }), deps.checkbox->GetId()); + if (deps.checkbox){ + bool is_empty = m_config->option(deps.key_list)->values.empty(); + deps.checkbox->SetValue(is_empty); + deps.btn->Enable(!is_empty); + } + + /* if (m_compatible_printers.checkbox) { bool is_empty = m_config->option("compatible_printers")->values.empty(); m_compatible_printers.checkbox->SetValue(is_empty); @@ -5971,6 +5988,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep m_compatible_prints.checkbox->SetValue(is_empty); is_empty ? m_compatible_prints.btn->Disable() : m_compatible_prints.btn->Enable(); } + */ deps.btn->Bind(wxEVT_BUTTON, ([this, parent, &deps](wxCommandEvent e) { diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 9161740239..8a11e54f93 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -164,7 +164,7 @@ protected: struct PresetDependencies { Preset::Type type = Preset::TYPE_INVALID; - wxCheckBox *checkbox = nullptr; + ::CheckBox* checkbox = nullptr; Button *btn = nullptr; std::string key_list; // "compatible_printers" std::string key_condition;