Improve UI of profile dependencies tab (#9553)
Some checks are pending
Build all / Build All (push) Waiting to run
Build all / Flatpak (push) Waiting to run

* init

* Update Tab.cpp

* update labels

* Update Tab.hpp

* Fix checkbox label

* Update Tab.cpp

---------

Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
yw4z 2025-05-10 08:49:52 +03:00 committed by GitHub
parent cc525608e9
commit 41ff632d28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 14 deletions

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18"><path d="M15.94,5.06c-.75-.75-1.97-.75-2.72,0l-2.04,2.04c-.75.75-.75,1.97,0,2.72s1.97.75,2.72,0l2.04-2.04c.75-.75.75-1.97,0-2.72Z" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><path d="M9.82,11.18c-.75-.75-1.97-.75-2.72,0l-2.04,2.04c-.75.75-.75,1.97,0,2.72s1.97.75,2.72,0l2.04-2.04c.75-.75.75-1.97,0-2.72Z" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><line x1="8" y1="13" x2="13" y2="8" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><line x1=".5" y1="2.5" x2="1.5" y2="2.5" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><line x1="3.5" y1="2.5" x2="8.5" y2="2.5" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><rect x="1.5" y=".5" width="2" height="4" rx=".67" ry=".67" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><line x1="8.5" y1="6.5" x2="7.5" y2="6.5" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><line x1="5.5" y1="6.5" x2=".5" y2="6.5" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><rect x="5.5" y="4.5" width="2" height="4" rx=".67" ry=".67" transform="translate(13 13) rotate(180)" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18"><line x1="2.5" y1="2.5" x2="6.5" y2="2.5" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><line x1="2.5" y1="6.5" x2="6.5" y2="6.5" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><rect x=".5" y=".5" width="8" height="8" rx="1.89" ry="1.89" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><line x1="4.5" y1="3.5" x2="4.5" y2="2.5" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><path d="M15.94,5.06c-.75-.75-1.97-.75-2.72,0l-2.04,2.04c-.75.75-.75,1.97,0,2.72s1.97.75,2.72,0l2.04-2.04c.75-.75.75-1.97,0-2.72Z" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><path d="M9.82,11.18c-.75-.75-1.97-.75-2.72,0l-2.04,2.04c-.75.75-.75,1.97,0,2.72s1.97.75,2.72,0l2.04-2.04c.75-.75.75-1.97,0-2.72Z" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><line x1="8" y1="13" x2="13" y2="8" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -1 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18"><path d="M15.75,1.25c-1-1-2.63-1-3.63,0l-2.72,2.72c-1,1-1,2.63,0,3.63,1,1,2.63,1,3.63,0l2.72-2.72c1-1,1-2.63,0-3.63Z" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><path d="M7.59,9.41c-1-1-2.63-1-3.63,0l-2.72,2.72c-1,1-1,2.63,0,3.63s2.63,1,3.63,0l2.72-2.72c1-1,1-2.63,0-3.63Z" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><line x1=".5" y1="2.5" x2="1.5" y2="2.5" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><polygon points="8 3 4 3 4 2 9 2 8 3" style="fill:#949494;"/><rect x="1.5" y=".5" width="3" height="4" rx=".82" ry=".82" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><polygon points="13 15 8 15 9 14 13 14 13 15" style="fill:#949494;"/><line x1="4.5" y1="12.5" x2="12.5" y2="4.5" style="fill:none; stroke:#009688; stroke-linecap:round; stroke-linejoin:round;"/><line x1="15.5" y1="14.5" x2="16.5" y2="14.5" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/><rect x="12.5" y="12.5" width="3" height="4" rx=".82" ry=".82" style="fill:none; stroke:#949494; stroke-linecap:square; stroke-linejoin:round;"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -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.");

View file

@ -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<std::string> {});
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<ConfigOptionStrings>(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<ConfigOptionStrings>("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)
{

View file

@ -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;