mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-15 21:17:41 +00:00
Rebuild the Brim Type Combobox Only When Its Entries Change
toggle_options() now runs on every value change and mode switch; rebuild the brim_type choices only when the leading-edge entry has to be added or removed.
This commit is contained in:
@@ -3229,16 +3229,17 @@ void TabPrint::toggle_options()
|
|||||||
const auto current = m_config->opt_enum<BrimType>("brim_type");
|
const auto current = m_config->opt_enum<BrimType>("brim_type");
|
||||||
auto &opt = const_cast<ConfigOptionDef &>(field->m_opt);
|
auto &opt = const_cast<ConfigOptionDef &>(field->m_opt);
|
||||||
auto cb = dynamic_cast<ComboBox *>(choice->window);
|
auto cb = dynamic_cast<ComboBox *>(choice->window);
|
||||||
if (cb != nullptr) {
|
// Keep the entry if it is already selected, so switching to a non-belt
|
||||||
|
// printer cannot leave the control showing a value it does not offer.
|
||||||
|
const bool offer_leading_edge = is_belt_printer || current == btLeadingEdgeOnly;
|
||||||
|
const bool offered = std::find(opt.enum_values.begin(), opt.enum_values.end(), "leading_edge_only") != opt.enum_values.end();
|
||||||
|
if (cb != nullptr && offer_leading_edge != offered) {
|
||||||
auto n = cb->GetValue();
|
auto n = cb->GetValue();
|
||||||
opt.enum_values.clear();
|
opt.enum_values.clear();
|
||||||
opt.enum_labels.clear();
|
opt.enum_labels.clear();
|
||||||
cb->Clear();
|
cb->Clear();
|
||||||
for (size_t i = 0; i < def->enum_values.size(); ++ i) {
|
for (size_t i = 0; i < def->enum_values.size(); ++ i) {
|
||||||
// Keep the entry if it is already selected, so switching to a non-belt
|
if (def->enum_values[i] == "leading_edge_only" && ! offer_leading_edge)
|
||||||
// printer cannot leave the control showing a value it does not offer.
|
|
||||||
if (def->enum_values[i] == "leading_edge_only" && ! is_belt_printer
|
|
||||||
&& current != btLeadingEdgeOnly)
|
|
||||||
continue;
|
continue;
|
||||||
opt.enum_values.push_back(def->enum_values[i]);
|
opt.enum_values.push_back(def->enum_values[i]);
|
||||||
opt.enum_labels.push_back(def->enum_labels[i]);
|
opt.enum_labels.push_back(def->enum_labels[i]);
|
||||||
|
|||||||
Reference in New Issue
Block a user